blob: ffde15628e081da975822b8acfa6534f6262e951 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
static int fdopen_entry(void)
{
int fd;
FILE *stream;
fd = open("fdopen_file.txt", O_CREAT | O_RDWR | O_APPEND);
if (fd < 0)
{
printf("open fail.\n");
return -1;
}
/* TODO */
stream = fdopen(fd, "w");
if (stream == NULL)
{
printf("fdopen fail.\n");
return -1;
}
fclose(stream);
return 0;
}
#include <utest.h>
static void test_fdopen(void)
{
uassert_int_equal(fdopen_entry(), 0);
}
static void testcase(void)
{
UTEST_UNIT_RUN(test_fdopen);
}
UTEST_TC_EXPORT(testcase, "posix.stdio_h.fdopen_tc.c", RT_NULL, RT_NULL, 10);
|