Lines Matching full:file
13 int file = -1; variable
21 TC_ERROR("Failed opening file: %d, errno=%d\n", res, errno); in test_file_open()
26 file = res; in test_file_open()
36 res = lseek(file, 0, SEEK_SET); in test_file_write()
39 close(file); in test_file_write()
40 file = -1; in test_file_write()
44 brw = write(file, (char *)test_str, strlen(test_str)); in test_file_write()
46 TC_PRINT("Failed writing to file [%d]\n", (int)brw); in test_file_write()
47 close(file); in test_file_write()
48 file = -1; in test_file_write()
55 close(file); in test_file_write()
56 file = -1; in test_file_write()
70 res = lseek(file, 0, SEEK_SET); in test_file_read()
73 close(file); in test_file_read()
74 file = -1; in test_file_read()
78 brw = read(file, read_buff, sz); in test_file_read()
80 TC_PRINT("Failed reading file [%d]\n", (int)brw); in test_file_read()
81 close(file); in test_file_read()
82 file = -1; in test_file_read()
96 res = lseek(file, 2, SEEK_SET); in test_file_read()
99 close(file); in test_file_read()
100 file = -1; in test_file_read()
104 brw = read(file, read_buff, sizeof(read_buff)); in test_file_read()
106 TC_PRINT("Failed reading file [%d]\n", (int)brw); in test_file_read()
107 close(file); in test_file_read()
108 file = -1; in test_file_read()
130 if (file >= 0) { in test_file_close()
131 res = close(file); in test_file_close()
133 TC_ERROR("Failed closing file: %d, errno=%d\n", res, errno); in test_file_close()
138 file = -1; in test_file_close()
148 if (file < 0) { in test_file_fsync()
152 res = fsync(file); in test_file_fsync()
154 TC_ERROR("Failed to sync file: %d, errno = %d\n", res, errno); in test_file_fsync()
158 close(file); in test_file_fsync()
159 file = -1; in test_file_fsync()
168 if (file < 0) { in test_file_fdatasync()
172 res = fdatasync(file); in test_file_fdatasync()
174 TC_ERROR("Failed to sync file: %d, errno = %d\n", res, errno); in test_file_fdatasync()
178 close(file); in test_file_fdatasync()
179 file = -1; in test_file_fdatasync()
189 if (file < 0) { in test_file_truncate()
193 res = ftruncate(file, truncate_size); in test_file_truncate()
195 TC_PRINT("Error truncating file [%d]\n", res); in test_file_truncate()
199 close(file); in test_file_truncate()
200 file = -1; in test_file_truncate()
210 TC_PRINT("Error deleting file [%d]\n", res); in test_file_delete()
231 * @details Test opens new file through POSIX open API.
267 * @details Test sync the file through POSIX fsync API.
280 * @details Test sync the file through POSIX fdatasync API.
297 * @details Test truncate the file through POSIX ftruncate API.
310 * @details Test closes the open file through POSIX close API.
322 * @details Test deletes a file through POSIX unlink API.
353 file = open(TEST_FILE, O_RDWR | O_TRUNC); in ZTEST()
354 zassert_not_equal(file, -1, in ZTEST()
355 "File open failed for truncate mode"); in ZTEST()
359 zassert_equal(buf.st_size, 0, "Error: file is not truncated"); in ZTEST()