Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
天中雨水
rt-thread
提交
b39210de
R
rt-thread
项目概览
天中雨水
/
rt-thread
该项目与 Fork 源项目分叉
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b39210de
编写于
7月 04, 2022
作者:
X
xiangxistu
提交者:
GitHub
7月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[add] posix testcase frame. (#6127)
上级
74ed15a8
变更
112
展开全部
隐藏空白更改
内联
并排
Showing
112 changed file
with
5160 addition
and
0 deletion
+5160
-0
examples/utest/testcases/Kconfig
examples/utest/testcases/Kconfig
+1
-0
examples/utest/testcases/posix/Kconfig
examples/utest/testcases/posix/Kconfig
+37
-0
examples/utest/testcases/posix/SConscript
examples/utest/testcases/posix/SConscript
+14
-0
examples/utest/testcases/posix/aio_h/Kconfig
examples/utest/testcases/posix/aio_h/Kconfig
+39
-0
examples/utest/testcases/posix/arpa/Kconfig
examples/utest/testcases/posix/arpa/Kconfig
+1
-0
examples/utest/testcases/posix/arpa/inet_h/Kconfig
examples/utest/testcases/posix/arpa/inet_h/Kconfig
+11
-0
examples/utest/testcases/posix/ctype_h/Kconfig
examples/utest/testcases/posix/ctype_h/Kconfig
+9
-0
examples/utest/testcases/posix/ctype_h/SConscript
examples/utest/testcases/posix/ctype_h/SConscript
+16
-0
examples/utest/testcases/posix/ctype_h/definitions/ctype_h.c
examples/utest/testcases/posix/ctype_h/definitions/ctype_h.c
+31
-0
examples/utest/testcases/posix/dirent_h/Kconfig
examples/utest/testcases/posix/dirent_h/Kconfig
+11
-0
examples/utest/testcases/posix/dirent_h/SConscript
examples/utest/testcases/posix/dirent_h/SConscript
+19
-0
examples/utest/testcases/posix/dirent_h/functions/open_read_close_dir_tc.c
...stcases/posix/dirent_h/functions/open_read_close_dir_tc.c
+41
-0
examples/utest/testcases/posix/errno_h/Kconfig
examples/utest/testcases/posix/errno_h/Kconfig
+3
-0
examples/utest/testcases/posix/errno_h/SConscript
examples/utest/testcases/posix/errno_h/SConscript
+15
-0
examples/utest/testcases/posix/errno_h/definitions/errno_h.c
examples/utest/testcases/posix/errno_h/definitions/errno_h.c
+104
-0
examples/utest/testcases/posix/fcntl_h/Kconfig
examples/utest/testcases/posix/fcntl_h/Kconfig
+9
-0
examples/utest/testcases/posix/fenv_h/Kconfig
examples/utest/testcases/posix/fenv_h/Kconfig
+9
-0
examples/utest/testcases/posix/inttypes_h/Kconfig
examples/utest/testcases/posix/inttypes_h/Kconfig
+9
-0
examples/utest/testcases/posix/libgen_h/Kconfig
examples/utest/testcases/posix/libgen_h/Kconfig
+15
-0
examples/utest/testcases/posix/locale_h/Kconfig
examples/utest/testcases/posix/locale_h/Kconfig
+15
-0
examples/utest/testcases/posix/mqueue_h/Kconfig
examples/utest/testcases/posix/mqueue_h/Kconfig
+9
-0
examples/utest/testcases/posix/net/Kconfig
examples/utest/testcases/posix/net/Kconfig
+1
-0
examples/utest/testcases/posix/net/if_h/Kconfig
examples/utest/testcases/posix/net/if_h/Kconfig
+11
-0
examples/utest/testcases/posix/netdb_h/Kconfig
examples/utest/testcases/posix/netdb_h/Kconfig
+11
-0
examples/utest/testcases/posix/pthread_h/Kconfig
examples/utest/testcases/posix/pthread_h/Kconfig
+43
-0
examples/utest/testcases/posix/pthread_h/SConscript
examples/utest/testcases/posix/pthread_h/SConscript
+47
-0
examples/utest/testcases/posix/pthread_h/definitions/pthread_h.c
...s/utest/testcases/posix/pthread_h/definitions/pthread_h.c
+159
-0
examples/utest/testcases/posix/pthread_h/functions/posixtest.h
...les/utest/testcases/posix/pthread_h/functions/posixtest.h
+25
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_broadcast/pthread_cond_broadcast_2-1_tc.c
...ns/pthread_cond_broadcast/pthread_cond_broadcast_2-1_tc.c
+138
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_destroy/pthread_cond_destroy_1-1_tc.c
...ctions/pthread_cond_destroy/pthread_cond_destroy_1-1_tc.c
+85
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_init/pthread_cond_init_1-1_tc.c
..._h/functions/pthread_cond_init/pthread_cond_init_1-1_tc.c
+65
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_timedwait/pthread_cond_timedwait_2-1_tc.c
...ns/pthread_cond_timedwait/pthread_cond_timedwait_2-1_tc.c
+143
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_create/pthread_create_1-2_tc.c
...thread_h/functions/pthread_create/pthread_create_1-2_tc.c
+61
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_1-1_tc.c
...thread_h/functions/pthread_detach/pthread_detach_1-1_tc.c
+91
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_2-1_tc.c
...thread_h/functions/pthread_detach/pthread_detach_2-1_tc.c
+87
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_4-1_tc.c
...thread_h/functions/pthread_detach/pthread_detach_4-1_tc.c
+92
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_exit/pthread_exit_1-1_tc.c
...ix/pthread_h/functions/pthread_exit/pthread_exit_1-1_tc.c
+79
-0
examples/utest/testcases/posix/pthread_h/functions/pthread_join/pthread_join_1-1_tc.c
...ix/pthread_h/functions/pthread_join/pthread_join_1-1_tc.c
+75
-0
examples/utest/testcases/posix/pthread_h/functions/rtt_utest_internal.h
.../testcases/posix/pthread_h/functions/rtt_utest_internal.h
+24
-0
examples/utest/testcases/posix/pthread_h/functions/testfrmw/testfrmw.c
...t/testcases/posix/pthread_h/functions/testfrmw/testfrmw.c
+68
-0
examples/utest/testcases/posix/pthread_h/functions/testfrmw/testfrmw.h
...t/testcases/posix/pthread_h/functions/testfrmw/testfrmw.h
+96
-0
examples/utest/testcases/posix/pthread_h/functions/testfrmw/threads_scenarii.c
...ses/posix/pthread_h/functions/testfrmw/threads_scenarii.c
+555
-0
examples/utest/testcases/posix/sched_h/Kconfig
examples/utest/testcases/posix/sched_h/Kconfig
+9
-0
examples/utest/testcases/posix/semaphore_h/Kconfig
examples/utest/testcases/posix/semaphore_h/Kconfig
+9
-0
examples/utest/testcases/posix/setjmp_h/Kconfig
examples/utest/testcases/posix/setjmp_h/Kconfig
+9
-0
examples/utest/testcases/posix/signal_h/Kconfig
examples/utest/testcases/posix/signal_h/Kconfig
+23
-0
examples/utest/testcases/posix/stdarg_h/Kconfig
examples/utest/testcases/posix/stdarg_h/Kconfig
+9
-0
examples/utest/testcases/posix/stdio_h/Kconfig
examples/utest/testcases/posix/stdio_h/Kconfig
+149
-0
examples/utest/testcases/posix/stdio_h/SConscript
examples/utest/testcases/posix/stdio_h/SConscript
+116
-0
examples/utest/testcases/posix/stdio_h/definitions/stdio_h.c
examples/utest/testcases/posix/stdio_h/definitions/stdio_h.c
+123
-0
examples/utest/testcases/posix/stdio_h/functions/clearerr_tc.c
...les/utest/testcases/posix/stdio_h/functions/clearerr_tc.c
+31
-0
examples/utest/testcases/posix/stdio_h/functions/fclose_tc.c
examples/utest/testcases/posix/stdio_h/functions/fclose_tc.c
+34
-0
examples/utest/testcases/posix/stdio_h/functions/fdopen_tc.c
examples/utest/testcases/posix/stdio_h/functions/fdopen_tc.c
+39
-0
examples/utest/testcases/posix/stdio_h/functions/feof_tc.c
examples/utest/testcases/posix/stdio_h/functions/feof_tc.c
+55
-0
examples/utest/testcases/posix/stdio_h/functions/ferror_tc.c
examples/utest/testcases/posix/stdio_h/functions/ferror_tc.c
+28
-0
examples/utest/testcases/posix/stdio_h/functions/fflush_tc.c
examples/utest/testcases/posix/stdio_h/functions/fflush_tc.c
+29
-0
examples/utest/testcases/posix/stdio_h/functions/fgetc_tc.c
examples/utest/testcases/posix/stdio_h/functions/fgetc_tc.c
+54
-0
examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c
examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/fileno_tc.c
examples/utest/testcases/posix/stdio_h/functions/fileno_tc.c
+26
-0
examples/utest/testcases/posix/stdio_h/functions/fopen_tc.c
examples/utest/testcases/posix/stdio_h/functions/fopen_tc.c
+28
-0
examples/utest/testcases/posix/stdio_h/functions/fprintf_tc.c
...ples/utest/testcases/posix/stdio_h/functions/fprintf_tc.c
+45
-0
examples/utest/testcases/posix/stdio_h/functions/fputc_tc.c
examples/utest/testcases/posix/stdio_h/functions/fputc_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/fputs_tc.c
examples/utest/testcases/posix/stdio_h/functions/fputs_tc.c
+45
-0
examples/utest/testcases/posix/stdio_h/functions/fread_tc.c
examples/utest/testcases/posix/stdio_h/functions/fread_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/fscanf_tc.c
examples/utest/testcases/posix/stdio_h/functions/fscanf_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/fseek_tc.c
examples/utest/testcases/posix/stdio_h/functions/fseek_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/ftell_tc.c
examples/utest/testcases/posix/stdio_h/functions/ftell_tc.c
+38
-0
examples/utest/testcases/posix/stdio_h/functions/fwrite_tc.c
examples/utest/testcases/posix/stdio_h/functions/fwrite_tc.c
+45
-0
examples/utest/testcases/posix/stdio_h/functions/perror_tc.c
examples/utest/testcases/posix/stdio_h/functions/perror_tc.c
+25
-0
examples/utest/testcases/posix/stdio_h/functions/printf_tc.c
examples/utest/testcases/posix/stdio_h/functions/printf_tc.c
+19
-0
examples/utest/testcases/posix/stdio_h/functions/putc_tc.c
examples/utest/testcases/posix/stdio_h/functions/putc_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/putchar_tc.c
...ples/utest/testcases/posix/stdio_h/functions/putchar_tc.c
+25
-0
examples/utest/testcases/posix/stdio_h/functions/puts_tc.c
examples/utest/testcases/posix/stdio_h/functions/puts_tc.c
+22
-0
examples/utest/testcases/posix/stdio_h/functions/remove_tc.c
examples/utest/testcases/posix/stdio_h/functions/remove_tc.c
+35
-0
examples/utest/testcases/posix/stdio_h/functions/rename_tc.c
examples/utest/testcases/posix/stdio_h/functions/rename_tc.c
+37
-0
examples/utest/testcases/posix/stdio_h/functions/rewind_tc.c
examples/utest/testcases/posix/stdio_h/functions/rewind_tc.c
+44
-0
examples/utest/testcases/posix/stdio_h/functions/setbuf_tc.c
examples/utest/testcases/posix/stdio_h/functions/setbuf_tc.c
+41
-0
examples/utest/testcases/posix/stdio_h/functions/setvbuf_tc.c
...ples/utest/testcases/posix/stdio_h/functions/setvbuf_tc.c
+41
-0
examples/utest/testcases/posix/stdio_h/functions/snprintf_tc.c
...les/utest/testcases/posix/stdio_h/functions/snprintf_tc.c
+27
-0
examples/utest/testcases/posix/stdio_h/functions/sprintf_tc.c
...ples/utest/testcases/posix/stdio_h/functions/sprintf_tc.c
+27
-0
examples/utest/testcases/posix/stdio_h/functions/sscanf_tc.c
examples/utest/testcases/posix/stdio_h/functions/sscanf_tc.c
+30
-0
examples/utest/testcases/posix/stdio_h/functions/vfprintf_tc.c
...les/utest/testcases/posix/stdio_h/functions/vfprintf_tc.c
+51
-0
examples/utest/testcases/posix/stdio_h/functions/vprintf_tc.c
...ples/utest/testcases/posix/stdio_h/functions/vprintf_tc.c
+30
-0
examples/utest/testcases/posix/stdio_h/functions/vsnprintf_tc.c
...es/utest/testcases/posix/stdio_h/functions/vsnprintf_tc.c
+38
-0
examples/utest/testcases/posix/stdio_h/functions/vsprintf_tc.c
...les/utest/testcases/posix/stdio_h/functions/vsprintf_tc.c
+38
-0
examples/utest/testcases/posix/stdlib_h/Kconfig
examples/utest/testcases/posix/stdlib_h/Kconfig
+23
-0
examples/utest/testcases/posix/stdlib_h/SConscript
examples/utest/testcases/posix/stdlib_h/SConscript
+27
-0
examples/utest/testcases/posix/stdlib_h/definitions/stdlib_h.c
...les/utest/testcases/posix/stdlib_h/definitions/stdlib_h.c
+85
-0
examples/utest/testcases/posix/stdlib_h/functions/atoi_tc.c
examples/utest/testcases/posix/stdlib_h/functions/atoi_tc.c
+67
-0
examples/utest/testcases/posix/stdlib_h/functions/atol_tc.c
examples/utest/testcases/posix/stdlib_h/functions/atol_tc.c
+69
-0
examples/utest/testcases/posix/stdlib_h/functions/qsort_tc.c
examples/utest/testcases/posix/stdlib_h/functions/qsort_tc.c
+136
-0
examples/utest/testcases/posix/stdlib_h/functions/strtol_tc.c
...ples/utest/testcases/posix/stdlib_h/functions/strtol_tc.c
+125
-0
examples/utest/testcases/posix/string_h/Kconfig
examples/utest/testcases/posix/string_h/Kconfig
+9
-0
examples/utest/testcases/posix/stropts_h/Kconfig
examples/utest/testcases/posix/stropts_h/Kconfig
+9
-0
examples/utest/testcases/posix/sys/Kconfig
examples/utest/testcases/posix/sys/Kconfig
+3
-0
examples/utest/testcases/posix/sys/mman_h/Kconfig
examples/utest/testcases/posix/sys/mman_h/Kconfig
+31
-0
examples/utest/testcases/posix/sys/select_h/Kconfig
examples/utest/testcases/posix/sys/select_h/Kconfig
+11
-0
examples/utest/testcases/posix/sys/shm_h/Kconfig
examples/utest/testcases/posix/sys/shm_h/Kconfig
+9
-0
examples/utest/testcases/posix/sys/socket_h/Kconfig
examples/utest/testcases/posix/sys/socket_h/Kconfig
+11
-0
examples/utest/testcases/posix/sys/stat_h/Kconfig
examples/utest/testcases/posix/sys/stat_h/Kconfig
+23
-0
examples/utest/testcases/posix/sys/statvfs_h/Kconfig
examples/utest/testcases/posix/sys/statvfs_h/Kconfig
+11
-0
examples/utest/testcases/posix/sys/uio_h/Kconfig
examples/utest/testcases/posix/sys/uio_h/Kconfig
+15
-0
examples/utest/testcases/posix/sys/utsname_h/Kconfig
examples/utest/testcases/posix/sys/utsname_h/Kconfig
+9
-0
examples/utest/testcases/posix/time_h/Kconfig
examples/utest/testcases/posix/time_h/Kconfig
+55
-0
examples/utest/testcases/posix/unistd_h/Kconfig
examples/utest/testcases/posix/unistd_h/Kconfig
+27
-0
examples/utest/testcases/posix/unistd_h/SConscript
examples/utest/testcases/posix/unistd_h/SConscript
+33
-0
examples/utest/testcases/posix/unistd_h/functions/access_tc.c
...ples/utest/testcases/posix/unistd_h/functions/access_tc.c
+44
-0
examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
+59
-0
examples/utest/testcases/posix/unistd_h/functions/ftruncate_tc.c
...s/utest/testcases/posix/unistd_h/functions/ftruncate_tc.c
+36
-0
examples/utest/testcases/posix/unistd_h/functions/isatty_tc.c
...ples/utest/testcases/posix/unistd_h/functions/isatty_tc.c
+22
-0
examples/utest/testcases/posix/unistd_h/functions/open_read_write_fsync_close_tc.c
...posix/unistd_h/functions/open_read_write_fsync_close_tc.c
+67
-0
examples/utest/testcases/posix/unistd_h/functions/rmdir_tc.c
examples/utest/testcases/posix/unistd_h/functions/rmdir_tc.c
+32
-0
未找到文件。
examples/utest/testcases/Kconfig
浏览文件 @
b39210de
...
...
@@ -11,6 +11,7 @@ source "$RTT_DIR/examples/utest/testcases/utest/Kconfig"
source "$RTT_DIR/examples/utest/testcases/kernel/Kconfig"
source "$RTT_DIR/examples/utest/testcases/cpp11/Kconfig"
source "$RTT_DIR/examples/utest/testcases/drivers/serial_v2/Kconfig"
source "$RTT_DIR/examples/utest/testcases/posix/Kconfig"
endif
...
...
examples/utest/testcases/posix/Kconfig
0 → 100644
浏览文件 @
b39210de
menu "RTT Posix Testcase"
config RTT_POSIX_TESTCASE
select RT_USING_UTEST
bool "RTT Posix Testcase"
default n
if RTT_POSIX_TESTCASE
# source "$RTT_DIR/examples/utest/testcases/posix/aio_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/arpa/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/ctype_h/Kconfig" # reserve
source "$RTT_DIR/examples/utest/testcases/posix/dirent_h/Kconfig"
# source "$RTT_DIR/examples/utest/testcases/posix/errno_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/fcntl_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/fenv_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/inttypes_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/libgen_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/locale_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/mqueue_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/net/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/netdb_h/Kconfig" # reserve
source "$RTT_DIR/examples/utest/testcases/posix/pthread_h/Kconfig"
# source "$RTT_DIR/examples/utest/testcases/posix/sched_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/semaphore_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/setjmp_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/signal_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/stdarg_h/Kconfig" # reserve
source "$RTT_DIR/examples/utest/testcases/posix/stdio_h/Kconfig"
source "$RTT_DIR/examples/utest/testcases/posix/stdlib_h/Kconfig"
# source "$RTT_DIR/examples/utest/testcases/posix/string_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/stropts_h/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/sys/Kconfig" # reserve
# source "$RTT_DIR/examples/utest/testcases/posix/time_h/Kconfig" # reserve
source "$RTT_DIR/examples/utest/testcases/posix/unistd_h/Kconfig"
endif
endmenu
examples/utest/testcases/posix/SConscript
0 → 100644
浏览文件 @
b39210de
import
os
Import
(
'RTT_ROOT'
)
from
building
import
*
cwd
=
GetCurrentDir
()
objs
=
[]
list
=
os
.
listdir
(
cwd
)
for
d
in
list
:
path
=
os
.
path
.
join
(
cwd
,
d
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
path
,
'SConscript'
)):
objs
=
objs
+
SConscript
(
os
.
path
.
join
(
d
,
'SConscript'
))
Return
(
'objs'
)
examples/utest/testcases/posix/aio_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_AIO_H
bool "<aio.h>"
default n
if RTT_POSIX_TESTCASE_AIO_H
config AIO_H_AIO_CANCEL
bool "<aio.h -> aio_cancel>"
default n
config AIO_H_AIO_ERROR
bool "<aio.h -> aio_error>"
default n
config AIO_H_AIO_FSYNC
bool "<aio.h -> aio_fsync>"
default n
config AIO_H_AIO_READ
bool "<aio.h -> aio_read>"
default n
config AIO_H_AIO_RETURN
bool "<aio.h -> aio_return>"
default n
config AIO_H_AIO_SUSPEND
bool "<aio.h -> aio_suspend>"
default n
config AIO_H_AIO_WRITE
bool "<aio.h -> aio_write>"
default n
config AIO_H_AIO_LISTIO
bool "<aio.h -> lio_listio>"
default n
endif
examples/utest/testcases/posix/arpa/Kconfig
0 → 100644
浏览文件 @
b39210de
source "$RTT_DIR/examples/utest/testcases/posix/arpa/inet_h/Kconfig"
examples/utest/testcases/posix/arpa/inet_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_ARPA_INET_H
bool "<arpa/inet.h>"
default n
if RTT_POSIX_TESTCASE_ARPA_INET_H
config ARPA_INET_H_INTERFACE
bool "<arpa/inet.h> -> htonl, htons, ntohl, ntohs, inet_addr, inet_ntoa, inet_ntop, inet_pton"
default n
endif
examples/utest/testcases/posix/ctype_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_CTYPE_H
bool "<ctype.h>"
default n
if RTT_POSIX_TESTCASE_CTYPE_H
# functions, TODO
endif
examples/utest/testcases/posix/ctype_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
]
src
=
[]
if
GetDepend
(
'RTT_POSIX_TESTCASE_CTYPE_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_CTYPE_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/ctype_h/definitions/ctype_h.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull SA. All rights reserved.
* Created by: Laurent.Vivier@bull.net
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/* <ctype.h> */
#include <ctype.h>
static
char
xx
;
static
int
test_defined
()
{
isalnum
(
xx
);
isalpha
(
xx
);
isblank
(
xx
);
iscntrl
(
xx
);
isdigit
(
xx
);
isgraph
(
xx
);
islower
(
xx
);
isprint
(
xx
);
ispunct
(
xx
);
isspace
(
xx
);
isupper
(
xx
);
isxdigit
(
xx
);
tolower
(
xx
);
toupper
(
xx
);
}
examples/utest/testcases/posix/dirent_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_DIRENT_H
bool "<dirent.h>"
default n
if RTT_POSIX_TESTCASE_DIRENT_H
config DIRENT_H_OPENDIR_READDIR_CLOSEDIR
bool "<dirent.h> -> opendir, readdir, closedir"
default n
endif
examples/utest/testcases/posix/dirent_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
]
src
=
[]
if
GetDepend
(
'RTT_POSIX_TESTCASE_DIRENT_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
if
GetDepend
(
'DIRENT_H_OPENDIR_READDIR_CLOSEDIR'
):
src
+=
Glob
(
'./functions/open_read_close_dir_tc.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_DIRENT_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/dirent_h/functions/open_read_close_dir_tc.c
0 → 100644
浏览文件 @
b39210de
#include <dirent.h>
#include <unistd.h>
#include <stdio.h>
#define DIRFD_TEST_NAME "/"
/* API for: opendir readdir closedir */
static
int
dir_test_entry
(
void
)
{
DIR
*
dirp
;
struct
dirent
*
d
;
dirp
=
opendir
(
DIRFD_TEST_NAME
);
if
(
dirp
==
RT_NULL
)
{
printf
(
"open directory error!
\n
"
);
}
else
{
while
((
d
=
readdir
(
dirp
))
!=
RT_NULL
)
{
printf
(
"found %s
\n
"
,
d
->
d_name
);
}
closedir
(
dirp
);
}
return
0
;
}
#include <utest.h>
static
void
test_dir
(
void
)
{
uassert_int_equal
(
dir_test_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_dir
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.dirent_h.open_read_close_dir_tc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/errno_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_ERRNO_H
bool "<errno.h>"
default n
examples/utest/testcases/posix/errno_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
]
src
=
[]
if
GetDepend
(
'RTT_POSIX_TESTCASE_ERRNO_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_ERRNO_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/errno_h/definitions/errno_h.c
0 → 100644
浏览文件 @
b39210de
/*
* This test tests if error.h is exist and useble
*author:ysun@lnxw.com
*/
#include <sys/errno.h>
static
int
errno_test
;
__attribute__
((
unused
))
static
int
dummy1
=
E2BIG
;
__attribute__
((
unused
))
static
int
dummy2
=
EACCES
;
__attribute__
((
unused
))
static
int
dummy3
=
EADDRINUSE
;
__attribute__
((
unused
))
static
int
dummy4
=
EADDRNOTAVAIL
;
__attribute__
((
unused
))
static
int
dummy5
=
EAFNOSUPPORT
;
__attribute__
((
unused
))
static
int
dummy6
=
EAGAIN
;
__attribute__
((
unused
))
static
int
dummy7
=
EALREADY
;
__attribute__
((
unused
))
static
int
dummy8
=
EBADF
;
#ifdef EBADMSG
__attribute__
((
unused
))
static
int
dummy9
=
EBADMSG
;
#endif
__attribute__
((
unused
))
static
int
dummy10
=
EBUSY
;
__attribute__
((
unused
))
static
int
dummy11
=
ECANCELED
;
__attribute__
((
unused
))
static
int
dummy12
=
ECHILD
;
__attribute__
((
unused
))
static
int
dummy13
=
ECONNABORTED
;
__attribute__
((
unused
))
static
int
dummy14
=
ECONNREFUSED
;
__attribute__
((
unused
))
static
int
dummy15
=
ECONNRESET
;
__attribute__
((
unused
))
static
int
dummy16
=
EDEADLK
;
__attribute__
((
unused
))
static
int
dummy17
=
EDESTADDRREQ
;
__attribute__
((
unused
))
static
int
dummy18
=
EDOM
;
__attribute__
((
unused
))
static
int
dummy19
=
EDQUOT
;
__attribute__
((
unused
))
static
int
dummy20
=
EEXIST
;
__attribute__
((
unused
))
static
int
dummy21
=
EFAULT
;
__attribute__
((
unused
))
static
int
dummy22
=
EFBIG
;
__attribute__
((
unused
))
static
int
dummy23
=
EHOSTUNREACH
;
__attribute__
((
unused
))
static
int
dummy24
=
EIDRM
;
__attribute__
((
unused
))
static
int
dummy25
=
EILSEQ
;
__attribute__
((
unused
))
static
int
dummy26
=
EINPROGRESS
;
__attribute__
((
unused
))
static
int
dummy27
=
EINTR
;
__attribute__
((
unused
))
static
int
dummy28
=
EINVAL
;
__attribute__
((
unused
))
static
int
dummy29
=
EIO
;
__attribute__
((
unused
))
static
int
dummy30
=
EISCONN
;
__attribute__
((
unused
))
static
int
dummy31
=
EISDIR
;
__attribute__
((
unused
))
static
int
dummy32
=
ELOOP
;
__attribute__
((
unused
))
static
int
dummy33
=
EMFILE
;
__attribute__
((
unused
))
static
int
dummy34
=
EMLINK
;
__attribute__
((
unused
))
static
int
dummy35
=
EMSGSIZE
;
__attribute__
((
unused
))
static
int
dummy36
=
EMULTIHOP
;
__attribute__
((
unused
))
static
int
dummy37
=
ENAMETOOLONG
;
__attribute__
((
unused
))
static
int
dummy38
=
ENETDOWN
;
__attribute__
((
unused
))
static
int
dummy39
=
ENETRESET
;
__attribute__
((
unused
))
static
int
dummy40
=
ENETUNREACH
;
__attribute__
((
unused
))
static
int
dummy41
=
ENFILE
;
__attribute__
((
unused
))
static
int
dummy42
=
ENOBUFS
;
#ifdef ENODATA
__attribute__
((
unused
))
static
int
dummy43
=
ENODATA
;
#endif
__attribute__
((
unused
))
static
int
dummy44
=
ENODEV
;
__attribute__
((
unused
))
static
int
dummy45
=
ENOENT
;
__attribute__
((
unused
))
static
int
dummy46
=
ENOEXEC
;
__attribute__
((
unused
))
static
int
dummy47
=
ENOLCK
;
__attribute__
((
unused
))
static
int
dummy48
=
ENOLINK
;
__attribute__
((
unused
))
static
int
dummy49
=
ENOMEM
;
__attribute__
((
unused
))
static
int
dummy50
=
ENOMSG
;
__attribute__
((
unused
))
static
int
dummy51
=
ENOPROTOOPT
;
__attribute__
((
unused
))
static
int
dummy52
=
ENOSPC
;
#ifdef ENOSR
__attribute__
((
unused
))
static
int
dummy53
=
ENOSR
;
#endif
#ifdef ENOSTR
__attribute__
((
unused
))
static
int
dummy54
=
ENOSTR
;
#endif
__attribute__
((
unused
))
static
int
dummy55
=
ENOSYS
;
__attribute__
((
unused
))
static
int
dummy56
=
ENOTCONN
;
__attribute__
((
unused
))
static
int
dummy57
=
ENOTDIR
;
__attribute__
((
unused
))
static
int
dummy58
=
ENOTEMPTY
;
__attribute__
((
unused
))
static
int
dummy59
=
ENOTSOCK
;
__attribute__
((
unused
))
static
int
dummy60
=
ENOTSUP
;
__attribute__
((
unused
))
static
int
dummy61
=
ENOTTY
;
__attribute__
((
unused
))
static
int
dummy62
=
ENXIO
;
__attribute__
((
unused
))
static
int
dummy63
=
EOPNOTSUPP
;
__attribute__
((
unused
))
static
int
dummy64
=
EOVERFLOW
;
__attribute__
((
unused
))
static
int
dummy65
=
EPERM
;
__attribute__
((
unused
))
static
int
dummy66
=
EPIPE
;
__attribute__
((
unused
))
static
int
dummy67
=
EPROTO
;
__attribute__
((
unused
))
static
int
dummy68
=
EPROTONOSUPPORT
;
__attribute__
((
unused
))
static
int
dummy69
=
EPROTOTYPE
;
__attribute__
((
unused
))
static
int
dummy70
=
ERANGE
;
__attribute__
((
unused
))
static
int
dummy71
=
EROFS
;
__attribute__
((
unused
))
static
int
dummy72
=
ESPIPE
;
__attribute__
((
unused
))
static
int
dummy73
=
ESRCH
;
__attribute__
((
unused
))
static
int
dummy74
=
ESTALE
;
#ifdef ETIME
__attribute__
((
unused
))
static
int
dummy75
=
ETIME
;
#endif
__attribute__
((
unused
))
static
int
dummy76
=
ETIMEDOUT
;
__attribute__
((
unused
))
static
int
dummy77
=
ETXTBSY
;
__attribute__
((
unused
))
static
int
dummy78
=
EWOULDBLOCK
;
__attribute__
((
unused
))
static
int
dummy79
=
EXDEV
;
__attribute__
((
unused
))
static
int
dummyfcn
(
void
)
{
errno_test
=
errno
;
return
0
;
}
examples/utest/testcases/posix/fcntl_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_FCNTL_H
bool "<fcntl.h>"
default n
if RTT_POSIX_TESTCASE_FCNTL_H
# function, TODO
endif
examples/utest/testcases/posix/fenv_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_FENV_H
bool "<fenv.h>"
default n
if RTT_POSIX_TESTCASE_FENV_H
# function, TODO
endif
examples/utest/testcases/posix/inttypes_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_INTTYPES_H
bool "<inttypes.h>"
default n
if RTT_POSIX_TESTCASE_INTTYPES_H
# function, TODO
endif
examples/utest/testcases/posix/libgen_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_LIBGEN_H
bool "<libgen.h>"
default n
if RTT_POSIX_TESTCASE_LIBGEN_H
config LIBGEN_H_BASENAME
bool "<libgen.h> -> basename"
default n
config LIBGEN_H_DIRNAME
bool "<libgen.h> -> dirname"
default n
endif
examples/utest/testcases/posix/locale_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_LOCALE_H
bool "<locale.h>"
default n
if RTT_POSIX_TESTCASE_LOCALE_H
config LOCALE_H_SETLOCALE
bool "<locale.h -> setlocale>"
default n
config LIBGEN_H_LOCALECONV
bool "<locale.h -> localconv>"
default n
endif
examples/utest/testcases/posix/mqueue_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_MQUEUE_H
bool "<mqueue.h>"
default n
if RTT_POSIX_TESTCASE_MQUEUE_H
# functions, TODO
endif
examples/utest/testcases/posix/net/Kconfig
0 → 100644
浏览文件 @
b39210de
source "$RTT_DIR/examples/utest/testcases/posix/net/if_h/Kconfig"
examples/utest/testcases/posix/net/if_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_NET_IF_H
bool "<net/if.h>"
default n
if RTT_POSIX_TESTCASE_NET_IF_H
config NET_IF_H_NAMEINDEX
bool "<net/if.h> -> if_freenameindex, if_indextoname, if_nameindex, if_nametoindex"
default n
endif
examples/utest/testcases/posix/netdb_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_NETDB_H
bool "<netdb.h>"
default n
if RTT_POSIX_TESTCASE_NETDB_H
config NETDB_H_ADDRINFO
bool "<netdb.h> -> getaddrinfo, gai_strerror, getnameinfo, freeaddrinfo"
default n
endif
examples/utest/testcases/posix/pthread_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_PTHREAD_H
bool "<pthread.h>"
default n
if RTT_POSIX_TESTCASE_PTHREAD_H
config PTHREAD_H_PTHREAD_CREATE
bool "<pthread.h> -> pthread_create"
default n
config PTHREAD_H_PTHREAD_JOIN
bool "<pthread.h> -> pthread_join"
default n
config PTHREAD_H_PTHREAD_EXIT
bool "<pthread.h> -> pthread_exit"
default n
config PTHREAD_H_PTHREAD_COND_INIT
bool "<pthread.h> -> pthread_cond_init"
default n
config PTHREAD_H_PTHREAD_COND_DESTROY
bool "<pthread.h> -> pthread_cond_destroy"
default n
config PTHREAD_H_PTHREAD_COND_BROADCAST
bool "<pthread.h> -> pthread_cond_broadcast"
default n
config PTHREAD_H_PTHREAD_COND_SIGNAL
bool "<pthread.h> -> pthread_cond_signal"
default n
config PTHREAD_H_PTHREAD_COND_TIMEWAIT
bool "<pthread.h> -> pthread_cond_timedwait"
default n
config PTHREAD_H_PTHREAD_DETACH
bool "<pthread.h> -> pthread_detach"
default n
endif
examples/utest/testcases/posix/pthread_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
+
'/functions'
]
src
=
[]
src
+=
Glob
(
'./definitions/testfrmw/*.c'
)
path
+=
[
cwd
+
'/functions/testfrmw'
]
if
GetDepend
(
'RTT_POSIX_TESTCASE_PTHREAD_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_CREATE'
]):
src
+=
Glob
(
'./functions/pthread_create/pthread_create_1-2_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_JOIN'
]):
src
+=
Glob
(
'./functions/pthread_join/pthread_join_1-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_EXIT'
]):
src
+=
Glob
(
'./functions/pthread_exit/pthread_exit_1-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_COND_INIT'
]):
src
+=
Glob
(
'./functions/pthread_cond_init/pthread_cond_init_1-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_COND_DESTROY'
]):
src
+=
Glob
(
'./functions/pthread_cond_destroy/pthread_cond_destroy_1-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_COND_BROADCAST'
]):
src
+=
Glob
(
'./functions/pthread_cond_broadcast/pthread_cond_broadcast_1-1_tc.c'
)
src
+=
Glob
(
'./functions/pthread_cond_broadcast/pthread_cond_broadcast_2-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_COND_SIGNAL'
]):
src
+=
Glob
(
'./functions/pthread_cond_signal/pthread_cond_signal_2-2_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_COND_TIMEWAIT'
]):
src
+=
Glob
(
'./functions/pthread_cond_timedwait/pthread_cond_timedwait_1-1_tc.c'
)
src
+=
Glob
(
'./functions/pthread_cond_timedwait/pthread_cond_timedwait_2-1_tc.c'
)
if
GetDepend
([
'PTHREAD_H_PTHREAD_DETACH'
]):
src
+=
Glob
(
'./functions/pthread_detach/pthread_detach_4-1_tc.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_PTHREAD_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/pthread_h/definitions/pthread_h.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
Test this function is defined:
int pthread_mutexattr_destroy(pthread_mutexattr_t *);
*/
#include <pthread.h>
int
(
*
test_pthread_atfork
)(
void
(
*
prepare
)(
void
),
void
(
*
parent
)(
void
),
void
(
*
child
)(
void
));
int
(
*
test_pthread_attr_destroy
)(
pthread_attr_t
*
__attr
);
int
(
*
test_pthread_attr_getdetachstate
)(
const
pthread_attr_t
*
__attr
,
int
*
__detachstate
);
int
(
*
test_pthread_attr_getguardsize
)(
const
pthread_attr_t
*
__attr
,
size_t
*
__guardsize
);
int
(
*
test_pthread_attr_getinheritsched
)(
const
pthread_attr_t
*
__attr
,
int
*
__inheritsched
);
int
(
*
test_pthread_attr_getschedparam
)(
const
pthread_attr_t
*
__attr
,
struct
sched_param
*
__param
);
int
(
*
test_pthread_attr_getschedpolicy
)(
const
pthread_attr_t
*
__attr
,
int
*
__policy
);
int
(
*
test_pthread_attr_getscope
)(
const
pthread_attr_t
*
__attr
,
int
*
__contentionscope
);
int
(
*
test_pthread_attr_getstack
)(
const
pthread_attr_t
*
attr
,
void
**
__stackaddr
,
size_t
*
__stacksize
);
int
(
*
test_pthread_attr_getstackaddr
)(
const
pthread_attr_t
*
__attr
,
void
**
__stackaddr
);
int
(
*
test_pthread_attr_getstacksize
)(
const
pthread_attr_t
*
__attr
,
size_t
*
__stacksize
);
int
(
*
test_pthread_attr_init
)(
pthread_attr_t
*
__attr
);
int
(
*
test_pthread_attr_setdetachstate
)(
pthread_attr_t
*
__attr
,
int
__detachstate
);
int
(
*
test_pthread_attr_setguardsize
)(
pthread_attr_t
*
__attr
,
size_t
__guardsize
);
int
(
*
test_pthread_attr_setinheritsched
)(
pthread_attr_t
*
__attr
,
int
__inheritsched
);
int
(
*
test_pthread_attr_setschedparam
)(
pthread_attr_t
*
__attr
,
const
struct
sched_param
*
__param
);
int
(
*
test_pthread_attr_setschedpolicy
)(
pthread_attr_t
*
__attr
,
int
__policy
);
int
(
*
test_pthread_attr_setscope
)(
pthread_attr_t
*
__attr
,
int
__contentionscope
);
int
(
*
test_pthread_attr_setstack
)(
pthread_attr_t
*
attr
,
void
*
__stackaddr
,
size_t
__stacksize
);
int
(
*
test_pthread_attr_setstackaddr
)(
pthread_attr_t
*
__attr
,
void
*
__stackaddr
);
int
(
*
test_pthread_attr_setstacksize
)(
pthread_attr_t
*
__attr
,
size_t
__stacksize
);
int
(
*
test_pthread_cancel
)(
pthread_t
__pthread
);
void
(
*
test_pthread_cleanup_pop
)(
int
execute
);
void
(
*
test_pthread_cleanup_push
)(
void
(
*
routine
)(
void
*
),
void
*
arg
);
int
(
*
test_pthread_cond_broadcast
)(
pthread_cond_t
*
__cond
);
int
(
*
test_pthread_cond_destroy
)(
pthread_cond_t
*
__mutex
);
int
(
*
test_pthread_cond_init
)(
pthread_cond_t
*
__cond
,
const
pthread_condattr_t
*
__attr
);
int
(
*
test_pthread_cond_signal
)(
pthread_cond_t
*
__cond
);
int
(
*
test_pthread_cond_timedwait
)(
pthread_cond_t
*
__cond
,
pthread_mutex_t
*
__mutex
,
const
struct
timespec
*
__abstime
);
int
(
*
test_pthread_cond_wait
)(
pthread_cond_t
*
__cond
,
pthread_mutex_t
*
__mutex
);
int
(
*
test_pthread_condattr_destroy
)(
pthread_condattr_t
*
__attr
);
int
(
*
test_pthread_condattr_getclock
)(
const
pthread_condattr_t
*
__restrict
__attr
,
clockid_t
*
__restrict
__clock_id
);
int
(
*
test_pthread_condattr_init
)(
pthread_condattr_t
*
__attr
);
int
(
*
test_pthread_condattr_setclock
)(
pthread_condattr_t
*
__attr
,
clockid_t
__clock_id
);
int
(
*
test_pthread_create
)(
pthread_t
*
__pthread
,
const
pthread_attr_t
*
__attr
,
void
*
(
*
__start_routine
)(
void
*
),
void
*
__arg
);
int
(
*
test_pthread_detach
)(
pthread_t
__pthread
);
int
(
*
test_pthread_equal
)(
pthread_t
__t1
,
pthread_t
__t2
);
void
(
*
test_pthread_exit
)(
void
*
__value_ptr
);
int
(
*
test_pthread_getcpuclockid
)(
pthread_t
thread
,
clockid_t
*
clock_id
);
int
(
*
test_pthread_getconcurrency
)(
void
);
int
(
*
test_pthread_getschedparam
)(
pthread_t
__pthread
,
int
*
__policy
,
struct
sched_param
*
__param
);
void
*
(
*
test_pthread_getspecific
)(
pthread_key_t
__key
);
int
(
*
test_pthread_join
)(
pthread_t
__pthread
,
void
**
__value_ptr
);
int
(
*
test_pthread_key_create
)(
pthread_key_t
*
__key
,
void
(
*
__destructor
)(
void
*
));
int
(
*
test_pthread_key_delete
)(
pthread_key_t
__key
);
int
(
*
test_pthread_mutex_destroy
)(
pthread_mutex_t
*
__mutex
);
int
(
*
test_pthread_mutex_getprioceiling
)(
const
pthread_mutex_t
*
__restrict
__mutex
,
int
*
__prioceiling
);
int
(
*
test_pthread_mutex_init
)(
pthread_mutex_t
*
__mutex
,
const
pthread_mutexattr_t
*
__attr
);
int
(
*
test_pthread_mutex_lock
)(
pthread_mutex_t
*
__mutex
);
int
(
*
test_pthread_mutex_setprioceiling
)(
pthread_mutex_t
*
__mutex
,
int
__prioceiling
,
int
*
__old_ceiling
);
int
(
*
test_pthread_mutex_trylock
)(
pthread_mutex_t
*
__mutex
);
int
(
*
test_pthread_mutex_unlock
)(
pthread_mutex_t
*
__mutex
);
int
(
*
test_pthread_mutexattr_destroy
)(
pthread_mutexattr_t
*
__attr
);
int
(
*
test_pthread_mutexattr_getprioceiling
)(
const
pthread_mutexattr_t
*
__attr
,
int
*
__prioceiling
);
int
(
*
test_pthread_mutexattr_getprotocol
)(
const
pthread_mutexattr_t
*
__attr
,
int
*
__protocol
);
int
(
*
test_pthread_mutexattr_gettype
)(
const
pthread_mutexattr_t
*
__attr
,
int
*
__kind
);
int
(
*
test_pthread_mutexattr_init
)(
pthread_mutexattr_t
*
__attr
);
int
(
*
test_pthread_mutexattr_setprioceiling
)(
const
pthread_mutexattr_t
*
__attr
,
int
__prioceiling
);
int
(
*
test_pthread_mutexattr_setprotocol
)(
const
pthread_mutexattr_t
*
__attr
,
int
__protocol
);
int
(
*
test_pthread_mutexattr_settype
)(
pthread_mutexattr_t
*
__attr
,
int
__kind
);
int
(
*
test_pthread_once
)(
pthread_once_t
*
__once_control
,
void
(
*
__init_routine
)(
void
));
pthread_t
(
*
test_pthread_self
)(
void
);
int
(
*
test_pthread_setcancelstate
)(
int
__state
,
int
*
__oldstate
);
int
(
*
test_pthread_setcanceltype
)(
int
__type
,
int
*
__oldtype
);
int
(
*
test_pthread_setconcurrency
)(
int
new_level
);
int
(
*
test_pthread_setschedparam
)(
pthread_t
__pthread
,
int
__policy
,
const
struct
sched_param
*
__param
);
int
(
*
test_pthread_setschedprio
)(
pthread_t
thread
,
int
prio
);
int
(
*
test_pthread_setspecific
)(
pthread_key_t
__key
,
const
void
*
__value
);
void
(
*
test_pthread_testcancel
)(
void
);
__attribute__
((
unused
))
static
void
dummy_func
()
{
test_pthread_atfork
=
pthread_atfork
;
test_pthread_attr_destroy
=
pthread_attr_destroy
;
test_pthread_attr_getdetachstate
=
pthread_attr_getdetachstate
;
test_pthread_attr_getguardsize
=
pthread_attr_getguardsize
;
test_pthread_attr_getinheritsched
=
pthread_attr_getinheritsched
;
test_pthread_attr_getschedparam
=
pthread_attr_getschedparam
;
test_pthread_attr_getschedpolicy
=
pthread_attr_getschedpolicy
;
test_pthread_attr_getscope
=
pthread_attr_getscope
;
test_pthread_attr_getstack
=
pthread_attr_getstack
;
test_pthread_attr_getstackaddr
=
pthread_attr_getstackaddr
;
test_pthread_attr_getstacksize
=
pthread_attr_getstacksize
;
test_pthread_attr_init
=
pthread_attr_init
;
test_pthread_attr_setdetachstate
=
pthread_attr_setdetachstate
;
test_pthread_attr_setguardsize
=
pthread_attr_setguardsize
;
test_pthread_attr_setinheritsched
=
pthread_attr_setinheritsched
;
test_pthread_attr_setschedparam
=
pthread_attr_setschedparam
;
test_pthread_attr_setschedpolicy
=
pthread_attr_setschedpolicy
;
test_pthread_attr_setscope
=
pthread_attr_setscope
;
test_pthread_attr_setstack
=
pthread_attr_setstack
;
test_pthread_attr_setstackaddr
=
pthread_attr_setstackaddr
;
test_pthread_attr_setstacksize
=
pthread_attr_setstacksize
;
test_pthread_cancel
=
pthread_cancel
;
test_pthread_cleanup_pop
=
pthread_cleanup_pop
;
test_pthread_cleanup_push
=
pthread_cleanup_push
;
test_pthread_cond_broadcast
=
pthread_cond_broadcast
;
test_pthread_cond_destroy
=
pthread_cond_destroy
;
test_pthread_cond_init
=
pthread_cond_init
;
test_pthread_cond_signal
=
pthread_cond_signal
;
test_pthread_cond_timedwait
=
pthread_cond_timedwait
;
test_pthread_cond_wait
=
pthread_cond_wait
;
test_pthread_condattr_destroy
=
pthread_condattr_destroy
;
test_pthread_condattr_getclock
=
pthread_condattr_getclock
;
test_pthread_condattr_init
=
pthread_condattr_init
;
test_pthread_condattr_setclock
=
pthread_condattr_setclock
;
test_pthread_create
=
pthread_create
;
test_pthread_detach
=
pthread_detach
;
test_pthread_equal
=
pthread_equal
;
test_pthread_exit
=
pthread_exit
;
test_pthread_getcpuclockid
=
pthread_getcpuclockid
;
test_pthread_getconcurrency
=
pthread_getconcurrency
;
test_pthread_getschedparam
=
pthread_getschedparam
;
test_pthread_getspecific
=
pthread_getspecific
;
test_pthread_join
=
pthread_join
;
test_pthread_key_create
=
pthread_key_create
;
test_pthread_key_delete
=
pthread_key_delete
;
test_pthread_mutex_destroy
=
pthread_mutex_destroy
;
test_pthread_mutex_getprioceiling
=
pthread_mutex_getprioceiling
;
test_pthread_mutex_init
=
pthread_mutex_init
;
test_pthread_mutex_lock
=
pthread_mutex_lock
;
test_pthread_mutex_setprioceiling
=
pthread_mutex_setprioceiling
;
test_pthread_mutex_trylock
=
pthread_mutex_trylock
;
test_pthread_mutex_unlock
=
pthread_mutex_unlock
;
test_pthread_mutexattr_destroy
=
pthread_mutexattr_destroy
;
test_pthread_mutexattr_getprioceiling
=
pthread_mutexattr_getprioceiling
;
test_pthread_mutexattr_getprotocol
=
pthread_mutexattr_getprotocol
;
test_pthread_mutexattr_gettype
=
pthread_mutexattr_gettype
;
test_pthread_mutexattr_init
=
pthread_mutexattr_init
;
test_pthread_mutexattr_setprioceiling
=
pthread_mutexattr_setprioceiling
;
test_pthread_mutexattr_setprotocol
=
pthread_mutexattr_setprotocol
;
test_pthread_mutexattr_settype
=
pthread_mutexattr_settype
;
test_pthread_once
=
pthread_once
;
test_pthread_self
=
pthread_self
;
test_pthread_setcancelstate
=
pthread_setcancelstate
;
test_pthread_setcanceltype
=
pthread_setcanceltype
;
test_pthread_setconcurrency
=
pthread_setconcurrency
;
test_pthread_setschedparam
=
pthread_setschedparam
;
test_pthread_setschedprio
=
pthread_setschedprio
;
test_pthread_setspecific
=
pthread_setspecific
;
test_pthread_testcancel
=
pthread_testcancel
;
return
;
}
examples/utest/testcases/posix/pthread_h/functions/posixtest.h
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* return codes
*/
#define PTS_PASS 0
#define PTS_FAIL 1
#define PTS_UNRESOLVED 2
#define PTS_UNSUPPORTED 4
#define PTS_UNTESTED 5
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
#endif
#define PTS_ATTRIBUTE_NORETURN __attribute__((noreturn))
#define PTS_ATTRIBUTE_UNUSED __attribute__((unused))
#define PTS_ATTRIBUTE_UNUSED_RESULT __attribute__((warn_unused_result))
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_broadcast/pthread_cond_broadcast_2-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: bing.wei.liu REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_cond_broadcast()
* When each thread unblocked as a result of pthread_cond_signal()
* returns from its call to pthread_cond_wait(), the thread shall
* own the mutex with which it called pthread_cond_wait().
*/
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "posixtest.h"
#define THREAD_NUM 3
static
struct
testdata
{
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
}
td
;
static
int
start_num
;
static
int
waken_num
;
static
void
*
thr_func
(
void
*
arg
PTS_ATTRIBUTE_UNUSED
)
{
int
rc
;
pthread_t
self
=
pthread_self
();
if
(
pthread_mutex_lock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"[Thread 0x%p] failed to acquire the mutex
\n
"
,
(
void
*
)
self
);
exit
(
PTS_UNRESOLVED
);
}
fprintf
(
stderr
,
"[Thread 0x%p] started and locked the mutex
\n
"
,
(
void
*
)
self
);
start_num
++
;
fprintf
(
stderr
,
"[Thread 0x%p] is waiting for the cond
\n
"
,
(
void
*
)
self
);
rc
=
pthread_cond_wait
(
&
td
.
cond
,
&
td
.
mutex
);
if
(
rc
!=
0
)
{
fprintf
(
stderr
,
"pthread_cond_wait return %d
\n
"
,
rc
);
exit
(
PTS_UNRESOLVED
);
}
if
(
pthread_mutex_trylock
(
&
td
.
mutex
)
==
0
)
{
fprintf
(
stderr
,
"[Thread 0x%p] should not be able to lock the "
"mutex again
\n
"
,
(
void
*
)
self
);
printf
(
"Test FAILED
\n
"
);
exit
(
PTS_FAIL
);
}
fprintf
(
stderr
,
"[Thread 0x%p] was wakened and acquired the "
"mutex again
\n
"
,
(
void
*
)
self
);
waken_num
++
;
if
(
pthread_mutex_unlock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"[Thread 0x%p] failed to release the "
"mutex
\n
"
,
(
void
*
)
self
);
printf
(
"Test FAILED
\n
"
);
exit
(
PTS_FAIL
);
}
fprintf
(
stderr
,
"[Thread 0x%p] released the mutex
\n
"
,
(
void
*
)
self
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
struct
timespec
completion_wait_ts
=
{
0
,
100000
};
int
i
,
rc
;
pthread_t
thread
[
THREAD_NUM
];
if
(
pthread_mutex_init
(
&
td
.
mutex
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
pthread_cond_init
(
&
td
.
cond
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize cond
\n
"
);
return
PTS_UNRESOLVED
;
}
for
(
i
=
0
;
i
<
THREAD_NUM
;
i
++
)
{
if
(
pthread_create
(
&
thread
[
i
],
NULL
,
thr_func
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to create thread[%d]
\n
"
,
i
);
return
PTS_UNRESOLVED
;
}
}
while
(
start_num
<
THREAD_NUM
)
nanosleep
(
&
completion_wait_ts
,
NULL
);
/* Acquire the mutex to make sure that all waiters are currently
blocked on pthread_cond_wait */
if
(
pthread_mutex_lock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Main: Fail to acquire mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
pthread_mutex_unlock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Main: Fail to release mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
/* broadcast the condition to wake up all waiters */
fprintf
(
stderr
,
"[Main thread] broadcast the condition
\n
"
);
rc
=
pthread_cond_broadcast
(
&
td
.
cond
);
if
(
rc
!=
0
)
{
fprintf
(
stderr
,
"[Main thread] failed to broadcast the "
"condition
\n
"
);
return
PTS_UNRESOLVED
;
}
sleep
(
1
);
if
(
waken_num
<
THREAD_NUM
)
{
fprintf
(
stderr
,
"[Main thread] Not all waiters were wakened
\n
"
);
for
(
i
=
0
;
i
<
THREAD_NUM
;
i
++
)
pthread_cancel
(
thread
[
i
]);
return
PTS_UNRESOLVED
;
}
fprintf
(
stderr
,
"[Main thread] all waiters were wakened
\n
"
);
/* join all secondary threads */
for
(
i
=
0
;
i
<
THREAD_NUM
;
i
++
)
{
if
(
pthread_join
(
thread
[
i
],
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to join thread[%d]
\n
"
,
i
);
return
PTS_UNRESOLVED
;
}
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_cond_broadcast.2-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_destroy/pthread_cond_destroy_1-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: bing.wei.liu REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_cond_destroy()
* shall destroy the condition variable referenced by 'cond';
* the condition variable object in effect becomes uninitialized.
*
*/
#include <pthread.h>
#include <stdio.h>
#include "posixtest.h"
static
pthread_cond_t
cond1
,
cond2
;
static
pthread_cond_t
cond3
=
PTHREAD_COND_INITIALIZER
;
static
int
posix_testcase
(
void
)
{
pthread_condattr_t
condattr
;
int
rc
;
/* Initialize a condition variable attribute object */
if
((
rc
=
pthread_condattr_init
(
&
condattr
))
!=
0
)
{
fprintf
(
stderr
,
"Error at pthread_condattr_init(), rc=%d
\n
"
,
rc
);
return
PTS_UNRESOLVED
;
}
printf
(
"Line-%04d
\n
"
,
__LINE__
);
/* Initialize cond1 with the default condition variable attribute */
if
((
rc
=
pthread_cond_init
(
&
cond1
,
&
condattr
))
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize cond1, rc=%d
\n
"
,
rc
);
return
PTS_UNRESOLVED
;
}
printf
(
"Line-%04d
\n
"
,
__LINE__
);
/* Initialize cond2 with NULL attributes */
if
((
rc
=
pthread_cond_init
(
&
cond2
,
NULL
))
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize cond2, rc=%d
\n
"
,
rc
);
return
PTS_UNRESOLVED
;
}
printf
(
"Line-%04d
\n
"
,
__LINE__
);
/* Destroy the condition variable attribute object */
if
((
rc
=
pthread_condattr_destroy
(
&
condattr
))
!=
0
)
{
fprintf
(
stderr
,
"Error at pthread_condattr_destroy(), rc=%d
\n
"
,
rc
);
return
PTS_UNRESOLVED
;
}
printf
(
"Line-%04d
\n
"
,
__LINE__
);
/* Destroy cond1 */
if
((
rc
=
pthread_cond_destroy
(
&
cond1
))
!=
0
)
{
fprintf
(
stderr
,
"Fail to destroy cond1, rc=%d
\n
"
,
rc
);
printf
(
"Test FAILED
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Line-%04d
\n
"
,
__LINE__
);
/* Destroy cond2 */
if
((
rc
=
pthread_cond_destroy
(
&
cond2
))
!=
0
)
{
fprintf
(
stderr
,
"Fail to destroy cond2, rc=%d
\n
"
,
rc
);
printf
(
"Test FAILED
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Line-%04d"
,
__LINE__
);
/* Destroy cond3 */
if
((
rc
=
pthread_cond_destroy
(
&
cond3
))
!=
0
)
{
fprintf
(
stderr
,
"Fail to destroy cond3, rc=%d
\n
"
,
rc
);
printf
(
"Test FAILED
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Line-%04d"
,
__LINE__
);
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_cond_destroy.1-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_init/pthread_cond_init_1-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: bing.wei.liu REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_cond_init()
* shall initialize the condition variable referenced by cond with attributes
* referenced by attr. If attr is NULL, the default condition variable
* attributes shall be used; the effect is the same as passing the address
* of a default condition variable attributes object.
* NOTE: There is no direct way to judge if two condition variables are equal,
* so this test does not cover the statement in the last sentence.
*
*
* Modified - LK coding style 30/05/2011
* Peter W. Morreale <pmorreale AT novell DOT com>
*/
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include "posixtest.h"
#define ERR_MSG(f, rc) printf("Failed: func: %s rc: %s (%u)\n", \
f, strerror(rc), rc);
static
int
posix_testcase
(
void
)
{
pthread_condattr_t
condattr
;
pthread_cond_t
cond1
;
pthread_cond_t
cond2
;
int
rc
;
char
*
f
;
int
status
=
PTS_UNRESOLVED
;
f
=
"pthread_condattr_init()"
;
rc
=
pthread_condattr_init
(
&
condattr
);
if
(
rc
)
goto
done
;
status
=
PTS_FAIL
;
f
=
"pthread_cond_init() - condattr"
;
rc
=
pthread_cond_init
(
&
cond1
,
&
condattr
);
if
(
rc
)
goto
done
;
f
=
"pthread_cond_init() - NULL"
;
rc
=
pthread_cond_init
(
&
cond2
,
NULL
);
if
(
rc
)
goto
done
;
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
done:
ERR_MSG
(
f
,
rc
);
return
status
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_cond_init.1-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_cond_timedwait/pthread_cond_timedwait_2-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: bing.wei.liu REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_cond_timedwait()
* shall be equivalent to pthread_cond_wait(), except that an error is returned
* if the absolute time specified by abstime passes before the condition cond is
* signaled or broadcasted, or if the absolute time specified by abstime has
* already been passed at the time of the call.
*
* Case 2-1
* Upon successful return, the mutex shall have been locked and shall
* be owned by the calling thread.
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include "posixtest.h"
#define INTERVAL 1
#define TIMEOUT 5
static
struct
testdata
{
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
}
td
;
static
int
t1_start
=
0
;
static
int
signaled
=
0
;
static
void
*
t1_func
(
void
*
arg
)
{
int
rc
;
struct
timespec
timeout
;
struct
timeval
curtime
;
(
void
)
arg
;
if
(
pthread_mutex_lock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Thread1 failed to acquire the mutex
\n
"
);
exit
(
PTS_UNRESOLVED
);
}
fprintf
(
stderr
,
"Thread1 started
\n
"
);
t1_start
=
1
;
/* let main thread continue */
if
(
gettimeofday
(
&
curtime
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to get current time
\n
"
);
exit
(
PTS_UNRESOLVED
);
}
timeout
.
tv_sec
=
curtime
.
tv_sec
+
TIMEOUT
;
timeout
.
tv_nsec
=
curtime
.
tv_usec
*
1000
;
fprintf
(
stderr
,
"Thread1 is waiting for the cond
\n
"
);
rc
=
pthread_cond_timedwait
(
&
td
.
cond
,
&
td
.
mutex
,
&
timeout
);
if
(
rc
!=
0
)
{
if
(
rc
==
ETIMEDOUT
)
{
fprintf
(
stderr
,
"Thread1 stops waiting when time is out
\n
"
);
exit
(
PTS_UNRESOLVED
);
}
else
{
fprintf
(
stderr
,
"pthread_cond_timedwait return %d
\n
"
,
rc
);
exit
(
PTS_UNRESOLVED
);
}
}
fprintf
(
stderr
,
"Thread1 wakened
\n
"
);
if
(
signaled
==
0
)
{
fprintf
(
stderr
,
"Thread1 did not block on the cond at all
\n
"
);
exit
(
PTS_UNRESOLVED
);
}
if
(
pthread_mutex_trylock
(
&
td
.
mutex
)
==
0
)
{
fprintf
(
stderr
,
"Thread1 should not be able to lock the mutex again
\n
"
);
printf
(
"Test FAILED
\n
"
);
exit
(
PTS_FAIL
);
}
fprintf
(
stderr
,
"Thread1 failed to trylock the mutex (as expected)
\n
"
);
if
(
pthread_mutex_unlock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Thread1 failed to release the mutex
\n
"
);
printf
(
"Test FAILED
\n
"
);
exit
(
PTS_FAIL
);
}
fprintf
(
stderr
,
"Thread1 released the mutex
\n
"
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_t
thread1
;
struct
timespec
thread_start_ts
=
{
0
,
100000
};
if
(
pthread_mutex_init
(
&
td
.
mutex
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
pthread_cond_init
(
&
td
.
cond
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to initialize cond
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
pthread_create
(
&
thread1
,
NULL
,
t1_func
,
NULL
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to create thread 1
\n
"
);
return
PTS_UNRESOLVED
;
}
while
(
!
t1_start
)
/* wait for thread1 started */
nanosleep
(
&
thread_start_ts
,
NULL
);
/* acquire the mutex released by pthread_cond_wait() within thread 1 */
if
(
pthread_mutex_lock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Main failed to acquire mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
pthread_mutex_unlock
(
&
td
.
mutex
)
!=
0
)
{
fprintf
(
stderr
,
"Main failed to release mutex
\n
"
);
return
PTS_UNRESOLVED
;
}
sleep
(
INTERVAL
);
fprintf
(
stderr
,
"Time to wake up thread1 by signaling a condition
\n
"
);
signaled
=
1
;
if
(
pthread_cond_signal
(
&
td
.
cond
)
!=
0
)
{
fprintf
(
stderr
,
"Main failed to signal the condition
\n
"
);
return
PTS_UNRESOLVED
;
}
pthread_join
(
thread1
,
NULL
);
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_cond_timedwait.2-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_create/pthread_create_1-2_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_create() creates a new thread with attributes specified
* by 'attr', within a process.
*
* Steps:
* 1. Create a thread using pthread_create()
* 2. Cancel that thread with pthread_cancel()
* 3. If that thread doesn't exist, then it pthread_cancel() will return
* an error code. This would mean that pthread_create() did not create
* a thread successfully.
*/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "posixtest.h"
static
void
*
a_thread_func
()
{
sleep
(
10
);
/* Shouldn't reach here. If we do, then the pthread_cancel()
* function did not succeed. */
fprintf
(
stderr
,
"Could not send cancel request correctly
\n
"
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_t
new_th
;
int
ret
;
ret
=
pthread_create
(
&
new_th
,
NULL
,
a_thread_func
,
NULL
);
if
(
ret
)
{
fprintf
(
stderr
,
"pthread_create(): %s
\n
"
,
strerror
(
ret
));
return
PTS_UNRESOLVED
;
}
/* Try to cancel the newly created thread. If an error is returned,
* then the thread wasn't created successfully. */
ret
=
pthread_cancel
(
new_th
);
if
(
ret
)
{
printf
(
"Test FAILED: A new thread wasn't created: %s
\n
"
,
strerror
(
ret
));
return
PTS_FAIL
;
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_create.1-2.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_1-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_detach()
*
* shall detach a thread. It shall indicate to the implementation that storage
* for 'thread' can be reclaimed when that thread terminates.
*
* STEPS:
* 1. Create a joinable thread
* 2. Detach that thread with pthread_detach()
* 3. Try and join the thread to main() using pthread_join()
* 4. An error should return from the pthread_join() function saying that the
* thread is detched. The test passes.
* 5. Else, if pthread_join is successful, the test fails.
*/
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "posixtest.h"
static
void
*
a_thread_func
()
{
pthread_setcanceltype
(
PTHREAD_CANCEL_ASYNCHRONOUS
,
NULL
);
/* If the thread wasn't canceled in 10 seconds, time out */
sleep
(
10
);
perror
(
"Thread couldn't be canceled (at cleanup time), timing out
\n
"
);
pthread_exit
(
0
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_attr_t
new_attr
;
pthread_t
new_th
;
int
ret
;
/* Initialize attribute */
if
(
pthread_attr_init
(
&
new_attr
)
!=
0
)
{
perror
(
"Cannot initialize attribute object
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Set the attribute object to be joinable */
if
(
pthread_attr_setdetachstate
(
&
new_attr
,
PTHREAD_CREATE_JOINABLE
)
!=
0
)
{
perror
(
"Error in pthread_attr_setdetachstate()
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Create the thread */
if
(
pthread_create
(
&
new_th
,
&
new_attr
,
a_thread_func
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Detach the thread. */
if
(
pthread_detach
(
new_th
)
!=
0
)
{
printf
(
"Error detaching thread
\n
"
);
return
PTS_FAIL
;
}
/* Now try and join it. This should fail. */
ret
=
pthread_join
(
new_th
,
NULL
);
/* Cleanup: Cancel the thread */
pthread_cancel
(
new_th
);
if
(
ret
==
0
)
{
printf
(
"Test FAILED
\n
"
);
return
PTS_FAIL
;
}
else
if
(
ret
==
EINVAL
)
{
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
else
{
perror
(
"Error in pthread_join
\n
"
);
return
PTS_UNRESOLVED
;
}
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_detach.1-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_2-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_detach()
*
* If 'thread' has not terminated, pthread_detach() shall not cause it to
* terminate. The effect of multiple pthread_detach() calls on the same
*
* STEPS:
* 1.Create a joinable thread
* 2.Detach that thread
* 3.Verify that the thread did not terminate because of this
*
*/
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "posixtest.h"
static
void
*
a_thread_func
()
{
pthread_setcanceltype
(
PTHREAD_CANCEL_ASYNCHRONOUS
,
NULL
);
/* If the thread wasn't canceled in 10 seconds, time out */
sleep
(
10
);
perror
(
"Thread couldn't be canceled (at cleanup time), timing out
\n
"
);
pthread_exit
(
0
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_attr_t
new_attr
;
pthread_t
new_th
;
int
ret
;
/* Initialize attribute */
if
(
pthread_attr_init
(
&
new_attr
)
!=
0
)
{
perror
(
"Cannot initialize attribute object
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Set the attribute object to be joinable */
if
(
pthread_attr_setdetachstate
(
&
new_attr
,
PTHREAD_CREATE_JOINABLE
)
!=
0
)
{
perror
(
"Error in pthread_attr_setdetachstate()
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Create the thread */
if
(
pthread_create
(
&
new_th
,
&
new_attr
,
a_thread_func
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Detach the thread. */
if
(
pthread_detach
(
new_th
)
!=
0
)
{
printf
(
"Error detaching thread
\n
"
);
return
PTS_FAIL
;
}
/* Verify that it hasn't terminated the thread */
ret
=
pthread_cancel
(
new_th
);
if
(
ret
!=
0
)
{
if
(
ret
==
ESRCH
)
{
printf
(
"Test FAILED
\n
"
);
return
PTS_FAIL
;
}
perror
(
"Error canceling thread
\n
"
);
return
PTS_UNRESOLVED
;
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_detach.2-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_detach/pthread_detach_4-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_detach()
*
* Upon failure, it shall return an error number:
* -[EINVAL] The implemenation has detected that the value specified by
* 'thread' does not refer to a joinable thread.
* -[ESRCH] No thread could be found corresponding to that thread
* It shall not return an error code of [EINTR]
*
* STEPS:
* 1.Create a detached state thread
* 2.Detach that thread
* 3.Check the return value and make sure it is EINVAL
*
*/
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "posixtest.h"
/* Thread function */
static
void
*
a_thread_func
()
{
pthread_setcanceltype
(
PTHREAD_CANCEL_ASYNCHRONOUS
,
NULL
);
/* If the thread wasn't canceled in 10 seconds, time out */
sleep
(
10
);
perror
(
"Thread couldn't be canceled (at cleanup time), timing out
\n
"
);
pthread_exit
(
0
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_attr_t
new_attr
;
pthread_t
new_th
;
int
ret
;
/* Initialize attribute */
if
(
pthread_attr_init
(
&
new_attr
)
!=
0
)
{
perror
(
"Cannot initialize attribute object
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Set the attribute object to be detached */
if
(
pthread_attr_setdetachstate
(
&
new_attr
,
PTHREAD_CREATE_DETACHED
)
!=
0
)
{
perror
(
"Error in pthread_attr_setdetachstate()
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Create the thread */
if
(
pthread_create
(
&
new_th
,
&
new_attr
,
a_thread_func
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Detach the thread. */
ret
=
pthread_detach
(
new_th
);
/* Cleanup and cancel the thread */
pthread_cancel
(
new_th
);
/* Check return value of pthread_detach() */
if
(
ret
!=
EINVAL
)
{
if
(
ret
==
ESRCH
)
{
perror
(
"Error detaching thread
\n
"
);
return
PTS_UNRESOLVED
;
}
printf
(
"Test FAILED: Incorrect return code
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_detach.4-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_exit/pthread_exit_1-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
* Test that pthread_exit()
*
* terminates the calling thread and makes the value 'value_ptr' available
* to any successful join with the terminating thread.
*
* Steps:
* 1. Create a new thread. Have it return a return code on pthread_exit();
* 2. Call pthread_join() in main(), and pass to it 'value_ptr'.
* 3. Check to see of the value_ptr and the value returned by pthread_exit() are the same;
*
*/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include "posixtest.h"
#define RETURN_CODE 100
/* Set a random return code number. This shall be the return code of the
thread when using pthread_exit(). */
#define INTHREAD 0
/* Control going to or is already for Thread */
#define INMAIN 1
/* Control going to or is already for Main */
static
int
sem
;
/* Manual semaphore used to indicate when the thread has been created. */
/* Thread's function. */
static
void
*
a_thread_func
()
{
sem
=
INMAIN
;
pthread_exit
((
void
*
)
RETURN_CODE
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_t
new_th
;
int
*
value_ptr
;
/* Initializing variables. */
value_ptr
=
0
;
sem
=
INTHREAD
;
/* Create a new thread. */
if
(
pthread_create
(
&
new_th
,
NULL
,
a_thread_func
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Make sure the thread was created before we join it. */
while
(
sem
==
INTHREAD
)
sleep
(
1
);
/* Wait for thread to return */
if
(
pthread_join
(
new_th
,
(
void
*
)
&
value_ptr
)
!=
0
)
{
perror
(
"Error in pthread_join()
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Check to make sure that 'value_ptr' that was passed to pthread_join() and the
* pthread_exit() return code that was used in the thread function are the same. */
if
((
long
)
value_ptr
!=
RETURN_CODE
)
{
printf
(
"Test FAILED: pthread_exit() could not pass the return value of the thread in 'value_ptr' to pthread_join().
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_exit.1-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/pthread_join/pthread_join_1-1_tc.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2002, Intel Corporation. All rights reserved.
* Created by: rolla.n.selbak REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*
* Test that pthread_join()
*
* shall suspend the execution of the calling thread until the target
* 'thread' terminates, unless 'thread' has already terminated.
*
* Steps:
* 1. Create a new thread. Have it sleep for 3 seconds.
* 2. The main() thread should wait for the new thread to finish
* execution before exiting out.
*
*/
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include "posixtest.h"
static
int
end_exec
;
static
void
*
a_thread_func
()
{
int
i
;
printf
(
"Wait for 3 seconds for thread to finish execution:
\n
"
);
for
(
i
=
1
;
i
<
4
;
i
++
)
{
printf
(
"Waited (%d) second
\n
"
,
i
);
sleep
(
1
);
}
/* Indicate that the thread has ended execution. */
end_exec
=
1
;
pthread_exit
(
0
);
return
NULL
;
}
static
int
posix_testcase
(
void
)
{
pthread_t
new_th
;
/* Initialize flag */
end_exec
=
0
;
/* Create a new thread. */
if
(
pthread_create
(
&
new_th
,
NULL
,
a_thread_func
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
return
PTS_UNRESOLVED
;
}
/* Wait for thread to return */
if
(
pthread_join
(
new_th
,
NULL
)
!=
0
)
{
perror
(
"Error in pthread_join()
\n
"
);
return
PTS_UNRESOLVED
;
}
if
(
end_exec
==
0
)
{
printf
(
"Test FAILED: When using pthread_join(), "
"main() did not wait for thread to finish "
"execution before continuing.
\n
"
);
return
PTS_FAIL
;
}
printf
(
"Test PASSED
\n
"
);
return
PTS_PASS
;
}
#include <rtt_utest_internal.h>
UTEST_TC_EXPORT
(
testcase
,
"posix.pthread_join.1-1.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/pthread_h/functions/rtt_utest_internal.h
0 → 100644
浏览文件 @
b39210de
#include <utest.h>
#include <pthread.h>
static
void
posix_unit_test
(
void
)
{
pthread_t
new_th
;
/* Create a new thread. */
int
err_val
;
if
(
pthread_create
(
&
new_th
,
NULL
,
(
void
*
(
*
)(
void
*
))
posix_testcase
,
NULL
)
!=
0
)
{
perror
(
"Error creating thread
\n
"
);
}
/* Wait for thread to return */
if
(
pthread_join
(
new_th
,
(
void
*
)
&
err_val
)
!=
0
)
{
perror
(
"Error in pthread_join()
\n
"
);
}
rt_thread_mdelay
(
1000
);
uassert_true
(
err_val
==
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
posix_unit_test
);
}
examples/utest/testcases/posix/pthread_h/functions/testfrmw/testfrmw.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull S.A.. All rights reserved.
* Created by: Sebastien Decugis
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This file is a wrapper to use the tests from the NPTL Test & Trace Project
* with either the Linux Test Project or the Open POSIX Test Suite.
* The following function are defined:
* void output_init()
* void output_fini()
* void output(char * string, ...)
*
* The are used to output informative text (as a printf).
*/
#include <time.h>
#include <sys/types.h>
#include <pthread.h>
#include <stdarg.h>
/* We use a mutex to avoid conflicts in traces */
static
pthread_mutex_t
m_trace
=
PTHREAD_MUTEX_INITIALIZER
;
static
void
output_init
(
void
)
{
return
;
}
static
void
output
(
char
*
string
,
...)
{
va_list
ap
;
struct
tm
*
now
;
time_t
nw
;
int
oldstate
;
pthread_setcancelstate
(
PTHREAD_CANCEL_DISABLE
,
&
oldstate
);
pthread_mutex_lock
(
&
m_trace
);
nw
=
time
(
NULL
);
now
=
localtime
(
&
nw
);
if
(
now
==
NULL
)
printf
(
"[??:??:??]
\n
"
);
else
printf
(
"[%2.2d:%2.2d:%2.2d]
\n
"
,
now
->
tm_hour
,
now
->
tm_min
,
now
->
tm_sec
);
va_start
(
ap
,
string
);
vprintf
(
string
,
ap
);
va_end
(
ap
);
pthread_mutex_unlock
(
&
m_trace
);
pthread_setcancelstate
(
oldstate
,
NULL
);
}
static
void
output_fini
(
void
)
{
return
;
}
examples/utest/testcases/posix/pthread_h/functions/testfrmw/testfrmw.h
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull S.A.. All rights reserved.
* Created by: Sebastien Decugis
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This file is a wrapper to use the tests from the NPTL Test & Trace Project
* with either the Linux Test Project or the Open POSIX Test Suite.
*
* The following macros are defined here:
* UNRESOLVED(ret, descr);
* where descr is a description of the error and ret is
* an int (error code for example)
* FAILED(descr);
* where descr is a short text saying why the test has failed.
* PASSED();
* No parameter.
*
* Both three macros shall terminate the calling process.
* The testcase shall not terminate without calling one of those macros.
*/
#include "posixtest.h"
#include <string.h>
#ifdef __GNUC__
#define UNRESOLVED(x, s) \
{ \
output("Test %s unresolved: got %i (%s) on line %i (%s)\n", \
__FILE__, x, strerror(x), __LINE__, s); \
output_fini(); \
exit(PTS_UNRESOLVED); \
}
#define FAILED(s) \
{ \
output("Test %s FAILED: %s\n", __FILE__, s); \
output_fini(); \
exit(PTS_FAIL); \
}
#define PASSED \
{ \
output_fini(); \
exit(PTS_PASS); \
}
#define UNTESTED(s) \
{ \
output("File %s cannot test: %s\n", __FILE__, s); \
output_fini(); \
exit(PTS_UNTESTED); \
}
#else
#define UNRESOLVED(x, s) \
{ \
output("Test unresolved: got %i (%s) on line %i (%s)\n", \
x, strerror(x), __LINE__, s); \
output_fini(); \
exit(PTS_UNRESOLVED); \
}
#define FAILED(s) \
{ \
output("Test FAILED: %s\n", s); \
output_fini(); \
exit(PTS_FAIL); \
}
#define PASSED \
{ \
output_fini(); \
exit(PTS_PASS); \
}
#define UNTESTED(s) \
{ \
output("Unable to test: %s\n", s); \
output_fini(); \
exit(PTS_UNTESTED); \
}
#endif
examples/utest/testcases/posix/pthread_h/functions/testfrmw/threads_scenarii.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull S.A.. All rights reserved.
* Created by: Sebastien Decugis
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This file is a helper file for the pthread_create tests
* It defines the following objects:
* scenarii: array of struct __scenario type.
* NSCENAR : macro giving the total # of scenarii
* scenar_init(): function to call before use the scenarii array.
* scenar_fini(): function to call after end of use of the scenarii array.
*/
static
struct
__scenario
{
/*
* Object to hold the given configuration,
* and which will be used to create the threads
*/
pthread_attr_t
ta
;
/* General parameters */
/* 0 => joinable; 1 => detached */
int
detached
;
/* Scheduling parameters */
/*
* 0 => sched policy is inherited;
* 1 => sched policy from the attr param
*/
int
explicitsched
;
/* 0 => default; 1=> SCHED_FIFO; 2=> SCHED_RR */
int
schedpolicy
;
/*
* 0 => default sched param;
* 1 => max value for sched param;
* -1 => min value for sched param
*/
int
schedparam
;
/*
* 0 => default contension scope;
* 1 => alternative contension scope
*/
int
altscope
;
/* Stack parameters */
/* 0 => system manages the stack; 1 => stack is provided */
int
altstack
;
/*
* 0 => default guardsize;
* 1=> guardsize is 0;
* 2=> guard is 1 page
* -- this setting only affect system stacks (not user's).
*/
int
guard
;
/*
* 0 => default stack size;
* 1 => stack size specified (min value)
* -- ignored when stack is provided
*/
int
altsize
;
/* Additionnal information */
/* object description */
char
*
descr
;
/* Stores the stack start when an alternate stack is required */
void
*
bottom
;
/*
* This thread creation is expected to:
* 0 => succeed; 1 => fail; 2 => unknown
*/
int
result
;
/*
* This semaphore is used to signal the end of
* the detached threads execution
*/
sem_t
sem
;
}
scenarii
[]
=
#define CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, res) \
{ \
.detached = det, \
.explicitsched = expl, \
.schedpolicy = scp, \
.schedparam = spa, \
.altscope = sco, \
.altstack = sta, \
.guard = gua, \
.altsize = ssi, \
.descr = desc, \
.bottom = NULL, \
.result = res \
}
#define CASE_POS(det, expl, scp, spa, sco, sta, gua, ssi, desc) \
CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 0)
#define CASE_NEG(det, expl, scp, spa, sco, sta, gua, ssi, desc) \
CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 1)
#define CASE_UNK(det, expl, scp, spa, sco, sta, gua, ssi, desc) \
CASE(det, expl, scp, spa, sco, sta, gua, ssi, desc, 2)
/*
* This array gives the different combinations of threads
* attributes for the testcases.
*
* Some combinations must be avoided.
* -> Do not have a detached thread use an alternative stack;
* as we don't know when the thread terminates to free the stack memory
* -> ... (to be completed)
*/
{
/* Unary tests */
CASE_POS
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
"default"
),
CASE_POS
(
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
"detached"
),
CASE_POS
(
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
,
"Explicit sched"
),
CASE_UNK
(
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
,
"FIFO Policy"
),
CASE_UNK
(
0
,
0
,
2
,
0
,
0
,
0
,
0
,
0
,
"RR Policy"
),
CASE_UNK
(
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
"Max sched param"
),
CASE_UNK
(
0
,
0
,
0
,
-
1
,
0
,
0
,
0
,
0
,
"Min sched param"
),
CASE_POS
(
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
,
"Alternative contension scope"
),
CASE_POS
(
0
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
"Alternative stack"
),
CASE_POS
(
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
"No guard size"
),
CASE_UNK
(
0
,
0
,
0
,
0
,
0
,
0
,
2
,
0
,
"1p guard size"
),
CASE_POS
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
"Min stack size"
),
/* Stack play */
CASE_POS
(
0
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
"Min stack size, no guard"
),
CASE_UNK
(
0
,
0
,
0
,
0
,
0
,
0
,
2
,
1
,
"Min stack size, 1p guard"
),
CASE_POS
(
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
"Detached, Alternative stack"
),
CASE_POS
(
1
,
0
,
0
,
0
,
0
,
0
,
1
,
1
,
"Detached, Min stack size, no guard"
),
CASE_UNK
(
1
,
0
,
0
,
0
,
0
,
0
,
2
,
1
,
"Detached, Min stack size, 1p guard"
),
/*
* Scheduling play
* -- all results are unknown since it might depend on
* the user priviledges
*/
CASE_UNK
(
0
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
"Explicit FIFO max param"
),
CASE_UNK
(
0
,
1
,
2
,
1
,
0
,
0
,
0
,
0
,
"Explicit RR max param"
),
CASE_UNK
(
0
,
1
,
1
,
-
1
,
0
,
0
,
0
,
0
,
"Explicit FIFO min param"
),
CASE_UNK
(
0
,
1
,
2
,
-
1
,
0
,
0
,
0
,
0
,
"Explicit RR min param"
),
CASE_UNK
(
0
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
"Explicit FIFO max param, alt scope"
),
CASE_UNK
(
0
,
1
,
2
,
1
,
1
,
0
,
0
,
0
,
"Explicit RR max param, alt scope"
),
CASE_UNK
(
0
,
1
,
1
,
-
1
,
1
,
0
,
0
,
0
,
"Explicit FIFO min param, alt scope"
),
CASE_UNK
(
0
,
1
,
2
,
-
1
,
1
,
0
,
0
,
0
,
"Explicit RR min param, alt scope"
),
CASE_UNK
(
1
,
1
,
1
,
1
,
0
,
0
,
0
,
0
,
"Detached, explicit FIFO max param"
),
CASE_UNK
(
1
,
1
,
2
,
1
,
0
,
0
,
0
,
0
,
"Detached, explicit RR max param"
),
CASE_UNK
(
1
,
1
,
1
,
-
1
,
0
,
0
,
0
,
0
,
"Detached, explicit FIFO min param"
),
CASE_UNK
(
1
,
1
,
2
,
-
1
,
0
,
0
,
0
,
0
,
"Detached, explicit RR min param"
),
CASE_UNK
(
1
,
1
,
1
,
1
,
1
,
0
,
0
,
0
,
"Detached, explicit FIFO max param,"
" alt scope"
),
CASE_UNK
(
1
,
1
,
2
,
1
,
1
,
0
,
0
,
0
,
"Detached, explicit RR max param,"
" alt scope"
),
CASE_UNK
(
1
,
1
,
1
,
-
1
,
1
,
0
,
0
,
0
,
"Detached, explicit FIFO min param,"
" alt scope"
),
CASE_UNK
(
1
,
1
,
2
,
-
1
,
1
,
0
,
0
,
0
,
"Detached, explicit RR min param,"
" alt scope"
),};
#define NSCENAR (sizeof(scenarii) / sizeof(scenarii[0]))
/*
* This function will initialize every pthread_attr_t object
* in the scenarii array
*/
static
void
scenar_init
(
void
)
{
int
ret
=
0
;
unsigned
int
i
;
int
old
;
long
pagesize
,
minstacksize
;
long
tsa
,
tss
,
tps
;
pagesize
=
sysconf
(
_SC_PAGESIZE
);
minstacksize
=
sysconf
(
_SC_THREAD_STACK_MIN
);
tsa
=
sysconf
(
_SC_THREAD_ATTR_STACKADDR
);
tss
=
sysconf
(
_SC_THREAD_ATTR_STACKSIZE
);
tps
=
sysconf
(
_SC_THREAD_PRIORITY_SCHEDULING
);
#if VERBOSE > 0
output
(
"System abilities:
\n
"
);
output
(
" TSA: %li
\n
"
,
tsa
);
output
(
" TSS: %li
\n
"
,
tss
);
output
(
" TPS: %li
\n
"
,
tps
);
output
(
" pagesize: %li
\n
"
,
pagesize
);
output
(
" min stack size: %li
\n
"
,
minstacksize
);
#endif
if
(
minstacksize
%
pagesize
)
UNTESTED
(
"The min stack size is not a multiple"
" of the page size"
);
for
(
i
=
0
;
i
<
NSCENAR
;
i
++
)
{
#if VERBOSE > 2
output
(
"Initializing attribute for scenario %i: %s
\n
"
,
i
,
scenarii
[
i
].
descr
);
#endif
ret
=
pthread_attr_init
(
&
scenarii
[
i
].
ta
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to initialize a"
" thread attribute object"
);
/* Set the attributes according to the scenario */
if
(
scenarii
[
i
].
detached
==
1
)
{
ret
=
pthread_attr_setdetachstate
(
&
scenarii
[
i
].
ta
,
PTHREAD_CREATE_DETACHED
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to set detachstate"
);
}
else
{
ret
=
pthread_attr_getdetachstate
(
&
scenarii
[
i
].
ta
,
&
old
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to get detachstate"
" from initialized attribute"
);
if
(
old
!=
PTHREAD_CREATE_JOINABLE
)
FAILED
(
"The default attribute is not"
" PTHREAD_CREATE_JOINABLE"
);
}
#if VERBOSE > 4
output
(
"Detach state was set sucessfully
\n
"
);
#endif
/* Sched related attributes */
/*
* This routine is dependent on the Thread Execution
* Scheduling option
*/
if
(
tps
>
0
)
{
if
(
scenarii
[
i
].
explicitsched
==
1
)
ret
=
pthread_attr_setinheritsched
(
&
scenarii
[
i
].
ta
,
PTHREAD_EXPLICIT_SCHED
);
else
ret
=
pthread_attr_setinheritsched
(
&
scenarii
[
i
].
ta
,
PTHREAD_INHERIT_SCHED
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to set inheritsched"
" attribute"
);
#if VERBOSE > 4
output
(
"inheritsched state was set sucessfully
\n
"
);
#endif
}
#if VERBOSE > 4
else
output
(
"TPS unsupported => inheritsched parameter"
" untouched
\n
"
);
#endif
if
(
tps
>
0
)
{
if
(
scenarii
[
i
].
schedpolicy
==
1
)
ret
=
pthread_attr_setschedpolicy
(
&
scenarii
[
i
].
ta
,
SCHED_FIFO
);
if
(
scenarii
[
i
].
schedpolicy
==
2
)
ret
=
pthread_attr_setschedpolicy
(
&
scenarii
[
i
].
ta
,
SCHED_RR
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to set the"
" sched policy"
);
#if VERBOSE > 4
if
(
scenarii
[
i
].
schedpolicy
)
output
(
"Sched policy was set sucessfully
\n
"
);
else
output
(
"Sched policy untouched
\n
"
);
#endif
}
#if VERBOSE > 4
else
output
(
"TPS unsupported => sched policy parameter"
" untouched
\n
"
);
#endif
if
(
scenarii
[
i
].
schedparam
!=
0
)
{
struct
sched_param
sp
;
ret
=
pthread_attr_getschedpolicy
(
&
scenarii
[
i
].
ta
,
&
old
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to get sched policy"
" from attribute"
);
if
(
scenarii
[
i
].
schedparam
==
1
)
sp
.
sched_priority
=
sched_get_priority_max
(
old
);
if
(
scenarii
[
i
].
schedparam
==
-
1
)
sp
.
sched_priority
=
sched_get_priority_min
(
old
);
ret
=
pthread_attr_setschedparam
(
&
scenarii
[
i
].
ta
,
&
sp
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to set the sched param"
);
#if VERBOSE > 4
output
(
"Sched param was set sucessfully to %i
\n
"
,
sp
.
sched_priority
);
}
else
{
output
(
"Sched param untouched
\n
"
);
#endif
}
if
(
tps
>
0
)
{
ret
=
pthread_attr_getscope
(
&
scenarii
[
i
].
ta
,
&
old
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to get contension"
" scope from thread attribute"
);
if
(
scenarii
[
i
].
altscope
!=
0
)
{
if
(
old
==
PTHREAD_SCOPE_PROCESS
)
old
=
PTHREAD_SCOPE_SYSTEM
;
else
old
=
PTHREAD_SCOPE_PROCESS
;
ret
=
pthread_attr_setscope
(
&
scenarii
[
i
].
ta
,
old
);
#if VERBOSE > 0
if
(
ret
!=
0
)
output
(
"WARNING: The TPS option is"
" claimed to be supported but"
" setscope fails
\n
"
);
#endif
#if VERBOSE > 4
output
(
"Contension scope set to %s
\n
"
,
old
==
PTHREAD_SCOPE_PROCESS
?
"PTHREAD_SCOPE_PROCESS"
:
"PTHREAD_SCOPE_SYSTEM"
);
}
else
{
output
(
"Contension scope untouched (%s)
\n
"
,
old
==
PTHREAD_SCOPE_PROCESS
?
"PTHREAD_SCOPE_PROCESS"
:
"PTHREAD_SCOPE_SYSTEM"
);
#endif
}
}
#if VERBOSE > 4
else
output
(
"TPS unsupported => sched contension scope"
" parameter untouched
\n
"
);
#endif
/* Stack related attributes */
/*
* This routine is dependent on the Thread Stack Address
* Attribute and Thread Stack Size Attribute options
*/
if
((
tss
>
0
)
&&
(
tsa
>
0
))
{
if
(
scenarii
[
i
].
altstack
!=
0
)
{
/*
* This is slightly more complicated.
* We need to alloc a new stackand free
* it upon test termination.
* We will alloc with a simulated guardsize
* of 1 pagesize */
scenarii
[
i
].
bottom
=
malloc
(
minstacksize
+
pagesize
);
if
(
scenarii
[
i
].
bottom
==
NULL
)
UNRESOLVED
(
errno
,
"Unable to alloc"
" enough memory for"
" alternative stack"
);
ret
=
pthread_attr_setstack
(
&
scenarii
[
i
].
ta
,
scenarii
[
i
].
bottom
,
minstacksize
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to specify"
" alternate stack"
);
#if VERBOSE > 1
output
(
"Alternate stack created successfully."
" Bottom=%p, Size=%i
\n
"
,
scenarii
[
i
].
bottom
,
minstacksize
);
#endif
}
}
#if VERBOSE > 4
else
output
(
"TSA or TSS unsupported => "
"No alternative stack
\n
"
);
#endif
#ifndef WITHOUT_XOPEN
if
(
scenarii
[
i
].
guard
!=
0
)
{
if
(
scenarii
[
i
].
guard
==
1
)
ret
=
pthread_attr_setguardsize
(
&
scenarii
[
i
].
ta
,
0
);
if
(
scenarii
[
i
].
guard
==
2
)
ret
=
pthread_attr_setguardsize
(
&
scenarii
[
i
].
ta
,
pagesize
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to set guard area"
" size in thread stack"
);
#if VERBOSE > 4
output
(
"Guard size set to %i
\n
"
,
scenarii
[
i
].
guard
==
1
?
1
:
pagesize
);
#endif
}
#endif
if
(
tss
>
0
)
{
if
(
scenarii
[
i
].
altsize
!=
0
)
{
ret
=
pthread_attr_setstacksize
(
&
scenarii
[
i
].
ta
,
minstacksize
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to change"
" stack size"
);
#if VERBOSE > 4
output
(
"Stack size set to %i (this is the "
"min)
\n
"
,
minstacksize
);
#endif
}
}
#if VERBOSE > 4
else
output
(
"TSS unsupported => stack size unchanged
\n
"
);
#endif
ret
=
sem_init
(
&
scenarii
[
i
].
sem
,
0
,
0
);
if
(
ret
==
-
1
)
UNRESOLVED
(
errno
,
"Unable to init a semaphore"
);
}
#if VERBOSE > 0
output
(
"All %i thread attribute objects were initialized
\n\n
"
,
NSCENAR
);
#endif
}
/*
* This function will free all resources consumed
* in the scenar_init() routine
*/
static
void
scenar_fini
(
void
)
{
int
ret
=
0
;
unsigned
int
i
;
for
(
i
=
0
;
i
<
NSCENAR
;
i
++
)
{
if
(
scenarii
[
i
].
bottom
!=
NULL
)
free
(
scenarii
[
i
].
bottom
);
ret
=
sem_destroy
(
&
scenarii
[
i
].
sem
);
if
(
ret
==
-
1
)
UNRESOLVED
(
errno
,
"Unable to destroy a semaphore"
);
ret
=
pthread_attr_destroy
(
&
scenarii
[
i
].
ta
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to destroy a thread"
" attribute object"
);
}
}
static
unsigned
int
sc
;
#ifdef STD_MAIN
static
void
*
threaded
(
void
*
arg
);
int
main
(
void
)
{
int
ret
=
0
;
pthread_t
child
;
output_init
();
scenar_init
();
for
(
sc
=
0
;
sc
<
NSCENAR
;
sc
++
)
{
#if VERBOSE > 0
output
(
"-----
\n
"
);
output
(
"Starting test with scenario (%i): %s
\n
"
,
sc
,
scenarii
[
sc
].
descr
);
#endif
ret
=
pthread_create
(
&
child
,
&
scenarii
[
sc
].
ta
,
threaded
,
NULL
);
switch
(
scenarii
[
sc
].
result
)
{
case
0
:
/* Operation was expected to succeed */
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Failed to create this thread"
);
break
;
case
1
:
/* Operation was expected to fail */
if
(
ret
==
0
)
UNRESOLVED
(
-
1
,
"An error was expected but the"
" thread creation succeeded"
);
break
;
case
2
:
/* We did not know the expected result */
default:
#if VERBOSE > 0
if
(
ret
==
0
)
output
(
"Thread has been created successfully"
" for this scenario
\n
"
);
else
output
(
"Thread creation failed with the error:"
" %s
\n
"
,
strerror
(
ret
));
#endif
}
if
(
ret
==
0
)
{
if
(
scenarii
[
sc
].
detached
==
0
)
{
ret
=
pthread_join
(
child
,
NULL
);
if
(
ret
!=
0
)
UNRESOLVED
(
ret
,
"Unable to join a"
" thread"
);
}
else
{
/* Just wait for the thread to terminate */
do
{
ret
=
sem_wait
(
&
scenarii
[
sc
].
sem
);
}
while
((
ret
==
-
1
)
&&
(
errno
==
EINTR
));
if
(
ret
==
-
1
)
UNRESOLVED
(
errno
,
"Failed to wait for"
" the semaphore"
);
}
}
}
scenar_fini
();
#if VERBOSE > 0
output
(
"-----
\n
"
);
output
(
"All test data destroyed
\n
"
);
output
(
"Test PASSED
\n
"
);
#endif
PASSED
;
}
#endif
examples/utest/testcases/posix/sched_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SCHED_H
bool "<sched.h>"
default n
if RTT_POSIX_TESTCASE_SCHED_H
# functions, TODO
endif
examples/utest/testcases/posix/semaphore_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SEMAPHORE_H
bool "<semaphore.h>"
default n
if RTT_POSIX_TESTCASE_SEMAPHORE_H
# functions, TODO
endif
examples/utest/testcases/posix/setjmp_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SETJMP_H
bool "<setjmp.h>"
default n
if RTT_POSIX_TESTCASE_SETJMP_H
# functions, TODO
endif
examples/utest/testcases/posix/signal_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SIGNAL_H
bool "<signal.h>"
default n
if RTT_POSIX_TESTCASE_SIGNAL_H
config SIGNAL_H_SIGACTION
bool "<signal.h> -> sigaction"
default n
config SIGNAL_H_SIGPROCMASK
bool "<signal.h> -> sigprocmask"
default n
config SIGNAL_H_RAISE
bool "<signal.h> -> raise"
default n
config SIGNAL_H_SIGNAL
bool "<signal.h> -> signal"
default n
endif
examples/utest/testcases/posix/stdarg_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_STDARG_H
bool "<stdarg.h>"
default n
if RTT_POSIX_TESTCASE_STDARG_H
# functions, TODO
endif
examples/utest/testcases/posix/stdio_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_STDIO_H
bool "<stdio.h>"
default n
if RTT_POSIX_TESTCASE_STDIO_H
config STDIO_H_CLEARERR
bool "<stdio.h> -> clearerr"
default n
config STDIO_H_FCLOSE
bool "<stdio.h> -> fclose"
default n
config STDIO_H_FDOPEN
bool "<stdio.h> -> fdopen"
default n
config STDIO_H_FEOF
bool "<stdio.h> -> feof"
default n
config STDIO_H_FERROR
bool "<stdio.h> -> ferror"
default n
config STDIO_H_FFLUSH
bool "<stdio.h> -> fflush"
default n
config STDIO_H_FGETC
bool "<stdio.h> -> fgetc"
default n
config STDIO_H_FGETS
bool "<stdio.h> -> fgets"
default n
config STDIO_H_FILENO
bool "<stdio.h> -> fileno"
default n
config STDIO_H_FOPEN
bool "<stdio.h> -> fopen"
default n
config STDIO_H_FPRINTF
bool "<stdio.h> -> fprintf"
default n
config STDIO_H_FPUTC
bool "<stdio.h> -> fputc"
default n
config STDIO_H_FPUTS
bool "<stdio.h> -> fputs"
default n
config STDIO_H_FREAD
bool "<stdio.h> -> fread"
default n
config STDIO_H_FSCANF
bool "<stdio.h> -> fscanf"
default n
config STDIO_H_FSEEK
bool "<stdio.h> -> fseek"
default n
config STDIO_H_FTELL
bool "<stdio.h> -> ftell"
default n
config STDIO_H_FWRITE
bool "<stdio.h> -> fwrite"
default n
config STDIO_H_PERROR
bool "<stdio.h> -> perror"
default n
config STDIO_H_PRINTF
bool "<stdio.h> -> printf"
default n
config STDIO_H_PUTC
bool "<stdio.h> -> putc"
default n
config STDIO_H_PUTCHAR
bool "<stdio.h> -> putchar"
default n
config STDIO_H_PUTS
bool "<stdio.h> -> puts"
default n
config STDIO_H_REMOVE
bool "<stdio.h> -> remove"
default n
config STDIO_H_RENAME
bool "<stdio.h> -> rename"
default n
config STDIO_H_REWIND
bool "<stdio.h> -> rewind"
default n
config STDIO_H_SETBUF
bool "<stdio.h> -> setbuf"
default n
config STDIO_H_SETVBUF
bool "<stdio.h> -> setvbuf"
default n
config STDIO_H_SNPRINTF
bool "<stdio.h> -> snprintf"
default n
config STDIO_H_SPRINTF
bool "<stdio.h> -> sprintf"
default n
config STDIO_H_SSCANF
bool "<stdio.h> -> sscanf"
default n
config STDIO_H_VFPRINTF
bool "<stdio.h> -> vfprintf"
default n
config STDIO_H_VPRINTF
bool "<stdio.h> -> vprintf"
default n
config STDIO_H_VSNPRINTF
bool "<stdio.h> -> vsnprintf"
default n
config STDIO_H_VSPRINTF
bool "<stdio.h> -> vsprintf"
default n
endif
examples/utest/testcases/posix/stdio_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
]
src
=
[]
if
GetDepend
(
'RTT_POSIX_TESTCASE_STDIO_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
if
GetDepend
(
'STDIO_H_CLEARERR'
):
src
+=
Glob
(
'./functions/clearerr.c'
)
if
GetDepend
(
'STDIO_H_FCLOSE'
):
src
+=
Glob
(
'./functions/fclose.c'
)
if
GetDepend
(
'STDIO_H_FDOPEN'
):
src
+=
Glob
(
'./functions/fdopen_tc.c'
)
if
GetDepend
(
'STDIO_H_FEOF'
):
src
+=
Glob
(
'./functions/feof.c'
)
if
GetDepend
(
'STDIO_H_FERROR'
):
src
+=
Glob
(
'./functions/ferror.c'
)
if
GetDepend
(
'STDIO_H_FFLUSH'
):
src
+=
Glob
(
'./functions/fflush.c'
)
if
GetDepend
(
'STDIO_H_FGETC'
):
src
+=
Glob
(
'./functions/fgetc.c'
)
if
GetDepend
(
'STDIO_H_FGETS'
):
src
+=
Glob
(
'./functions/fgets.c'
)
if
GetDepend
(
'STDIO_H_FILENO'
):
src
+=
Glob
(
'./functions/fileno.c'
)
if
GetDepend
(
'STDIO_H_FOPEN'
):
src
+=
Glob
(
'./functions/fopen.c'
)
if
GetDepend
(
'STDIO_H_FPRINTF'
):
src
+=
Glob
(
'./functions/fprintf.c'
)
if
GetDepend
(
'STDIO_H_FPUTC'
):
src
+=
Glob
(
'./functions/fputc.c'
)
if
GetDepend
(
'STDIO_H_FPUTS'
):
src
+=
Glob
(
'./functions/fputs.c'
)
if
GetDepend
(
'STDIO_H_FREAD'
):
src
+=
Glob
(
'./functions/fread.c'
)
if
GetDepend
(
'STDIO_H_FSCANF'
):
src
+=
Glob
(
'./functions/fscanf.c'
)
if
GetDepend
(
'STDIO_H_FSEEK'
):
src
+=
Glob
(
'./functions/fseek.c'
)
if
GetDepend
(
'STDIO_H_FTELL'
):
src
+=
Glob
(
'./functions/ftell.c'
)
if
GetDepend
(
'STDIO_H_FWRITE'
):
src
+=
Glob
(
'./functions/fwrite.c'
)
if
GetDepend
(
'STDIO_H_PERROR'
):
src
+=
Glob
(
'./functions/perror.c'
)
if
GetDepend
(
'STDIO_H_PRINTF'
):
src
+=
Glob
(
'./functions/printf.c'
)
if
GetDepend
(
'STDIO_H_PUTC'
):
src
+=
Glob
(
'./functions/puts.c'
)
if
GetDepend
(
'STDIO_H_REMOVE'
):
src
+=
Glob
(
'./functions/remove.c'
)
if
GetDepend
(
'STDIO_H_RENAME'
):
src
+=
Glob
(
'./functions/rename.c'
)
if
GetDepend
(
'STDIO_H_REWIND'
):
src
+=
Glob
(
'./functions/rewind.c'
)
if
GetDepend
(
'STDIO_H_SETBUF'
):
src
+=
Glob
(
'./functions/setbuf.c'
)
if
GetDepend
(
'STDIO_H_SETVBUF'
):
src
+=
Glob
(
'./functions/setvbuf.c'
)
if
GetDepend
(
'STDIO_H_SNPRINTF'
):
src
+=
Glob
(
'./functions/snprintf.c'
)
if
GetDepend
(
'STDIO_H_SPRINTF'
):
src
+=
Glob
(
'./functions/sprintf.c'
)
if
GetDepend
(
'STDIO_H_SSCANF'
):
src
+=
Glob
(
'./functions/sscanf.c'
)
if
GetDepend
(
'STDIO_H_VFPRINTF'
):
src
+=
Glob
(
'./functions/vfprintf.c'
)
if
GetDepend
(
'STDIO_H_VPRINTF'
):
src
+=
Glob
(
'./functions/vprintf.c'
)
if
GetDepend
(
'STDIO_H_VSNPRINTF'
):
src
+=
Glob
(
'./functions/vsnprintf.c'
)
if
GetDepend
(
'STDIO_H_VSPRINTF'
):
src
+=
Glob
(
'./functions/vsprintf.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_STDIO_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/stdio_h/definitions/stdio_h.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull SA. All rights reserved.
* Created by: Laurent.Vivier@bull.net
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/* test if stdio.h exists and can be included */
// #define _POSIX_C_SOURCE 2
#include <stdio.h>
#include <stdarg.h>
void
(
*
test_clearerr
)(
FILE
*
);
int
(
*
test_fclose
)(
FILE
*
);
FILE
*
(
*
test_fdopen
)(
int
,
const
char
*
);
int
(
*
test_feof
)(
FILE
*
);
int
(
*
test_ferror
)(
FILE
*
);
int
(
*
test_fflush
)(
FILE
*
);
int
(
*
test_fgetc
)(
FILE
*
);
char
*
(
*
test_fgets
)(
char
*
__restrict
,
int
,
FILE
*
__restrict
);
int
(
*
test_fileno
)(
FILE
*
);
void
(
*
test_flockfile
)(
FILE
*
);
FILE
*
(
*
test_fopen
)(
const
char
*
__restrict
_name
,
const
char
*
__restrict
_type
);
int
(
*
test_fprintf
)(
FILE
*
__restrict
,
const
char
*
__restrict
,
...);
int
(
*
test_fputc
)(
int
,
FILE
*
);
int
(
*
test_fputs
)(
const
char
*
__restrict
,
FILE
*
__restrict
);
size_t
(
*
test_fread
)(
void
*
__restrict
,
size_t
_size
,
size_t
_n
,
FILE
*
__restrict
);
FILE
*
(
*
test_freopen
)(
const
char
*
__restrict
,
const
char
*
__restrict
,
FILE
*
__restrict
);
int
(
*
test_fscanf
)(
FILE
*
__restrict
,
const
char
*
__restrict
,
...);
int
(
*
test_ftrylockfile
)(
FILE
*
);
void
(
*
test_funlockfile
)(
FILE
*
);
size_t
(
*
test_fwrite
)(
const
void
*
__restrict
,
size_t
_size
,
size_t
_n
,
FILE
*
);
int
(
*
test_getc
)(
FILE
*
);
int
(
*
test_getc_unlocked
)(
FILE
*
);
int
(
*
test_getchar
)(
void
);
int
(
*
test_getchar_unlocked
)(
void
);
char
*
(
*
test_gets
)(
char
*
);
void
(
*
test_perror
)(
const
char
*
);
int
(
*
test_printf
)(
const
char
*
__restrict
,
...);
int
(
*
test_putc
)(
int
,
FILE
*
);
int
(
*
test_putc_unlocked
)(
int
,
FILE
*
);
int
(
*
test_putchar
)(
int
);
int
(
*
test_putchar_unlocked
)(
int
);
int
(
*
test_puts
)(
const
char
*
);
int
(
*
test_scanf
)(
const
char
*
__restrict
,
...);
void
(
*
test_setbuf
)(
FILE
*
__restrict
,
char
*
__restrict
);
int
(
*
test_setvbuf
)(
FILE
*
__restrict
,
char
*
__restrict
,
int
,
size_t
);
int
(
*
test_snprintf
)(
char
*
__restrict
,
size_t
,
const
char
*
__restrict
,
...);
int
(
*
test_sprintf
)(
char
*
__restrict
,
const
char
*
__restrict
,
...);
int
(
*
test_sscanf
)(
const
char
*
__restrict
,
const
char
*
__restrict
,
...);
int
(
*
test_ungetc
)(
int
,
FILE
*
);
FILE
*
test_stderr
;
FILE
*
test_stdin
;
FILE
*
test_stdout
;
int
(
*
test_vfprintf
)(
FILE
*
restrict
,
const
char
*
restrict
,
va_list
);
int
(
*
test_vfscanf
)(
FILE
*
restrict
,
const
char
*
restrict
,
va_list
);
int
(
*
test_vprintf
)(
const
char
*
restrict
,
va_list
);
int
(
*
test_vscanf
)(
const
char
*
restrict
,
va_list
);
int
(
*
test_vsnprintf
)(
char
*
restrict
,
size_t
,
const
char
*
restrict
,
va_list
);
int
(
*
test_vsprintf
)(
char
*
restrict
,
const
char
*
restrict
,
va_list
);
int
(
*
test_vsscanf
)(
const
char
*
restrict
,
const
char
*
restrict
,
va_list
);
__attribute__
((
unused
))
static
int
test_defined
()
{
test_clearerr
=
clearerr
;
test_fclose
=
fclose
;
// test_fdopen = fdopen;
test_feof
=
feof
;
test_ferror
=
ferror
;
test_fflush
=
fflush
;
test_fgetc
=
fgetc
;
test_fgets
=
fgets
;
// test_fileno = fileno;
// test_flockfile = flockfile;
test_fopen
=
fopen
;
test_fprintf
=
fprintf
;
test_fputc
=
fputc
;
test_fputs
=
fputs
;
test_fread
=
fread
;
test_freopen
=
freopen
;
test_fscanf
=
fscanf
;
// test_ftrylockfile = ftrylockfile;
// test_funlockfile = funlockfile;
test_fwrite
=
fwrite
;
test_getc
=
getc
;
// test_getc_unlocked = getc_unlocked;
test_getchar
=
getchar
;
test_gets
=
gets
;
test_perror
=
perror
;
test_printf
=
printf
;
test_putc
=
putc
;
// test_putc_unlocked = putc_unlocked;
test_putchar
=
putchar
;
// test_putchar_unlocked = putchar_unlocked;
test_puts
=
puts
;
test_scanf
=
scanf
;
test_setbuf
=
setbuf
;
test_setvbuf
=
setvbuf
;
test_snprintf
=
snprintf
;
test_sprintf
=
sprintf
;
test_sscanf
=
sscanf
;
test_ungetc
=
ungetc
;
test_stderr
=
stderr
;
test_stdin
=
stdin
;
test_stdout
=
stdout
;
test_vfprintf
=
vfprintf
;
test_vfscanf
=
vfscanf
;
test_vprintf
=
vprintf
;
test_vscanf
=
vscanf
;
test_vsnprintf
=
vsnprintf
;
test_vsprintf
=
vsprintf
;
test_vsscanf
=
vsscanf
;
return
0
;
}
examples/utest/testcases/posix/stdio_h/functions/clearerr_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
clearerr_entry
(
void
)
{
putc
(
'c'
,
stdin
);
if
(
ferror
(
stdin
)
)
{
perror
(
"Write error"
);
clearerr
(
stdin
);
}
if
(
ferror
(
stdin
))
{
perror
(
"clearerr error"
);
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_clearerr
(
void
)
{
uassert_int_equal
(
clearerr_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_clearerr
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.clearerr.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fclose_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fclose_entry
(
void
)
{
FILE
*
stream
;
stream
=
fopen
(
"fopen_file.txt"
,
"a+"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
return
-
1
;
}
if
(
fclose
(
stream
))
{
perror
(
"fclose fail"
);
return
-
1
;
}
if
(
fclose
(
stream
))
{
printf
(
"fclose sucess
\n
"
);
}
return
0
;
}
#include <utest.h>
static
void
test_fclose
(
void
)
{
uassert_int_equal
(
fclose_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fclose
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fclose.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fdopen_tc.c
0 → 100644
浏览文件 @
b39210de
#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
);
examples/utest/testcases/posix/stdio_h/functions/feof_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
feof_entry
(
void
)
{
FILE
*
stream
;
char
data
[]
=
"test fgetc"
;
char
getc
[
sizeof
(
data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
int
i
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w+"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fwrite
(
data
,
sizeof
(
data
),
1
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
while
(
1
)
{
getc
[
i
]
=
fgetc
(
stream
);
i
++
;
if
(
feof
(
stream
)
)
{
break
;
}
}
if
(
strcmp
(
getc
,
data
))
{
return
-
1
;
}
fclose
(
stream
);
__exit:
return
ret
;
}
#include <utest.h>
static
void
test_feof
(
void
)
{
uassert_int_equal
(
feof_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_feof
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.feof.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/ferror_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
ferror_entry
(
void
)
{
int
c
;
putc
(
'c'
,
stdin
);
if
(
ferror
(
stdin
)
)
{
clearerr
(
stdin
);
}
else
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_ferror
(
void
)
{
uassert_int_equal
(
ferror_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_ferror
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.ferror.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fflush_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fflush_entry
(
void
)
{
fflush
(
stdout
);
printf
(
"test fflush
\n
"
);
printf
(
"t"
);
printf
(
"e"
);
printf
(
"s"
);
printf
(
"t"
);
fflush
(
stdout
);
printf
(
" fflush"
);
fflush
(
stdout
);
printf
(
"
\n
"
);
return
0
;
}
#include <utest.h>
static
void
test_fflush
(
void
)
{
uassert_int_equal
(
fflush_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fflush
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fflush.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fgetc_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fgetc_entry
(
void
)
{
FILE
*
stream
;
char
data
[]
=
"test fgetc"
;
char
getc
[
sizeof
(
data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
int
i
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w+"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fwrite
(
data
,
sizeof
(
data
),
1
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
while
(
1
)
{
getc
[
i
]
=
fgetc
(
stream
);
i
++
;
if
(
feof
(
stream
)
)
{
break
;
}
}
if
(
strcmp
(
getc
,
data
))
{
return
-
1
;
}
fclose
(
stream
);
__exit:
return
ret
;
}
#include <utest.h>
static
void
test_fgetc
(
void
)
{
uassert_int_equal
(
fgetc_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fgetc
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fgetc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fgets_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fgets_entry
(
void
)
{
FILE
*
stream
;
char
data
[]
=
"test fgets"
;
char
gets
[
sizeof
(
data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fwrite
(
data
,
sizeof
(
data
),
1
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fgets
(
gets
,
sizeof
(
gets
),
stream
);
if
(
strcmp
(
gets
,
data
))
{
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_fgets
(
void
)
{
uassert_int_equal
(
fgets_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fgets
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fgets.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fileno_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fdopen_entry
(
void
)
{
int
stdin_no
=
fileno
(
stdin
);
int
stdout_no
=
fileno
(
stdout
);
int
stderr_no
=
fileno
(
stderr
);
if
((
stdin_no
==
0
)
&&
(
stdout_no
==
1
)
&&
(
stderr_no
==
2
))
{
return
0
;
}
return
-
1
;
}
#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.fileno.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fopen_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fopen_entry
(
void
)
{
FILE
*
stream
;
/* TODO: other mode fopen */
stream
=
fopen
(
"fopen_file.txt"
,
"a+"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
return
-
1
;
}
fclose
(
stream
);
return
0
;
}
#include <utest.h>
static
void
test_fopen
(
void
)
{
uassert_int_equal
(
fopen_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fopen
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fopen.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fdopen_entry
(
void
)
{
FILE
*
stream
;
char
test_data
[]
=
"1a2bxx"
;
char
gets
[
sizeof
(
test_data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fprintf
(
stream
,
"%d%c%d%c%s"
,
1
,
'a'
,
2
,
'b'
,
"xx"
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fgets
(
gets
,
sizeof
(
gets
),
stream
);
if
(
strcmp
(
test_data
,
gets
))
{
printf
(
"%s
\n
"
,
gets
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#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.fprintf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fputc_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
fputc_entry
(
void
)
{
FILE
*
stream
;
int
ch
=
'a'
;
int
getc
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fputc
(
ch
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
getc
=
fgetc
(
stream
);
if
(
getc
!=
ch
)
{
perror
(
"fputc"
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_fputc
(
void
)
{
uassert_int_equal
(
fputc_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fputc
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fputs_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fputs_entry
(
void
)
{
FILE
*
stream
;
char
test_data
[]
=
"1a2bxx"
;
char
gets
[
sizeof
(
test_data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fputs
(
test_data
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fgets
(
gets
,
sizeof
(
gets
),
stream
);
if
(
strcmp
(
test_data
,
gets
))
{
printf
(
"%s
\n
"
,
gets
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_fputs
(
void
)
{
uassert_int_equal
(
fputs_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fputs
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fread_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fread_entry
(
void
)
{
FILE
*
stream
;
char
data
[]
=
"test fread"
;
char
gets
[
sizeof
(
data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fwrite
(
data
,
sizeof
(
data
),
1
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fread
(
gets
,
sizeof
(
gets
),
1
,
stream
);
if
(
strcmp
(
gets
,
data
))
{
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_fread
(
void
)
{
uassert_int_equal
(
fread_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fread
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fscanf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fscanf_entry
(
void
)
{
long
l
;
char
s
[
81
]
=
{
0
};
char
c
;
int
ret
=
0
;
FILE
*
stream
=
fopen
(
"fopen_file.txt"
,
"w+"
);
if
(
stream
==
NULL
)
{
ret
=
-
1
;
perror
(
"fopen"
);
}
else
{
fprintf
(
stream
,
"%s %d %c"
,
"a_string"
,
6500
,
'x'
);
fseek
(
stream
,
0L
,
SEEK_SET
);
fscanf
(
stream
,
"%s"
,
s
);
fscanf
(
stream
,
"%ld"
,
&
l
);
fscanf
(
stream
,
" %c"
,
&
c
);
if
((
strcmp
(
s
,
"a_string"
)
!=
0
)
||
(
l
!=
6500
)
||
(
c
!=
'x'
))
{
ret
=
-
1
;
}
fclose
(
stream
);
}
return
ret
;
}
#include <utest.h>
static
void
test_fscanf
(
void
)
{
uassert_int_equal
(
fscanf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fscanf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.fscanf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fseek_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fdopen_entry
(
void
)
{
long
l
;
char
s
[
81
]
=
{
0
};
char
c
;
int
ret
=
0
;
FILE
*
stream
=
fopen
(
"fopen_file.txt"
,
"w+"
);
if
(
stream
==
NULL
)
{
ret
=
-
1
;
perror
(
"fopen"
);
}
else
{
fprintf
(
stream
,
"%s %d %c"
,
"a_string"
,
6500
,
'x'
);
fseek
(
stream
,
0L
,
SEEK_SET
);
fscanf
(
stream
,
"%s"
,
s
);
fscanf
(
stream
,
"%ld"
,
&
l
);
fscanf
(
stream
,
" %c"
,
&
c
);
if
((
strcmp
(
s
,
"a_string"
)
!=
0
)
||
(
l
!=
6500
)
||
(
c
!=
'x'
))
{
ret
=
-
1
;
}
fclose
(
stream
);
}
return
ret
;
}
#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
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/ftell_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
ftell_entry
(
void
)
{
FILE
*
stream
;
char
str
[]
=
"123456789"
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen"
);
ret
=
-
1
;
}
else
{
fprintf
(
stream
,
"%s"
,
str
);
if
(
ftell
(
stream
)
!=
strlen
(
str
))
{
ret
=
-
1
;
}
fclose
(
stream
);
}
return
ret
;
}
#include <utest.h>
static
void
test_ftell
(
void
)
{
uassert_int_equal
(
ftell_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_ftell
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/fwrite_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
fwrite_entry
(
void
)
{
FILE
*
stream
;
char
test_data
[]
=
"1a2bxx"
;
char
gets
[
sizeof
(
test_data
)]
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
fwrite
(
test_data
,
sizeof
(
test_data
),
1
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fgets
(
gets
,
sizeof
(
gets
),
stream
);
if
(
strcmp
(
test_data
,
gets
))
{
printf
(
"%s
\n
"
,
gets
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_fwrite
(
void
)
{
uassert_int_equal
(
fwrite_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_fwrite
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/perror_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
perror_entry
(
void
)
{
FILE
*
stream
;
stream
=
fopen
(
"nulltest.txt"
,
"r"
);
if
(
stream
==
NULL
)
{
printf
(
"perror test:"
);
perror
(
"nulltest.txt"
);
}
return
0
;
}
#include <utest.h>
static
void
test_perror
(
void
)
{
uassert_int_equal
(
perror_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_perror
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/printf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
printf_entry
(
void
)
{
printf
(
"printf test:%s-%d-%c %f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
return
0
;
}
#include <utest.h>
static
void
test_printf
(
void
)
{
uassert_int_equal
(
printf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_printf
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/putc_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
putc_entry
(
void
)
{
FILE
*
stream
;
int
ch
=
'a'
;
int
getc
=
{
0
};
size_t
size
=
0
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
putc
(
ch
,
stream
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
getc
=
fgetc
(
stream
);
if
(
getc
!=
ch
)
{
printf
(
"fputc test:getc %c"
,
getc
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_putc
(
void
)
{
uassert_int_equal
(
putc_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_putc
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/putchar_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
putchar_entry
(
void
)
{
char
data
[]
=
"putchar testcase
\n
"
;
int
i
=
0
;
for
(;
i
<
sizeof
(
data
);
i
++
)
{
putchar
(
data
[
i
]);
}
fflush
(
stdout
);
return
0
;
}
#include <utest.h>
static
void
test_putchar
(
void
)
{
uassert_int_equal
(
putchar_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_putchar
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/puts_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
puts_entry
(
void
)
{
char
data
[]
=
"puts testcase
\n
"
;
printf
(
"puts testcase:"
);
puts
(
data
);
return
0
;
}
#include <utest.h>
static
void
test_puts
(
void
)
{
uassert_int_equal
(
puts_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_puts
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.puts.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/remove_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
remove_entry
(
void
)
{
FILE
*
stream
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
)
{
fclose
(
stream
);
remove
(
"fopen_file.txt"
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
if
(
stream
)
{
fclose
(
stream
);
return
-
1
;
}
}
else
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_remove
(
void
)
{
uassert_int_equal
(
remove_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_remove
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/rename_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
static
int
rename_entry
(
void
)
{
FILE
*
stream
;
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
if
(
stream
==
NULL
)
{
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
return
-
1
;
}
}
fclose
(
stream
);
rename
(
"fopen_file.txt"
,
"rename_test.txt"
);
stream
=
fopen
(
"rename_test.txt"
,
"r"
);
if
(
stream
==
NULL
)
{
return
-
1
;
}
fclose
(
stream
);
return
0
;
}
#include <utest.h>
static
void
test_rename
(
void
)
{
uassert_int_equal
(
rename_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_rename
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.rename.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/rewind_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
rewind_entry
(
void
)
{
long
l
;
char
s
[
81
]
=
{
0
};
char
c
;
int
ret
=
0
;
FILE
*
stream
=
fopen
(
"fopen_file.txt"
,
"w+"
);
if
(
stream
==
NULL
)
{
ret
=
-
1
;
perror
(
"fopen"
);
}
else
{
fprintf
(
stream
,
"%s %d %c"
,
"a_string"
,
6500
,
'x'
);
rewind
(
stream
);
fscanf
(
stream
,
"%s"
,
s
);
fscanf
(
stream
,
"%ld"
,
&
l
);
fscanf
(
stream
,
" %c"
,
&
c
);
if
((
strcmp
(
s
,
"a_string"
)
!=
0
)
||
(
l
!=
6500
)
||
(
c
!=
'x'
))
{
ret
=
-
1
;
}
fclose
(
stream
);
}
return
ret
;
}
#include <utest.h>
static
void
test_rewind
(
void
)
{
uassert_int_equal
(
rewind_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_rewind
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.rewind.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/setbuf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
char
outbuf
[
BUFSIZ
];
static
int
setbuf_entry
(
void
)
{
FILE
*
stream
;
char
test_data
[]
=
"test setbuf"
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
setbuf
(
stream
,
outbuf
);
fwrite
(
test_data
,
sizeof
(
test_data
),
1
,
stream
);
if
(
strcmp
(
test_data
,
outbuf
))
{
printf
(
"setbuf test:%s
\n
"
,
test_data
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_setbuf
(
void
)
{
uassert_int_equal
(
setbuf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_setbuf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.setbuf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/setvbuf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
char
outbuf
[
BUFSIZ
];
static
int
setvbuf_entry
(
void
)
{
FILE
*
stream
;
char
test_data
[]
=
"test setbuf"
;
int
ret
=
0
;
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
==
NULL
)
{
perror
(
"fopen fail"
);
ret
=
-
1
;
goto
__exit
;
}
setvbuf
(
stream
,
outbuf
,
_IOLBF
,
BUFSIZ
);
fwrite
(
test_data
,
sizeof
(
test_data
),
1
,
stream
);
if
(
strcmp
(
test_data
,
outbuf
))
{
printf
(
"setvbuf test:%s
\n
"
,
test_data
);
ret
=
-
1
;
}
__exit:
fclose
(
stream
);
return
ret
;
}
#include <utest.h>
static
void
test_setvbuf
(
void
)
{
uassert_int_equal
(
setvbuf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_setvbuf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.setvbuf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/snprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
snprintf_entry
(
void
)
{
char
buf
[
64
]
=
{
0
};
char
test_data
[]
=
"snprintf test:2021-8-"
;
snprintf
(
buf
,
22
,
"snprintf test:%s-%d-%c %.02f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
if
(
strcmp
(
buf
,
test_data
))
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_snprintf
(
void
)
{
uassert_int_equal
(
snprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_snprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.snprintf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/sprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
sprintf_entry
(
void
)
{
char
buf
[
64
]
=
{
0
};
char
test_data
[]
=
"sprintf test:2021-8-1 3.14 0xff"
;
sprintf
(
buf
,
"sprintf test:%s-%d-%c %.02f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
if
(
strcmp
(
buf
,
test_data
))
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_sprintf
(
void
)
{
uassert_int_equal
(
sprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_sprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.sprintf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/sscanf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <string.h>
static
int
sscanf_entry
(
void
)
{
int
day
,
year
;
char
weekday
[
20
],
month
[
20
],
dtm
[
100
];
strcpy
(
dtm
,
"Friday January 1 2021"
);
sscanf
(
dtm
,
"%s %s %d %d"
,
weekday
,
month
,
&
day
,
&
year
);
if
(
strcmp
(
month
,
"January"
)
||
strcmp
(
weekday
,
"Friday"
)
||
(
year
!=
2021
)
||
(
day
!=
1
))
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_sscanf
(
void
)
{
uassert_int_equal
(
sscanf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_sscanf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.sscanf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/vfprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static
void
WriteFrmtd
(
FILE
*
stream
,
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
vfprintf
(
stream
,
format
,
args
);
va_end
(
args
);
}
static
int
vfprintf_entry
(
void
)
{
int
ret
=
0
;
char
buf
[
64
]
=
{
0
};
char
test_data
[]
=
"vfprintf test:2021-8-1 3.14 0xff"
;
FILE
*
stream
=
fopen
(
"fopen_file.txt"
,
"w"
);
if
(
stream
)
{
WriteFrmtd
(
stream
,
"vfprintf test:%s-%d-%c %.02f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
fclose
(
stream
);
stream
=
fopen
(
"fopen_file.txt"
,
"r"
);
fread
(
buf
,
1
,
sizeof
(
test_data
),
stream
);
if
(
strcmp
(
buf
,
test_data
))
{
ret
=
-
1
;
}
fclose
(
stream
);
}
else
{
ret
=
-
1
;
}
return
ret
;
}
#include <utest.h>
static
void
test_vfprintf
(
void
)
{
uassert_int_equal
(
vfprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_vfprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/vprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static
void
WriteFrmtd
(
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
vprintf
(
format
,
args
);
va_end
(
args
);
}
static
int
vprintf_entry
(
void
)
{
WriteFrmtd
(
"vprintf test:%s-%d-%c %.02f 0x%x
\n
"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
return
0
;
}
#include <utest.h>
static
void
test_vprintf
(
void
)
{
uassert_int_equal
(
vprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_vprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdio_h.vprintf.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/vsnprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static
char
buf
[
64
]
=
{
0
};
static
void
WriteFrmtd
(
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
vsnprintf
(
buf
,
22
,
format
,
args
);
va_end
(
args
);
}
static
int
vsnprintf_entry
(
void
)
{
char
buf
[
64
]
=
{
0
};
char
test_data
[]
=
"vsnprintf test:2021-8"
;
snprintf
(
buf
,
22
,
"vsnprintf test:%s-%d-%c %.02f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
if
(
strcmp
(
buf
,
test_data
))
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_vsnprintf
(
void
)
{
uassert_int_equal
(
vsnprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_vsnprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdio_h/functions/vsprintf_tc.c
0 → 100644
浏览文件 @
b39210de
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
static
char
buf
[
64
]
=
{
0
};
static
void
WriteFrmtd
(
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
vsprintf
(
buf
,
format
,
args
);
va_end
(
args
);
}
static
int
vsprintf_entry
(
void
)
{
char
buf
[
64
]
=
{
0
};
char
test_data
[]
=
"vsprintf test:2021-8-1 3.14 0xff"
;
sprintf
(
buf
,
"vsprintf test:%s-%d-%c %.02f 0x%x"
,
"2021"
,
8
,
'1'
,
3
.
14
,
0xff
);
if
(
strcmp
(
buf
,
test_data
))
{
return
-
1
;
}
return
0
;
}
#include <utest.h>
static
void
test_vsprintf
(
void
)
{
uassert_int_equal
(
vsprintf_entry
(),
0
);
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_vsprintf
);
}
UTEST_TC_EXPORT
(
testcase
,
"rtt_posix_testcase.stdio_h."
__FILE__
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdlib_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_STDLIB_H
bool "<stdlib.h>"
default n
if RTT_POSIX_TESTCASE_STDLIB_H
config STDLIB_H_ATOI
bool "<stdlib.h> -> atoi"
default n
config STDLIB_H_ATOL
bool "<stdlib.h> -> atol"
default n
config STDLIB_H_QSORT
bool "<stdlib.h> -> qsort"
default n
config STDLIB_H_STRTOL
bool "<stdlib.h> -> strtol"
default n
endif
examples/utest/testcases/posix/stdlib_h/SConscript
0 → 100644
浏览文件 @
b39210de
import
rtconfig
Import
(
'RTT_ROOT'
)
from
building
import
*
# get current directory
cwd
=
GetCurrentDir
()
path
=
[
cwd
]
src
=
[]
if
GetDepend
(
'RTT_POSIX_TESTCASE_STDLIB_H'
):
src
+=
Glob
(
'./definitions/*.c'
)
if
GetDepend
(
'STDLIB_H_ATOI'
):
src
+=
Glob
(
'./functions/atoi_tc.c'
)
if
GetDepend
(
'STDLIB_H_ATOL'
):
src
+=
Glob
(
'./functions/atol_tc.c'
)
if
GetDepend
(
'STDLIB_H_QSORT'
):
src
+=
Glob
(
'./functions/qsort_tc.c'
)
if
GetDepend
(
'STDLIB_H_STRTOL'
):
src
+=
Glob
(
'./functions/strtol_tc.c'
)
group
=
DefineGroup
(
'rtt_posix_testcase'
,
src
,
depend
=
[
'RTT_POSIX_TESTCASE_STDLIB_H'
],
CPPPATH
=
path
)
Return
(
'group'
)
examples/utest/testcases/posix/stdlib_h/definitions/stdlib_h.c
0 → 100644
浏览文件 @
b39210de
/*
* Copyright (c) 2004, Bull SA. All rights reserved.
* Created by: Laurent.Vivier@bull.net
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/* test if stdlib.h exists and can be included */
// #define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <sys/time.h>
#ifndef __compar_fn_t_defined
#define __compar_fn_t_defined
typedef
int
(
*
__compar_fn_t
)
(
const
void
*
,
const
void
*
);
#endif
void
(
*
test_abort
)(
void
);
int
(
*
test_abs
)(
int
);
double
(
*
test_atof
)(
const
char
*
__nptr
);
int
(
*
test_atoi
)(
const
char
*
__nptr
);
long
(
*
test_atol
)(
const
char
*
__nptr
);
long
long
(
*
test_atoll
)(
const
char
*
__nptr
);
void
*
(
*
test_bsearch
)(
const
void
*
__key
,
const
void
*
__base
,
size_t
__nmemb
,
size_t
__size
,
__compar_fn_t
_compar
);
void
*
(
*
test_calloc
)(
size_t
,
size_t
);
div_t
(
*
test_div
)(
int
__numer
,
int
__denom
);
void
(
*
test_free
)(
void
*
);
char
*
(
*
test_getenv
)(
const
char
*
__string
);
long
(
*
test_labs
)(
long
);
ldiv_t
(
*
test_ldiv
)(
long
__numer
,
long
__denom
);
void
*
(
*
test_malloc
)(
size_t
);
void
(
*
test_qsort
)(
void
*
__base
,
size_t
__nmemb
,
size_t
__size
,
__compar_fn_t
_compar
);
int
(
*
test_rand
)(
void
);
int
(
*
test_rand_r
)(
unsigned
*
__seed
);
void
*
(
*
test_realloc
)(
void
*
,
size_t
);
int
(
*
test_setenv
)(
const
char
*
__string
,
const
char
*
__value
,
int
__overwrite
);
void
(
*
test_srand
)(
unsigned
__seed
);
double
(
*
test_strtod
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
);
float
(
*
test_strtof
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
);
long
(
*
test_strtol
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
,
int
__base
);
long
double
(
*
test_strtold
)(
const
char
*
__restrict
,
char
**
__restrict
);
long
long
(
*
test_strtoll
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
,
int
__base
);
unsigned
long
(
*
test_strtoul
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
,
int
__base
);
unsigned
long
long
(
*
test_strtoull
)(
const
char
*
__restrict
__n
,
char
**
__restrict
__end_PTR
,
int
__base
);
int
(
*
test_unsetenv
)(
const
char
*
__string
);
__attribute__
((
unused
))
static
int
test_defined
()
{
test_abort
=
abort
;
test_abs
=
abs
;
test_atof
=
atof
;
test_atoi
=
atoi
;
test_atol
=
atol
;
test_atoll
=
atoll
;
test_bsearch
=
bsearch
;
test_calloc
=
calloc
;
test_div
=
div
;
test_free
=
free
;
test_getenv
=
getenv
;
test_labs
=
labs
;
test_ldiv
=
ldiv
;
test_malloc
=
malloc
;
test_qsort
=
qsort
;
test_rand
=
rand
;
// test_rand_r = rand_r;
test_realloc
=
realloc
;
// test_setenv = setenv;
test_srand
=
srand
;
test_strtod
=
strtod
;
test_strtof
=
strtof
;
test_strtol
=
strtol
;
test_strtold
=
strtold
;
test_strtoll
=
strtoll
;
test_strtoul
=
strtoul
;
test_strtoull
=
strtoull
;
// test_unsetenv = unsetenv;
return
0
;
}
examples/utest/testcases/posix/stdlib_h/functions/atoi_tc.c
0 → 100644
浏览文件 @
b39210de
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct
atoi_data
{
char
string
[
15
];
// int max 2147483647
int
ret_num
;
};
struct
atoi_data
test_data
[]
=
{
/* positive integer */
{
"0"
,
0
},
{
"1"
,
1
},
{
"1.123"
,
1
},
{
"123"
,
123
},
{
"98993489"
,
98993489
},
{
"98993489.12"
,
98993489
},
{
"2147483647"
,
2147483647
},
/* negtive integer */
{
"-1"
,
-
1
},
{
"-1.123"
,
-
1
},
{
"-123"
,
-
123
},
{
"-98993489"
,
-
98993489
},
{
"-98993489.12"
,
-
98993489
},
{
"-2147483647"
,
-
2147483647
},
/* letters and numbers */
{
"12a45"
,
12
},
{
"-12a45"
,
-
12
},
{
"12/45"
,
12
},
{
"-12/45"
,
-
12
},
/* cannot be resolved */
{
""
,
0
},
{
" "
,
0
},
{
"abc12"
,
0
},
{
" abc12"
,
0
},
/* {NULL, -1} compiler warning */
};
#include <utest.h>
int
atoi_entry
(
void
)
{
int
i
=
0
;
int
res
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
test_data
[
0
]);
i
++
)
{
res
=
atoi
(
test_data
[
i
].
string
);
uassert_int_equal
(
res
,
test_data
[
i
].
ret_num
);
}
return
0
;
}
static
void
test_atoi
(
void
)
{
atoi_entry
();
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_atoi
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdlib_h.atoi_tc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdlib_h/functions/atol_tc.c
0 → 100644
浏览文件 @
b39210de
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct
atol_data
{
char
string
[
15
];
// long max 2147483647
int
ret_num
;
};
struct
atol_data
test_data1
[]
=
{
/* positive integer */
{
"0"
,
0
},
{
"1"
,
1
},
{
"1.123"
,
1
},
{
"123"
,
123
},
{
"98993489"
,
98993489
},
{
"98993489.12"
,
98993489
},
{
"2147483647"
,
2147483647
},
/* negtive integer */
{
"-1"
,
-
1
},
{
"-1.123"
,
-
1
},
{
"-123"
,
-
123
},
{
"-98993489"
,
-
98993489
},
{
"-98993489.12"
,
-
98993489
},
{
"-2147483647"
,
-
2147483647
},
/* letters and numbers */
{
"12a45"
,
12
},
{
"-12a45"
,
-
12
},
{
"12/45"
,
12
},
{
"-12/45"
,
-
12
},
/* cannot be resolved */
{
""
,
0
},
{
" "
,
0
},
{
"abc12"
,
0
},
{
" abc12"
,
0
},
/* {NULL, -1} compiler warning */
};
#include <utest.h>
int
atol_entry
(
void
)
{
int
i
=
0
;
int
res
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
test_data1
[
0
]);
i
++
)
{
res
=
atol
(
test_data1
[
i
].
string
);
uassert_int_equal
(
res
,
test_data1
[
i
].
ret_num
);
}
return
0
;
}
static
void
test_atol
(
void
)
{
atol_entry
();
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_atol
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdlib_h.atol_tc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdlib_h/functions/qsort_tc.c
0 → 100644
浏览文件 @
b39210de
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <utest.h>
static
int
scmp
(
const
void
*
a
,
const
void
*
b
)
{
return
strcmp
(
*
(
char
**
)
a
,
*
(
char
**
)
b
);
}
static
int
icmp
(
const
void
*
a
,
const
void
*
b
)
{
return
*
(
int
*
)
a
-
*
(
int
*
)
b
;
}
static
int
ccmp
(
const
void
*
a
,
const
void
*
b
)
{
return
*
(
char
*
)
a
-
*
(
char
*
)
b
;
}
/**
* static int cmp64(const void *a, const void *b)
* {
* const uint64_t *ua = a, *ub = b;
* return *ua < *ub ? -1 : *ua != *ub;
* }
*/
/* 26 items -- even */
static
const
char
*
s
[]
=
{
"Bob"
,
"Alice"
,
"John"
,
"Ceres"
,
"Helga"
,
"Drepper"
,
"Emeralda"
,
"Zoran"
,
"Momo"
,
"Frank"
,
"Pema"
,
"Xavier"
,
"Yeva"
,
"Gedun"
,
"Irina"
,
"Nono"
,
"Wiener"
,
"Vincent"
,
"Tsering"
,
"Karnica"
,
"Lulu"
,
"Quincy"
,
"Osama"
,
"Riley"
,
"Ursula"
,
"Sam"
};
static
const
char
*
s_sorted
[]
=
{
"Alice"
,
"Bob"
,
"Ceres"
,
"Drepper"
,
"Emeralda"
,
"Frank"
,
"Gedun"
,
"Helga"
,
"Irina"
,
"John"
,
"Karnica"
,
"Lulu"
,
"Momo"
,
"Nono"
,
"Osama"
,
"Pema"
,
"Quincy"
,
"Riley"
,
"Sam"
,
"Tsering"
,
"Ursula"
,
"Vincent"
,
"Wiener"
,
"Xavier"
,
"Yeva"
,
"Zoran"
};
/* 23 items -- odd, prime */
static
int
n
[]
=
{
879045
,
394
,
99405644
,
33434
,
232323
,
4334
,
5454
,
343
,
45545
,
454
,
324
,
22
,
34344
,
233
,
45345
,
343
,
848405
,
3434
,
3434344
,
3535
,
93994
,
2230404
,
4334
};
static
int
n_sorted
[]
=
{
22
,
233
,
324
,
343
,
343
,
394
,
454
,
3434
,
3535
,
4334
,
4334
,
5454
,
33434
,
34344
,
45345
,
45545
,
93994
,
232323
,
848405
,
879045
,
2230404
,
3434344
,
99405644
};
static
void
str_test
(
const
char
**
a
,
const
char
**
a_sorted
,
int
len
)
{
int
i
;
qsort
(
a
,
len
,
sizeof
*
a
,
scmp
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
uassert_true
(
strcmp
(
a
[
i
],
a_sorted
[
i
])
==
0
);
}
}
static
void
int_test
(
int
*
a
,
int
*
a_sorted
,
int
len
)
{
int
i
;
qsort
(
a
,
len
,
sizeof
*
a
,
icmp
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
uassert_true
(
a
[
i
]
==
a_sorted
[
i
]);
}
}
#define T(a, a_sorted) do { \
char p[] = a; \
qsort(p, sizeof p - 1, 1, ccmp); \
uassert_true(memcmp(p, a_sorted, sizeof p) == 0);\
} while(0)
static
void
char_test
(
void
)
{
T
(
""
,
""
);
T
(
"1"
,
"1"
);
T
(
"11"
,
"11"
);
T
(
"12"
,
"12"
);
T
(
"21"
,
"12"
);
T
(
"111"
,
"111"
);
T
(
"211"
,
"112"
);
T
(
"121"
,
"112"
);
T
(
"112"
,
"112"
);
T
(
"221"
,
"122"
);
T
(
"212"
,
"122"
);
T
(
"122"
,
"122"
);
T
(
"123"
,
"123"
);
T
(
"132"
,
"123"
);
T
(
"213"
,
"123"
);
T
(
"231"
,
"123"
);
T
(
"321"
,
"123"
);
T
(
"312"
,
"123"
);
T
(
"1423"
,
"1234"
);
T
(
"51342"
,
"12345"
);
T
(
"261435"
,
"123456"
);
T
(
"4517263"
,
"1234567"
);
T
(
"37245618"
,
"12345678"
);
T
(
"812436597"
,
"123456789"
);
T
(
"987654321"
,
"123456789"
);
T
(
"321321321"
,
"111222333"
);
T
(
"49735862185236174"
,
"11223344556677889"
);
}
void
posix_testcase
(
void
)
{
str_test
(
s
,
s_sorted
,
sizeof
s
/
sizeof
*
s
);
int_test
(
n
,
n_sorted
,
sizeof
n
/
sizeof
*
n
);
char_test
();
/* todo uint64 test */
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
posix_testcase
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdlib_h.qsort_tc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/stdlib_h/functions/strtol_tc.c
0 → 100644
浏览文件 @
b39210de
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define TEST(r, f, x, m) uassert_int_equal(f, x)
#define TEST2(r, f, x, m) uassert_int_equal(f, x)
#define TEST3(r, f, x, m) uassert_int_not_equal(f, x)
#include <utest.h>
#define ERANGE 34
#define EINVAL 22
int
strtol_entry
(
void
)
{
__attribute__
((
unused
))
int
i
;
__attribute__
((
unused
))
long
l
;
__attribute__
((
unused
))
unsigned
long
ul
;
__attribute__
((
unused
))
long
long
ll
;
__attribute__
((
unused
))
unsigned
long
long
ull
;
__attribute__
((
unused
))
char
*
msg
=
""
;
__attribute__
((
unused
))
char
*
s
,
*
c
;
TEST
(
l
,
atol
(
"2147483647"
),
2147483647L
,
"max 32bit signed %ld != %ld"
);
TEST
(
l
,
strtol
(
"2147483647"
,
0
,
0
),
2147483647L
,
"max 32bit signed %ld != %ld"
);
TEST
(
ul
,
strtoul
(
"4294967295"
,
0
,
0
),
4294967295UL
,
"max 32bit unsigned %lu != %lu"
);
if
(
sizeof
(
long
)
==
4
)
{
TEST
(
l
,
strtol
(
s
=
"2147483648"
,
&
c
,
0
),
2147483647L
,
"uncaught overflow %ld != %ld"
);
TEST2
(
i
,
c
-
s
,
10
,
"wrong final position %d != %d"
);
TEST
(
l
,
strtol
(
s
=
"-2147483649"
,
&
c
,
0
),
-
2147483647L
-
1
,
"uncaught overflow %ld != %ld"
);
TEST2
(
i
,
c
-
s
,
11
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"4294967296"
,
&
c
,
0
),
4294967295UL
,
"uncaught overflow %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
10
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-1"
,
&
c
,
0
),
-
1UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-2"
,
&
c
,
0
),
-
2UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-2147483648"
,
&
c
,
0
),
-
2147483648UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
11
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-2147483649"
,
&
c
,
0
),
-
2147483649UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
11
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-4294967296"
,
&
c
,
0
),
4294967295UL
,
"uncaught negative overflow %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
11
,
"wrong final position %d != %d"
);
}
else
if
(
sizeof
(
long
)
==
8
)
{
TEST
(
l
,
strtol
(
s
=
"9223372036854775808"
,
&
c
,
0
),
9223372036854775807L
,
"uncaught overflow %ld != %ld"
);
TEST2
(
i
,
c
-
s
,
19
,
"wrong final position %d != %d"
);
TEST
(
l
,
strtol
(
s
=
"-9223372036854775809"
,
&
c
,
0
),
-
9223372036854775807L
-
1
,
"uncaught overflow %ld != %ld"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"18446744073709551616"
,
&
c
,
0
),
18446744073709551615UL
,
"uncaught overflow %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-1"
,
&
c
,
0
),
-
1UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-2"
,
&
c
,
0
),
-
2UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-9223372036854775808"
,
&
c
,
0
),
-
9223372036854775808UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-9223372036854775809"
,
&
c
,
0
),
-
9223372036854775809UL
,
"rejected negative %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ul
,
strtoul
(
s
=
"-18446744073709551616"
,
&
c
,
0
),
18446744073709551615UL
,
"uncaught negative overflow %lu != %lu"
);
TEST2
(
i
,
c
-
s
,
21
,
"wrong final position %d != %d"
);
}
else
{
printf
(
"sizeof(long) == %d, not implemented
\n
"
,
(
int
)
sizeof
(
long
));
}
if
(
sizeof
(
long
long
)
==
8
)
{
TEST
(
ll
,
strtoll
(
s
=
"9223372036854775808"
,
&
c
,
0
),
9223372036854775807LL
,
"uncaught overflow %lld != %lld"
);
TEST2
(
i
,
c
-
s
,
19
,
"wrong final position %d != %d"
);
TEST
(
ll
,
strtoll
(
s
=
"-9223372036854775809"
,
&
c
,
0
),
-
9223372036854775807LL
-
1
,
"uncaught overflow %lld != %lld"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"18446744073709551616"
,
&
c
,
0
),
18446744073709551615ULL
,
"uncaught overflow %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"-1"
,
&
c
,
0
),
-
1ULL
,
"rejected negative %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"-2"
,
&
c
,
0
),
-
2ULL
,
"rejected negative %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
2
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"-9223372036854775808"
,
&
c
,
0
),
-
9223372036854775808ULL
,
"rejected negative %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"-9223372036854775809"
,
&
c
,
0
),
-
9223372036854775809ULL
,
"rejected negative %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
20
,
"wrong final position %d != %d"
);
TEST
(
ull
,
strtoull
(
s
=
"-18446744073709551616"
,
&
c
,
0
),
18446744073709551615ULL
,
"uncaught negative overflow %llu != %llu"
);
TEST2
(
i
,
c
-
s
,
21
,
"wrong final position %d != %d"
);
}
else
{
printf
(
"sizeof(long long) == %d, not implemented
\n
"
,
(
int
)
sizeof
(
long
long
));
}
TEST
(
l
,
strtol
(
"z"
,
0
,
36
),
35L
,
"%ld != %ld"
);
TEST
(
l
,
strtol
(
"00010010001101000101011001111000"
,
0
,
2
),
0x12345678L
,
"%ld != %ld"
);
TEST
(
l
,
strtol
(
s
=
"0F5F"
,
&
c
,
16
),
0x0f5fL
,
"%ld != %ld"
);
TEST
(
l
,
strtol
(
s
=
"0xz"
,
&
c
,
16
),
0L
,
"%ld != %ld"
);
TEST3
(
i
,
c
-
s
,
1
,
"wrong final position %ld != %ld"
);
TEST
(
l
,
strtol
(
s
=
"0x1234"
,
&
c
,
16
),
0x1234
,
"%ld != %ld"
);
TEST2
(
i
,
c
-
s
,
6
,
"wrong final position %ld != %ld"
);
c
=
NULL
;
TEST3
(
l
,
strtol
(
s
=
"123"
,
&
c
,
37
),
0
,
"%ld != %ld"
);
TEST3
(
i
,
c
-
s
,
0
,
"wrong final position %d != %d"
);
TEST
(
l
,
strtol
(
s
=
" 15437"
,
&
c
,
8
),
015437
,
"%ld != %ld"
);
TEST2
(
i
,
c
-
s
,
7
,
"wrong final position %d != %d"
);
TEST
(
l
,
strtol
(
s
=
" 1"
,
&
c
,
0
),
1
,
"%ld != %ld"
);
TEST2
(
i
,
c
-
s
,
3
,
"wrong final position %d != %d"
);
return
0
;
}
static
void
test_strtol
(
void
)
{
strtol_entry
();
}
static
void
testcase
(
void
)
{
UTEST_UNIT_RUN
(
test_strtol
);
}
UTEST_TC_EXPORT
(
testcase
,
"posix.stdlib_h.strtol_tc.c"
,
RT_NULL
,
RT_NULL
,
10
);
examples/utest/testcases/posix/string_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_STRING_H
bool "<string.h>"
default n
if RTT_POSIX_TESTCASE_STRING_H
# functions, TODO
endif
examples/utest/testcases/posix/stropts_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_STROPTS_H
bool "<stropts.h>"
default n
if RTT_POSIX_TESTCASE_STROPTS_H
# functions, TODO
endif
examples/utest/testcases/posix/sys/Kconfig
0 → 100644
浏览文件 @
b39210de
source "$RTT_DIR/examples/utest/testcases/posix/sys/mman_h/Kconfig"
source "$RTT_DIR/examples/utest/testcases/posix/sys/shm_h/Kconfig"
source "$RTT_DIR/examples/utest/testcases/posix/sys/utsname_h/Kconfig"
examples/utest/testcases/posix/sys/mman_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SYS_MMAN_H
bool "<sys/mman.h>"
default n
if RTT_POSIX_TESTCASE_SYS_MMAN_H
config MMAN_H_MLOCK
bool "<sys/mman.h> -> mlock"
default n
config MMAN_H_MMAP
bool "<sys/mman.h> -> mmap"
default n
config MMAN_H_MPROTECT
bool "<sys/mman.h> -> mprotect"
default n
config MMAN_H_MSYNC
bool "<sys/mman.h> -> msync"
default n
config MMAN_H_MUNLOCK
bool "<sys/mman.h> -> munlock"
default n
config MMAN_H_MUNMAP
bool "<sys/mman.h> -> munmap"
default n
endif
examples/utest/testcases/posix/sys/select_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SYS_SHM_H
bool "<sys/shm.h>"
default n
if RTT_POSIX_TESTCASE_SYS_SELECT_H
config SELECT_H_SELECT
bool "<sys/select.h> -> select"
default n
endif
examples/utest/testcases/posix/sys/shm_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SYS_SHM_H
bool "<sys/shm.h>"
default n
if RTT_POSIX_TESTCASE_SYS_SHM_H
# functions, TODO
endif
examples/utest/testcases/posix/sys/socket_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SYS_SOCKET_H
bool "<sys/shm.h>"
default n
if RTT_POSIX_TESTCASE_SYS_SOCKET_H
config SOCKET_H_SELECT
bool "<sys/socket.h> -> socket, accept, listen...."
default n
endif
examples/utest/testcases/posix/sys/stat_h/Kconfig
0 → 100644
浏览文件 @
b39210de
menuconfig RTT_POSIX_TESTCASE_SYS_STAT_H
bool "<sys/shm.h>"
default n
if RTT_POSIX_TESTCASE_SYS_STAT_H
config STAT_H_CHMOD
bool "<sys/stat.h> -> chmod"
default n
config STAT_H_FCHMOD
bool "<sys/stat.h> -> fchmod"
default n
config STAT_H_FSTAT
bool "<sys/stat.h> -> fstat"
default n
config STAT_H_LSTAT
bool "<sys/stat.h> -> lstat"
default n
endif
examples/utest/testcases/posix/sys/statvfs_h/Kconfig
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/sys/uio_h/Kconfig
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/sys/utsname_h/Kconfig
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/time_h/Kconfig
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/Kconfig
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/SConscript
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/access_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/chdir_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/ftruncate_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/isatty_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/open_read_write_fsync_close_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
examples/utest/testcases/posix/unistd_h/functions/rmdir_tc.c
0 → 100644
浏览文件 @
b39210de
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录