Skip to content

Commit 5dfbe14

Browse files
Jakub Klimczakfkokosinski
authored andcommitted
tests/posix/fs: Add test for fdopen
Add a test to the POSIX filesystem API suite that checks whether fdopen() returns a valid value. Signed-off-by: Jakub Klimczak <jklimczak@internships.antmicro.com> Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
1 parent c28a23d commit 5dfbe14

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/posix/fs/src/test_fs_file.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ static int test_file_open(void)
2828
return TC_PASS;
2929
}
3030

31+
static int test_file_fdopen(void)
32+
{
33+
FILE *fp = fdopen(file, "r");
34+
35+
if (fp == NULL) {
36+
TC_ERROR("Failed associating file descriptor %d with FILE, errno=%d\n", file,
37+
errno);
38+
return TC_FAIL;
39+
}
40+
return TC_PASS;
41+
}
42+
3143
int test_file_write(void)
3244
{
3345
ssize_t brw;
@@ -197,6 +209,18 @@ ZTEST(posix_fs_file_test, test_fs_open)
197209
zassert_true(test_file_open() == TC_PASS);
198210
}
199211

212+
/**
213+
* @brief Test for POSIX fdopen API
214+
*
215+
* @details Test converts file descriptor to FILE * through POSIX fdopen API.
216+
*/
217+
ZTEST(posix_fs_file_test, test_fs_fdopen)
218+
{
219+
/* FIXME: restructure tests as per #46897 */
220+
zassert_true(test_file_open() == TC_PASS);
221+
zassert_true(test_file_fdopen() == TC_PASS);
222+
}
223+
200224
/**
201225
* @brief Test for POSIX write API
202226
*

0 commit comments

Comments
 (0)