tests: posix: fs: add testsuite for open truncate
add tests for posix open() with truncate flag Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
This commit is contained in:
parent
063d938aa5
commit
12e8bc7f82
1 changed files with 17 additions and 0 deletions
|
@ -342,3 +342,20 @@ ZTEST(posix_fs_file_test, test_fs_fd_leak)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ZTEST(posix_fs_file_test, test_file_open_truncate)
|
||||
{
|
||||
struct stat buf = {0};
|
||||
|
||||
zassert_ok(test_file_open());
|
||||
zassert_ok(test_file_write());
|
||||
zassert_ok(test_file_close());
|
||||
file = open(TEST_FILE, O_RDWR | O_TRUNC);
|
||||
zassert_not_equal(file, -1,
|
||||
"File open failed for truncate mode");
|
||||
|
||||
zassert_ok(test_file_close());
|
||||
zassert_ok(stat(TEST_FILE, &buf));
|
||||
zassert_equal(buf.st_size, 0, "Error: file is not truncated");
|
||||
zassert_ok(test_file_delete());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue