Lines Matching +full:- +full:f

1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
7 // http://www.apache.org/licenses/LICENSE-2.0
41 FILE* f = fopen(name, "wb"); in test_fatfs_create_file_with_text() local
42 TEST_ASSERT_NOT_NULL(f); in test_fatfs_create_file_with_text()
43 TEST_ASSERT_TRUE(fputs(text, f) != EOF); in test_fatfs_create_file_with_text()
44 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_create_file_with_text()
84 FILE* f = fopen(filename, "r"); in test_fatfs_read_file() local
85 TEST_ASSERT_NOT_NULL(f); in test_fatfs_read_file()
87 int cb = fread(buf, 1, sizeof(buf), f); in test_fatfs_read_file()
90 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_read_file()
95 FILE* f = fopen(filename, "r"); in test_fatfs_read_file_utf_8() local
96 TEST_ASSERT_NOT_NULL(f); in test_fatfs_read_file_utf_8()
97 char buf[64] = { 0 }; //Doubled buffer size to allow for longer UTF-8 strings in test_fatfs_read_file_utf_8()
98 int cb = fread(buf, 1, sizeof(buf), f); in test_fatfs_read_file_utf_8()
101 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_read_file_utf_8()
108 TEST_ASSERT_NOT_EQUAL(-1, fd); in test_fatfs_pread_file()
117 TEST_ASSERT_EQUAL(strlen(fatfs_test_hello_str) - 1, r); in test_fatfs_pread_file()
122 TEST_ASSERT_EQUAL(strlen(fatfs_test_hello_str) - 5, r); in test_fatfs_pread_file()
134 TEST_ASSERT_EQUAL(strlen(fatfs_test_hello_str) - 10, r); in test_fatfs_pread_file()
146 TEST_ASSERT_NOT_EQUAL(-1, fd); in test_pwrite()
148 …const off_t current_pos = lseek(fd, 0, SEEK_END); // O_APPEND is not the same - jumps to the end o… in test_pwrite()
162 TEST_ASSERT_NOT_EQUAL(-1, fd); in test_file_content()
165 TEST_ASSERT_NOT_EQUAL(-1, r); in test_file_content()
174 TEST_ASSERT_NOT_EQUAL(-1, fd); in test_fatfs_pwrite_file()
204 FILE* f = fopen(filename, "wb+"); in test_fatfs_lseek() local
205 TEST_ASSERT_NOT_NULL(f); in test_fatfs_lseek()
206 TEST_ASSERT_EQUAL(11, fprintf(f, "0123456789\n")); in test_fatfs_lseek()
207 TEST_ASSERT_EQUAL(0, fseek(f, -2, SEEK_CUR)); in test_fatfs_lseek()
208 TEST_ASSERT_EQUAL('9', fgetc(f)); in test_fatfs_lseek()
209 TEST_ASSERT_EQUAL(0, fseek(f, 3, SEEK_SET)); in test_fatfs_lseek()
210 TEST_ASSERT_EQUAL('3', fgetc(f)); in test_fatfs_lseek()
211 TEST_ASSERT_EQUAL(0, fseek(f, -3, SEEK_END)); in test_fatfs_lseek()
212 TEST_ASSERT_EQUAL('8', fgetc(f)); in test_fatfs_lseek()
213 TEST_ASSERT_EQUAL(0, fseek(f, 3, SEEK_END)); in test_fatfs_lseek()
214 TEST_ASSERT_EQUAL(14, ftell(f)); in test_fatfs_lseek()
215 TEST_ASSERT_EQUAL(4, fprintf(f, "abc\n")); in test_fatfs_lseek()
216 TEST_ASSERT_EQUAL(0, fseek(f, 0, SEEK_END)); in test_fatfs_lseek()
217 TEST_ASSERT_EQUAL(18, ftell(f)); in test_fatfs_lseek()
218 TEST_ASSERT_EQUAL(0, fseek(f, 0, SEEK_SET)); in test_fatfs_lseek()
221 TEST_ASSERT_EQUAL(18, fread(buf, 1, sizeof(buf), f)); in test_fatfs_lseek()
223 TEST_ASSERT_EQUAL_INT8_ARRAY(ref_buf, buf, sizeof(ref_buf) - 1); in test_fatfs_lseek()
224 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_lseek()
227 f = fopen(filename, "rb+"); in test_fatfs_lseek()
228 TEST_ASSERT_NOT_NULL(f); in test_fatfs_lseek()
229 TEST_ASSERT_EQUAL(0, fseek(f, 0, SEEK_END)); in test_fatfs_lseek()
230 TEST_ASSERT_EQUAL(18, ftell(f)); in test_fatfs_lseek()
231 TEST_ASSERT_EQUAL(0, fseek(f, -4, SEEK_CUR)); in test_fatfs_lseek()
232 TEST_ASSERT_EQUAL(14, ftell(f)); in test_fatfs_lseek()
233 TEST_ASSERT_EQUAL(0, fseek(f, -14, SEEK_CUR)); in test_fatfs_lseek()
234 TEST_ASSERT_EQUAL(0, ftell(f)); in test_fatfs_lseek()
236 TEST_ASSERT_EQUAL(18, fread(buf, 1, sizeof(buf), f)); in test_fatfs_lseek()
237 TEST_ASSERT_EQUAL_INT8_ARRAY(ref_buf, buf, sizeof(ref_buf) - 1); in test_fatfs_lseek()
238 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_lseek()
251 FILE* f = fopen(filename, "wb"); in test_fatfs_truncate_file() local
253 TEST_ASSERT_NOT_NULL(f); in test_fatfs_truncate_file()
254 TEST_ASSERT_EQUAL(strlen(input), fprintf(f, input)); in test_fatfs_truncate_file()
256 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_truncate_file()
260 TEST_ASSERT_EQUAL(-1, truncate(filename, strlen(input) + 1)); in test_fatfs_truncate_file()
263 TEST_ASSERT_EQUAL(-1, truncate(filename, -1)); in test_fatfs_truncate_file()
273 f = fopen(filename, "rb"); in test_fatfs_truncate_file()
274 TEST_ASSERT_NOT_NULL(f); in test_fatfs_truncate_file()
277 read = fread(output, 1, sizeof(output), f); in test_fatfs_truncate_file()
282 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_truncate_file()
287 TEST_ASSERT_EQUAL(-1, truncate(filename, truncated_len + 1)); in test_fatfs_truncate_file()
290 TEST_ASSERT_EQUAL(-1, truncate(filename, strlen(input))); in test_fatfs_truncate_file()
293 TEST_ASSERT_EQUAL(-1, truncate(filename, strlen(input) + 1)); in test_fatfs_truncate_file()
296 TEST_ASSERT_EQUAL(-1, truncate(filename, -1)); in test_fatfs_truncate_file()
306 f = fopen(filename, "rb"); in test_fatfs_truncate_file()
307 TEST_ASSERT_NOT_NULL(f); in test_fatfs_truncate_file()
310 read = fread(output, 1, sizeof(output), f); in test_fatfs_truncate_file()
315 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_truncate_file()
321 tm.tm_year = 2017 - 1900; in test_fatfs_stat()
340 TEST_ASSERT(abs(mtime - t) < 2); // fatfs library stores time with 2 second precision in test_fatfs_stat()
363 …// Setting up a false actual time - used when the file is created and for modification with the cu… in test_fatfs_utime()
364 desired_tm.tm_mon = 10 - 1; in test_fatfs_utime()
366 desired_tm.tm_year = 2018 - 1900; in test_fatfs_utime()
378 // 00:00:00. January 1st, 1980 - FATFS cannot handle earlier dates in test_fatfs_utime()
379 desired_tm.tm_mon = 1 - 1; in test_fatfs_utime()
381 desired_tm.tm_year = 1980 - 1900; in test_fatfs_utime()
396 TEST_ASSERT(false_now - achieved_stat.st_mtime <= 2); // two seconds of tolerance are given in test_fatfs_utime()
399 desired_tm.tm_mon = 12 - 1; in test_fatfs_utime()
401 desired_tm.tm_year = 2037 - 1900; in test_fatfs_utime()
413 // 00:00:00. January 1st, 1970 - FATFS cannot handle years before 1980 in test_fatfs_utime()
414 desired_tm.tm_mon = 1 - 1; in test_fatfs_utime()
416 desired_tm.tm_year = 1970 - 1900; in test_fatfs_utime()
422 TEST_ASSERT_EQUAL(-1, utime(filename, &desired_time)); in test_fatfs_utime()
448 FILE* f = fopen(name_src, "w+"); in test_fatfs_link_rename() local
449 TEST_ASSERT_NOT_NULL(f); in test_fatfs_link_rename()
452 TEST_ASSERT_NOT_EQUAL(EOF, fputs(str, f)); in test_fatfs_link_rename()
454 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_link_rename()
485 TEST_ASSERT_EQUAL(-1, stat(name_dir1, &st)); in test_fatfs_mkdir_rmdir()
495 TEST_ASSERT_EQUAL(-1, rmdir(name_dir2)); in test_fatfs_mkdir_rmdir()
515 if (strcasecmp(de->d_name, file_name) == 0) { in test_fatfs_can_opendir()
562 printf("found '%s'\n", de->d_name); in test_fatfs_opendir_readdir_rewinddir()
563 if (strcasecmp(de->d_name, "1.txt") == 0) { in test_fatfs_opendir_readdir_rewinddir()
564 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir()
567 } else if (strcasecmp(de->d_name, "2.txt") == 0) { in test_fatfs_opendir_readdir_rewinddir()
568 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir()
571 } else if (strcasecmp(de->d_name, "inner") == 0) { in test_fatfs_opendir_readdir_rewinddir()
572 TEST_ASSERT_TRUE(de->d_type == DT_DIR); in test_fatfs_opendir_readdir_rewinddir()
575 } else if (strcasecmp(de->d_name, "boo.bin") == 0) { in test_fatfs_opendir_readdir_rewinddir()
576 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir()
588 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[0])); in test_fatfs_opendir_readdir_rewinddir()
592 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[3])); in test_fatfs_opendir_readdir_rewinddir()
596 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[1])); in test_fatfs_opendir_readdir_rewinddir()
600 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[2])); in test_fatfs_opendir_readdir_rewinddir()
642 printf("found '%s'\n", de->d_name); in test_fatfs_opendir_readdir_rewinddir_utf_8()
643 if (strcasecmp(de->d_name, "文件一.txt") == 0) { in test_fatfs_opendir_readdir_rewinddir_utf_8()
644 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir_utf_8()
647 } else if (strcasecmp(de->d_name, "文件二.txt") == 0) { in test_fatfs_opendir_readdir_rewinddir_utf_8()
648 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir_utf_8()
651 } else if (strcasecmp(de->d_name, "内部目录") == 0) { in test_fatfs_opendir_readdir_rewinddir_utf_8()
652 TEST_ASSERT_TRUE(de->d_type == DT_DIR); in test_fatfs_opendir_readdir_rewinddir_utf_8()
655 } else if (strcasecmp(de->d_name, "文件三.bin") == 0) { in test_fatfs_opendir_readdir_rewinddir_utf_8()
656 TEST_ASSERT_TRUE(de->d_type == DT_REG); in test_fatfs_opendir_readdir_rewinddir_utf_8()
668 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[0])); in test_fatfs_opendir_readdir_rewinddir_utf_8()
672 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[3])); in test_fatfs_opendir_readdir_rewinddir_utf_8()
676 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[1])); in test_fatfs_opendir_readdir_rewinddir_utf_8()
680 TEST_ASSERT_EQUAL(0, strcasecmp(de->d_name, names[2])); in test_fatfs_opendir_readdir_rewinddir_utf_8()
706 FILE* f = fopen(args->filename, args->write ? "wb" : "rb"); in read_write_task() local
707 if (f == NULL) { in read_write_task()
708 args->result = ESP_ERR_NOT_FOUND; in read_write_task()
712 srand(args->seed); in read_write_task()
713 for (size_t i = 0; i < args->word_count; ++i) { in read_write_task()
715 if (args->write) { in read_write_task()
716 int cnt = fwrite(&val, sizeof(val), 1, f); in read_write_task()
719 args->result = ESP_FAIL; in read_write_task()
724 int cnt = fread(&rval, sizeof(rval), 1, f); in read_write_task()
727 args->result = ESP_FAIL; in read_write_task()
732 args->result = ESP_OK; in read_write_task()
735 fclose(f); in read_write_task()
738 xSemaphoreGive(args->done); in read_write_task()
757 const int cpuid_1 = portNUM_PROCESSORS - 1; in test_fatfs_concurrent()
804 FILE* f = fopen(filename, (is_write) ? "wb" : "rb"); in test_fatfs_rw_speed() local
805 TEST_ASSERT_NOT_NULL(f); in test_fatfs_rw_speed()
811 TEST_ASSERT_EQUAL(buf_size, write(fileno(f), buf, buf_size)); in test_fatfs_rw_speed()
813 if (read(fileno(f), buf, buf_size) != buf_size) { in test_fatfs_rw_speed()
814 printf("reading at n=%d, eof=%d", n, feof(f)); in test_fatfs_rw_speed()
823 TEST_ASSERT_EQUAL(0, fclose(f)); in test_fatfs_rw_speed()
825 float t_s = tv_end.tv_sec - tv_start.tv_sec + 1e-6f * (tv_end.tv_usec - tv_start.tv_usec); in test_fatfs_rw_speed()
826 printf("%s %d bytes (block size %d) in %.3fms (%.3f MB/s)\n", in test_fatfs_rw_speed()
828 file_size / (1024.0f * 1024.0f * t_s)); in test_fatfs_rw_speed()