diff --git a/testing/ltp/CMakeLists.txt b/testing/ltp/CMakeLists.txt index 1152b8963cb..d83beb74b77 100644 --- a/testing/ltp/CMakeLists.txt +++ b/testing/ltp/CMakeLists.txt @@ -71,33 +71,150 @@ if(CONFIG_TESTING_LTP) endif() endif() - if(EXISTS ${TESTDIR}) - set(BLACKWORDS) - set(BLACKSRCS) + # the BLACKWORDS are shared for posix testcases and kernel testcases + set(BLACKWORDS) + if(NOT CONFIG_FS_AIO) + list(APPEND BLACKWORDS "aio.h" "SIGPOLL") + endif() + list(APPEND BLACKWORDS "pthread_mutexattr_setprioceiling" + "pthread_mutexattr_getprioceiling" "pthread_getattr_np" + "pthread_mutex_getprioceiling") - if(NOT CONFIG_FS_AIO) - list(APPEND BLACKWORDS "aio.h" "SIGPOLL") - endif() - list(APPEND BLACKWORDS "pthread_mutexattr_setprioceiling" - "pthread_mutexattr_getprioceiling" "pthread_getattr_np" - "pthread_mutex_getprioceiling") + if(NOT CONFIG_PTHREAD_SPINLOCKS) + list(APPEND BLACKWORDS "pthread_spin_init" "pthread_spin_destroy" + "pthread_spin_trylock") + endif() + list( + APPEND + BLACKWORDS + "CHILD_MAX" + "setpgid(" + "PTHREAD_SCOPE_PROCESS" + "setpgrp" + "threads_scenarii.c" + "pthread_mutex_lock" + "ucontext.h" + "msync" + "lfind") + + if(NOT CONFIG_FS_TMPFS) + list(APPEND BLACKWORDS "lio_listio") + endif() - if(NOT CONFIG_PTHREAD_SPINLOCKS) - list(APPEND BLACKWORDS "pthread_spin_init" "pthread_spin_destroy" - "pthread_spin_trylock") - endif() + if(NOT CONFIG_SIG_EVTHREAD) + list(APPEND BLACKWORDS "fork") + endif() + + if(NOT CONFIG_MQ_MAXMSGSIZE GREATER_EQUAL 64) list( APPEND BLACKWORDS - "CHILD_MAX" - "setpgid(" - "PTHREAD_SCOPE_PROCESS" - "setpgrp" - "threads_scenarii.c" - "pthread_mutex_lock" - "ucontext.h" - "msync" - "lfind") + "mq_close" + "mq_getattr" + "mq_notify" + "mq_open" + "mq_receive" + "mq_send" + "mq_setattr" + "mq_timedreceive" + "mq_timedsend" + "mq_unlink") + endif() + + if(NOT CONFIG_PTHREAD_MUTEX_TYPES) + list(APPEND BLACKWORDS "pthread_mutexattr_settype") + endif() + + if(NOT CONFIG_SIG_DEFAULT) + list(APPEND BLACKWORDS "SIGKILL" "SIGSTOP") + endif() + + if(NOT CONFIG_RR_INTERVAL GREATER 0) + list(APPEND BLACKWORDS "SCHED_RR") + endif() + + if(NOT CONFIG_FS_NAMED_SEMAPHORES) + list(APPEND BLACKWORDS "sem_open" "sem_close" "sem_unlink") + endif() + + if(NOT CONFIG_PIPES) + list(APPEND BLACKWORDS "pipe") + endif() + + if(NOT CONFIG_PTHREAD_SPINLOCKS) + list(APPEND BLACKWORDS "pthread_spin_lock") + endif() + + if(NOT CONFIG_SCHED_WAITPID) + list(APPEND BLACKWORDS "waitpid") + endif() + + if(NOT CONFIG_SCHED_WAITPID OR NOT CONFIG_SCHED_HAVE_PARENT) + list(APPEND BLACKWORDS "wait") + endif() + + if(NOT CONFIG_SCHED_USER_IDENTITY) + list( + APPEND + BLACKWORDS + "setuid" + "setgid" + "getuid" + "getgid" + "seteuid" + "setegid" + "geteuid" + "getegid") + endif() + + if(CONFIG_TLS_NELEM EQUAL 0) + list(APPEND BLACKWORDS "pthread_key_create" "pthread_key_delete" + "pthread_setspecific" "pthread_getspecific") + endif() + + if(CONFIG_TLS_NCLEANUP EQUAL 0) + list(APPEND BLACKWORDS "pthread_cleanup_push" "pthread_cleanup_pop") + endif() + + if(NOT CONFIG_LIBC_EXECFUNCS) + list(APPEND BLACKWORDS "execl" "execvp" "execlp" "execvpe") + endif() + + if(NOT CONFIG_FS_SHMFS) + list(APPEND BLACKWORDS "shm_open" "shm_unlink") + endif() + + if(NOT LIBC_LOCALE_CATALOG) + list(APPEND BLACKWORDS "catopen" "catgets" "catclose") + endif() + + if(NOT CONFIG_MM_SHM) + list(APPEND BLACKWORDS "shmget" "shmat") + endif() + + add_compile_options( + -Wall + -Wno-strict-prototypes + -Wno-return-type + -Wno-format + -Wno-uninitialized + -Wno-unused-variable + -Wno-unused-function + -Wno-unused-but-set-variable + -Wno-unused-value + -Wno-int-conversion + -Wno-shadow + -Wno-incompatible-pointer-types + -Wno-overflow + -Wno-int-to-pointer-cast) + + if(APPLE) + add_compile_options(-Wno-integer-overflow -Wno-absolute-value) + endif() + + # to build the posix testcases + if(EXISTS ${TESTDIR}) + set(BLACKSRCS) list( APPEND @@ -143,34 +260,6 @@ if(CONFIG_TESTING_LTP) ${TESTDIR}/conformance/behavior/WIFEXITED/1-2.c) endif() - if(NOT CONFIG_FS_TMPFS) - list(APPEND BLACKWORDS "lio_listio") - endif() - - if(NOT CONFIG_SIG_EVTHREAD) - list(APPEND BLACKWORDS "fork") - endif() - - if(NOT CONFIG_MQ_MAXMSGSIZE GREATER_EQUAL 64) - list( - APPEND - BLACKWORDS - "mq_close" - "mq_getattr" - "mq_notify" - "mq_open" - "mq_receive" - "mq_send" - "mq_setattr" - "mq_timedreceive" - "mq_timedsend" - "mq_unlink") - endif() - - if(NOT CONFIG_PTHREAD_MUTEX_TYPES) - list(APPEND BLACKWORDS "pthread_mutexattr_settype") - endif() - if(NOT CONFIG_SCHED_SPORADIC) list( APPEND @@ -180,22 +269,6 @@ if(CONFIG_TESTING_LTP) ${TESTDIR}/conformance/interfaces/sched_setscheduler/19-4.c) endif() - if(NOT CONFIG_SIG_DEFAULT) - list(APPEND BLACKWORDS "SIGKILL" "SIGSTOP") - endif() - - if(NOT CONFIG_RR_INTERVAL GREATER 0) - list(APPEND BLACKWORDS "SCHED_RR") - endif() - - if(NOT CONFIG_FS_NAMED_SEMAPHORES) - list(APPEND BLACKWORDS "sem_open" "sem_close" "sem_unlink") - endif() - - if(NOT CONFIG_PIPES) - list(APPEND BLACKWORDS "pipe") - endif() - if(NOT CONFIG_LIBC_MAX_EXITFUNS GREATER_EQUAL 32) list(APPEND BLACKSRCS ${TESTDIR}/conformance/interfaces/pthread_exit/4-1.c @@ -212,53 +285,6 @@ if(CONFIG_TESTING_LTP) ${TESTDIR}/conformance/interfaces/pthread_setspecific/1-1.c) endif() - if(NOT CONFIG_PTHREAD_SPINLOCKS) - list(APPEND BLACKWORDS "pthread_spin_lock") - endif() - - if(NOT CONFIG_SCHED_WAITPID) - list(APPEND BLACKWORDS "waitpid") - endif() - - if(NOT CONFIG_SCHED_USER_IDENTITY) - list( - APPEND - BLACKWORDS - "setuid" - "setgid" - "getuid" - "getgid" - "seteuid" - "setegid" - "geteuid" - "getegid") - endif() - - if(CONFIG_TLS_NELEM EQUAL 0) - list(APPEND BLACKWORDS "pthread_key_create" "pthread_key_delete" - "pthread_setspecific" "pthread_getspecific") - endif() - - if(CONFIG_TLS_NCLEANUP EQUAL 0) - list(APPEND BLACKWORDS "pthread_cleanup_push" "pthread_cleanup_pop") - endif() - - if(NOT CONFIG_LIBC_EXECFUNCS) - list(APPEND BLACKWORDS "execl" "execvp" "execlp" "execvpe") - endif() - - if(NOT CONFIG_FS_SHMFS) - list(APPEND BLACKWORDS "shm_open" "shm_unlink") - endif() - - if(NOT LIBC_LOCALE_CATALOG) - list(APPEND BLACKWORDS "catopen" "catgets" "catclose") - endif() - - if(NOT CONFIG_MM_SHM) - list(APPEND BLACKWORDS "shmget" "shmat") - endif() - file(GLOB_RECURSE LTP_ORIGS ${TESTDIR}/*.c) if(LTP_ORIGS) @@ -330,33 +356,473 @@ if(CONFIG_TESTING_LTP) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${TESTDIR}/include) + include_directories(${TESTDIR}/../../../include) include_directories(${TESTDIR}/../../include) + list(LENGTH LTP_MAINCSRCS SOURCE_FILES_COUNT) + math(EXPR LAST_INDEX "${SOURCE_FILES_COUNT} - 1") + + foreach(INDEX RANGE 0 ${LAST_INDEX}) + list(GET LTP_MAINCSRCS ${INDEX} SOURCE_FILES) + list(GET PROGNAME ${INDEX} EXECUTABLE_NAMES) + nuttx_add_application( + NAME + ${EXECUTABLE_NAMES} + PRIORITY + SCHED_PRIORITY_DEFAULT + STACKSIZE + ${CONFIG_TESTING_LTP_STACKSIZE} + SRCS + ${SOURCE_FILES}) + endforeach() + endif() + + # ############################################################################ + # to build the linux kernel testcases + set(TESTLINUX_DIR ${LTP_UNPACK}/testcases/kernel) + + if(EXISTS ${TESTLINUX_DIR}) + list( + APPEND + BLACKWORDS + "connectors" + "netlink" + "cgroup" + "cpuctl" + "scsi" # nuttx do not support scsi device driver + "RTC_" + "V4L2" + "v4l2" + "TUSB_MAJOR" + "tagp" + "tmod" + "LO_FLAGS_AUTOCLEAR" + "IFF_ONE_QUEUE" + "LO_FLAGS_READ_ONLY" + "loopinfo" + "sigjmp_buf" + "FIBMAP" + "block_dev_handle" + "drm" + "tst_path_has_mnt_flags" + "personality" # nuttx do not support execution domains api + "getcontext" + "fmtmsg" + "MS_BIND" # nuttx mount do not support MS_BIND flags + "sound" + "tracing" + "CLONE_NEWNS" + "CLONE_NEWPID" + "CLONE_NEWUSER" + "CLONE_NEWIPC" + "CLONE_NEWUTS" + "CLONE_NEWNET" + "CLONE_NEWIPC" + "NAMESPACE" + "cap_last_cap" + "crypto" + "NUMA") + + if(NOT CONFIG_LIBC_EXECFUNCS) + list(APPEND BLACKWORDS "execv" "execve") + endif() + + list( + APPEND + BLACKWORDS + "bitmask_alloc" + "input" + "msgctl" # nuttx do not support System V IPC api + "semget" + "semctl" + "shmctl" + "logging" + "mce-test" + "numa" + "hugetlb" # nuttx do not support hugetlb + "tomoyo" # nuttx do not support tomoyo security module + "posix_fadvise" # nuttx do not support posix_fadvise syscall + "sysctl" # nuttx do not support sysctl syscall + "getgroups" # nuttx do not support getgroups syscall + "setgroups" # nuttx do not support setgroups syscall + "getdents" # nuttx do not support getdents syscall + "rt_sigaction" # nuttx do not support rt_sigaction syscall + "socketcall" # nuttx do not support socketcall syscall + "readahead" # nuttx do not support readahead syscall + "capget" # nuttx do not support capget syscall + "BLKROSET" # nuttx do not support BLKROSET flag in ioctl syscall + "quotactl" # nuttx do not support quotactl syscall + "swapon" # nuttx do not support swapon syscall + "swapoff" # nuttx do not support swapoff syscall + "bpf" # nuttx do not support bpf syscall + "mincore" # nuttx do not support mincore syscall + "unshare" # nuttx do not support unshare syscall + "kcmp" # nuttx do not support kcmp syscall + "clone" # nuttx do not support clone syscall + "capset" # nuttx do not support capset syscall + "adjtimex" # nuttx do not support adjtimex syscall + "confstr" # nuttx do not support confstr syscall + "fallocate" # nuttx do not support fallocate syscall, and only support + # posix_fallocate syscall + "rt_tgsigqueueinfo" # nuttx do not support rt_tgsigqueueinfo syscall + "sync_file_range" # nuttx do not support sync_file_range syscall + "vhangup" # nuttx do not support vhangup syscall + "remap_file_pages" # nuttx do not support remap_file_pages syscall + "acct" # nuttx do not support acct syscall + "gethostid" # nuttx do not support gethostid syscall + "mallopt" # nuttx do not support malloopt syscall + ) + + if(NOT CONFIG_TIMER_FD) + list(APPEND BLACKWORDS "timerfd_create" "timerfd_gettime") + endif() + + list(APPEND BLACKWORDS "renameat2" # nuttx do not support renameat2 syscall + ) + + if(NOT CONFIG_PSEUDOTERM) + list(APPEND BLACKWORDS "unlockpt" "grantpt") + endif() + + list(APPEND BLACKWORDS "eaccess" # nuttx do not support eaccess api + "mremap" # nuttx do not support mremap api + ) + + if(NOT CONFIG_SMP) + list(APPEND BLACKWORDS "sched_getaffinity") + endif() + + if(NOT CONFIG_ARCH_ADDRENV + OR NOT CONFIG_MM_PGALLOC + OR NOT CONFIG_ARCH_USE_MMU) + list(APPEND BLACKWORDS "sbrk") + endif() + + list( + APPEND + BLACKWORDS + "RLIMIT_RSS" + "RLIMIT_NPROC" + "RLIMIT_LOCKS" + "RLIMIT_MSGQUEUE" + "RLIMIT_SIGPENDING" + "modify_ldt" # nuttd do not support modify_ldt syscall interface + "SIGPWR" + "_SC_PASS_MAX" + "_SC_XOPEN_XCU_VERSION" + "UL_GETFSIZE" + "setresuid" + "setresgid" + "getsid" + "getresuid" + "getresgid") + + if(NOT CONFIG_PSEUDOFS_SOFTLINKS) + list(APPEND BLACKWORDS "symlink" "link") + endif() + + if(NOT CONFIG_FS_LARGEFILE) + list(APPEND BLACKWORDS "off64_t" "fpos64_t" "F_GETLK64") + list(APPEND BLACKWORDS "F_SETLK64" "F_SETLKW64" "flock64") + list(APPEND BLACKWORDS "open64" "openat64" "creat64") + list(APPEND BLACKWORDS "fallocate64" "posix_fadvise64" + "posix_fallocate64") + list(APPEND BLACKWORDS "lseek64" "pread64" "pwrite64") + list(APPEND BLACKWORDS "truncate64" "ftruncate64" "lockf64") + list( + APPEND + BLACKWORDS + "getrlimit64" + "setrlimit64" + "prlimit64" + "rlimit64" + "rlim64_t") + endif() + if(NOT CONFIG_ARCH_SETJMP_H) + list(APPEND BLACKWORDS "setjmp" "longjmp") + endif() + list( + APPEND + BLACKWORDS + "in6addr_loopback" + "BLKGETSIZE64" + "BLKRAGET" + "BLKRASET" + "RNDGETENTCNT" + "KEYCTL_JOIN_SESSION_KEYRING" + "keyctl" # nuttx do not support keyctl syscall interface + "ioctl_ns" # nuttx do not support ioctl_ns (ioctl for linux namespace) + "si_uid" # nuttx "struct siginfo" do not have "si_uid" member + "si_addr" # nuttx "struct siginfo" do not have "si_addr" member + "TFD_TIMER_ABSTIME" + "setdomainname" + "chroot" + "safe_chroot" + "SAFE_BIND" + "wait4" + "ksmd" + "PR_SET_PDEATHSIG" + "PR_GET_PDEATHSIG" + "ptrace" # nuttx do not support ptrace + "uevents" # nuttx do not support uevents + "futex" # nuttx do not support futex for now + "tst_module_exists" # nuttx do not support linux kernel module framework + "tst_module_load" + "tst_module_unload" + "module" + "setpgid" + "safe_setpgid" + "safe_getpgid" + "open_kconfig" + "close_kconfig" + "firmware" # nuttx do not support linux firmware load framework + "nftw64") + + list( + APPEND + BLACKSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/io/disktest/main.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/io/direct_io/dma_thread_diotest.c + ) + + # syscalls/nftw/test_func.c has provide the implementation of test_func*(), + # and the implementation are completely same as syscalls/nftw/test_func64.c + # provided implementation, we just need to keep one of them. and the + # following test64.c/lib64.c/tools64.c are deleted from source list with + # same reason as test_func64.c + list( + APPEND + BLACKSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/test_func64.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/test64.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/lib64.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/tools64.c) + + add_compile_options( + -DHAVE_FCHOWNAT + -DMAXPATHLEN=256 + -DUNIT_TEST + -DHAVE_MKDIRAT + -DHAVE_OPENAT + -DTEST_CLEANUP + -DBLKGETSIZE64=BLKGETSIZE + -D__linux__ + -DLINUX) + add_compile_options( - -Wall - -Wno-strict-prototypes - -Wno-return-type - -Wno-format - -Wno-uninitialized - -Wno-unused-variable - -Wno-unused-function - -Wno-unused-but-set-variable - -Wno-unused-value - -Wno-int-conversion - -Wno-shadow - -Wno-incompatible-pointer-types - -Wno-overflow - -Wno-int-to-pointer-cast) - - if(APPLE) - add_compile_options(-Wno-integer-overflow -Wno-absolute-value) + -DHAVE_ASPRINTF + -DHAVE_LINUX_FS_H + -DTST_USE_NEWER64_SYSCALL=0 + -DINVALID_TEST_CASES=0 + -DHAVE_STRUCT_RLIMIT64 + -DHAVE_READLINKAT + -DHAVE_FSTATAT) + + if(CONFIG_TIMER_FD) + add_compile_options(-DHAVE_TIMERFD_CREATE -DHAVE_SYS_TIMERFD_H) endif() + add_compile_options( + -DHAVE_TIMERFD_GETTIME -DHAVE_TIMERFD_SETTIME -DHAVE_SYNCFS + -DHAVE_MKNODAT -DHAVE_RENAMEAT2 -DHAVE_RENAMEAT) - list(LENGTH LTP_MAINCSRCS SOURCE_FILES_COUNT) + # add the macro definition to handle the naming conflication betweeb ltp + # kernel testcases and the vela external projects + add_compile_options( + -Dsafe_touch=ltp_safe_touch + -Dsafe_socket=ltp_safe_socket + -Dsafe_bind=ltp_safe_bind + -Dsafe_listen=ltp_safe_listen + -Dsafe_connect=ltp_safe_connect + -Dsafe_getsockname=ltp_safe_getsockname + -Dsafe_close=ltp_safe_close + -Dsafe_open=ltp_safe_open + -Dsafe_write=ltp_safe_write + -Derror=ltp_error) + + # The following warnings are all reported by the LTP kernel test cases + # themselves. To avoid affecting the CI build working procedure, we need to + # ignore these warnings. + add_compile_options( + -Wno-undef + -Wno-pointer-sign + -Wno-parentheses + -Wno-use-after-free + -Wno-discarded-qualifiers + -Wno-implicit-int + -Wno-pointer-to-int-cast + -Wno-switch-bool + -Wno-restrict + -Wno-stringop-overflow + -Wno-array-bounds + -Wno-shift-count-overflow + -Wno-stringop-overread) + + file(GLOB_RECURSE LTP_LINUX_ORIGS ${TESTLINUX_DIR}/*.c) + + if(LTP_LINUX_ORIGS) + foreach(word IN LISTS BLACKWORDS) + foreach(file ${LTP_LINUX_ORIGS}) + file(STRINGS ${file} content) + string(FIND "${content}" "${word}" pos) + if(pos GREATER -1) + list(APPEND BLACKLIST ${file}) + endif() + endforeach() + endforeach() + endif() + + foreach(src ${BLACKSRCS}) + foreach(orig ${LTP_LINUX_ORIGS}) + string(REGEX MATCH "${src}$" matched ${orig}) + if(matched) + list(APPEND BLACKLIST ${orig}) + endif() + endforeach() + endforeach() + + foreach(ITEM ${BLACKLIST}) + list(REMOVE_ITEM LTP_LINUX_ORIGS ${ITEM}) + endforeach() + + set(LTP_LINUX_MAINCSRCS "") + if(LTP_LINUX_ORIGS) + foreach(file ${LTP_LINUX_ORIGS}) + file(STRINGS ${file} content) + string(FIND "${content}" "main(" pos) + if(pos GREATER -1) + list(APPEND LTP_LINUX_MAINCSRCS ${file}) + else() + string(FIND "${content}" "struct tst_test" pos) + if(pos GREATER -1) + list(APPEND LTP_LINUX_MAINCSRCS ${file}) + endif() + endif() + endforeach() + endif() + + set(LTP_KERNEL_CSRCS ${LTP_LINUX_ORIGS}) + foreach(ITEM ${LTP_LINUX_MAINCSRCS}) + list(REMOVE_ITEM LTP_KERNEL_CSRCS ${ITEM}) + endforeach() + + set(PROGNAME "") + if(LTP_LINUX_MAINCSRCS) + foreach(file ${LTP_LINUX_MAINCSRCS}) + string(REPLACE "/" ";" file_parts ${file}) + list(LENGTH file_parts num_parts) + if(num_parts GREATER 2) + list(GET file_parts -3 part1) + list(GET file_parts -2 part2) + list(GET file_parts -1 part3) + string(REPLACE "-" "_" part1 ${part1}) + string(REPLACE "-" "_" part2 ${part2}) + string(REPLACE "-" "_" part3 ${part3}) + set(prog "ltp_${part1}_${part2}_${part3}") + get_filename_component(progg ${prog} NAME_WE) + list(APPEND PROGNAME ${progg}) + endif() + endforeach() + endif() + + # since we have enabled the UNIT_TEST, the random_range.c and parse_opts.c + # self unittest will also be build as an executable, we name it as + # random_range_test and parse_opts_test + list(APPEND LTP_LINUX_MAINCSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/random_range.c) + list(APPEND PROGNAME "random_range_test") + list(APPEND LTP_LINUX_MAINCSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/parse_opts.c) + list(APPEND PROGNAME "parse_opts_test") + list(APPEND LTP_LINUX_MAINCSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/fs/doio/open_flags.c) + list(APPEND PROGNAME "doio_openflags_test") + + # the following are the basic source + list( + APPEND + LTP_KERNEL_CSRCS + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/get_path.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/safe_file_ops.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/safe_macros.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/parse_opts.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/self_exec.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_ansi_color.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_assert.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_device.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_res.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_sys_conf.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_test.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_tmpdir.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_wallclock.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_checkpoint.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_clocks.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_sig.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_parse_opts.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_pid.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_cmd.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fill_file.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_mkfs.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_kvercmp.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_kernel.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_timer_test.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_hugepage.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_buffers.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_resource.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fs_setup.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_safe_macros.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/safe_net.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/safe_pthread.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/safe_stdio.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_supported_fs_types.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_timer.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_get_bad_addr.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_status.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_sig_proc.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_process_state.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_virt.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_kconfig.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_path_has_mnt_flags.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_capability.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fs_type.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_cpu.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fill_fs.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fs_link_count.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_dir_is_empty.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_coredump.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_fs_has_free.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/fs/fs-bench/boxmuler.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/fs/doio/bytes_by_prefix.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/fs/doio/string_to_tokens.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/device-drivers/base/user_base/tbase_ki.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/tools.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/lib.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/sched/sched_stress/sched.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/io/direct_io/diotest_routines.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/controllers/libcontrollers/libcontrollers.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/mem/lib/mem.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/memfd_create/memfd_create_common.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/lib/tst_safe_sysv_ipc.c + ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/ipc/lib/libipc.c + ${CMAKE_CURRENT_LIST_DIR}/src/nx_syscall.c + ${CMAKE_CURRENT_LIST_DIR}/src/dummy.c) + + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${TESTLINUX_DIR}/include) + include_directories(${TESTLINUX_DIR}/../../include) + include_directories(${TESTLINUX_DIR}/syscalls/ptrace) + include_directories(${TESTLINUX_DIR}/syscalls/utils) + include_directories(${TESTLINUX_DIR}/../../include/old) + include_directories(${TESTLINUX_DIR}/fs/doio/include) + include_directories(${TESTLINUX_DIR}/controllers/libcontrollers) + include_directories(${TESTLINUX_DIR}/mem/include) + include_directories(${TESTLINUX_DIR}/syscalls/ipc/lib) + include_directories(${TESTLINUX_DIR}/syscalls/ipc/libnewipc) + + list(LENGTH LTP_LINUX_MAINCSRCS SOURCE_FILES_COUNT) math(EXPR LAST_INDEX "${SOURCE_FILES_COUNT} - 1") foreach(INDEX RANGE 0 ${LAST_INDEX}) - list(GET LTP_MAINCSRCS ${INDEX} SOURCE_FILES) + list(GET LTP_LINUX_MAINCSRCS ${INDEX} SOURCE_FILES) list(GET PROGNAME ${INDEX} EXECUTABLE_NAMES) nuttx_add_application( NAME @@ -370,6 +836,7 @@ if(CONFIG_TESTING_LTP) endforeach() endif() + list(APPEND LTP_CSRCS ${LTP_KERNEL_CSRCS}) nuttx_add_library(ltp) target_sources(ltp PRIVATE ${LTP_CSRCS}) diff --git a/testing/ltp/Makefile b/testing/ltp/Makefile index 1fc2c943d99..583a00a1868 100644 --- a/testing/ltp/Makefile +++ b/testing/ltp/Makefile @@ -27,9 +27,8 @@ LTP_DOWNLOAD_URL = https://github.com/linux-test-project/ltp/archive/refs/tags/ LTP_UNPACK = ltp LTP_URL = https://github.com/linux-test-project/ltp.git -TESTDIR = $(LTP_UNPACK)/testcases/open_posix_testsuite +# to construct the test for LTP POSIX interface testcases -ifneq ($(wildcard $(TESTDIR)),) ifeq ($(CONFIG_FS_AIO),) BLACKWORDS += "aio.h" BLACKWORDS += "SIGPOLL" @@ -55,36 +54,6 @@ BLACKWORDS += "ucontext.h" BLACKWORDS += "msync" BLACKWORDS += "lfind" -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/19-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/definitions/signal_h/21-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/definitions/signal_h/27-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/19-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/sem_post/8-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/9-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/2-2.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/10-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-5.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-3.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/2-3.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-4.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_sigmask/18-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_sigmask/4-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/sigprocmask/4-1.c -ifeq ($(CONFIG_LIBC_LOCALTIME),) -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/34-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-3-buildonly.c -endif -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-1-buildonly.c -BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-2-buildonly.c -BLACKSRCS += $(TESTDIR)/stress/threads/pthread_kill/stress.c -ifeq ($(CONFIG_PTHREAD_SPINLOCKS),) -BLACKSRCS += $(TESTDIR)/conformance/definitions/pthread_h/3-12-buildonly.c -endif -ifeq ($(CONFIG_SCHED_CHILD_STATUS),) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/6-1.c -BLACKSRCS += $(TESTDIR)/conformance/behavior/WIFEXITED/1-1.c -BLACKSRCS += $(TESTDIR)/conformance/behavior/WIFEXITED/1-2.c -endif ifeq ($(CONFIG_FS_TMPFS),) BLACKWORDS += lio_listio endif @@ -106,11 +75,7 @@ endif ifeq ($(CONFIG_PTHREAD_MUTEX_TYPES),) BLACKWORDS += pthread_mutexattr_settype endif -ifeq ($(CONFIG_SCHED_SPORADIC),) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-2.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-3.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-4.c -endif + ifeq ($(CONFIG_SIG_DEFAULT),) BLACKWORDS += SIGKILL BLACKWORDS += SIGSTOP @@ -126,22 +91,20 @@ endif ifeq ($(CONFIG_PIPES),) BLACKWORDS += pipe endif -ifneq ($(shell expr $(CONFIG_LIBC_MAX_EXITFUNS) \>= 32),1) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/4-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/5-1.c -endif -ifeq ($(CONFIG_CANCELLATION_POINTS),) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/3-1.c -endif -ifneq ($(shell expr $(CONFIG_TLS_NELEM) \>= 16),1) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_setspecific/1-1.c -endif + ifeq ($(CONFIG_PTHREAD_SPINLOCKS),) BLACKWORDS += pthread_spin_lock endif ifeq ($(CONFIG_SCHED_WAITPID),) BLACKWORDS += waitpid endif + +ifeq ($(CONFIG_SCHED_WAITPID),) +BLACKWORDS += wait +else ifeq ($(CONFIG_SCHED_HAVE_PARENT),) +BLACKWORDS += wait +endif + ifeq ($(CONFIG_SCHED_USER_IDENTITY),) BLACKWORDS += setuid BLACKWORDS += setgid @@ -184,6 +147,69 @@ endif MAINWORDS += "main(" +# Relax warning checks to avoid expected compile errors: +CFLAGS += -Wno-strict-prototypes -Wno-return-type -Wno-format -Wno-uninitialized +CFLAGS += -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-value +CFLAGS += -Wno-int-conversion -Wno-shadow + +# Should be removed if possible in the future +CFLAGS += -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-to-pointer-cast + +# Specific compilation errors ignored in MacOS platform +ifneq ($(CONFIG_HOST_MACOS),) +CFLAGS += -Wno-integer-overflow -Wno-absolute-value +endif + +TESTDIR = $(LTP_UNPACK)/testcases/open_posix_testsuite + +ifneq ($(wildcard $(TESTDIR)),) + +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/19-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/definitions/signal_h/21-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/definitions/signal_h/27-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/19-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/sem_post/8-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/9-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/2-2.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/10-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-5.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-3.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/2-3.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/clock_nanosleep/1-4.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_sigmask/18-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_sigmask/4-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/sigprocmask/4-1.c +ifeq ($(CONFIG_LIBC_LOCALTIME),) +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/34-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-3-buildonly.c +endif +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-1-buildonly.c +BLACKSRCS += $(TESTDIR)/conformance/definitions/time_h/35-2-buildonly.c +BLACKSRCS += $(TESTDIR)/stress/threads/pthread_kill/stress.c +ifeq ($(CONFIG_PTHREAD_SPINLOCKS),) +BLACKSRCS += $(TESTDIR)/conformance/definitions/pthread_h/3-12-buildonly.c +endif +ifeq ($(CONFIG_SCHED_CHILD_STATUS),) +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/6-1.c +BLACKSRCS += $(TESTDIR)/conformance/behavior/WIFEXITED/1-1.c +BLACKSRCS += $(TESTDIR)/conformance/behavior/WIFEXITED/1-2.c +endif +ifeq ($(CONFIG_SCHED_SPORADIC),) +BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-2.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-3.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/sched_setscheduler/19-4.c +endif +ifneq ($(shell expr $(CONFIG_LIBC_MAX_EXITFUNS) \>= 32),1) +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/4-1.c +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/5-1.c +endif +ifeq ($(CONFIG_CANCELLATION_POINTS),) +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_exit/3-1.c +endif +ifneq ($(shell expr $(CONFIG_TLS_NELEM) \>= 16),1) +BLACKSRCS += $(TESTDIR)/conformance/interfaces/pthread_setspecific/1-1.c +endif + LTP_ORIGS := $(shell find $(TESTDIR) -name *.c) ifneq ($(LTP_ORIGS),) $(eval $(call SPLITVARIABLE,ORIGS_SPILT,$(LTP_ORIGS),200)) @@ -224,22 +250,420 @@ MODULE = $(CONFIG_TESTING_LTP) CSRCS := $(LTP_CSRCS) CFLAGS += -I$(CURDIR) CFLAGS += -I$(TESTDIR)/include +CFLAGS += -I$(TESTDIR)/../../../include CFLAGS += -I$(TESTDIR)/../../include + +endif # TESTDIR not empty + +######################################################################################## + +TESTLINUX_DIR = $(LTP_UNPACK)/testcases/kernel + +# there are two kinds of testcases that kernel api can run, first is using main() function +# to build as an executable directly, the second is by include "include/tst_test.h" +# header file, and include/tst_test.h will generate main() function for this case, we +# need to support both cases +MAINWORDS += "tst_test" + +BLACKWORDS += connectors +BLACKWORDS += netlink +BLACKWORDS += cgroup +BLACKWORDS += cpuctl + +# the device-drivers related blackwords +BLACKWORDS += scsi # nuttx do not support scsi device driver +BLACKWORDS += RTC_ +BLACKWORDS += V4L2 +BLACKWORDS += v4l2 +BLACKWORDS += TUSB_MAJOR +BLACKWORDS += tagp +BLACKWORDS += tmod +BLACKWORDS += LO_FLAGS_AUTOCLEAR +BLACKWORDS += IFF_ONE_QUEUE +BLACKWORDS += LO_FLAGS_READ_ONLY +BLACKWORDS += loopinfo +BLACKWORDS += sigjmp_buf +BLACKWORDS += FIBMAP +BLACKWORDS += block_dev_handle +BLACKWORDS += drm +BLACKWORDS += tst_path_has_mnt_flags +BLACKWORDS += personality # nuttx do not support execution domains api +BLACKWORDS += getcontext +BLACKWORDS += fmtmsg +BLACKWORDS += MS_BIND # nuttx mount do not support MS_BIND flags +BLACKWORDS += sound +BLACKWORDS += tracing + +BLACKWORDS += CLONE_NEWNS +BLACKWORDS += CLONE_NEWPID +BLACKWORDS += CLONE_NEWUSER +BLACKWORDS += CLONE_NEWIPC +BLACKWORDS += CLONE_NEWUTS +BLACKWORDS += CLONE_NEWNET +BLACKWORDS += CLONE_NEWIPC +BLACKWORDS += NAMESPACE +BLACKWORDS += cap_last_cap +BLACKWORDS += crypto +BLACKWORDS += NUMA + +ifeq ($(CONFIG_LIBC_EXECFUNCS),) +BLACKWORDS += execv +BLACKWORDS += execve endif -# Relax warning checks to avoid expected compile errors: -CFLAGS += -Wno-strict-prototypes -Wno-return-type -Wno-format -Wno-uninitialized -CFLAGS += -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-value -CFLAGS += -Wno-int-conversion -Wno-shadow +BLACKWORDS += bitmask_alloc +BLACKWORDS += input -# Should be removed if possible in the future -CFLAGS += -Wno-incompatible-pointer-types -Wno-overflow -Wno-int-to-pointer-cast +BLACKWORDS += msgctl # nuttx do not support System V IPC api +BLACKWORDS += semget +BLACKWORDS += semctl +BLACKWORDS += shmctl -# Specific compilation errors ignored in MacOS platform -ifneq ($(CONFIG_HOST_MACOS),) -CFLAGS += -Wno-integer-overflow -Wno-absolute-value +BLACKWORDS += logging +BLACKWORDS += mce-test +BLACKWORDS += numa + +BLACKWORDS += hugetlb # nuttx do not support hugetlb +BLACKWORDS += tomoyo # nuttx do not support tomoyo security module + +BLACKWORDS += posix_fadvise # nuttx do not support posix_fadvise syscall +BLACKWORDS += sysctl # nuttx do not support sysctl syscall +BLACKWORDS += getgroups # nuttx do not support getgroups syscall +BLACKWORDS += setgroups # nuttx do not support setgroups syscall +BLACKWORDS += getdents # nuttx do not support getdents syscall +BLACKWORDS += rt_sigaction # nuttx do not support rt_sigaction syscall +BLACKWORDS += socketcall # nuttx do not support socketcall syscall +BLACKWORDS += readahead # nuttx do not support readahead syscall +BLACKWORDS += capget # nuttx do not support capget syscall +BLACKWORDS += BLKROSET # nuttx do not support BLKROSET flag in ioctl syscall +BLACKWORDS += quotactl # nuttx do not support quotactl syscall +BLACKWORDS += swapon # nuttx do not support swapon syscall +BLACKWORDS += swapoff # nuttx do not support swapoff syscall +BLACKWORDS += bpf # nuttx do not support bpf syscall +BLACKWORDS += mincore # nuttx do not support mincore syscall +BLACKWORDS += unshare # nuttx do not support unshare syscall +BLACKWORDS += kcmp # nuttx do not support kcmp syscall +BLACKWORDS += clone # nuttx do not support clone syscall +BLACKWORDS += capset # nuttx do not support capset syscall +BLACKWORDS += adjtimex # nuttx do not support adjtimex syscall +BLACKWORDS += confstr # nuttx do not support confstr syscall +BLACKWORDS += fallocate # nuttx do not support fallocate syscall, and only support posix_fallocate syscall +BLACKWORDS += rt_tgsigqueueinfo # nuttx do not support rt_tgsigqueueinfo syscall +BLACKWORDS += sync_file_range # nuttx do not support sync_file_range syscall +BLACKWORDS += vhangup # nuttx do not support vhangup syscall +BLACKWORDS += remap_file_pages # nuttx do not support remap_file_pages syscall +BLACKWORDS += acct # nuttx do not support acct syscall +BLACKWORDS += gethostid # nuttx do not support gethostid syscall +BLACKWORDS += mallopt # nuttx do not support malloopt syscall +ifeq ($(CONFIG_TIMER_FD),) +BLACKWORDS += timerfd_create +BLACKWORDS += timerfd_gettime +endif + +BLACKWORDS += renameat2 # nuttx do not support renameat2 syscall + +ifeq ($(CONFIG_PSEUDOTERM),) +BLACKWORDS += unlockpt +BLACKWORDS += grantpt +endif + +BLACKWORDS += eaccess # nuttx do not support eaccess api +BLACKWORDS += mremap # nuttx do not support mremap api + +ifeq ($(CONFIG_SMP),) +BLACKWORDS += sched_getaffinity +endif + +ifeq ($(CONFIG_ARCH_ADDRENV),) +BLACKWORDS += sbrk +else ifeq ($(CONFIG_MM_PGALLOC),) +BLACKWORDS += sbrk +else ifeq ($(CONFIG_ARCH_USE_MMU),) +BLACKWORDS += sbrk +endif + +BLACKWORDS += RLIMIT_RSS +BLACKWORDS += RLIMIT_NPROC +BLACKWORDS += RLIMIT_LOCKS +BLACKWORDS += RLIMIT_MSGQUEUE +BLACKWORDS += RLIMIT_SIGPENDING +BLACKWORDS += modify_ldt # nuttd do not support modify_ldt syscall interface +BLACKWORDS += SIGPWR +BLACKWORDS += _SC_PASS_MAX +BLACKWORDS += _SC_XOPEN_XCU_VERSION +BLACKWORDS += UL_GETFSIZE + +BLACKWORDS += setresuid +BLACKWORDS += setresgid +BLACKWORDS += getsid +BLACKWORDS += getresuid +BLACKWORDS += getresgid +ifeq ($(CONFIG_PSEUDOFS_SOFTLINKS),) +BLACKWORDS += symlink +BLACKWORDS += link +endif +ifeq ($(CONFIG_FS_LARGEFILE),) +BLACKWORDS += off64_t +BLACKWORDS += fpos64_t +BLACKWORDS += F_GETLK64 +BLACKWORDS += F_SETLK64 +BLACKWORDS += F_SETLKW64 +BLACKWORDS += flock64 +BLACKWORDS += open64 +BLACKWORDS += openat64 +BLACKWORDS += creat64 +BLACKWORDS += fallocate64 +BLACKWORDS += posix_fadvise64 +BLACKWORDS += posix_fallocate64 +BLACKWORDS += lseek64 +BLACKWORDS += pread64 +BLACKWORDS += pwrite64 +BLACKWORDS += truncate64 +BLACKWORDS += ftruncate64 +BLACKWORDS += lockf64 +BLACKWORDS += getrlimit64 +BLACKWORDS += setrlimit64 +BLACKWORDS += prlimit64 +BLACKWORDS += rlimit64 +BLACKWORDS += rlim64_t +endif +ifeq ($(CONFIG_ARCH_SETJMP_H),) +BLACKWORDS += setjmp +BLACKWORDS += longjmp +endif + +BLACKWORDS += in6addr_loopback +BLACKWORDS += BLKGETSIZE64 +BLACKWORDS += BLKRAGET +BLACKWORDS += BLKRASET +BLACKWORDS += RNDGETENTCNT +BLACKWORDS += KEYCTL_JOIN_SESSION_KEYRING +BLACKWORDS += keyctl # nuttx do not support keyctl syscall interface + +BLACKWORDS += ioctl_ns # nuttx do not support ioctl_ns (ioctl for linux namespace) +BLACKWORDS += si_uid # nuttx "struct siginfo" do not have "si_uid" member +BLACKWORDS += si_addr # nuttx "struct siginfo" do not have "si_addr" member +BLACKWORDS += TFD_TIMER_ABSTIME +BLACKWORDS += setdomainname +BLACKWORDS += chroot +BLACKWORDS += safe_chroot +BLACKWORDS += SAFE_BIND +BLACKWORDS += wait4 +BLACKWORDS += ksmd +BLACKWORDS += PR_SET_PDEATHSIG +BLACKWORDS += PR_GET_PDEATHSIG + +BLACKWORDS += ptrace # nuttx do not support ptrace +BLACKWORDS += uevents # nuttx do not support uevents +BLACKWORDS += futex # nuttx do not support futex for now + +BLACKWORDS += tst_module_exists # nuttx do not support linux kernel module framework +BLACKWORDS += tst_module_load +BLACKWORDS += tst_module_unload +BLACKWORDS += module + +BLACKWORDS += setpgid +BLACKWORDS += safe_setpgid +BLACKWORDS += safe_getpgid + +BLACKWORDS += open_kconfig +BLACKWORDS += close_kconfig + +BLACKWORDS += firmware # nuttx do not support linux firmware load framework +BLACKWORDS += nftw64 + +BLACKSRCS += $(TESTLINUX_DIR)/io/disktest/main.c +BLACKSRCS += $(TESTLINUX_DIR)/io/direct_io/dma_thread_diotest.c + +# syscalls/nftw/test_func.c has provide the implementation of test_func*(), +# and the implementation are completely same as syscalls/nftw/test_func64.c +# provided implementation, we just need to keep one of them. +# and the following test64.c/lib64.c/tools64.c are deleted from source list +# with same reason as test_func64.c +BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/test_func64.c +BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/test64.c +BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/lib64.c +BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/tools64.c + +LTP_LINUX_ORIGS := $(shell find $(TESTLINUX_DIR) -name *.c) + +ifneq ($(LTP_LINUX_ORIGS),) +$(eval $(call SPLITVARIABLE,ORIGS_SPILT,$(LTP_LINUX_ORIGS),200)) +$(foreach BATCH, $(ORIGS_SPILT_TOTAL), \ + $(foreach word, $(BLACKWORDS), $(eval LINUX_BLACKLIST+=$(shell grep -lr $(word) $(ORIGS_SPILT_$(BATCH))))) \ +) endif +$(foreach src, $(BLACKSRCS), $(eval LINUX_BLACKLIST+=$(filter %$(src),$(LTP_LINUX_ORIGS)))) + +LTP_LINUX_ORIGS := $(filter-out $(LINUX_BLACKLIST), $(LTP_LINUX_ORIGS)) + +ifneq ($(LTP_LINUX_ORIGS),) +$(eval $(call SPLITVARIABLE,ORIGS_SPILT,$(LTP_LINUX_ORIGS),190)) +$(foreach BATCH, $(ORIGS_SPILT_TOTAL), \ + $(foreach word, $(MAINWORDS), $(eval LTP_LINUX_MAINCSRCS+=$(shell grep -lr $(word) $(ORIGS_SPILT_$(BATCH))))) \ +) +endif + +LTP_LINUX_CSRCS := $(filter-out $(LTP_LINUX_MAINCSRCS), $(LTP_LINUX_ORIGS)) + +ifneq ($(LTP_LINUX_MAINCSRCS),) +$(eval $(call SPLITVARIABLE,MAINCSRC_SPILT,$(LTP_LINUX_MAINCSRCS),50)) +$(foreach BATCH, $(MAINCSRC_SPILT_TOTAL), \ + $(eval PROGNAME+=$(basename $(shell echo $(MAINCSRC_SPILT_$(BATCH)) | xargs -n 1 | awk -F "[/]" '{print "ltp_"$$(NF-2)"_"$$(NF-1)"_"$$(NF)}' | sed s/-/_/g))) \ +) +endif + +MAINSRC += $(LTP_LINUX_MAINCSRCS) + +CSRCS += ltp/lib/get_path.c +CSRCS += ltp/lib/safe_file_ops.c +CSRCS += ltp/lib/safe_macros.c +CSRCS += ltp/lib/parse_opts.c +CSRCS += ltp/lib/self_exec.c +CSRCS += ltp/lib/tst_ansi_color.c +CSRCS += ltp/lib/tst_assert.c +CSRCS += ltp/lib/tst_device.c +CSRCS += ltp/lib/tst_res.c +CSRCS += ltp/lib/tst_sys_conf.c +CSRCS += ltp/lib/tst_test.c +CSRCS += ltp/lib/tst_tmpdir.c +CSRCS += ltp/lib/tst_wallclock.c +CSRCS += ltp/lib/tst_checkpoint.c +CSRCS += ltp/lib/tst_clocks.c +CSRCS += ltp/lib/tst_sig.c +CSRCS += ltp/lib/tst_parse_opts.c +CSRCS += ltp/lib/tst_pid.c +CSRCS += ltp/lib/tst_cmd.c +CSRCS += ltp/lib/tst_fill_file.c +CSRCS += ltp/lib/tst_mkfs.c +CSRCS += ltp/lib/tst_kvercmp.c +CSRCS += ltp/lib/tst_kernel.c +CSRCS += ltp/lib/tst_timer_test.c +CSRCS += ltp/lib/tst_hugepage.c +CSRCS += ltp/lib/tst_buffers.c +CSRCS += ltp/lib/tst_resource.c +CSRCS += ltp/lib/tst_fs_setup.c +CSRCS += ltp/lib/tst_safe_macros.c +CSRCS += ltp/lib/safe_net.c +CSRCS += ltp/lib/safe_pthread.c +CSRCS += ltp/lib/safe_stdio.c +CSRCS += ltp/lib/tst_supported_fs_types.c +CSRCS += ltp/lib/tst_timer.c +CSRCS += ltp/lib/tst_get_bad_addr.c +CSRCS += ltp/lib/tst_status.c +CSRCS += ltp/lib/tst_sig_proc.c +CSRCS += ltp/lib/tst_process_state.c +CSRCS += ltp/lib/tst_virt.c +CSRCS += ltp/lib/tst_kconfig.c +CSRCS += ltp/lib/tst_path_has_mnt_flags.c +CSRCS += ltp/lib/tst_capability.c +CSRCS += ltp/lib/tst_fs_type.c +CSRCS += ltp/lib/tst_cpu.c +CSRCS += ltp/lib/tst_fill_fs.c +CSRCS += ltp/lib/tst_fs_link_count.c +CSRCS += ltp/lib/tst_dir_is_empty.c +CSRCS += ltp/lib/tst_coredump.c +CSRCS += ltp/lib/tst_fs_has_free.c + +CSRCS += ltp/testcases/kernel/fs/fs-bench/boxmuler.c +CSRCS += ltp/testcases/kernel/fs/doio/bytes_by_prefix.c +CSRCS += ltp/testcases/kernel/fs/doio/string_to_tokens.c +CSRCS += ltp/testcases/kernel/device-drivers/base/user_base/tbase_ki.c +CSRCS += ltp/testcases/kernel/syscalls/nftw/tools.c +CSRCS += ltp/testcases/kernel/syscalls/nftw/lib.c +CSRCS += ltp/testcases/kernel/sched/sched_stress/sched.c +CSRCS += ltp/testcases/kernel/io/direct_io/diotest_routines.c +CSRCS += ltp/testcases/kernel/controllers/libcontrollers/libcontrollers.c +CSRCS += ltp/testcases/kernel/mem/lib/mem.c +CSRCS += ltp/testcases/kernel/syscalls/memfd_create/memfd_create_common.c +CSRCS += ltp/lib/tst_safe_sysv_ipc.c +CSRCS += ltp/testcases/kernel/syscalls/ipc/lib/libipc.c + +# the syscall wrapper implementation for NuttX +CSRCS += src/nx_syscall.c +CSRCS += src/dummy.c + +CSRCS += $(LTP_LINUX_CSRCS) + +# since we have enabled the UNIT_TEST, the random_range.c and parse_opts.c +# self unittest will also be build as an executable, we name it as +# random_range_test and parse_opts_test +MAINSRC += ltp/lib/random_range.c +PROGNAME += random_range_test + +MAINSRC += ltp/lib/parse_opts.c +PROGNAME += parse_opts_test + +MAINSRC += ltp/testcases/kernel/fs/doio/open_flags.c +PROGNAME += doio_openflags_test + +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = $(CONFIG_TESTING_LTP_STACKSIZE) +MODULE = $(CONFIG_TESTING_LTP) + +CFLAGS += -I$(CURDIR) +CFLAGS += -I$(TESTLINUX_DIR)/include +CFLAGS += -I$(TESTLINUX_DIR)/../../include +CFLAGS += -I$(TESTLINUX_DIR)/syscalls/ptrace +CFLAGS += -I$(TESTLINUX_DIR)/syscalls/utils +CFLAGS += -I$(TESTLINUX_DIR)/../../include/old +CFLAGS += -I$(TESTLINUX_DIR)/fs/doio/include +CFLAGS += -I$(TESTLINUX_DIR)/controllers/libcontrollers +CFLAGS += -I$(TESTLINUX_DIR)/mem/include +CFLAGS += -I$(TESTLINUX_DIR)/syscalls/ipc/lib +CFLAGS += -I$(TESTLINUX_DIR)/syscalls/ipc/libnewipc + +CFLAGS += -DHAVE_FCHOWNAT +CFLAGS += -DMAXPATHLEN=256 +CFLAGS += -DUNIT_TEST +CFLAGS += -DHAVE_MKDIRAT +CFLAGS += -DHAVE_OPENAT +CFLAGS += -DTEST_CLEANUP +CFLAGS += -DBLKGETSIZE64=BLKGETSIZE +CFLAGS += -D__linux__ +CFLAGS += -DLINUX + +CFLAGS += -DHAVE_ASPRINTF +CFLAGS += -DHAVE_LINUX_FS_H +CFLAGS += -DTST_USE_NEWER64_SYSCALL=0 +CFLAGS += -DINVALID_TEST_CASES=0 +CFLAGS += -DHAVE_STRUCT_RLIMIT64 +CFLAGS += -DHAVE_READLINKAT +CFLAGS += -DHAVE_FSTATAT +ifeq ($(CONFIG_TIMER_FD),y) +CFLAGS += -DHAVE_TIMERFD_CREATE +CFLAGS += -DHAVE_SYS_TIMERFD_H +endif +CFLAGS += -DHAVE_TIMERFD_GETTIME +CFLAGS += -DHAVE_TIMERFD_SETTIME +CFLAGS += -DHAVE_SYNCFS +CFLAGS += -DHAVE_MKNODAT +CFLAGS += -DHAVE_RENAMEAT2 +CFLAGS += -DHAVE_RENAMEAT + +# add the macro definition to handle the naming conflication betweeb ltp +# kernel testcases and the vela external projects +CFLAGS += -Dsafe_touch=ltp_safe_touch +CFLAGS += -Dsafe_socket=ltp_safe_socket +CFLAGS += -Dsafe_bind=ltp_safe_bind +CFLAGS += -Dsafe_listen=ltp_safe_listen +CFLAGS += -Dsafe_connect=ltp_safe_connect +CFLAGS += -Dsafe_getsockname=ltp_safe_getsockname +CFLAGS += -Dsafe_close=ltp_safe_close +CFLAGS += -Dsafe_open=ltp_safe_open +CFLAGS += -Dsafe_write=ltp_safe_write +CFLAGS += -Derror=ltp_error + +# The following warnings are all reported by the LTP kernel test cases themselves. +# To avoid affecting the CI build working procedure, we need to ignore these warnings. +CFLAGS += -Wno-undef -Wno-pointer-sign -Wno-parentheses -Wno-use-after-free +CFLAGS += -Wno-discarded-qualifiers -Wno-implicit-int -Wno-pointer-to-int-cast +CFLAGS += -Wno-switch-bool -Wno-restrict -Wno-stringop-overflow -Wno-array-bounds +CFLAGS += -Wno-shift-count-overflow -Wno-stringop-overread + +##################################################################################### + ltp-$(LTPS_VERSION).zip: $(call DOWNLOAD,$(LTP_DOWNLOAD_URL),$(LTPS_VERSION).zip, ltp.zip) diff --git a/testing/ltp/include/asm/posix_types.h b/testing/ltp/include/asm/posix_types.h new file mode 100644 index 00000000000..f4cb3d2306a --- /dev/null +++ b/testing/ltp/include/asm/posix_types.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/asm/posix_types.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_ASM_POSIX_TYPES_H +#define _LTP_ASM_POSIX_TYPES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_ASM_POSIX_TYPES_H */ diff --git a/testing/ltp/include/asm/types.h b/testing/ltp/include/asm/types.h new file mode 100644 index 00000000000..f7e515df48d --- /dev/null +++ b/testing/ltp/include/asm/types.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/asm/types.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_ASM_TYPES_H +#define _LTP_ASM_TYPES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_ASM_TYPES_H */ diff --git a/testing/ltp/include/features.h b/testing/ltp/include/features.h new file mode 100644 index 00000000000..37e5dc8f3b6 --- /dev/null +++ b/testing/ltp/include/features.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * apps/testing/ltp/include/features.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* when we build target at sim platform, the sim build will reference the + * "/usr/include/features.h" in the host system. The implementation of the + * "/usr/include/features.h" file in the host system uses the "_FEATURES_H" + * macro to prevent duplicate inclusions. + * To avoid inclusion failures, we need to define a different macro to solve + * this problem. + */ + +#ifndef _LTP_FEATURES_H +#define _LTP_FEATURES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#if __has_include_next("features.h") +#include_next +#endif + +#endif /* _LTP_FEATURES_H */ diff --git a/testing/ltp/include/grp.h b/testing/ltp/include/grp.h new file mode 100644 index 00000000000..8bc98a38386 --- /dev/null +++ b/testing/ltp/include/grp.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * apps/testing/ltp/include/grp.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_GRP_H +#define _LTP_GRP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/* the following function declaration to handle + * -Wimplicit-function-declaration build warnings + */ + +int getgroups(int size, gid_t list[]); + +int setgroups(size_t size, const gid_t *list); + +#endif /* _LTP_GRP_H */ diff --git a/testing/ltp/include/lapi/posix_clocks.h b/testing/ltp/include/lapi/posix_clocks.h new file mode 100644 index 00000000000..7a11bf86b0b --- /dev/null +++ b/testing/ltp/include/lapi/posix_clocks.h @@ -0,0 +1,50 @@ +/**************************************************************************** + * apps/testing/ltp/include/lapi/posix_clocks.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LAPI_POSIX_CLOCKS_H__ +#define _LTP_LAPI_POSIX_CLOCKS_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define MAX_CLOCKS 16 + +#define CLOCK_MONOTONIC_RAW 5 + +#define CLOCK_REALTIME_COARSE 6 + +#define CLOCK_MONOTONIC_COARSE 7 + +#define CLOCK_REALTIME_ALARM 8 + +#define CLOCK_BOOTTIME_ALARM 9 + +#define CLOCK_TAI 11 + +#endif /* _LTP_LAPI_POSIX_CLOCKS_H__ */ diff --git a/testing/ltp/include/lapi/syscalls.h b/testing/ltp/include/lapi/syscalls.h new file mode 100644 index 00000000000..bcd1f565da9 --- /dev/null +++ b/testing/ltp/include/lapi/syscalls.h @@ -0,0 +1,563 @@ +/**************************************************************************** + * apps/testing/ltp/include/lapi/syscalls.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/* Here we stick all the ugly *fallback* logic for linux + * system call numbers (those __NR_ thingies). + * + * Licensed under the GPLv2 or later, see the COPYING file. + */ + +#ifndef __LAPI_SYSCALLS_H__ +#define __LAPI_SYSCALLS_H__ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include "cleanup.c" + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/* the standard syscall() function interface in Linux platform */ + +int syscall(int syscall_nr, ...); + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The syscall numbers in the NuttX system are not fixed in advance in + * the code, but are dynamically generated through the code. + * All syscall numbers are defined in enums in the dynamically generated + * code. And if current build not enable the protect build, then syscall + * is also not available, so for flat build, we should convert the syscall + * to direct function call + */ + +#define ltp_syscall(NR, ...) ({ \ + int __ret; \ + if (NR == __LTP__NR_INVALID_SYSCALL) { \ + errno = ENOSYS; \ + __ret = -1; \ + } else { \ + __ret = syscall(NR, ##__VA_ARGS__); \ + } \ + if (__ret == -1 && errno == ENOSYS) { \ + tst_brkm(TCONF, CLEANUP, \ + "syscall(%d) " #NR " not supported on your arch", \ + NR); \ + } \ + __ret; \ +}) + +#define tst_syscall(NR, ...) ({ \ + int tst_ret; \ + if (NR == __LTP__NR_INVALID_SYSCALL) { \ + errno = ENOSYS; \ + tst_ret = -1; \ + } else { \ + tst_ret = syscall(NR, ##__VA_ARGS__); \ + } \ + if (tst_ret == -1 && errno == ENOSYS) { \ + tst_brk(TCONF, "syscall(%d) " #NR " not supported", NR); \ + } \ + tst_ret; \ +}) + +/* Actually, the system call numbers we define are just for identification. + * The bottom layer of vela will not actually use these system call numbers. + * Because in the ltp test case, we also initiate real system calls directly + * through function calls. + * So the system call number here can be defined arbitrarily, as long as it + * is unique + */ + +#define __LTP__NR_INVALID_SYSCALL -1 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +enum nx_syscall_num +{ + __NR_exit = 1, + __NR_fork, + __NR_read, + __NR_write, + __NR_open, + __NR_close, + __NR_creat, + __NR_link, + __NR_unlink, + __NR_execve, + __NR_chdir, + __NR_mknod, + __NR_chmod, + __NR_lchown, + __NR_lseek, + __NR_getpid, + __NR_mount, + __NR_setuid, + __NR_getuid, + __NR_ptrace, + __NR_pause, + __NR_access, + __NR_nice, + __NR_sync, + __NR_kill, + __NR_rename, + __NR_mkdir, + __NR_rmdir, + __NR_dup, + __NR_pipe, + __NR_times, + __NR_brk, + __NR_setgid, + __NR_getgid, + __NR_geteuid, + __NR_getegid, + __NR_acct, + __NR_umount2, + __NR_ioctl, + __NR_fcntl, + __NR_setpgid, + __NR_umask, + __NR_chroot, + __NR_ustat, + __NR_dup2, + __NR_getppid, + __NR_getpgrp, + __NR_setsid, + __NR_sigaction, + __NR_setreuid, + __NR_setregid, + __NR_sigsuspend, + __NR_sigpending, + __NR_sethostname, + __NR_setrlimit, + __NR_getrusage, + __NR_gettimeofday, + __NR_settimeofday, + __NR_getgroups, + __NR_setgroups, + __NR_symlink, + __NR_readlink, + __NR_uselib, + __NR_swapon, + __NR_reboot, + __NR_munmap, + __NR_truncate, + __NR_ftruncate, + __NR_fchmod, + __NR_fchown, + __NR_getpriority, + __NR_setpriority, + __NR_statfs, + __NR_fstatfs, + __NR_syslog, + __NR_setitimer, + __NR_getitimer, + __NR_stat, + __NR_lstat, + __NR_fstat, + __NR_vhangup, + __NR_wait4, + __NR_swapoff, + __NR_sysinfo, + __NR_fsync, + __NR_sigreturn, + __NR_clone, + __NR_setdomainname, + __NR_uname, + __NR_adjtimex, + __NR_mprotect, + __NR_sigprocmask, + __NR_init_module, + __NR_delete_module, + __NR_quotactl, + __NR_getpgid, + __NR_fchdir, + __NR_bdflush, + __NR_sysfs, + __NR_personality, + __NR_setfsuid, + __NR_setfsgid, + __NR__llseek, + __NR_getdents, + __NR__newselect, + __NR_flock, + __NR_msync, + __NR_readv, + __NR_writev, + __NR_getsid, + __NR_fdatasync, + __NR__sysctl, + __NR_mlock, + __NR_munlock, + __NR_mlockall, + __NR_munlockall, + __NR_sched_setparam, + __NR_sched_getparam, + __NR_sched_setscheduler, + __NR_sched_getscheduler, + __NR_sched_yield, + __NR_sched_get_priority_max, + __NR_sched_get_priority_min, + __NR_sched_rr_get_interval, + __NR_nanosleep, + __NR_mremap, + __NR_setresuid, + __NR_getresuid, + __NR_poll, + __NR_nfsservctl, + __NR_setresgid, + __NR_getresgid, + __NR_prctl, + __NR_rt_sigreturn, + __NR_rt_sigaction, + __NR_rt_sigprocmask, + __NR_rt_sigpending, + __NR_rt_sigtimedwait, + __NR_rt_sigqueueinfo, + __NR_rt_sigsuspend, + __NR_pread64, + __NR_pwrite64, + __NR_chown, + __NR_getcwd, + __NR_capget, + __NR_capset, + __NR_sigaltstack, + __NR_sendfile, + __NR_vfork, + __NR_getrlimit, + __NR_ugetrlimit, + __NR_mmap2, + __NR_truncate64, + __NR_ftruncate64, + __NR_stat64, + __NR_lstat64, + __NR_fstat64, + __NR_lchown32, + __NR_getuid32, + __NR_getgid32, + __NR_geteuid32, + __NR_getegid32, + __NR_setreuid32, + __NR_setregid32, + __NR_getgroups32, + __NR_setgroups32, + __NR_fchown32, + __NR_setresuid32, + __NR_getresuid32, + __NR_setresgid32, + __NR_getresgid32, + __NR_chown32, + __NR_setuid32, + __NR_setgid32, + __NR_setfsuid32, + __NR_setfsgid32, + __NR_getdents64, + __NR_pivot_root, + __NR_mincore, + __NR_madvise, + __NR_fcntl64, + __NR_gettid, + __NR_readahead, + __NR_setxattr, + __NR_lsetxattr, + __NR_fsetxattr, + __NR_getxattr, + __NR_lgetxattr, + __NR_fgetxattr, + __NR_listxattr, + __NR_llistxattr, + __NR_flistxattr, + __NR_removexattr, + __NR_lremovexattr, + __NR_fremovexattr, + __NR_tkill, + __NR_sendfile64, + __NR_futex, + __NR_sched_setaffinity, + __NR_sched_getaffinity, + __NR_io_setup, + __NR_io_destroy, + __NR_io_getevents, + __NR_io_submit, + __NR_io_cancel, + __NR_exit_group, + __NR_lookup_dcookie, + __NR_epoll_create, + __NR_epoll_ctl, + __NR_epoll_wait, + __NR_remap_file_pages, + __NR_set_tid_address, + __NR_timer_create, + __NR_timer_settime, + __NR_timer_gettime, + __NR_timer_getoverrun, + __NR_timer_delete, + __NR_clock_settime, + __NR_clock_gettime, + __NR_clock_getres, + __NR_clock_nanosleep, + __NR_statfs64, + __NR_fstatfs64, + __NR_tgkill, + __NR_utimes, + __NR_arm_fadvise64_64, + __NR_pciconfig_iobase, + __NR_pciconfig_read, + __NR_pciconfig_write, + __NR_mq_open, + __NR_mq_unlink, + __NR_mq_timedsend, + __NR_mq_timedreceive, + __NR_mq_notify, + __NR_mq_getsetattr, + __NR_waitid, + __NR_socket, + __NR_bind, + __NR_connect, + __NR_listen, + __NR_accept, + __NR_getsockname, + __NR_getpeername, + __NR_socketpair, + __NR_send, + __NR_sendto, + __NR_recv, + __NR_recvfrom, + __NR_shutdown, + __NR_setsockopt, + __NR_getsockopt, + __NR_sendmsg, + __NR_recvmsg, + __NR_semop, + __NR_semget, + __NR_semctl, + __NR_msgsnd, + __NR_msgrcv, + __NR_msgget, + __NR_msgctl, + __NR_shmat, + __NR_shmdt, + __NR_shmget, + __NR_shmctl, + __NR_add_key, + __NR_request_key, + __NR_keyctl, + __NR_semtimedop, + __NR_vserver, + __NR_ioprio_set, + __NR_ioprio_get, + __NR_inotify_init, + __NR_inotify_add_watch, + __NR_inotify_rm_watch, + __NR_mbind, + __NR_get_mempolicy, + __NR_set_mempolicy, + __NR_openat, + __NR_mkdirat, + __NR_mknodat, + __NR_fchownat, + __NR_futimesat, + __NR_fstatat, + __NR_fstatat64, + __NR_unlinkat, + __NR_renameat, + __NR_linkat, + __NR_symlinkat, + __NR_readlinkat, + __NR_fchmodat, + __NR_faccessat, + __NR_pselect6, + __NR_ppoll, + __NR_unshare, + __NR_set_robust_list, + __NR_get_robust_list, + __NR_splice, + __NR_arm_sync_file_range, + __NR_sync_file_range2, + __NR_tee, + __NR_vmsplice, + __NR_move_pages, + __NR_getcpu, + __NR_epoll_pwait, + __NR_kexec_load, + __NR_utimensat, + __NR_signalfd, + __NR_timerfd_create, + __NR_eventfd, + __NR_fallocate, + __NR_timerfd_settime, + __NR_timerfd_gettime, + __NR_signalfd4, + __NR_eventfd2, + __NR_epoll_create1, + __NR_dup3, + __NR_pipe2, + __NR_inotify_init1, + __NR_preadv, + __NR_pwritev, + __NR_rt_tgsigqueueinfo, + __NR_perf_event_open, + __NR_recvmmsg, + __NR_accept4, + __NR_fanotify_init, + __NR_fanotify_mark, + __NR_prlimit64, + __NR_name_to_handle_at, + __NR_open_by_handle_at, + __NR_clock_adjtime, + __NR_syncfs, + __NR_sendmmsg, + __NR_setns, + __NR_process_vm_readv, + __NR_process_vm_writev, + __NR_kcmp, + __NR_finit_module, + __NR_sched_setattr, + __NR_sched_getattr, + __NR_renameat2, + __NR_seccomp, + __NR_getrandom, + __NR_memfd_create, + __NR_bpf, + __NR_execveat, + __NR_userfaultfd, + __NR_membarrier, + __NR_mlock2, + __NR_copy_file_range, + __NR_preadv2, + __NR_pwritev2, + __NR_pkey_mprotect, + __NR_pkey_alloc, + __NR_pkey_free, + __NR_statx, + __NR_rseq, + __NR_io_pgetevents, + __NR_migrate_pages, + __NR_kexec_file_load, + __NR_clock_gettime64, + __NR_clock_settime64, + __NR_clock_adjtime64, + __NR_clock_getres_time64, + __NR_clock_nanosleep_time64, + __NR_timer_gettime64, + __NR_timer_settime64, + __NR_timerfd_gettime64, + __NR_timerfd_settime64, + __NR_utimensat_time64, + __NR_pselect6_time64, + __NR_ppoll_time64, + __NR_io_pgetevents_time64, + __NR_recvmmsg_time64, + __NR_mq_timedsend_time64, + __NR_mq_timedreceive_time64, + __NR_semtimedop_time64, + __NR_rt_sigtimedwait_time64, + __NR_futex_time64, + __NR_sched_rr_get_interval_time64, + __NR_pidfd_send_signal, + __NR_io_uring_setup, + __NR_io_uring_enter, + __NR_io_uring_register, + __NR_open_tree, + __NR_move_mount, + __NR_fsopen, + __NR_fsconfig, + __NR_fsmount, + __NR_fspick, + __NR_pidfd_open, + __NR_clone3, + __NR_openat2, + __NR_pidfd_getfd, + __NR_readdir, + __NR_select, + __NR_stime, + __NR__assert, + __NR_boardctl, + __NR_clearenv, + __NR_clock, + __NR_exec, + __NR_futimens, + __NR_gethostname, + __NR_lchmod, + __NR_lutimens, + __NR_mmap, + __NR_mq_close, + __NR_mq_getattr, + __NR_mq_receive, + __NR_mq_send, + __NR_mq_setattr, + __NR_posix_spawn, + __NR_pread, + __NR_pselect, + __NR_putenv, + __NR_pwrite, + __NR_sched_backtrace, + __NR_sched_getcpu, + __NR_sched_lock, + __NR_sched_lockcount, + __NR_sched_unlock, + __NR_setegid, + __NR_setenv, + __NR_seteuid, + __NR_signal, + __NR_sigqueue, + __NR_sigtimedwait, + __NR_sigwaitinfo, + __NR_shm_open, + __NR_shm_unlink, + __NR_task_create, + __NR_task_delete, + __NR_task_restart, + __NR_task_spawn, + __NR_time, + __NR_unsetenv, + __NR_up_fork, + __NR_utimens, + __NR_wait, + __NR_waitpid, + __NR_ext_alarm, + __NR_aio_cancel, + __NR_aio_fsync, + __NR_aio_read, + __NR_aio_write, + __NR_arc4random_buf, + __NR_insmod, + __NR_modhandle, + __NR_rmmod +}; + +#define SYS_getpid __NR_getpid +#define SYS_getuid __NR_getuid +#define SYS_getgid __NR_getgid +#define SYS_futex __NR_futex + +#endif /* __LAPI_SYSCALLS_H__ */ diff --git a/testing/ltp/include/libaio.h b/testing/ltp/include/libaio.h new file mode 100644 index 00000000000..d468b53a5b1 --- /dev/null +++ b/testing/ltp/include/libaio.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/libaio.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LIBAIO_H +#define _LTP_LIBAIO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_LIBAIO_H */ diff --git a/testing/ltp/include/linux/errno.h b/testing/ltp/include/linux/errno.h new file mode 100644 index 00000000000..5751e53dad9 --- /dev/null +++ b/testing/ltp/include/linux/errno.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/errno.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_ERRNO_H +#define _LTP_LINUX_ERRNO_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_ERRNO_H */ diff --git a/testing/ltp/include/linux/fs.h b/testing/ltp/include/linux/fs.h new file mode 100644 index 00000000000..440acd5b6fe --- /dev/null +++ b/testing/ltp/include/linux/fs.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/fs.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_FS_H +#define _LTP_LINUX_FS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_FS_H */ diff --git a/testing/ltp/include/linux/futex.h b/testing/ltp/include/linux/futex.h new file mode 100644 index 00000000000..f7f453c5bf5 --- /dev/null +++ b/testing/ltp/include/linux/futex.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/futex.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_FUTEX_H +#define _LTP_LINUX_FUTEX_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifndef FUTEX_WAIT +#define FUTEX_WAIT 1 +#endif + +#ifndef FUTEX_WAKE +#define FUTEX_WAKE 2 +#endif + +#endif /* _LTP_LINUX_FUTEX_H */ diff --git a/testing/ltp/include/linux/if_tun.h b/testing/ltp/include/linux/if_tun.h new file mode 100644 index 00000000000..cf1a2a3678d --- /dev/null +++ b/testing/ltp/include/linux/if_tun.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/if_tun.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_IF_TUN_H +#define _LTP_LINUX_IF_TUN_H + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_LINUX_IF_TUN_H */ diff --git a/testing/ltp/include/linux/input.h b/testing/ltp/include/linux/input.h new file mode 100644 index 00000000000..f1d3bb5854b --- /dev/null +++ b/testing/ltp/include/linux/input.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/input.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_INPUT_H +#define _LTP_LINUX_INPUT_H + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_LINUX_INPUT_H */ diff --git a/testing/ltp/include/linux/kernel.h b/testing/ltp/include/linux/kernel.h new file mode 100644 index 00000000000..15c23ab17ca --- /dev/null +++ b/testing/ltp/include/linux/kernel.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/kernel.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_KERNEL_H +#define _LTP_LINUX_KERNEL_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_KERNEL_H */ diff --git a/testing/ltp/include/linux/limits.h b/testing/ltp/include/linux/limits.h new file mode 100644 index 00000000000..da9ce43299a --- /dev/null +++ b/testing/ltp/include/linux/limits.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/limits.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_LIMITS_H +#define _LTP_LINUX_LIMITS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_LIMITS_H */ diff --git a/testing/ltp/include/linux/loop.h b/testing/ltp/include/linux/loop.h new file mode 100644 index 00000000000..74dcb856dd5 --- /dev/null +++ b/testing/ltp/include/linux/loop.h @@ -0,0 +1,74 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/loop.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_LOOP_H +#define _LTP_LINUX_LOOP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_DEV_LOOP + +#define LOOP_SET_FD 0x4C00 +#define LOOP_CLR_FD 0x4C01 +#define LOOP_SET_STATUS 0x4C02 +#define LOOP_GET_STATUS 0x4C03 +#define LOOP_SET_STATUS64 0x4C04 +#define LOOP_GET_STATUS64 0x4C05 +#define LOOP_CHANGE_FD 0x4C06 + +#define LO_NAME_SIZE 64 +#define LO_KEY_SIZE 32 + +#endif + +/**************************************************************************** + * Type Definitions + ****************************************************************************/ + +#ifdef CONFIG_DEV_LOOP + +struct loop_info +{ + int lo_number; /* ioctl r/o */ + uint16_t lo_device; /* ioctl r/o */ + unsigned long lo_inode; /* ioctl r/o */ + uint16_t lo_rdevice; /* ioctl r/o */ + int lo_offset; + int lo_encrypt_key_size; /* ioctl w/o */ + int lo_flags; + char lo_name[LO_NAME_SIZE]; + unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ + unsigned long lo_init[2]; + char reserved[4]; +}; + +#endif + +#endif /* _LTP_LINUX_LOOP_H */ diff --git a/testing/ltp/include/linux/mman.h b/testing/ltp/include/linux/mman.h new file mode 100644 index 00000000000..c4153adb666 --- /dev/null +++ b/testing/ltp/include/linux/mman.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/mman.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_MMAN_H +#define _LTP_LINUX_MMAN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_MMAN_H */ diff --git a/testing/ltp/include/linux/net.h b/testing/ltp/include/linux/net.h new file mode 100644 index 00000000000..75b415abe68 --- /dev/null +++ b/testing/ltp/include/linux/net.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/net.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_NET_H +#define _LTP_LINUX_NET_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_NET_H */ diff --git a/testing/ltp/include/linux/random.h b/testing/ltp/include/linux/random.h new file mode 100644 index 00000000000..20783e88547 --- /dev/null +++ b/testing/ltp/include/linux/random.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/random.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_RANDOM_H +#define _LTP_LINUX_RANDOM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_RANDOM_H */ diff --git a/testing/ltp/include/linux/rtc.h b/testing/ltp/include/linux/rtc.h new file mode 100644 index 00000000000..40a2fcfd074 --- /dev/null +++ b/testing/ltp/include/linux/rtc.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/rtc.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_RTC_H +#define _LTP_LINUX_RTC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_RTC_H */ diff --git a/testing/ltp/include/linux/types.h b/testing/ltp/include/linux/types.h new file mode 100644 index 00000000000..0a6902ad886 --- /dev/null +++ b/testing/ltp/include/linux/types.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/types.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_TYPES_H +#define _LTP_LINUX_TYPES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_LINUX_TYPES_H */ diff --git a/testing/ltp/include/linux/unistd.h b/testing/ltp/include/linux/unistd.h new file mode 100644 index 00000000000..22ad8180971 --- /dev/null +++ b/testing/ltp/include/linux/unistd.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * apps/testing/ltp/include/linux/unistd.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LINUX_UNISTD_H +#define _LTP_LINUX_UNISTD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _LTP_LINUX_UNISTD_H */ diff --git a/testing/ltp/include/ltp_priv.h b/testing/ltp/include/ltp_priv.h new file mode 100644 index 00000000000..45a2c622d9b --- /dev/null +++ b/testing/ltp/include/ltp_priv.h @@ -0,0 +1,60 @@ +/**************************************************************************** + * apps/testing/ltp/include/ltp_priv.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_LTP_PRIV_H +#define _LTP_LTP_PRIV_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next "ltp_priv.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The LTP kernel test cases are divided into two categories according to: + * the execution method: + * The first category is executed directly using the built-in main function, + * and the second category is executed using the test framework defined in + * tst_test.h. + * According to the design of the LTP kernel test framework, these two types + * of cases cannot be linked together. If they are linked together, when + * the first type of case finishes execution, it will check whether the + * tst_test variable exists. If it does, it will directly report an error, + * prompting "executed from newlib!". + * The implementation of this checking process is the NO_NEWLIB_ASSERT macro + * located in the file "./include/old/ltp_priv.h". + * However, in the implementation of NuttX, both types of cases are + * integrated together. So when we execute the first type of case in NuttX, + * we will find that an error "executed from newlib!" is reported when the + * case finishes execution. + * To avoid this kind of error that has nothing to do with the case itself, + * we choose to directly define the NO_NEWLIB_ASSERT macro as empty to ensure + * the successful execution of the first type of case in NuttX. + */ + +#undef NO_NEWLIB_ASSERT +#define NO_NEWLIB_ASSERT(file, lineno) + +#endif /* _LTP_LTP_PRIV_H */ diff --git a/testing/ltp/include/mntent.h b/testing/ltp/include/mntent.h new file mode 100644 index 00000000000..1dff3d0743b --- /dev/null +++ b/testing/ltp/include/mntent.h @@ -0,0 +1,52 @@ +/**************************************************************************** + * apps/testing/ltp/include/mntent.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_MNTENT_H +#define _LTP_MNTENT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +struct mntent +{ + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +FILE *setmntent(const char *filename, const char *type); +struct mntent *getmntent(FILE *stream); +int endmntent(FILE *streamp); +char *hasmntopt(const struct mntent *mnt, const char *opt); + +#endif /* _LTP_MNTENT_H */ diff --git a/testing/ltp/include/sched.h b/testing/ltp/include/sched.h new file mode 100644 index 00000000000..dea2f0495fb --- /dev/null +++ b/testing/ltp/include/sched.h @@ -0,0 +1,39 @@ +/**************************************************************************** + * apps/testing/ltp/include/sched.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SCHED_H +#define _LTP_SCHED_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/* add unshare and chroot function declaration to handle + * -Wimplicit-function-declaration build warnings + */ + +int unshare(int flags); +int chroot(const char *path); + +#endif /* _LTP_SCHED_H */ diff --git a/testing/ltp/include/sys/endian.h b/testing/ltp/include/sys/endian.h new file mode 100644 index 00000000000..650db598e1a --- /dev/null +++ b/testing/ltp/include/sys/endian.h @@ -0,0 +1,42 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/endian.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_ENDIAN_H +#define _LTP_SYS_ENDIAN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_ENDIAN_BIG +# define __LONG_LONG_PAIR(HI, LO) HI, LO +#else +# define __LONG_LONG_PAIR(HI, LO) LO, HI +#endif + +#endif /* _LTP_SYS_ENDIAN_H */ diff --git a/testing/ltp/include/sys/fsuid.h b/testing/ltp/include/sys/fsuid.h new file mode 100644 index 00000000000..8e7d7c31433 --- /dev/null +++ b/testing/ltp/include/sys/fsuid.h @@ -0,0 +1,35 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/fsuid.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_FSUID_H +#define _LTP_SYS_FSUID_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +int setfsgid(uid_t fsgid); +int setfsuid(uid_t fsuid); + +#endif /* _LTP_SYS_FSUID_H */ diff --git a/testing/ltp/include/sys/mman.h b/testing/ltp/include/sys/mman.h new file mode 100644 index 00000000000..d8cf029bfc3 --- /dev/null +++ b/testing/ltp/include/sys/mman.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/mman.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_MMAN_H +#define _LTP_SYS_MMAN_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +int mincore(void *addr, size_t len, unsigned char *vec); + +#endif /* _LTP_SYS_MMAN_H */ diff --git a/testing/ltp/include/sys/param.h b/testing/ltp/include/sys/param.h new file mode 100644 index 00000000000..d9981a24158 --- /dev/null +++ b/testing/ltp/include/sys/param.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/param.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_PARAM_H +#define _LTP_SYS_PARAM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define DEV_BSIZE 512 + +#endif /* _LTP_SYS_PARAM_H */ diff --git a/testing/ltp/include/sys/personality.h b/testing/ltp/include/sys/personality.h new file mode 100644 index 00000000000..55e3c3ba589 --- /dev/null +++ b/testing/ltp/include/sys/personality.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/personality.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_PERSONALITY_H +#define _LTP_SYS_PERSONALITY_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +int personality(unsigned long persona_val); + +#endif /* _LTP_SYS_PERSONALITY_H */ diff --git a/testing/ltp/include/sys/ptrace.h b/testing/ltp/include/sys/ptrace.h new file mode 100644 index 00000000000..2734b2caca7 --- /dev/null +++ b/testing/ltp/include/sys/ptrace.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/ptrace.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_PTRACE_H +#define _LTP_SYS_PTRACE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +enum __ptrace_request +{ + PTRACE_TRACEME = 0, +}; + +long ptrace(enum __ptrace_request request, pid_t pid, + void *addr, void *data); + +#endif /* _LTP_SYS_PTRACE_H */ diff --git a/testing/ltp/include/sys/quota.h b/testing/ltp/include/sys/quota.h new file mode 100644 index 00000000000..aae67517348 --- /dev/null +++ b/testing/ltp/include/sys/quota.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/quota.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_QUOTA_H +#define _LTP_SYS_QUOTA_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_SYS_QUOTA_H */ diff --git a/testing/ltp/include/sys/sem.h b/testing/ltp/include/sys/sem.h new file mode 100644 index 00000000000..160dbe15bcf --- /dev/null +++ b/testing/ltp/include/sys/sem.h @@ -0,0 +1,38 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/sem.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_SEM_H +#define _LTP_SYS_SEM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/* the following function declaration to handle + * -Wimplicit-function-declaration build warnings + */ + +int semctl(int semid, int semnum, int cmd, ...); + +#endif /* _LTP_SYS_SEM_H */ diff --git a/testing/ltp/include/sys/timex.h b/testing/ltp/include/sys/timex.h new file mode 100644 index 00000000000..9740dd6984d --- /dev/null +++ b/testing/ltp/include/sys/timex.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/timex.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_TIMEX_H +#define _LTP_SYS_TIMEX_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* here we use struct timeval to implement the same func of struct timex. */ + +typedef struct timex timeval; + +#endif /* _LTP_SYS_TIMEX_H */ diff --git a/testing/ltp/include/sys/ttydefaults.h b/testing/ltp/include/sys/ttydefaults.h new file mode 100644 index 00000000000..e4fd6f1f60c --- /dev/null +++ b/testing/ltp/include/sys/ttydefaults.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/ttydefaults.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_TTYDEFAULTS_H +#define _LTP_SYS_TTYDEFAULTS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_SYS_TTYDEFAULTS_H */ diff --git a/testing/ltp/include/sys/user.h b/testing/ltp/include/sys/user.h new file mode 100644 index 00000000000..8d49c67064c --- /dev/null +++ b/testing/ltp/include/sys/user.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/user.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_USER_H +#define _LTP_SYS_USER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_SYS_USER_H */ diff --git a/testing/ltp/include/sys/xattr.h b/testing/ltp/include/sys/xattr.h new file mode 100644 index 00000000000..a5b901a7b4e --- /dev/null +++ b/testing/ltp/include/sys/xattr.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * apps/testing/ltp/include/sys/xattr.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_SYS_XATTR_H +#define _LTP_SYS_XATTR_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +ssize_t getxattr(const char *path, const char *name, + void *value, size_t size); +int setxattr(const char *path, const char *name, + const void *value, size_t size, int flags); +int lsetxattr(const char *path, const char *name, + const void *value, size_t size, int flags); +int fsetxattr(int fd, const char *name, + const void *value, size_t size, int flags); + +int removexattr(const char *path, const char *name); +int lremovexattr(const char *path, const char *name); +int fremovexattr(int fd, const char *name); + +#endif /* _LTP_SYS_XATTR_H */ diff --git a/testing/ltp/include/ulimit.h b/testing/ltp/include/ulimit.h new file mode 100644 index 00000000000..8318463cedd --- /dev/null +++ b/testing/ltp/include/ulimit.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/ulimit.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_ULIMIT_H +#define _LTP_ULIMIT_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_ULIMIT_H */ diff --git a/testing/ltp/include/unistd.h b/testing/ltp/include/unistd.h new file mode 100644 index 00000000000..ba13a201b16 --- /dev/null +++ b/testing/ltp/include/unistd.h @@ -0,0 +1,41 @@ +/**************************************************************************** + * apps/testing/ltp/include/unistd.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_UNISTD_H +#define _LTP_UNISTD_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include_next + +/* the following function declaration to handle + * -Wimplicit-function-declaration build warnings + */ + +int setpgid(pid_t pid, pid_t pgid); +pid_t setsid(void); +int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); +int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); + +#endif /* _LTP_UNISTD_H */ diff --git a/testing/ltp/include/values.h b/testing/ltp/include/values.h new file mode 100644 index 00000000000..da68dc27079 --- /dev/null +++ b/testing/ltp/include/values.h @@ -0,0 +1,34 @@ +/**************************************************************************** + * apps/testing/ltp/include/values.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef _LTP_VALUES_H +#define _LTP_VALUES_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +/* This is just a placeholder to simplify cross-compiling the LTP Linux + * Kernel cases + */ + +#endif /* _LTP_VALUES_H */ diff --git a/testing/ltp/src/dummy.c b/testing/ltp/src/dummy.c new file mode 100644 index 00000000000..9bb98d26029 --- /dev/null +++ b/testing/ltp/src/dummy.c @@ -0,0 +1,142 @@ +/**************************************************************************** + * apps/testing/ltp/src/dummy.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* the following implementation build when CONFIG_SYSTEM_POPEN option + * is disabled + */ + +#ifndef CONFIG_SYSTEM_POPEN + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +FILE *popen(const char *command, const char *mode) +{ + return NULL; +} + +int pclose(FILE *stream) +{ + return OK; +} +#endif + +/* the following empty implementation using to compile the LTP Kernel case + * on nuttx + */ + +int chroot(const char *path) +{ + return -1; +} + +int setpgid(pid_t pid, pid_t pgid) +{ + return -1; +} + +FILE *setmntent(const char *filep, const char *type) +{ + return NULL; +} + +struct mntent *getmntent(FILE *filep) +{ + return NULL; +} + +struct mntent *getmntent_r(FILE *, struct mntent *, char *, int) +{ + return NULL; +} + +int endmntent(FILE *filep) +{ + return -1; +} + +char *hasmntopt(const struct mntent *mnt, const char *opt) +{ + return NULL; +} + +/* the following are dummy implementation using to compile fsgid related + * cased on nuttx + */ + +int setfsgid(uid_t fsgid) +{ + return -1; +} + +int setfsuid(uid_t fsuid) +{ + return -1; +} + +/* the following syscalls are needed by: + * lib/tst_safe_macros.c + * lib/safe_macros.c + * lib/parse_opts.c + */ + +int mincore(void *addr, size_t length, unsigned char *vec) +{ + return -1; +} + +pid_t setsid(void) +{ + return -1; +} + +int brk(void *addr) +{ + return -1; +} + +int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) +{ + return -1; +} + +int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) +{ + return -1; +} diff --git a/testing/ltp/src/nx_syscall.c b/testing/ltp/src/nx_syscall.c new file mode 100644 index 00000000000..7548d6243f4 --- /dev/null +++ b/testing/ltp/src/nx_syscall.c @@ -0,0 +1,1764 @@ +/**************************************************************************** + * apps/testing/ltp/src/nx_syscall.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "lapi/syscalls.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int syscall(int syscall_nr, ...) +{ + int ret = 0; + + /* extract out the detailed params list from __va_args list, + * and then convert to the detailed function calling + */ + + va_list ap; + va_start(ap, syscall_nr); + switch (syscall_nr) + { + case __NR__assert: + { + const char *filename = va_arg(ap, const char *); + int linenum = va_arg(ap, int); + const char *msg = va_arg(ap, const char *); + void *reg = va_arg(ap, void *); + int irq = va_arg(ap, int); + _assert(filename, linenum, msg, reg, irq); + break; + } + + case __NR_exit: + { + int status = va_arg(ap, int); + _exit(status); + break; + } + + case __NR_accept4: + { + int sockfd = va_arg(ap, int); + struct sockaddr *addr = va_arg(ap, struct sockaddr *); + socklen_t *addrlen = va_arg(ap, socklen_t *); + int flags = va_arg(ap, int); + ret = accept4(sockfd, addr, addrlen, flags); + break; + } + +#if defined(CONFIG_CLOCK_TIMEKEEPING) || defined(CONFIG_CLOCK_ADJTIME) + case __NR_adjtimex: + { + const struct timeval *delta = va_arg(ap, const struct timeval *); + const struct timeval *olddelta = va_arg(ap, const struct timeval *); + ret = adjtime(delta, olddelta); + break; + } +#endif + +#ifdef CONFIG_FS_AIO + case __NR_aio_cancel: + { + int fildes = va_arg(ap, int); + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_cancel(fildes, aiocbp); + break; + } +#endif + +#ifdef CONFIG_FS_AIO + case __NR_aio_fsync: + { + int op = va_arg(ap, int); + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_fsync(op, aiocbp); + break; + } +#endif + +#ifdef CONFIG_FS_AIO + case __NR_aio_read: + { + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_read(aiocbp); + break; + } +#endif + +#ifdef CONFIG_FS_AIO + case __NR_aio_write: + { + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_write(aiocbp); + break; + } +#endif + +#ifdef CONFIG_CRYPTO_RANDOM_POOL + case __NR_arc4random_buf: + { + void *buf = va_arg(ap, void *); + size_t nbytes = va_arg(ap, size_t); + arc4random_buf(buf, nbytes); + break; + } +#endif + +#ifdef CONFIG_NET + case __NR_bind: + { + int sockfd = va_arg(ap, int); + const struct sockaddr *addr = va_arg(ap, const struct sockaddr *); + socklen_t addrlen = va_arg(ap, socklen_t); + ret = bind(sockfd, addr, addrlen); + break; + } +#endif + +#ifdef CONFIG_BOARDCTL + case __NR_boardctl: + { + unsigned int cmd = va_arg(ap, unsigned int); + uintptr_t arg = va_arg(ap, uintptr_t); + ret = boardctl(cmd, arg); + break; + } +#endif + + case __NR_chmod: + { + const char *path = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = chmod(path, mode); + break; + } + + case __NR_chown: + { + const char *path = va_arg(ap, const char *); + uid_t owner = va_arg(ap, uid_t); + gid_t group = va_arg(ap, gid_t); + ret = chown(path, owner, group); + break; + } + +#ifndef CONFIG_DISABLE_ENVIRON + case __NR_clearenv: + { + ret = clearenv(); + break; + } +#endif + + case __NR_clock: + { + ret = clock(); + break; + } + + case __NR_clock_gettime: + { + int clockid = va_arg(ap, int); + struct timespec *ts = va_arg(ap, struct timespec *); + ret = clock_gettime(clockid, ts); + break; + } + + case __NR_clock_nanosleep: + { + clockid_t clockid = va_arg(ap, clockid_t); + int flags = va_arg(ap, int); + const struct timespec *req = va_arg(ap, const struct timespec *); + struct timespec *rem = va_arg(ap, struct timespec *); + ret = clock_nanosleep(clockid, flags, req, rem); + break; + } + + case __NR_clock_settime: + { + clockid_t clockid = va_arg(ap, clockid_t); + struct timespec *ts = va_arg(ap, struct timespec *); + ret = clock_settime(clockid, ts); + break; + } + + case __NR_close: + { + int fd = va_arg(ap, int); + ret = close(fd); + break; + } + +#ifdef CONFIG_NET + case __NR_connect: + { + int sockfd = va_arg(ap, int); + const struct sockaddr *addr = va_arg(ap, const struct sockaddr *); + socklen_t addrlen = va_arg(ap, socklen_t); + ret = connect(sockfd, addr, addrlen); + break; + } +#endif + + case __NR_dup: + { + int fd = va_arg(ap, int); + ret = dup(fd); + break; + } + + case __NR_dup2: + { + int fd1 = va_arg(ap, int); + int fd2 = va_arg(ap, int); + ret = dup2(fd1, fd2); + break; + } + + case __NR_epoll_create1: + { + int flags = va_arg(ap, int); + ret = epoll_create1(flags); + break; + } + + case __NR_epoll_ctl: + { + int epfd = va_arg(ap, int); + int op = va_arg(ap, int); + int fd = va_arg(ap, int); + struct epoll_event *event = va_arg(ap, struct epoll_event *); + ret = epoll_ctl(epfd, op, fd, event); + break; + } + + case __NR_epoll_wait: + { + int epfd = va_arg(ap, int); + struct epoll_event *events = va_arg(ap, struct epoll_event *); + int maxevents = va_arg(ap, int); + int timeout = va_arg(ap, int); + ret = epoll_wait(epfd, events, maxevents, timeout); + break; + } + +#if defined(CONFIG_EVENT_FD) + case __NR_eventfd: + { + unsigned int count = va_arg(ap, unsigned int); + int flags = va_arg(ap, int); + ret = eventfd(count, flags); + break; + } +#endif + +#if !defined(CONFIG_BINFMT_DISABLE) && !defined(CONFIG_BUILD_KERNEL) + case __NR_exec: + { + const char *filename = va_arg(ap, const char *); + char *const *argv = va_arg(ap, char *const *); + char *const *envp = va_arg(ap, char *const *); + const struct symtab_s *exports = va_arg(ap, const struct symtab_s *); + int nexports = va_arg(ap, int); + ret = exec(filename, argv, envp, exports, nexports); + break; + } +#endif + +#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS) + case __NR_execve: + { + const char *path = va_arg(ap, const char *); + char *const *argv = va_arg(ap, char *const *); + char *const *envp = va_arg(ap, char *const *); + ret = execve(path, argv, envp); + break; + } +#endif + + case __NR_fchmod: + { + int fd = va_arg(ap, int); + mode_t mode = va_arg(ap, mode_t); + ret = fchmod(fd, mode); + break; + } + + case __NR_fchown: + { + int fd = va_arg(ap, int); + uid_t owner = va_arg(ap, uid_t); + gid_t group = va_arg(ap, gid_t); + ret = fchown(fd, owner, group); + break; + } + + case __NR_fdatasync: + { + int fd = va_arg(ap, int); + ret = fdatasync(fd); + break; + } + + case __NR_fstatat: + case __NR_fstatat64: + { + int dirfd = va_arg(ap, int); + const char *pathname = va_arg(ap, const char *); + struct stat *buf = va_arg(ap, struct stat *); + int flags = va_arg(ap, int); + ret = fstatat(dirfd, pathname, buf, flags); + break; + } + + case __NR_fcntl: + { + int fd = va_arg(ap, int); + int cmd = va_arg(ap, int); + long arg = va_arg(ap, long); + ret = fcntl(fd, cmd, arg); + break; + } + + case __NR_fstat: + { + int fd = va_arg(ap, int); + struct stat *buf = va_arg(ap, struct stat *); + ret = fstat(fd, buf); + break; + } + + case __NR_fstatfs: + { + int fd = va_arg(ap, int); + struct statfs *buf = va_arg(ap, struct statfs *); + ret = fstatfs(fd, buf); + break; + } + + case __NR_fsync: + { + int fd = va_arg(ap, int); + ret = fsync(fd); + break; + } + + case __NR_ftruncate: + { + int fd = va_arg(ap, int); + off_t length = va_arg(ap, off_t); + ret = ftruncate(fd, length); + break; + } + + case __NR_futimens: + { + int fd = va_arg(ap, int); + const struct timespec *times = va_arg(ap, const struct timespec *); + ret = futimens(fd, times); + break; + } + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_getegid: + { + ret = getegid(); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_geteuid: + { + ret = geteuid(); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_getgid: + { + ret = getgid(); + break; + } +#endif + + case __NR_gethostname: + { + char *name = va_arg(ap, char *); + size_t name_len = va_arg(ap, size_t); + ret = gethostname(name, name_len); + break; + } + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_getitimer: + { + int which = va_arg(ap, int); + struct itimerval *value = va_arg(ap, struct itimerval *); + ret = getitimer(which, value); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_getpeername: + { + int sockfd = va_arg(ap, int); + struct sockaddr *addr = va_arg(ap, struct sockaddr *); + socklen_t *addrlen = va_arg(ap, socklen_t *); + ret = getpeername(sockfd, addr, addrlen); + break; + } +#endif + + case __NR_getpid: + { + ret = getpid(); + break; + } + +#if defined(CONFIG_SCHED_HAVE_PARENT) + case __NR_getppid: + { + ret = getppid(); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_getsockname: + { + int sockfd = va_arg(ap, int); + struct sockaddr *addr = va_arg(ap, struct sockaddr *); + socklen_t *addrlen = va_arg(ap, socklen_t *); + ret = getsockname(sockfd, addr, addrlen); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_getsockopt: + { + int sockfd = va_arg(ap, int); + int level = va_arg(ap, int); + int option = va_arg(ap, int); + void *value = va_arg(ap, void *); + socklen_t *value_len = va_arg(ap, socklen_t *); + ret = getsockopt(sockfd, level, option, value, value_len); + break; + } +#endif + + case __NR_gettid: + { + ret = gettid(); + break; + } + + case __NR_gettimeofday: + { + struct timeval *tv = va_arg(ap, struct timeval *); + struct timezone *tz = va_arg(ap, struct timezone *); + ret = gettimeofday(tv, tz); + break; + } + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_getuid: + { + ret = getuid(); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case __NR_inotify_add_watch: + { + int fd = va_arg(ap, int); + const char *pathname = va_arg(ap, const char *); + uint32_t mask = va_arg(ap, uint32_t); + ret = inotify_add_watch(fd, pathname, mask); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case __NR_inotify_init: + { + ret = inotify_init(); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case __NR_inotify_init1: + { + int flags = va_arg(ap, int); + ret = inotify_init1(flags); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case __NR_inotify_rm_watch: + { + int fd = va_arg(ap, int); + int wd = va_arg(ap, int); + ret = inotify_rm_watch(fd, wd); + break; + } +#endif + +#if defined(CONFIG_MODULE) + case __NR_insmod: + { + const char *file_name = va_arg(ap, const char *); + const char *mod_name = va_arg(ap, const char *); + insmod(file_name, mod_name); + break; + } +#endif + + case __NR_ioctl: + { + int fd = va_arg(ap, int); + int req = va_arg(ap, int); + long arg = va_arg(ap, long); + ret = ioctl(fd, req, arg); + break; + } + + case __NR_kill: + { + pid_t pid = va_arg(ap, pid_t); + int sig = va_arg(ap, int); + ret = kill(pid, sig); + break; + } + + case __NR_lchmod: + { + const char *pathname = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = lchmod(pathname, mode); + break; + } + + case __NR_lchown: + { + const char *path = va_arg(ap, const char *); + uid_t owner = va_arg(ap, uid_t); + gid_t group = va_arg(ap, gid_t); + ret = lchown(path, owner, group); + break; + } + +#if defined(CONFIG_PSEUDOFS_SOFTLINKS) + case __NR_link: + { + const char *old_path = va_arg(ap, const char *); + const char *new_path = va_arg(ap, const char *); + ret = link(old_path, new_path); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_listen: + { + int sockfd = va_arg(ap, int); + int backlog = va_arg(ap, int); + ret = listen(sockfd, backlog); + break; + } +#endif + + case __NR_lseek: + { + int fd = va_arg(ap, int); + off_t offset = va_arg(ap, off_t); + int whence = va_arg(ap, int); + ret = lseek(fd, offset, whence); + break; + } + + case __NR_lstat: + { + const char *path = va_arg(ap, const char *); + struct stat *buf = va_arg(ap, struct stat *); + ret = lstat(path, buf); + break; + } + + case __NR_lutimens: + { + const char *path = va_arg(ap, const char *); + const struct timespec *times = va_arg(ap, const struct timespec *); + ret = lutimens(path, times); + break; + } + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case __NR_mkdir: + { + const char *pathname = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = mkdir(pathname, mode); + break; + } +#endif + + case __NR_mmap: + { + void *addr = va_arg(ap, void *); + size_t length = va_arg(ap, size_t); + int prot = va_arg(ap, int); + int flags = va_arg(ap, int); + int fd = va_arg(ap, int); + off_t offset = va_arg(ap, off_t); + mmap(addr, length, prot, flags, fd, offset); + break; + } + +#if defined(CONFIG_MODULE) + case __NR_modhandle: + { + const char *name = va_arg(ap, const char *); + modhandle(name); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case __NR_mount: + { + const char *source = va_arg(ap, const char *); + const char *target = va_arg(ap, const char *); + const char *filesystemtype = va_arg(ap, const char *); + unsigned long mountflags = va_arg(ap, unsigned long); + const void *data = va_arg(ap, const void *); + ret = mount(source, target, filesystemtype, mountflags, data); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_close: + { + mqd_t mqdes = va_arg(ap, mqd_t); + ret = mq_close(mqdes); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_getattr: + { + mqd_t mqdes = va_arg(ap, mqd_t); + struct mq_attr *attr = va_arg(ap, struct mq_attr *); + ret = mq_getattr(mqdes, attr); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_notify: + { + mqd_t mqdes = va_arg(ap, mqd_t); + const struct sigevent *notification = + va_arg(ap, const struct sigevent *); + ret = mq_notify(mqdes, notification); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_open: + { + const char *name = va_arg(ap, const char *); + int oflag = va_arg(ap, int); + mode_t mode = va_arg(ap, mode_t); + struct mq_attr *attr = va_arg(ap, struct mq_attr *); + ret = mq_open(name, oflag, mode, attr); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_receive: + { + mqd_t mqdes = va_arg(ap, mqd_t); + char *msg = va_arg(ap, char *); + size_t msg_len = va_arg(ap, size_t); + unsigned int *prio = va_arg(ap, unsigned int *); + ret = mq_receive(mqdes, msg, msg_len, prio); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_send: + { + mqd_t mqdes = va_arg(ap, mqd_t); + const char *msg = va_arg(ap, const char *); + size_t msg_len = va_arg(ap, size_t); + unsigned int prio = va_arg(ap, unsigned int); + ret = mq_send(mqdes, msg, msg_len, prio); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_setattr: + { + mqd_t mqdes = va_arg(ap, mqd_t); + const struct mq_attr *newattr = va_arg(ap, const struct mq_attr *); + struct mq_attr *oldattr = va_arg(ap, struct mq_attr *); + ret = mq_setattr(mqdes, newattr, oldattr); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_timedreceive: + { + mqd_t mqdes = va_arg(ap, mqd_t); + char *msg = va_arg(ap, char *); + size_t msg_len = va_arg(ap, size_t); + unsigned int *prio = va_arg(ap, unsigned int *); + const struct timespec *abstime = va_arg(ap, const struct timespec *); + ret = mq_timedreceive(mqdes, msg, msg_len, prio, abstime); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_timedsend: + { + mqd_t mqdes = va_arg(ap, mqd_t); + const char *msg = va_arg(ap, const char *); + size_t msg_len = va_arg(ap, size_t); + unsigned int prio = va_arg(ap, unsigned int); + struct timespec *abstime = va_arg(ap, struct timespec *); + ret = mq_timedsend(mqdes, msg, msg_len, prio, abstime); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case __NR_mq_unlink: + { + const char *name = va_arg(ap, const char *); + ret = mq_unlink(name); + break; + } +#endif + + case __NR_msync: + { + void *addr = va_arg(ap, void *); + size_t length = va_arg(ap, size_t); + int flags = va_arg(ap, int); + ret = msync(addr, length, flags); + break; + } + + case __NR_munmap: + { + void *addr = va_arg(ap, void *); + size_t length = va_arg(ap, size_t); + ret = munmap(addr, length); + break; + } + + case __NR_nanosleep: + { + const struct timespec *req = va_arg(ap, const struct timespec *); + struct timespec *rem = va_arg(ap, struct timespec *); + ret = nanosleep(req, rem); + break; + } + + case __NR_open: + { + const char *path = va_arg(ap, const char *); + int oflags = va_arg(ap, int); + mode_t mode = va_arg(ap, mode_t); + ret = open(path, oflags, mode); + break; + } + +#if defined(CONFIG_BUILD_KERNEL) + case __NR_pgalloc: + { + uintptr_t brkaddr = va_arg(ap, uintptr_t); + unsigned int npages = va_arg(ap, unsigned int); + pgalloc(brkaddr, npages); + break; + } +#endif + +#if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 + case __NR_pipe2: + { + int *pipefd = va_arg(ap, int *); + int flags = va_arg(ap, int); + ret = pipe2(pipefd, flags); + break; + } +#endif + + case __NR_poll: + { + struct pollfd *fds = va_arg(ap, struct pollfd *); + nfds_t nfds = va_arg(ap, nfds_t); + int timeout = va_arg(ap, int); + ret = poll(fds, nfds, timeout); + break; + } + +#if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS) + case __NR_posix_spawn: + { + pid_t *pid = va_arg(ap, pid_t *); + const char *path = va_arg(ap, const char *); + const posix_spawn_file_actions_t *file_actions = + va_arg(ap, const posix_spawn_file_actions_t *); + const posix_spawnattr_t *attrp = va_arg(ap, const posix_spawnattr_t *); + const char *const *argv = va_arg(ap, const char *const *); + const char *const *envp = va_arg(ap, const char *const *); + ret = posix_spawn(pid, path, file_actions, attrp, argv, envp); + break; + } +#endif + + case __NR_ppoll: + { + struct pollfd *fds = va_arg(ap, struct pollfd *); + nfds_t nfds = va_arg(ap, nfds_t); + const struct timespec *timeout_ts = + va_arg(ap, const struct timespec *); + const sigset_t *sigmask = va_arg(ap, const sigset_t *); + ret = ppoll(fds, nfds, timeout_ts, sigmask); + break; + } + + case __NR_prctl: + { + int option = va_arg(ap, int); + unsigned long arg2 = va_arg(ap, unsigned long); + unsigned long arg3 = va_arg(ap, unsigned long); + ret = prctl(option, arg2, arg3); + break; + } + + case __NR_pread: + { + int fd = va_arg(ap, int); + void *buf = va_arg(ap, void *); + size_t count = va_arg(ap, size_t); + off_t offset = va_arg(ap, off_t); + ret = pread(fd, buf, count, offset); + break; + } + + case __NR_pselect: + { + int nfds = va_arg(ap, int); + fd_set *readfds = va_arg(ap, fd_set *); + fd_set *writefds = va_arg(ap, fd_set *); + fd_set *exceptfds = va_arg(ap, fd_set *); + const struct timespec *timeout = va_arg(ap, const struct timespec *); + const sigset_t *sigmask = va_arg(ap, const sigset_t *); + ret = pselect(nfds, readfds, writefds, exceptfds, timeout, sigmask); + break; + } + +#if !defined(CONFIG_DISABLE_ENVIRON) + case __NR_putenv: + { + const char *string = va_arg(ap, const char *); + ret = putenv(string); + break; + } +#endif + + case __NR_pwrite: + { + int fd = va_arg(ap, int); + const void *buf = va_arg(ap, const void *); + size_t nbytes = va_arg(ap, size_t); + off_t offset = va_arg(ap, off_t); + ret = pwrite(fd, buf, nbytes, offset); + break; + } + + case __NR_read: + { + int fd = va_arg(ap, int); + void *buf = va_arg(ap, void *); + size_t count = va_arg(ap, size_t); + ret = read(fd, buf, count); + break; + } + +#if defined(CONFIG_PSEUDOFS_SOFTLINKS) + case __NR_readlink: + { + const char *path = va_arg(ap, const char *); + char *buf = va_arg(ap, char *); + size_t bufsiz = va_arg(ap, size_t); + ret = readlink(path, buf, bufsiz); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_recv: + { + int sockfd = va_arg(ap, int); + void *buf = va_arg(ap, void *); + size_t len = va_arg(ap, size_t); + int flags = va_arg(ap, int); + ret = recv(sockfd, buf, len, flags); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_recvfrom: + { + int sockfd = va_arg(ap, int); + void *buf = va_arg(ap, void *); + size_t len = va_arg(ap, size_t); + int flags = va_arg(ap, int); + struct sockaddr *src_addr = va_arg(ap, struct sockaddr *); + socklen_t *addrlen = va_arg(ap, socklen_t *); + ret = recvfrom(sockfd, buf, len, flags, src_addr, addrlen); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_recvmsg: + { + int sockfd = va_arg(ap, int); + struct msghdr *msg = va_arg(ap, struct msghdr *); + int flags = va_arg(ap, int); + ret = recvmsg(sockfd, msg, flags); + break; + } +#endif + + case __NR_rename: + { + const char *old_path = va_arg(ap, const char *); + const char *new_path = va_arg(ap, const char *); + ret = rename(old_path, new_path); + break; + } + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case __NR_rmdir: + { + const char *pathname = va_arg(ap, const char *); + ret = rmdir(pathname); + break; + } +#endif + +#if defined(CONFIG_MODULE) + case __NR_rmmod: + { + void *handle = va_arg(ap, void *); + ret = rmmod(handle); + break; + } +#endif + +#if defined(CONFIG_SCHED_BACKTRACE) + case __NR_sched_backtrace: + { + pid_t pid = va_arg(ap, int); + void **buffer = va_arg(ap, void **); + int size = va_arg(ap, int); + int skip = va_arg(ap, int); + ret = sched_backtrace(pid, buffer, size, skip); + break; + } +#endif + + case __NR_sched_getaffinity: + { + pid_t pid = va_arg(ap, pid_t); + size_t cpusetsize = va_arg(ap, size_t); + cpu_set_t *mask = va_arg(ap, cpu_set_t *); + ret = sched_getaffinity(pid, cpusetsize, mask); + break; + } + + case __NR_sched_getcpu: + { + ret = sched_getcpu(); + break; + } + + case __NR_sched_getparam: + { + pid_t pid = va_arg(ap, pid_t); + struct sched_param *param = va_arg(ap, struct sched_param *); + ret = sched_getparam(pid, param); + break; + } + + case __NR_sched_getscheduler: + { + pid_t pid = va_arg(ap, pid_t); + ret = sched_getscheduler(pid); + break; + } + + case __NR_sched_lock: + { + sched_lock(); + break; + } + + case __NR_sched_lockcount: + { + ret = sched_lockcount(); + break; + } + + case __NR_sched_rr_get_interval: + { + pid_t pid = va_arg(ap, pid_t); + struct timespec *interval = va_arg(ap, struct timespec *); + ret = sched_rr_get_interval(pid, interval); + break; + } + + case __NR_sched_setaffinity: + { + pid_t pid = va_arg(ap, pid_t); + size_t cpusetsize = va_arg(ap, size_t); + cpu_set_t *mask = va_arg(ap, cpu_set_t *); + ret = sched_setaffinity(pid, cpusetsize, mask); + break; + } + + case __NR_sched_setparam: + { + pid_t pid = va_arg(ap, pid_t); + struct sched_param *param = va_arg(ap, struct sched_param *); + ret = sched_setparam(pid, param); + break; + } + + case __NR_sched_setscheduler: + { + pid_t pid = va_arg(ap, pid_t); + int policy = va_arg(ap, int); + struct sched_param *param = va_arg(ap, struct sched_param *); + ret = sched_setscheduler(pid, policy, param); + break; + } + + case __NR_sched_unlock: + { + sched_unlock(); + break; + } + + case __NR_sched_yield: + { + ret = sched_yield(); + break; + } + + case __NR_select: + { + int nfds = va_arg(ap, int); + fd_set *readfds = va_arg(ap, fd_set *); + fd_set *writefds = va_arg(ap, fd_set *); + fd_set *exceptfds = va_arg(ap, fd_set *); + struct timeval *timeout = va_arg(ap, struct timeval *); + ret = select(nfds, readfds, writefds, exceptfds, timeout); + break; + } + +#if defined(CONFIG_NET) + case __NR_send: + { + int sockfd = va_arg(ap, int); + const void *buf = va_arg(ap, const void *); + size_t len = va_arg(ap, size_t); + int flags = va_arg(ap, int); + ret = send(sockfd, buf, len, flags); + break; + } +#endif + + case __NR_sendfile: + { + int out_fd = va_arg(ap, int); + int in_fd = va_arg(ap, int); + off_t *offset = va_arg(ap, off_t *); + size_t count = va_arg(ap, size_t); + ret = sendfile(out_fd, in_fd, offset, count); + break; + } + +#if defined(CONFIG_NET) + case __NR_sendmsg: + { + int sockfd = va_arg(ap, int); + const struct msghdr *msg = va_arg(ap, const struct msghdr *); + int flags = va_arg(ap, int); + ret = sendmsg(sockfd, msg, flags); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_sendto: + { + int sockfd = va_arg(ap, int); + const void *buf = va_arg(ap, const void *); + size_t len = va_arg(ap, size_t); + int flags = va_arg(ap, int); + const struct sockaddr *dest_addr = va_arg(ap, const struct sockaddr *); + socklen_t addrlen = va_arg(ap, socklen_t); + ret = sendto(sockfd, buf, len, flags, dest_addr, addrlen); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_setegid: + { + gid_t egid = va_arg(ap, gid_t); + ret = setegid(egid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_ENVIRON) + case __NR_setenv: + { + const char *name = va_arg(ap, const char *); + const char *value = va_arg(ap, const char *); + int overwrite = va_arg(ap, int); + ret = setenv(name, value, overwrite); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_seteuid: + { + uid_t euid = va_arg(ap, uid_t); + ret = seteuid(euid); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_setgid: + { + gid_t gid = va_arg(ap, gid_t); + ret = setgid(gid); + break; + } +#endif + + case __NR_sethostname: + { + const char *name = va_arg(ap, const char *); + size_t len = va_arg(ap, size_t); + ret = sethostname(name, len); + break; + } + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_setitimer: + { + int which = va_arg(ap, int); + const struct itimerval *value = va_arg(ap, const struct itimerval *); + struct itimerval *oldvalue = va_arg(ap, struct itimerval *); + ret = setitimer(which, value, oldvalue); + break; + } +#endif + +#if defined(CONFIG_NET) && defined(CONFIG_NET_SOCKOPTS) + case __NR_setsockopt: + { + int sockfd = va_arg(ap, int); + int level = va_arg(ap, int); + int option = va_arg(ap, int); + const void *value = va_arg(ap, const void *); + socklen_t value_len = va_arg(ap, socklen_t); + ret = setsockopt(sockfd, level, option, value, value_len); + break; + } +#endif + + case __NR_settimeofday: + { + const struct timeval *tv = va_arg(ap, const struct timeval *); + const struct timezone *tz = va_arg(ap, const struct timezone *); + ret = settimeofday(tv, tz); + break; + } + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case __NR_setuid: + { + uid_t euid = va_arg(ap, uid_t); + ret = seteuid(euid); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case __NR_shmctl: + { + int shmid = va_arg(ap, int); + int cmd = va_arg(ap, int); + struct shmid_ds *buf = va_arg(ap, struct shmid_ds *); + ret = shmctl(shmid, cmd, buf); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case __NR_shmdt: + { + const void *shmaddr = va_arg(ap, const void *); + ret = shmdt(shmaddr); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case __NR_shmget: + { + key_t key = va_arg(ap, key_t); + size_t size = va_arg(ap, size_t); + int shmflg = va_arg(ap, int); + ret = shmget(key, size, shmflg); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_shutdown: + { + int sockfd = va_arg(ap, int); + int how = va_arg(ap, int); + ret = shutdown(sockfd, how); + break; + } +#endif + + case __NR_sigaction: + { + int signo = va_arg(ap, int); + const struct sigaction *act = va_arg(ap, const struct sigaction *); + struct sigaction *old_act = va_arg(ap, struct sigaction *); + ret = sigaction(signo, act, old_act); + break; + } + + case __NR_signal: + { + int signo = va_arg(ap, int); + _sa_handler_t func = va_arg(ap, _sa_handler_t); + ret = signal(signo, func); + break; + } + +#if defined(CONFIG_SIGNAL_FD) + case __NR_signalfd: + { + int fd = va_arg(ap, int); + sigset_t *mask = va_arg(ap, sigset_t *); + int flags = va_arg(ap, int); + ret = signalfd(fd, mask, flags); + break; + } +#endif + + case __NR_sigpending: + { + sigset_t *set = va_arg(ap, sigset_t *); + ret = sigpending(set); + break; + } + + case __NR_sigprocmask: + { + int how = va_arg(ap, int); + const sigset_t *set = va_arg(ap, const sigset_t *); + sigset_t *oldset = va_arg(ap, sigset_t *); + ret = sigprocmask(how, set, oldset); + break; + } + + case __NR_sigqueue: + { + int pid = va_arg(ap, int); + int signo = va_arg(ap, int); + union sigval value = va_arg(ap, union sigval); + ret = sigqueue(pid, signo, value); + break; + } + + case __NR_sigsuspend: + { + const sigset_t *mask = va_arg(ap, sigset_t *); + ret = sigsuspend(mask); + break; + } + + case __NR_sigtimedwait: + { + const sigset_t *set = va_arg(ap, sigset_t *); + struct siginfo *value = va_arg(ap, struct siginfo *); + struct timespec *timeout = va_arg(ap, struct timespec *); + ret = sigtimedwait(set, value, timeout); + break; + } + + case __NR_sigwaitinfo: + { + const sigset_t *set = va_arg(ap, const sigset_t *); + struct siginfo *info = va_arg(ap, struct siginfo *); + ret = sigwaitinfo(set, info); + break; + } + +#if defined(CONFIG_NET) + case __NR_socket: + { + int domain = va_arg(ap, int); + int type = va_arg(ap, int); + int protocol = va_arg(ap, int); + ret = socket(domain, type, protocol); + break; + } +#endif + +#if defined(CONFIG_NET) + case __NR_socketpair: + { + int domain = va_arg(ap, int); + int type = va_arg(ap, int); + int protocol = va_arg(ap, int); + int *sv = va_arg(ap, int *); + ret = socketpair(domain, type, protocol, sv); + break; + } +#endif + + case __NR_stat: + { + const char *path = va_arg(ap, const char *); + struct stat *buf = va_arg(ap, struct stat *); + ret = stat(path, buf); + break; + } + + case __NR_statfs: + { + const char *path = va_arg(ap, const char *); + struct statfs *buf = va_arg(ap, struct statfs *); + ret = statfs(path, buf); + break; + } + +#if defined(CONFIG_PSEUDOFS_SOFTLINKS) + case __NR_symlink: + { + const char *target = va_arg(ap, const char *); + const char *linkpath = va_arg(ap, const char *); + ret = symlink(target, linkpath); + break; + } +#endif + + case __NR_sync: + { + sync(); + break; + } + +#if defined(CONFIG_FS_SHMFS) + case __NR_shm_open: + { + const char *name = va_arg(ap, const char *); + int oflag = va_arg(ap, int); + mode_t mode = va_arg(ap, mode_t); + ret = shm_open(name, oflag, mode); + break; + } +#endif + +#if defined(CONFIG_FS_SHMFS) + case __NR_shm_unlink: + { + const char *name = va_arg(ap, const char *); + ret = shm_unlink(name); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case __NR_shmat: + { + int shmid = va_arg(ap, int); + const void *shmaddr = va_arg(ap, const void *); + int shmflg = va_arg(ap, int); + void *shm_ret = shmat(shmid, shmaddr, shmflg); + if (!shm_ret) + { + ret = -1; + } + + break; + } +#endif + + case __NR_sysinfo: + { + struct sysinfo *info = va_arg(ap, struct sysinfo *); + ret = sysinfo(info); + break; + } + +#if !defined(CONFIG_BUILD_KERNEL) + case __NR_task_create: + { + const char *name = va_arg(ap, const char *); + int priority = va_arg(ap, int); + int stack_size = va_arg(ap, int); + main_t entry = va_arg(ap, main_t); + char *const *argv = va_arg(ap, char *const *); + ret = task_create(name, priority, stack_size, entry, argv); + break; + } +#endif + +#if !defined(CONFIG_BUILD_KERNEL) + case __NR_task_delete: + { + pid_t pid = va_arg(ap, pid_t); + ret = task_delete(pid); + break; + } +#endif + +#if !defined(CONFIG_BUILD_KERNEL) + case __NR_task_restart: + { + pid_t pid = va_arg(ap, pid_t); + ret = task_restart(pid); + break; + } +#endif + +#if !defined(CONFIG_BUILD_KERNEL) + case __NR_task_spawn: + { + const char *path = va_arg(ap, const char *); + main_t entry = va_arg(ap, main_t); + const posix_spawn_file_actions_t *file_actions = + va_arg(ap, const posix_spawn_file_actions_t *); + const posix_spawnattr_t *attr = va_arg(ap, const posix_spawnattr_t *); + char *const *argv = va_arg(ap, char *const *); + char *const *envp = va_arg(ap, char *const *); + ret = task_spawn(path, entry, file_actions, attr, argv, envp); + break; + } +#endif + + case __NR_tgkill: + { + pid_t pid = va_arg(ap, pid_t); + pid_t tid = va_arg(ap, pid_t); + int signo = va_arg(ap, int); + ret = tgkill(pid, tid, signo); + break; + } + + case __NR_time: + { + time_t *timep = va_arg(ap, time_t *); + ret = time(timep); + break; + } + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_timer_create: + { + int clockid = va_arg(ap, int); + struct sigevent *sevp = va_arg(ap, struct sigevent *); + timer_t *timerid = va_arg(ap, timer_t *); + ret = timer_create(clockid, sevp, timerid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_timer_delete: + { + timer_t timerid = va_arg(ap, timer_t); + ret = timer_delete(timerid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_timer_getoverrun: + { + timer_t timerid = va_arg(ap, timer_t); + ret = timer_getoverrun(timerid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_timer_gettime: + { + int clockid = va_arg(ap, int); + struct itimerspec *curr_value = va_arg(ap, struct itimerspec *); + ret = timer_gettime(clockid, curr_value); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case __NR_timer_settime: + { + int clockid = va_arg(ap, int); + int flags = va_arg(ap, int); + const struct itimerspec *new_value = + va_arg(ap, const struct itimerspec *); + struct itimerspec *old_value = va_arg(ap, struct itimerspec *); + ret = timer_settime(clockid, flags, new_value, old_value); + break; + } +#endif + +#if defined(CONFIG_TIMER_FD) + case __NR_timerfd_create: + { + int clockid = va_arg(ap, int); + int flags = va_arg(ap, int); + ret = timerfd_create(clockid, flags); + break; + } +#endif + +#if defined(CONFIG_TIMER_FD) + case __NR_timerfd_gettime: + { + int fd = va_arg(ap, int); + struct itimerspec *curr_value = va_arg(ap, struct itimerspec *); + ret = timerfd_gettime(fd, curr_value); + break; + } +#endif + +#if defined(CONFIG_TIMER_FD) + case __NR_timerfd_settime: + { + int fd = va_arg(ap, int); + int flags = va_arg(ap, int); + const struct itimerspec *new_value = + va_arg(ap, const struct itimerspec *); + struct itimerspec *old_value = va_arg(ap, struct itimerspec *); + ret = timerfd_settime(fd, flags, new_value, old_value); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case __NR_umount2: + { + const char *target = va_arg(ap, const char *); + unsigned int flags = va_arg(ap, unsigned int); + ret = umount2(target, flags); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case __NR_unlink: + { + const char *pathname = va_arg(ap, const char *); + ret = unlink(pathname); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_ENVIRON) + case __NR_unsetenv: + { + const char *name = va_arg(ap, const char *); + ret = unsetenv(name); + break; + } +#endif + + case __NR_up_fork: + { + ret = up_fork(); + break; + } + + case __NR_utimens: + { + const char *path = va_arg(ap, const char *); + const struct timespec *times = va_arg(ap, const struct timespec *); + ret = utimens(path, times); + break; + } + +#if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) + case __NR_wait: + { + int *stat_loc = va_arg(ap, int *); + ret = wait(stat_loc); + break; + } +#endif + +#if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) + case __NR_waitid: + { + idtype_t idtype = (int) va_arg(ap, int); + id_t id = va_arg(ap, id_t); + siginfo_t *info = va_arg(ap, siginfo_t *); + int options = va_arg(ap, int); + ret = waitid(idtype, id, info, options); + break; + } +#endif + +#ifdef CONFIG_SCHED_WAITPID + case __NR_waitpid: + { + pid_t pid = va_arg(ap, pid_t); + int *stat_loc = va_arg(ap, int *); + int options = va_arg(ap, int); + ret = waitpid(pid, stat_loc, options); + break; + } +#endif + + case __NR_write: + { + int fd = va_arg(ap, int); + const void *buf = va_arg(ap, const void *); + size_t count = va_arg(ap, size_t); + ret = write(fd, buf, count); + break; + } + + case __NR_futex: + { + /* nuttx do not support futex */ + + ret = -1; + break; + } + + case __NR_clock_getres: + { + clockid_t clockid = va_arg(ap, clockid_t); + struct timespec *res = va_arg(ap, struct timespec *); + ret = clock_getres(clockid, res); + break; + } + + case __NR_ext_alarm: + { + unsigned int seconds = va_arg(ap, unsigned int); + ret = alarm(seconds); + break; + } + + default: + ret = -1; + break; + } + + va_end(ap); + return ret; +}