From 9490634ece14455f442f68d88a2d6f60776d17ab Mon Sep 17 00:00:00 2001 From: guoshichao Date: Sat, 12 Oct 2024 16:46:44 +0800 Subject: [PATCH 1/5] testing/ltp: add linux kernel interface test support Major enhancements to LTP build system: - Split CMakeLists.txt into shared/posix/kernel sections with unified blacklisting - Add header stubs (linux/*.h, asm/*.h, lapi/*.h) for kernel test dependencies - Implement syscalls.h generation via regen.sh for NuttX syscall mapping - Define feature macros (HAVE_*, UNIT_TEST) and compiler flags for kernel tests - Resolve naming conflicts (safe_* functions) with macro renaming This enables LTP kernel test execution on NuttX, covering syscalls, filesystem, device drivers, and scheduler tests. Signed-off-by: guoshichao --- testing/ltp/CMakeLists.txt | 760 ++++++++-- testing/ltp/Makefile | 552 ++++++- testing/ltp/include/asm/posix_types.h | 34 + testing/ltp/include/asm/types.h | 32 + testing/ltp/include/features.h | 42 + testing/ltp/include/grp.h | 40 + testing/ltp/include/lapi/posix_clocks.h | 50 + testing/ltp/include/libaio.h | 34 + testing/ltp/include/linux/errno.h | 32 + testing/ltp/include/linux/fs.h | 32 + testing/ltp/include/linux/futex.h | 38 + testing/ltp/include/linux/if_tun.h | 30 + testing/ltp/include/linux/input.h | 30 + testing/ltp/include/linux/kernel.h | 32 + testing/ltp/include/linux/limits.h | 32 + testing/ltp/include/linux/loop.h | 32 + testing/ltp/include/linux/mman.h | 32 + testing/ltp/include/linux/net.h | 32 + testing/ltp/include/linux/random.h | 32 + testing/ltp/include/linux/rtc.h | 32 + testing/ltp/include/linux/types.h | 34 + testing/ltp/include/linux/unistd.h | 32 + testing/ltp/include/mntent.h | 52 + testing/ltp/include/sched.h | 39 + testing/ltp/include/sys/endian.h | 42 + testing/ltp/include/sys/fsuid.h | 35 + testing/ltp/include/sys/mman.h | 34 + testing/ltp/include/sys/param.h | 38 + testing/ltp/include/sys/personality.h | 34 + testing/ltp/include/sys/ptrace.h | 45 + testing/ltp/include/sys/quota.h | 34 + testing/ltp/include/sys/sem.h | 38 + testing/ltp/include/sys/timex.h | 40 + testing/ltp/include/sys/ttydefaults.h | 34 + testing/ltp/include/sys/user.h | 34 + testing/ltp/include/sys/xattr.h | 45 + testing/ltp/include/ulimit.h | 34 + testing/ltp/include/unistd.h | 41 + testing/ltp/include/values.h | 34 + testing/ltp/src/dummy.c | 142 ++ testing/ltp/src/nx_syscall.c | 1763 +++++++++++++++++++++++ testing/ltp/syscalls/nuttx.in | 449 ++++++ testing/ltp/syscalls/regen.sh | 147 ++ 43 files changed, 4958 insertions(+), 192 deletions(-) create mode 100644 testing/ltp/include/asm/posix_types.h create mode 100644 testing/ltp/include/asm/types.h create mode 100644 testing/ltp/include/features.h create mode 100644 testing/ltp/include/grp.h create mode 100644 testing/ltp/include/lapi/posix_clocks.h create mode 100644 testing/ltp/include/libaio.h create mode 100644 testing/ltp/include/linux/errno.h create mode 100644 testing/ltp/include/linux/fs.h create mode 100644 testing/ltp/include/linux/futex.h create mode 100644 testing/ltp/include/linux/if_tun.h create mode 100644 testing/ltp/include/linux/input.h create mode 100644 testing/ltp/include/linux/kernel.h create mode 100644 testing/ltp/include/linux/limits.h create mode 100644 testing/ltp/include/linux/loop.h create mode 100644 testing/ltp/include/linux/mman.h create mode 100644 testing/ltp/include/linux/net.h create mode 100644 testing/ltp/include/linux/random.h create mode 100644 testing/ltp/include/linux/rtc.h create mode 100644 testing/ltp/include/linux/types.h create mode 100644 testing/ltp/include/linux/unistd.h create mode 100644 testing/ltp/include/mntent.h create mode 100644 testing/ltp/include/sched.h create mode 100644 testing/ltp/include/sys/endian.h create mode 100644 testing/ltp/include/sys/fsuid.h create mode 100644 testing/ltp/include/sys/mman.h create mode 100644 testing/ltp/include/sys/param.h create mode 100644 testing/ltp/include/sys/personality.h create mode 100644 testing/ltp/include/sys/ptrace.h create mode 100644 testing/ltp/include/sys/quota.h create mode 100644 testing/ltp/include/sys/sem.h create mode 100644 testing/ltp/include/sys/timex.h create mode 100644 testing/ltp/include/sys/ttydefaults.h create mode 100644 testing/ltp/include/sys/user.h create mode 100644 testing/ltp/include/sys/xattr.h create mode 100644 testing/ltp/include/ulimit.h create mode 100644 testing/ltp/include/unistd.h create mode 100644 testing/ltp/include/values.h create mode 100644 testing/ltp/src/dummy.c create mode 100644 testing/ltp/src/nx_syscall.c create mode 100644 testing/ltp/syscalls/nuttx.in create mode 100644 testing/ltp/syscalls/regen.sh diff --git a/testing/ltp/CMakeLists.txt b/testing/ltp/CMakeLists.txt index 2e458d5e4d2..055f8367ed1 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 @@ -148,34 +265,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 @@ -185,22 +274,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 @@ -217,53 +290,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) @@ -335,33 +361,502 @@ 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 + ) + + 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) + + # to generate the lapi/syscalls.h to handle syscall for NuttX platform + set(LAPI_SYSCALL_FILE ${CMAKE_CURRENT_LIST_DIR}/../syscalls.h) + if(NOT EXISTS ${LAPI_SYSCALL_FILE}) + message( + STATUS + "the ${LAPI_SYSCALL_FILE} do not exist, start to generate at ${CMAKE_CURRENT_LIST_DIR}" + ) + + get_filename_component( + regen_file ${CMAKE_CURRENT_LIST_DIR}/syscalls/regen.sh ABSOLUTE) + set(GEN_SYSCALLS_H_CMD_STR + "bash ${CMAKE_CURRENT_LIST_DIR}/syscalls/regen.sh ${CMAKE_CURRENT_LIST_DIR}/ltp/include/lapi/" + ) + separate_arguments(GEN_SYSCALLS_H_CMD UNIX_COMMAND + ${GEN_SYSCALLS_H_CMD_STR}) + add_custom_command( + OUTPUT ${LAPI_SYSCALL_FILE} + COMMAND ${GEN_SYSCALLS_H_CMD} + COMMAND mv ${CMAKE_CURRENT_LIST_DIR}/../syscalls.h + ${CMAKE_CURRENT_LIST_DIR}/ltp/include/lapi/ + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + DEPENDS ${regen_file} + VERBATIM + COMMENT "LAPI:Gen and Updating ${LAPI_SYSCALL_FILE}") + add_custom_target(GEN_SYSCALLS_H DEPENDS ${LAPI_SYSCALL_FILE}) + add_dependencies(apps_context GEN_SYSCALLS_H) + endif() + + 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}/../../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 @@ -375,6 +870,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 c6f712614dc..ef9aa9f1636 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,40 +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_FDCHECK),y) -BLACKSRCS += $(TESTDIR)/conformance/interfaces/mq_close/3-1.c -BLACKSRCS += $(TESTDIR)/conformance/interfaces/mq_close/4-1.c -endif -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 @@ -110,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 @@ -130,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 @@ -188,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)) @@ -228,22 +250,428 @@ 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 + +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 + + +# to generate the lapi/syscalls.h to handle syscall for nuttx platform +.PHONY: gen_ltp_kernel_syscall +gen_ltp_kernel_syscall: + $(Q) echo "start to generate the ltp/include/lapi/syscalls.h" + $(Q) bash syscalls/regen.sh ltp/include/lapi/ + $(Q) mv ../syscalls.h ltp/include/lapi/ + +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)/../../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) @@ -273,4 +701,8 @@ distclean:: $(Q) rm -rf $(LTP_UNPACK) endif +ifeq ($(CONFIG_TESTING_LTP),y) +context:: gen_ltp_kernel_syscall +endif + include $(APPDIR)/Application.mk 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/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..ca66832343c --- /dev/null +++ b/testing/ltp/include/linux/loop.h @@ -0,0 +1,32 @@ +/**************************************************************************** + * 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 _LINUX_LOOP_H +#define _LINUX_LOOP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#endif /* _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/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..23ca9fefde6 --- /dev/null +++ b/testing/ltp/src/nx_syscall.c @@ -0,0 +1,1763 @@ +/**************************************************************************** + * 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 SYS__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 SYS__exit: + { + int status = va_arg(ap, int); + _exit(status); + break; + } + + case SYS_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 SYS_adjtime: + { + 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 SYS_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 SYS_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 SYS_aio_read: + { + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_read(aiocbp); + break; + } +#endif + +#ifdef CONFIG_FS_AIO + case SYS_aio_write: + { + struct aiocb *aiocbp = va_arg(ap, struct aiocb *); + ret = aio_write(aiocbp); + break; + } +#endif + +#ifdef CONFIG_CRYPTO_RANDOM_POOL + case SYS_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 SYS_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 SYS_boardctl: + { + unsigned int cmd = va_arg(ap, unsigned int); + uintptr_t arg = va_arg(ap, uintptr_t); + ret = boardctl(cmd, arg); + break; + } +#endif + + case SYS_chmod: + { + const char *path = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = chmod(path, mode); + break; + } + + case SYS_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 SYS_clearenv: + { + ret = clearenv(); + break; + } +#endif + + case SYS_clock: + { + ret = clock(); + break; + } + + case SYS_clock_gettime: + { + int clockid = va_arg(ap, int); + struct timespec *ts = va_arg(ap, struct timespec *); + ret = clock_gettime(clockid, ts); + break; + } + + case SYS_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 SYS_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 SYS_close: + { + int fd = va_arg(ap, int); + ret = close(fd); + break; + } + +#ifdef CONFIG_NET + case SYS_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 SYS_dup: + { + int fd = va_arg(ap, int); + ret = dup(fd); + break; + } + + case SYS_dup2: + { + int fd1 = va_arg(ap, int); + int fd2 = va_arg(ap, int); + ret = dup2(fd1, fd2); + break; + } + + case SYS_epoll_create1: + { + int flags = va_arg(ap, int); + ret = epoll_create1(flags); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_fchmod: + { + int fd = va_arg(ap, int); + mode_t mode = va_arg(ap, mode_t); + ret = fchmod(fd, mode); + break; + } + + case SYS_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 SYS_fdatasync: + { + int fd = va_arg(ap, int); + ret = fdatasync(fd); + break; + } + + case SYS_fstatat: + { + 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 SYS_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 SYS_fstat: + { + int fd = va_arg(ap, int); + struct stat *buf = va_arg(ap, struct stat *); + ret = fstat(fd, buf); + break; + } + + case SYS_fstatfs: + { + int fd = va_arg(ap, int); + struct statfs *buf = va_arg(ap, struct statfs *); + ret = fstatfs(fd, buf); + break; + } + + case SYS_fsync: + { + int fd = va_arg(ap, int); + ret = fsync(fd); + break; + } + + case SYS_ftruncate: + { + int fd = va_arg(ap, int); + off_t length = va_arg(ap, off_t); + ret = ftruncate(fd, length); + break; + } + + case SYS_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 SYS_getegid: + { + ret = getegid(); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case SYS_geteuid: + { + ret = geteuid(); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case SYS_getgid: + { + ret = getgid(); + break; + } +#endif + + case SYS_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 SYS_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 SYS_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 SYS_getpid: + { + ret = getpid(); + break; + } + +#if defined(CONFIG_SCHED_HAVE_PARENT) + case SYS_getppid: + { + ret = getppid(); + break; + } +#endif + +#if defined(CONFIG_NET) + case SYS_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 SYS_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 SYS_gettid: + { + ret = gettid(); + break; + } + + case SYS_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 SYS_getuid: + { + ret = getuid(); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case SYS_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 SYS_inotify_init: + { + ret = inotify_init(); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case SYS_inotify_init1: + { + int flags = va_arg(ap, int); + ret = inotify_init1(flags); + break; + } +#endif + +#if defined(CONFIG_FS_NOTIFY) + case SYS_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 SYS_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 SYS_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 SYS_kill: + { + pid_t pid = va_arg(ap, pid_t); + int sig = va_arg(ap, int); + ret = kill(pid, sig); + break; + } + + case SYS_lchmod: + { + const char *pathname = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = lchmod(pathname, mode); + break; + } + + case SYS_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 SYS_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 SYS_listen: + { + int sockfd = va_arg(ap, int); + int backlog = va_arg(ap, int); + ret = listen(sockfd, backlog); + break; + } +#endif + + case SYS_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 SYS_lstat: + { + const char *path = va_arg(ap, const char *); + struct stat *buf = va_arg(ap, struct stat *); + ret = lstat(path, buf); + break; + } + + case SYS_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 SYS_mkdir: + { + const char *pathname = va_arg(ap, const char *); + mode_t mode = va_arg(ap, mode_t); + ret = mkdir(pathname, mode); + break; + } +#endif + + case SYS_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 SYS_modhandle: + { + const char *name = va_arg(ap, const char *); + modhandle(name); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MOUNTPOINT) + case SYS_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 SYS_mq_close: + { + mqd_t mqdes = va_arg(ap, mqd_t); + ret = mq_close(mqdes); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_MQUEUE) + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_mq_unlink: + { + const char *name = va_arg(ap, const char *); + ret = mq_unlink(name); + break; + } +#endif + + case SYS_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 SYS_munmap: + { + void *addr = va_arg(ap, void *); + size_t length = va_arg(ap, size_t); + ret = munmap(addr, length); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_pipe2: + { + int *pipefd = va_arg(ap, int *); + int flags = va_arg(ap, int); + ret = pipe2(pipefd, flags); + break; + } +#endif + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_putenv: + { + const char *string = va_arg(ap, const char *); + ret = putenv(string); + break; + } +#endif + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_rmdir: + { + const char *pathname = va_arg(ap, const char *); + ret = rmdir(pathname); + break; + } +#endif + +#if defined(CONFIG_MODULE) + case SYS_rmmod: + { + void *handle = va_arg(ap, void *); + ret = rmmod(handle); + break; + } +#endif + +#if defined(CONFIG_SCHED_BACKTRACE) + case SYS_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 SYS_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 SYS_sched_getcpu: + { + ret = sched_getcpu(); + break; + } + + case SYS_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 SYS_sched_getscheduler: + { + pid_t pid = va_arg(ap, pid_t); + ret = sched_getscheduler(pid); + break; + } + + case SYS_sched_lock: + { + sched_lock(); + break; + } + + case SYS_sched_lockcount: + { + ret = sched_lockcount(); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_sched_unlock: + { + sched_unlock(); + break; + } + + case SYS_sched_yield: + { + ret = sched_yield(); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_setegid: + { + gid_t egid = va_arg(ap, gid_t); + ret = setegid(egid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_ENVIRON) + case SYS_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 SYS_seteuid: + { + uid_t euid = va_arg(ap, uid_t); + ret = seteuid(euid); + break; + } +#endif + +#if defined(CONFIG_SCHED_USER_IDENTITY) + case SYS_setgid: + { + gid_t gid = va_arg(ap, gid_t); + ret = setgid(gid); + break; + } +#endif + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_setuid: + { + uid_t euid = va_arg(ap, uid_t); + ret = seteuid(euid); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case SYS_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 SYS_shmdt: + { + const void *shmaddr = va_arg(ap, const void *); + ret = shmdt(shmaddr); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case SYS_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 SYS_shutdown: + { + int sockfd = va_arg(ap, int); + int how = va_arg(ap, int); + ret = shutdown(sockfd, how); + break; + } +#endif + + case SYS_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 SYS_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 SYS_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 SYS_sigpending: + { + sigset_t *set = va_arg(ap, sigset_t *); + ret = sigpending(set); + break; + } + + case SYS_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 SYS_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 SYS_sigsuspend: + { + const sigset_t *mask = va_arg(ap, sigset_t *); + ret = sigsuspend(mask); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_stat: + { + const char *path = va_arg(ap, const char *); + struct stat *buf = va_arg(ap, struct stat *); + ret = stat(path, buf); + break; + } + + case SYS_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 SYS_symlink: + { + const char *target = va_arg(ap, const char *); + const char *linkpath = va_arg(ap, const char *); + ret = symlink(target, linkpath); + break; + } +#endif + + case SYS_sync: + { + sync(); + break; + } + +#if defined(CONFIG_FS_SHMFS) + case SYS_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 SYS_shm_unlink: + { + const char *name = va_arg(ap, const char *); + ret = shm_unlink(name); + break; + } +#endif + +#if defined(CONFIG_MM_SHM) + case SYS_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 SYS_sysinfo: + { + struct sysinfo *info = va_arg(ap, struct sysinfo *); + ret = sysinfo(info); + break; + } + +#if !defined(CONFIG_BUILD_KERNEL) + case SYS_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 SYS_task_delete: + { + pid_t pid = va_arg(ap, pid_t); + ret = task_delete(pid); + break; + } +#endif + +#if !defined(CONFIG_BUILD_KERNEL) + case SYS_task_restart: + { + pid_t pid = va_arg(ap, pid_t); + ret = task_restart(pid); + break; + } +#endif + +#if !defined(CONFIG_BUILD_KERNEL) + case SYS_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 SYS_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 SYS_time: + { + time_t *timep = va_arg(ap, time_t *); + ret = time(timep); + break; + } + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case SYS_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 SYS_timer_delete: + { + timer_t timerid = va_arg(ap, timer_t); + ret = timer_delete(timerid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case SYS_timer_getoverrun: + { + timer_t timerid = va_arg(ap, timer_t); + ret = timer_getoverrun(timerid); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_POSIX_TIMERS) + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_unlink: + { + const char *pathname = va_arg(ap, const char *); + ret = unlink(pathname); + break; + } +#endif + +#if !defined(CONFIG_DISABLE_ENVIRON) + case SYS_unsetenv: + { + const char *name = va_arg(ap, const char *); + ret = unsetenv(name); + break; + } +#endif + + case SYS_up_fork: + { + ret = up_fork(); + break; + } + + case SYS_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 SYS_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 SYS_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 SYS_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 SYS_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 SYS_futex: + { + /* nuttx do not support futex */ + + ret = -1; + break; + } + + case SYS_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 SYS_ext_alarm: + { + unsigned int seconds = va_arg(ap, unsigned int); + ret = alarm(seconds); + break; + } + + default: + ret = -1; + break; + } + + va_end(ap); + return ret; +} diff --git a/testing/ltp/syscalls/nuttx.in b/testing/ltp/syscalls/nuttx.in new file mode 100644 index 00000000000..5816b6d0975 --- /dev/null +++ b/testing/ltp/syscalls/nuttx.in @@ -0,0 +1,449 @@ +exit SYS__exit 1 +fork SYS_fork 2 +read SYS_read 3 +write SYS_write 4 +open SYS_open 5 +close SYS_close 6 +creat SYS_creat 8 +link SYS_link 9 +unlink SYS_unlink 10 +execve SYS_execve 11 +chdir SYS_chdir 12 +mknod SYS_mknod 14 +chmod SYS_chmod 15 +lchown SYS_lchown 16 +lseek SYS_lseek 19 +getpid SYS_getpid 20 +mount SYS_mount 21 +setuid SYS_setuid 23 +getuid SYS_getuid 24 +ptrace SYS_ptrace 26 +pause SYS_pause 29 +access SYS_access 33 +nice SYS_nice 34 +sync SYS_sync 36 +kill SYS_kill 37 +rename SYS_rename 38 +mkdir SYS_mkdir 39 +rmdir SYS_rmdir 40 +dup SYS_dup 41 +pipe SYS_pipe 42 +times SYS_times 43 +brk SYS_brk 45 +setgid SYS_setgid 46 +getgid SYS_getgid 47 +geteuid SYS_geteuid 49 +getegid SYS_getegid 50 +acct SYS_acct 51 +umount2 SYS_umount2 52 +ioctl SYS_ioctl 54 +fcntl SYS_fcntl 55 +setpgid SYS_setpgid 57 +umask SYS_umask 60 +chroot SYS_chroot 61 +ustat SYS_ustat 62 +dup2 SYS_dup2 63 +getppid SYS_getppid 64 +getpgrp SYS_getpgrp 65 +setsid SYS_setsid 66 +sigaction SYS_sigaction 67 +setreuid SYS_setreuid 70 +setregid SYS_setregid 71 +sigsuspend SYS_sigsuspend 72 +sigpending SYS_sigpending 73 +sethostname SYS_sethostname 74 +setrlimit SYS_setrlimit 75 +getrusage SYS_getrusage 77 +gettimeofday SYS_gettimeofday 78 +settimeofday SYS_settimeofday 79 +getgroups SYS_getgroups 80 +setgroups SYS_setgroups 81 +symlink SYS_symlink 83 +readlink SYS_readlink 85 +uselib SYS_uselib 86 +swapon SYS_swapon 87 +reboot SYS_reboot 88 +munmap SYS_munmap 91 +truncate SYS_truncate 92 +ftruncate SYS_ftruncate 93 +fchmod SYS_fchmod 94 +fchown SYS_fchown 95 +getpriority SYS_getpriority 96 +setpriority SYS_setpriority 97 +statfs SYS_statfs 99 +fstatfs SYS_fstatfs 100 +syslog SYS_syslog 103 +setitimer SYS_setitimer 104 +getitimer SYS_getitimer 105 +stat SYS_stat 106 +lstat SYS_lstat 107 +fstat SYS_fstat 108 +vhangup SYS_vhangup 111 +wait4 SYS_wait4 114 +swapoff SYS_swapoff 115 +sysinfo SYS_sysinfo 116 +fsync SYS_fsync 118 +sigreturn SYS_sigreturn 119 +clone SYS_clone 120 +setdomainname SYS_setdomainname 121 +uname SYS_uname 122 +adjtimex SYS_adjtimex 124 +mprotect SYS_mprotect 125 +sigprocmask SYS_sigprocmask 126 +init_module SYS_init_module 128 +delete_module SYS_delete_module 129 +quotactl SYS_quotactl 131 +getpgid SYS_getpgid 132 +fchdir SYS_fchdir 133 +bdflush SYS_bdflush 134 +sysfs SYS_sysfs 135 +personality SYS_personality 136 +setfsuid SYS_setfsuid 138 +setfsgid SYS_setfsgid 139 +_llseek SYS__llseek 140 +getdents SYS_getdents 141 +_newselect SYS__newselect 142 +flock SYS_flock 143 +msync SYS_msync 144 +readv SYS_readv 145 +writev SYS_writev 146 +getsid SYS_getsid 147 +fdatasync SYS_fdatasync 148 +_sysctl SYS__sysctl 149 +mlock SYS_mlock 150 +munlock SYS_munlock 151 +mlockall SYS_mlockall 152 +munlockall SYS_munlockall 153 +sched_setparam SYS_sched_setparam 154 +sched_getparam SYS_sched_getparam 155 +sched_setscheduler SYS_sched_setscheduler 156 +sched_getscheduler SYS_sched_getscheduler 157 +sched_yield SYS_sched_yield 158 +sched_get_priority_max SYS_sched_get_priority_max 159 +sched_get_priority_min SYS_sched_get_priority_min 160 +sched_rr_get_interval SYS_sched_rr_get_interval 161 +nanosleep SYS_nanosleep 162 +mremap SYS_mremap 163 +setresuid SYS_setresuid 164 +getresuid SYS_getresuid 165 +poll SYS_poll 168 +nfsservctl SYS_nfsservctl 169 +setresgid SYS_setresgid 170 +getresgid SYS_getresgid 171 +prctl SYS_prctl 172 +rt_sigreturn SYS_rt_sigreturn 173 +rt_sigaction SYS_rt_sigaction 174 +rt_sigprocmask SYS_rt_sigprocmask 175 +rt_sigpending SYS_rt_sigpending 176 +rt_sigtimedwait SYS_rt_sigtimedwait 177 +rt_sigqueueinfo SYS_rt_sigqueueinfo 178 +rt_sigsuspend SYS_rt_sigsuspend 179 +pread64 SYS_pread64 180 +pwrite64 SYS_pwrite64 181 +chown SYS_chown 182 +getcwd SYS_getcwd 183 +capget SYS_capget 184 +capset SYS_capset 185 +sigaltstack SYS_sigaltstack 186 +sendfile SYS_sendfile 187 +vfork SYS_vfork 190 +getrlimit SYS_getrlimit 191 +ugetrlimit SYS_ugetrlimit SYS_getrlimit +mmap2 SYS_mmap2 192 +truncate64 SYS_truncate64 193 +ftruncate64 SYS_ftruncate64 194 +stat64 SYS_stat64 195 +lstat64 SYS_lstat64 196 +fstat64 SYS_fstat64 197 +lchown32 SYS_lchown32 198 +getuid32 SYS_getuid32 199 +getgid32 SYS_getgid32 200 +geteuid32 SYS_geteuid32 201 +getegid32 SYS_getegid32 202 +setreuid32 SYS_setreuid32 203 +setregid32 SYS_setregid32 204 +getgroups32 SYS_getgroups32 205 +setgroups32 SYS_setgroups32 206 +fchown32 SYS_fchown32 207 +setresuid32 SYS_setresuid32 208 +getresuid32 SYS_getresuid32 209 +setresgid32 SYS_setresgid32 210 +getresgid32 SYS_getresgid32 211 +chown32 SYS_chown32 212 +setuid32 SYS_setuid32 213 +setgid32 SYS_setgid32 214 +setfsuid32 SYS_setfsuid32 215 +setfsgid32 SYS_setfsgid32 216 +getdents64 SYS_getdents64 217 +pivot_root SYS_pivot_root 218 +mincore SYS_mincore 219 +madvise SYS_madvise 220 +fcntl64 SYS_fcntl64 221 +gettid SYS_gettid 224 +readahead SYS_readahead 225 +setxattr SYS_setxattr 226 +lsetxattr SYS_lsetxattr 227 +fsetxattr SYS_fsetxattr 228 +getxattr SYS_getxattr 229 +lgetxattr SYS_lgetxattr 230 +fgetxattr SYS_fgetxattr 231 +listxattr SYS_listxattr 232 +llistxattr SYS_llistxattr 233 +flistxattr SYS_flistxattr 234 +removexattr SYS_removexattr 235 +lremovexattr SYS_lremovexattr 236 +fremovexattr SYS_fremovexattr 237 +tkill SYS_tkill 238 +sendfile64 SYS_sendfile64 239 +futex SYS_futex 240 +sched_setaffinity SYS_sched_setaffinity 241 +sched_getaffinity SYS_sched_getaffinity 242 +io_setup SYS_io_setup 243 +io_destroy SYS_io_destroy 244 +io_getevents SYS_io_getevents 245 +io_submit SYS_io_submit 246 +io_cancel SYS_io_cancel 247 +exit_group SYS_exit_group 248 +lookup_dcookie SYS_lookup_dcookie 249 +epoll_create SYS_epoll_create 250 +epoll_ctl SYS_epoll_ctl 251 +epoll_wait SYS_epoll_wait 252 +remap_file_pages SYS_remap_file_pages 253 +set_tid_address SYS_set_tid_address 256 +timer_create SYS_timer_create 257 +timer_settime SYS_timer_settime 258 +timer_gettime SYS_timer_gettime 259 +timer_getoverrun SYS_timer_getoverrun 260 +timer_delete SYS_timer_delete 261 +clock_settime SYS_clock_settime 262 +clock_gettime SYS_clock_gettime 263 +clock_getres SYS_clock_getres 264 +clock_nanosleep SYS_clock_nanosleep 265 +statfs64 SYS_statfs64 266 +fstatfs64 SYS_fstatfs64 267 +tgkill SYS_tgkill 268 +utimes SYS_utimes 269 +arm_fadvise64_64 SYS_arm_fadvise64_64 270 +pciconfig_iobase SYS_pciconfig_iobase 271 +pciconfig_read SYS_pciconfig_read 272 +pciconfig_write SYS_pciconfig_write 273 +mq_open SYS_mq_open 274 +mq_unlink SYS_mq_unlink 275 +mq_timedsend SYS_mq_timedsend 276 +mq_timedreceive SYS_mq_timedreceive 277 +mq_notify SYS_mq_notify 278 +mq_getsetattr SYS_mq_getsetattr 279 +waitid SYS_waitid 280 +socket SYS_socket 281 +bind SYS_bind 282 +connect SYS_connect 283 +listen SYS_listen 284 +accept SYS_accept 285 +getsockname SYS_getsockname 286 +getpeername SYS_getpeername 287 +socketpair SYS_socketpair 288 +send SYS_send 289 +sendto SYS_sendto 290 +recv SYS_recv 291 +recvfrom SYS_recvfrom 292 +shutdown SYS_shutdown 293 +setsockopt SYS_setsockopt 294 +getsockopt SYS_getsockopt 295 +sendmsg SYS_sendmsg 296 +recvmsg SYS_recvmsg 297 +semop SYS_semop 298 +semget SYS_semget 299 +semctl SYS_semctl 300 +msgsnd SYS_msgsnd 301 +msgrcv SYS_msgrcv 302 +msgget SYS_msgget 303 +msgctl SYS_msgctl 304 +shmat SYS_shmat 305 +shmdt SYS_shmdt 306 +shmget SYS_shmget 307 +shmctl SYS_shmctl 308 +add_key SYS_add_key 309 +request_key SYS_request_key 310 +keyctl SYS_keyctl 311 +semtimedop SYS_semtimedop 312 +vserver SYS_vserver 313 +ioprio_set SYS_ioprio_set 314 +ioprio_get SYS_ioprio_get 315 +inotify_init SYS_inotify_init 316 +inotify_add_watch SYS_inotify_add_watch 317 +inotify_rm_watch SYS_inotify_rm_watch 318 +mbind SYS_mbind 319 +get_mempolicy SYS_get_mempolicy 320 +set_mempolicy SYS_set_mempolicy 321 +openat SYS_openat 322 +mkdirat SYS_mkdirat 323 +mknodat SYS_mknodat 324 +fchownat SYS_fchownat 325 +futimesat SYS_futimesat 326 +fstatat SYS_fstatat 327 +fstatat64 SYS_fstatat64 SYS_fstatat +unlinkat SYS_unlinkat 328 +renameat SYS_renameat 329 +linkat SYS_linkat 330 +symlinkat SYS_symlinkat 331 +readlinkat SYS_readlinkat 332 +fchmodat SYS_fchmodat 333 +faccessat SYS_faccessat 334 +pselect6 SYS_pselect6 335 +ppoll SYS_ppoll 336 +unshare SYS_unshare 337 +set_robust_list SYS_set_robust_list 338 +get_robust_list SYS_get_robust_list 339 +splice SYS_splice 340 +arm_sync_file_range SYS_arm_sync_file_range 341 +sync_file_range2 SYS_sync_file_range2 __NR_arm_sync_file_range +tee SYS_tee 342 +vmsplice SYS_vmsplice 343 +move_pages SYS_move_pages 344 +getcpu SYS_getcpu 345 +epoll_pwait SYS_epoll_pwait 346 +kexec_load SYS_kexec_load 347 +utimensat SYS_utimensat 348 +signalfd SYS_signalfd 349 +timerfd_create SYS_timerfd_create 350 +eventfd SYS_eventfd 351 +fallocate SYS_fallocate 352 +timerfd_settime SYS_timerfd_settime 353 +timerfd_gettime SYS_timerfd_gettime 354 +signalfd4 SYS_signalfd4 355 +eventfd2 SYS_eventfd2 356 +epoll_create1 SYS_epoll_create1 357 +dup3 SYS_dup3 358 +pipe2 SYS_pipe2 359 +inotify_init1 SYS_inotify_init1 360 +preadv SYS_preadv 361 +pwritev SYS_pwritev 362 +rt_tgsigqueueinfo SYS_rt_tgsigqueueinfo 363 +perf_event_open SYS_perf_event_open 364 +recvmmsg SYS_recvmmsg 365 +accept4 SYS_accept4 366 +fanotify_init SYS_fanotify_init 367 +fanotify_mark SYS_fanotify_mark 368 +prlimit64 SYS_prlimit64 369 +name_to_handle_at SYS_name_to_handle_at 370 +open_by_handle_at SYS_open_by_handle_at 371 +clock_adjtime SYS_clock_adjtime 372 +syncfs SYS_syncfs 373 +sendmmsg SYS_sendmmsg 374 +setns SYS_setns 375 +process_vm_readv SYS_process_vm_readv 376 +process_vm_writev SYS_process_vm_writev 377 +kcmp SYS_kcmp 378 +finit_module SYS_finit_module 379 +sched_setattr SYS_sched_setattr 380 +sched_getattr SYS_sched_getattr 381 +renameat2 SYS_renameat2 382 +seccomp SYS_seccomp 383 +getrandom SYS_getrandom 384 +memfd_create SYS_memfd_create 385 +bpf SYS_bpf 386 +execveat SYS_execveat 387 +userfaultfd SYS_userfaultfd 388 +membarrier SYS_membarrier 389 +mlock2 SYS_mlock2 390 +copy_file_range SYS_copy_file_range 391 +preadv2 SYS_preadv2 392 +pwritev2 SYS_pwritev2 393 +pkey_mprotect SYS_pkey_mprotect 394 +pkey_alloc SYS_pkey_alloc 395 +pkey_free SYS_pkey_free 396 +statx SYS_statx 397 +rseq SYS_rseq 398 +io_pgetevents SYS_io_pgetevents 399 +migrate_pages SYS_migrate_pages 400 +kexec_file_load SYS_kexec_file_load 401 +clock_gettime64 SYS_clock_gettime64 403 +clock_settime64 SYS_clock_settime64 404 +clock_adjtime64 SYS_clock_adjtime64 405 +clock_getres_time64 SYS_clock_getres_time64 406 +clock_nanosleep_time64 SYS_clock_nanosleep_time64 407 +timer_gettime64 SYS_timer_gettime64 408 +timer_settime64 SYS_timer_settime64 409 +timerfd_gettime64 SYS_timerfd_gettime64 410 +timerfd_settime64 SYS_timerfd_settime64 411 +utimensat_time64 SYS_utimensat_time64 412 +pselect6_time64 SYS_pselect6_time64 413 +ppoll_time64 SYS_ppoll_time64 414 +io_pgetevents_time64 SYS_io_pgetevents_time64 416 +recvmmsg_time64 SYS_recvmmsg_time64 417 +mq_timedsend_time64 SYS_mq_timedsend_time64 418 +mq_timedreceive_time64 SYS_mq_timedreceive_time64 419 +semtimedop_time64 SYS_semtimedop_time64 420 +rt_sigtimedwait_time64 SYS_rt_sigtimedwait_time64 421 +futex_time64 SYS_futex_time64 422 +sched_rr_get_interval_time64 SYS_sched_rr_get_interval_time64 423 +pidfd_send_signal SYS_pidfd_send_signal 424 +io_uring_setup SYS_io_uring_setup 425 +io_uring_enter SYS_io_uring_enter 426 +io_uring_register SYS_io_uring_register 427 +open_tree SYS_open_tree 428 +move_mount SYS_move_mount 429 +fsopen SYS_fsopen 430 +fsconfig SYS_fsconfig 431 +fsmount SYS_fsmount 432 +fspick SYS_fspick 433 +pidfd_open SYS_pidfd_open 434 +clone3 SYS_clone3 435 +openat2 SYS_openat2 437 +pidfd_getfd SYS_pidfd_getfd 438 +readdir SYS_readdir 439 +select SYS_select 440 +stime SYS_stime 441 +_assert SYS__assert 442 +boardctl SYS_boardctl 443 +clearenv SYS_clearenv 444 +clock SYS_clock 445 +exec SYS_exec 446 +futimens SYS_futimens 447 +gethostname SYS_gethostname 448 +lchmod SYS_lchmod 449 +lutimens SYS_lutimens 450 +mmap SYS_mmap 451 +mq_close SYS_mq_close 452 +mq_getattr SYS_mq_getattr 453 +mq_receive SYS_mq_receive 454 +mq_send SYS_mq_send 455 +mq_setattr SYS_mq_setattr 456 +posix_spawn SYS_posix_spawn 457 +pread SYS_pread 458 +pselect SYS_pselect 459 +putenv SYS_putenv 460 +pwrite SYS_pwrite 461 +sched_backtrace SYS_sched_backtrace 462 +sched_getcpu SYS_sched_getcpu 463 +sched_lock SYS_sched_lock 464 +sched_lockcount SYS_sched_lockcount 465 +sched_unlock SYS_sched_unlock 466 +setegid SYS_setegid 467 +setenv SYS_setenv 468 +seteuid SYS_seteuid 469 +signal SYS_signal 470 +sigqueue SYS_sigqueue 471 +sigtimedwait SYS_sigtimedwait 472 +sigwaitinfo SYS_sigwaitinfo 473 +shm_open SYS_shm_open 474 +shm_unlink SYS_shm_unlink 475 +task_create SYS_task_create 476 +task_delete SYS_task_delete 477 +task_restart SYS_task_restart 478 +task_spawn SYS_task_spawn 479 +time SYS_time 480 +unsetenv SYS_unsetenv 481 +up_fork SYS_up_fork 482 +utimens SYS_utimens 483 +wait SYS_wait 484 +waitpid SYS_waitpid 485 +ext_alarm SYS_ext_alarm 486 +aio_cancel SYS_aio_cancel 487 +aio_fsync SYS_aio_fsync 488 +aio_read SYS_aio_read 489 +aio_write SYS_aio_write 490 +arc4random_buf SYS_arc4random_buf 491 +insmod SYS_insmod 492 +modhandle SYS_modhandle 493 +rmmod SYS_rmmod 494 diff --git a/testing/ltp/syscalls/regen.sh b/testing/ltp/syscalls/regen.sh new file mode 100644 index 00000000000..1eb30521d42 --- /dev/null +++ b/testing/ltp/syscalls/regen.sh @@ -0,0 +1,147 @@ +#!/bin/sh + +# this file is modified from "include/lapi/syscalls/regen.sh", which is belonged to +# ltp project, and using to generate the syscalls.h file. +# Here we using this bash script to generate the syscalls.h that working with +# NuttX syscall number and interfaces + +output="syscalls.h" +rm -f "${output}".[1-9]* +output_pid="${output}.$$" + +max_jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null) +: ${max_jobs:=1} + +srcdir=${0%/*} + +err() { + echo "$*" 1>&2 + exit 1 +} + +cat << EOF > "${output_pid}" +/************************************************ + * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE * + * change your arch specific .in file instead * + ************************************************/ + +/* + * 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__ + +#include +#include +#include +#include "cleanup.c" + +/* the standard syscall() function interface in Linux platform */ + +int syscall(int syscall_nr, ...); + +/* 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 + */ + +EOF + +jobs=0 + +( +echo "Generating data for NuttX ... " + +( +echo +while read line ; do + set -- ${line} + nr="__NR_$1" + shift + if [ $# -eq 0 ] ; then + err "invalid line found: $line" + fi + echo "#ifndef ${nr}" + echo "# define $*" + echo "# define ${nr} $1" + echo "#endif" +done < "${srcdir}/nuttx.in" +echo +) >> "${output_pid}.nuttx" + +) & + +jobs=$(( jobs + 1 )) +if [ ${jobs} -ge ${max_jobs} ] ; then + wait || exit 1 + jobs=0 +fi + +echo "Generating stub list ... " +( +echo +echo "/* Common stubs */" +echo "#define __LTP__NR_INVALID_SYSCALL -1" >> "${output_pid}" +for nr in $(awk '{print $1}' "${srcdir}/"*.in | sort -u) ; do + nr="__NR_${nr}" + echo "#ifndef ${nr}" + echo "# define ${nr} __LTP__NR_INVALID_SYSCALL" + echo "#endif" +done +echo "#endif" +) >> "${output_pid}._footer" + +wait || exit 1 + +printf "Combining them all ... " +for arch in nuttx _footer ; do + cat "${output_pid}.${arch}" +done >> "${output_pid}" +mv "${output_pid}" "../${output}" +rm -f "${output_pid}"* +echo "OK!" From e6423d04850ea3db1c0694823221b719e046296d Mon Sep 17 00:00:00 2001 From: guoshichao Date: Fri, 24 Jan 2025 10:44:10 +0800 Subject: [PATCH 2/5] testing/ltp: add linux struct loop_info struct definition Define the complete loop_info structure and LOOP_* ioctl command constants in testing/ltp/include/linux/loop.h, matching Linux kernel's loop device interface. This allows LTP loop device testcases to build and execute when NuttX loop device support (CONFIG_DEV_LOOP) is available. Signed-off-by: guoshichao --- testing/ltp/include/linux/loop.h | 48 ++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/testing/ltp/include/linux/loop.h b/testing/ltp/include/linux/loop.h index ca66832343c..74dcb856dd5 100644 --- a/testing/ltp/include/linux/loop.h +++ b/testing/ltp/include/linux/loop.h @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef _LINUX_LOOP_H -#define _LINUX_LOOP_H +#ifndef _LTP_LINUX_LOOP_H +#define _LTP_LINUX_LOOP_H /**************************************************************************** * Included Files @@ -29,4 +29,46 @@ #include -#endif /* _LINUX_LOOP_H */ +/**************************************************************************** + * 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 */ From 58d763d55b1da21c4a2b3a4771fb45cbd899b10b Mon Sep 17 00:00:00 2001 From: guoshichao Date: Thu, 27 Feb 2025 17:29:48 +0800 Subject: [PATCH 3/5] testing/ltp: maintain the lapi/syscalls.h file manually For the NuttX platform, the system call numbers themselves are independent of the architecture(arm/x86/risc-v). Therefore, there is no need to consider the differences between different architectures(arm/x86/risc-v). As a result, we can directly maintain them manually instead of relying on the regen.sh script to generate them dynamically. This makes it easier for maintenance, upgrading, and modification. Signed-off-by: guoshichao --- testing/ltp/CMakeLists.txt | 29 -- testing/ltp/Makefile | 13 - testing/ltp/include/lapi/syscalls.h | 563 ++++++++++++++++++++++++++++ testing/ltp/src/nx_syscall.c | 355 +++++++++--------- testing/ltp/syscalls/nuttx.in | 449 ---------------------- testing/ltp/syscalls/regen.sh | 147 -------- 6 files changed, 741 insertions(+), 815 deletions(-) create mode 100644 testing/ltp/include/lapi/syscalls.h delete mode 100644 testing/ltp/syscalls/nuttx.in delete mode 100644 testing/ltp/syscalls/regen.sh diff --git a/testing/ltp/CMakeLists.txt b/testing/ltp/CMakeLists.txt index 055f8367ed1..73a628910dc 100644 --- a/testing/ltp/CMakeLists.txt +++ b/testing/ltp/CMakeLists.txt @@ -603,34 +603,6 @@ if(CONFIG_TESTING_LTP) ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/lib64.c ${CMAKE_CURRENT_LIST_DIR}/ltp/testcases/kernel/syscalls/nftw/tools64.c) - # to generate the lapi/syscalls.h to handle syscall for NuttX platform - set(LAPI_SYSCALL_FILE ${CMAKE_CURRENT_LIST_DIR}/../syscalls.h) - if(NOT EXISTS ${LAPI_SYSCALL_FILE}) - message( - STATUS - "the ${LAPI_SYSCALL_FILE} do not exist, start to generate at ${CMAKE_CURRENT_LIST_DIR}" - ) - - get_filename_component( - regen_file ${CMAKE_CURRENT_LIST_DIR}/syscalls/regen.sh ABSOLUTE) - set(GEN_SYSCALLS_H_CMD_STR - "bash ${CMAKE_CURRENT_LIST_DIR}/syscalls/regen.sh ${CMAKE_CURRENT_LIST_DIR}/ltp/include/lapi/" - ) - separate_arguments(GEN_SYSCALLS_H_CMD UNIX_COMMAND - ${GEN_SYSCALLS_H_CMD_STR}) - add_custom_command( - OUTPUT ${LAPI_SYSCALL_FILE} - COMMAND ${GEN_SYSCALLS_H_CMD} - COMMAND mv ${CMAKE_CURRENT_LIST_DIR}/../syscalls.h - ${CMAKE_CURRENT_LIST_DIR}/ltp/include/lapi/ - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - DEPENDS ${regen_file} - VERBATIM - COMMENT "LAPI:Gen and Updating ${LAPI_SYSCALL_FILE}") - add_custom_target(GEN_SYSCALLS_H DEPENDS ${LAPI_SYSCALL_FILE}) - add_dependencies(apps_context GEN_SYSCALLS_H) - endif() - add_compile_options( -DHAVE_FCHOWNAT -DMAXPATHLEN=256 @@ -841,7 +813,6 @@ if(CONFIG_TESTING_LTP) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${TESTLINUX_DIR}/include) - include_directories(${TESTLINUX_DIR}/../../../include) include_directories(${TESTLINUX_DIR}/../../include) include_directories(${TESTLINUX_DIR}/syscalls/ptrace) include_directories(${TESTLINUX_DIR}/syscalls/utils) diff --git a/testing/ltp/Makefile b/testing/ltp/Makefile index ef9aa9f1636..c4f9dffa6b4 100644 --- a/testing/ltp/Makefile +++ b/testing/ltp/Makefile @@ -484,14 +484,6 @@ BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/test64.c BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/lib64.c BLACKSRCS += $(TESTLINUX_DIR)/syscalls/nftw/tools64.c - -# to generate the lapi/syscalls.h to handle syscall for nuttx platform -.PHONY: gen_ltp_kernel_syscall -gen_ltp_kernel_syscall: - $(Q) echo "start to generate the ltp/include/lapi/syscalls.h" - $(Q) bash syscalls/regen.sh ltp/include/lapi/ - $(Q) mv ../syscalls.h ltp/include/lapi/ - LTP_LINUX_ORIGS := $(shell find $(TESTLINUX_DIR) -name *.c) ifneq ($(LTP_LINUX_ORIGS),) @@ -610,7 +602,6 @@ 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)/../../include CFLAGS += -I$(TESTLINUX_DIR)/syscalls/ptrace @@ -701,8 +692,4 @@ distclean:: $(Q) rm -rf $(LTP_UNPACK) endif -ifeq ($(CONFIG_TESTING_LTP),y) -context:: gen_ltp_kernel_syscall -endif - include $(APPDIR)/Application.mk 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/src/nx_syscall.c b/testing/ltp/src/nx_syscall.c index 23ca9fefde6..7548d6243f4 100644 --- a/testing/ltp/src/nx_syscall.c +++ b/testing/ltp/src/nx_syscall.c @@ -81,7 +81,7 @@ int syscall(int syscall_nr, ...) va_start(ap, syscall_nr); switch (syscall_nr) { - case SYS__assert: + case __NR__assert: { const char *filename = va_arg(ap, const char *); int linenum = va_arg(ap, int); @@ -92,14 +92,14 @@ int syscall(int syscall_nr, ...) break; } - case SYS__exit: + case __NR_exit: { int status = va_arg(ap, int); _exit(status); break; } - case SYS_accept4: + case __NR_accept4: { int sockfd = va_arg(ap, int); struct sockaddr *addr = va_arg(ap, struct sockaddr *); @@ -110,7 +110,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_CLOCK_TIMEKEEPING) || defined(CONFIG_CLOCK_ADJTIME) - case SYS_adjtime: + case __NR_adjtimex: { const struct timeval *delta = va_arg(ap, const struct timeval *); const struct timeval *olddelta = va_arg(ap, const struct timeval *); @@ -120,7 +120,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_FS_AIO - case SYS_aio_cancel: + case __NR_aio_cancel: { int fildes = va_arg(ap, int); struct aiocb *aiocbp = va_arg(ap, struct aiocb *); @@ -130,7 +130,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_FS_AIO - case SYS_aio_fsync: + case __NR_aio_fsync: { int op = va_arg(ap, int); struct aiocb *aiocbp = va_arg(ap, struct aiocb *); @@ -140,7 +140,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_FS_AIO - case SYS_aio_read: + case __NR_aio_read: { struct aiocb *aiocbp = va_arg(ap, struct aiocb *); ret = aio_read(aiocbp); @@ -149,7 +149,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_FS_AIO - case SYS_aio_write: + case __NR_aio_write: { struct aiocb *aiocbp = va_arg(ap, struct aiocb *); ret = aio_write(aiocbp); @@ -158,7 +158,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_CRYPTO_RANDOM_POOL - case SYS_arc4random_buf: + case __NR_arc4random_buf: { void *buf = va_arg(ap, void *); size_t nbytes = va_arg(ap, size_t); @@ -168,7 +168,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_NET - case SYS_bind: + case __NR_bind: { int sockfd = va_arg(ap, int); const struct sockaddr *addr = va_arg(ap, const struct sockaddr *); @@ -179,7 +179,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_BOARDCTL - case SYS_boardctl: + case __NR_boardctl: { unsigned int cmd = va_arg(ap, unsigned int); uintptr_t arg = va_arg(ap, uintptr_t); @@ -188,7 +188,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_chmod: + case __NR_chmod: { const char *path = va_arg(ap, const char *); mode_t mode = va_arg(ap, mode_t); @@ -196,7 +196,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_chown: + case __NR_chown: { const char *path = va_arg(ap, const char *); uid_t owner = va_arg(ap, uid_t); @@ -206,20 +206,20 @@ int syscall(int syscall_nr, ...) } #ifndef CONFIG_DISABLE_ENVIRON - case SYS_clearenv: + case __NR_clearenv: { ret = clearenv(); break; } #endif - case SYS_clock: + case __NR_clock: { ret = clock(); break; } - case SYS_clock_gettime: + case __NR_clock_gettime: { int clockid = va_arg(ap, int); struct timespec *ts = va_arg(ap, struct timespec *); @@ -227,7 +227,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_clock_nanosleep: + case __NR_clock_nanosleep: { clockid_t clockid = va_arg(ap, clockid_t); int flags = va_arg(ap, int); @@ -237,7 +237,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_clock_settime: + case __NR_clock_settime: { clockid_t clockid = va_arg(ap, clockid_t); struct timespec *ts = va_arg(ap, struct timespec *); @@ -245,7 +245,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_close: + case __NR_close: { int fd = va_arg(ap, int); ret = close(fd); @@ -253,7 +253,7 @@ int syscall(int syscall_nr, ...) } #ifdef CONFIG_NET - case SYS_connect: + case __NR_connect: { int sockfd = va_arg(ap, int); const struct sockaddr *addr = va_arg(ap, const struct sockaddr *); @@ -263,14 +263,14 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_dup: + case __NR_dup: { int fd = va_arg(ap, int); ret = dup(fd); break; } - case SYS_dup2: + case __NR_dup2: { int fd1 = va_arg(ap, int); int fd2 = va_arg(ap, int); @@ -278,14 +278,14 @@ int syscall(int syscall_nr, ...) break; } - case SYS_epoll_create1: + case __NR_epoll_create1: { int flags = va_arg(ap, int); ret = epoll_create1(flags); break; } - case SYS_epoll_ctl: + case __NR_epoll_ctl: { int epfd = va_arg(ap, int); int op = va_arg(ap, int); @@ -295,7 +295,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_epoll_wait: + case __NR_epoll_wait: { int epfd = va_arg(ap, int); struct epoll_event *events = va_arg(ap, struct epoll_event *); @@ -306,7 +306,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_EVENT_FD) - case SYS_eventfd: + case __NR_eventfd: { unsigned int count = va_arg(ap, unsigned int); int flags = va_arg(ap, int); @@ -316,7 +316,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_BINFMT_DISABLE) && !defined(CONFIG_BUILD_KERNEL) - case SYS_exec: + case __NR_exec: { const char *filename = va_arg(ap, const char *); char *const *argv = va_arg(ap, char *const *); @@ -329,7 +329,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS) - case SYS_execve: + case __NR_execve: { const char *path = va_arg(ap, const char *); char *const *argv = va_arg(ap, char *const *); @@ -339,7 +339,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_fchmod: + case __NR_fchmod: { int fd = va_arg(ap, int); mode_t mode = va_arg(ap, mode_t); @@ -347,7 +347,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fchown: + case __NR_fchown: { int fd = va_arg(ap, int); uid_t owner = va_arg(ap, uid_t); @@ -356,14 +356,15 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fdatasync: + case __NR_fdatasync: { int fd = va_arg(ap, int); ret = fdatasync(fd); break; } - case SYS_fstatat: + case __NR_fstatat: + case __NR_fstatat64: { int dirfd = va_arg(ap, int); const char *pathname = va_arg(ap, const char *); @@ -373,7 +374,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fcntl: + case __NR_fcntl: { int fd = va_arg(ap, int); int cmd = va_arg(ap, int); @@ -382,7 +383,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fstat: + case __NR_fstat: { int fd = va_arg(ap, int); struct stat *buf = va_arg(ap, struct stat *); @@ -390,7 +391,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fstatfs: + case __NR_fstatfs: { int fd = va_arg(ap, int); struct statfs *buf = va_arg(ap, struct statfs *); @@ -398,14 +399,14 @@ int syscall(int syscall_nr, ...) break; } - case SYS_fsync: + case __NR_fsync: { int fd = va_arg(ap, int); ret = fsync(fd); break; } - case SYS_ftruncate: + case __NR_ftruncate: { int fd = va_arg(ap, int); off_t length = va_arg(ap, off_t); @@ -413,7 +414,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_futimens: + case __NR_futimens: { int fd = va_arg(ap, int); const struct timespec *times = va_arg(ap, const struct timespec *); @@ -422,7 +423,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_getegid: + case __NR_getegid: { ret = getegid(); break; @@ -430,7 +431,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_geteuid: + case __NR_geteuid: { ret = geteuid(); break; @@ -438,14 +439,14 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_getgid: + case __NR_getgid: { ret = getgid(); break; } #endif - case SYS_gethostname: + case __NR_gethostname: { char *name = va_arg(ap, char *); size_t name_len = va_arg(ap, size_t); @@ -454,7 +455,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_getitimer: + case __NR_getitimer: { int which = va_arg(ap, int); struct itimerval *value = va_arg(ap, struct itimerval *); @@ -464,7 +465,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_getpeername: + case __NR_getpeername: { int sockfd = va_arg(ap, int); struct sockaddr *addr = va_arg(ap, struct sockaddr *); @@ -474,14 +475,14 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_getpid: + case __NR_getpid: { ret = getpid(); break; } #if defined(CONFIG_SCHED_HAVE_PARENT) - case SYS_getppid: + case __NR_getppid: { ret = getppid(); break; @@ -489,7 +490,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_getsockname: + case __NR_getsockname: { int sockfd = va_arg(ap, int); struct sockaddr *addr = va_arg(ap, struct sockaddr *); @@ -500,7 +501,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_getsockopt: + case __NR_getsockopt: { int sockfd = va_arg(ap, int); int level = va_arg(ap, int); @@ -512,13 +513,13 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_gettid: + case __NR_gettid: { ret = gettid(); break; } - case SYS_gettimeofday: + case __NR_gettimeofday: { struct timeval *tv = va_arg(ap, struct timeval *); struct timezone *tz = va_arg(ap, struct timezone *); @@ -527,7 +528,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_getuid: + case __NR_getuid: { ret = getuid(); break; @@ -535,7 +536,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_FS_NOTIFY) - case SYS_inotify_add_watch: + case __NR_inotify_add_watch: { int fd = va_arg(ap, int); const char *pathname = va_arg(ap, const char *); @@ -546,7 +547,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_FS_NOTIFY) - case SYS_inotify_init: + case __NR_inotify_init: { ret = inotify_init(); break; @@ -554,7 +555,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_FS_NOTIFY) - case SYS_inotify_init1: + case __NR_inotify_init1: { int flags = va_arg(ap, int); ret = inotify_init1(flags); @@ -563,7 +564,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_FS_NOTIFY) - case SYS_inotify_rm_watch: + case __NR_inotify_rm_watch: { int fd = va_arg(ap, int); int wd = va_arg(ap, int); @@ -573,7 +574,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MODULE) - case SYS_insmod: + case __NR_insmod: { const char *file_name = va_arg(ap, const char *); const char *mod_name = va_arg(ap, const char *); @@ -582,7 +583,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_ioctl: + case __NR_ioctl: { int fd = va_arg(ap, int); int req = va_arg(ap, int); @@ -591,7 +592,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_kill: + case __NR_kill: { pid_t pid = va_arg(ap, pid_t); int sig = va_arg(ap, int); @@ -599,7 +600,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_lchmod: + case __NR_lchmod: { const char *pathname = va_arg(ap, const char *); mode_t mode = va_arg(ap, mode_t); @@ -607,7 +608,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_lchown: + case __NR_lchown: { const char *path = va_arg(ap, const char *); uid_t owner = va_arg(ap, uid_t); @@ -617,7 +618,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_PSEUDOFS_SOFTLINKS) - case SYS_link: + case __NR_link: { const char *old_path = va_arg(ap, const char *); const char *new_path = va_arg(ap, const char *); @@ -627,7 +628,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_listen: + case __NR_listen: { int sockfd = va_arg(ap, int); int backlog = va_arg(ap, int); @@ -636,7 +637,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_lseek: + case __NR_lseek: { int fd = va_arg(ap, int); off_t offset = va_arg(ap, off_t); @@ -645,7 +646,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_lstat: + case __NR_lstat: { const char *path = va_arg(ap, const char *); struct stat *buf = va_arg(ap, struct stat *); @@ -653,7 +654,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_lutimens: + case __NR_lutimens: { const char *path = va_arg(ap, const char *); const struct timespec *times = va_arg(ap, const struct timespec *); @@ -662,7 +663,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_MOUNTPOINT) - case SYS_mkdir: + case __NR_mkdir: { const char *pathname = va_arg(ap, const char *); mode_t mode = va_arg(ap, mode_t); @@ -671,7 +672,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_mmap: + case __NR_mmap: { void *addr = va_arg(ap, void *); size_t length = va_arg(ap, size_t); @@ -684,7 +685,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_MODULE) - case SYS_modhandle: + case __NR_modhandle: { const char *name = va_arg(ap, const char *); modhandle(name); @@ -693,7 +694,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) - case SYS_mount: + case __NR_mount: { const char *source = va_arg(ap, const char *); const char *target = va_arg(ap, const char *); @@ -706,7 +707,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_close: + case __NR_mq_close: { mqd_t mqdes = va_arg(ap, mqd_t); ret = mq_close(mqdes); @@ -715,7 +716,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_getattr: + case __NR_mq_getattr: { mqd_t mqdes = va_arg(ap, mqd_t); struct mq_attr *attr = va_arg(ap, struct mq_attr *); @@ -725,7 +726,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_notify: + case __NR_mq_notify: { mqd_t mqdes = va_arg(ap, mqd_t); const struct sigevent *notification = @@ -736,7 +737,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_open: + case __NR_mq_open: { const char *name = va_arg(ap, const char *); int oflag = va_arg(ap, int); @@ -748,7 +749,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_receive: + case __NR_mq_receive: { mqd_t mqdes = va_arg(ap, mqd_t); char *msg = va_arg(ap, char *); @@ -760,7 +761,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_send: + case __NR_mq_send: { mqd_t mqdes = va_arg(ap, mqd_t); const char *msg = va_arg(ap, const char *); @@ -772,7 +773,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_setattr: + case __NR_mq_setattr: { mqd_t mqdes = va_arg(ap, mqd_t); const struct mq_attr *newattr = va_arg(ap, const struct mq_attr *); @@ -783,7 +784,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_timedreceive: + case __NR_mq_timedreceive: { mqd_t mqdes = va_arg(ap, mqd_t); char *msg = va_arg(ap, char *); @@ -796,7 +797,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_timedsend: + case __NR_mq_timedsend: { mqd_t mqdes = va_arg(ap, mqd_t); const char *msg = va_arg(ap, const char *); @@ -809,7 +810,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MQUEUE) - case SYS_mq_unlink: + case __NR_mq_unlink: { const char *name = va_arg(ap, const char *); ret = mq_unlink(name); @@ -817,7 +818,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_msync: + case __NR_msync: { void *addr = va_arg(ap, void *); size_t length = va_arg(ap, size_t); @@ -826,7 +827,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_munmap: + case __NR_munmap: { void *addr = va_arg(ap, void *); size_t length = va_arg(ap, size_t); @@ -834,7 +835,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_nanosleep: + case __NR_nanosleep: { const struct timespec *req = va_arg(ap, const struct timespec *); struct timespec *rem = va_arg(ap, struct timespec *); @@ -842,7 +843,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_open: + case __NR_open: { const char *path = va_arg(ap, const char *); int oflags = va_arg(ap, int); @@ -852,7 +853,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_BUILD_KERNEL) - case SYS_pgalloc: + case __NR_pgalloc: { uintptr_t brkaddr = va_arg(ap, uintptr_t); unsigned int npages = va_arg(ap, unsigned int); @@ -862,7 +863,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_PIPES) && CONFIG_DEV_PIPE_SIZE > 0 - case SYS_pipe2: + case __NR_pipe2: { int *pipefd = va_arg(ap, int *); int flags = va_arg(ap, int); @@ -871,7 +872,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_poll: + case __NR_poll: { struct pollfd *fds = va_arg(ap, struct pollfd *); nfds_t nfds = va_arg(ap, nfds_t); @@ -881,7 +882,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_BINFMT_DISABLE) && defined(CONFIG_LIBC_EXECFUNCS) - case SYS_posix_spawn: + case __NR_posix_spawn: { pid_t *pid = va_arg(ap, pid_t *); const char *path = va_arg(ap, const char *); @@ -895,7 +896,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_ppoll: + case __NR_ppoll: { struct pollfd *fds = va_arg(ap, struct pollfd *); nfds_t nfds = va_arg(ap, nfds_t); @@ -906,7 +907,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_prctl: + case __NR_prctl: { int option = va_arg(ap, int); unsigned long arg2 = va_arg(ap, unsigned long); @@ -915,7 +916,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_pread: + case __NR_pread: { int fd = va_arg(ap, int); void *buf = va_arg(ap, void *); @@ -925,7 +926,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_pselect: + case __NR_pselect: { int nfds = va_arg(ap, int); fd_set *readfds = va_arg(ap, fd_set *); @@ -938,7 +939,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_ENVIRON) - case SYS_putenv: + case __NR_putenv: { const char *string = va_arg(ap, const char *); ret = putenv(string); @@ -946,7 +947,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_pwrite: + case __NR_pwrite: { int fd = va_arg(ap, int); const void *buf = va_arg(ap, const void *); @@ -956,7 +957,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_read: + case __NR_read: { int fd = va_arg(ap, int); void *buf = va_arg(ap, void *); @@ -966,7 +967,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_PSEUDOFS_SOFTLINKS) - case SYS_readlink: + case __NR_readlink: { const char *path = va_arg(ap, const char *); char *buf = va_arg(ap, char *); @@ -977,7 +978,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_recv: + case __NR_recv: { int sockfd = va_arg(ap, int); void *buf = va_arg(ap, void *); @@ -989,7 +990,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_recvfrom: + case __NR_recvfrom: { int sockfd = va_arg(ap, int); void *buf = va_arg(ap, void *); @@ -1003,7 +1004,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_recvmsg: + case __NR_recvmsg: { int sockfd = va_arg(ap, int); struct msghdr *msg = va_arg(ap, struct msghdr *); @@ -1013,7 +1014,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_rename: + case __NR_rename: { const char *old_path = va_arg(ap, const char *); const char *new_path = va_arg(ap, const char *); @@ -1022,7 +1023,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_MOUNTPOINT) - case SYS_rmdir: + case __NR_rmdir: { const char *pathname = va_arg(ap, const char *); ret = rmdir(pathname); @@ -1031,7 +1032,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MODULE) - case SYS_rmmod: + case __NR_rmmod: { void *handle = va_arg(ap, void *); ret = rmmod(handle); @@ -1040,7 +1041,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_BACKTRACE) - case SYS_sched_backtrace: + case __NR_sched_backtrace: { pid_t pid = va_arg(ap, int); void **buffer = va_arg(ap, void **); @@ -1051,7 +1052,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sched_getaffinity: + case __NR_sched_getaffinity: { pid_t pid = va_arg(ap, pid_t); size_t cpusetsize = va_arg(ap, size_t); @@ -1060,13 +1061,13 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_getcpu: + case __NR_sched_getcpu: { ret = sched_getcpu(); break; } - case SYS_sched_getparam: + case __NR_sched_getparam: { pid_t pid = va_arg(ap, pid_t); struct sched_param *param = va_arg(ap, struct sched_param *); @@ -1074,26 +1075,26 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_getscheduler: + case __NR_sched_getscheduler: { pid_t pid = va_arg(ap, pid_t); ret = sched_getscheduler(pid); break; } - case SYS_sched_lock: + case __NR_sched_lock: { sched_lock(); break; } - case SYS_sched_lockcount: + case __NR_sched_lockcount: { ret = sched_lockcount(); break; } - case SYS_sched_rr_get_interval: + case __NR_sched_rr_get_interval: { pid_t pid = va_arg(ap, pid_t); struct timespec *interval = va_arg(ap, struct timespec *); @@ -1101,7 +1102,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_setaffinity: + case __NR_sched_setaffinity: { pid_t pid = va_arg(ap, pid_t); size_t cpusetsize = va_arg(ap, size_t); @@ -1110,7 +1111,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_setparam: + case __NR_sched_setparam: { pid_t pid = va_arg(ap, pid_t); struct sched_param *param = va_arg(ap, struct sched_param *); @@ -1118,7 +1119,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_setscheduler: + case __NR_sched_setscheduler: { pid_t pid = va_arg(ap, pid_t); int policy = va_arg(ap, int); @@ -1127,19 +1128,19 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sched_unlock: + case __NR_sched_unlock: { sched_unlock(); break; } - case SYS_sched_yield: + case __NR_sched_yield: { ret = sched_yield(); break; } - case SYS_select: + case __NR_select: { int nfds = va_arg(ap, int); fd_set *readfds = va_arg(ap, fd_set *); @@ -1151,7 +1152,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_NET) - case SYS_send: + case __NR_send: { int sockfd = va_arg(ap, int); const void *buf = va_arg(ap, const void *); @@ -1162,7 +1163,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sendfile: + case __NR_sendfile: { int out_fd = va_arg(ap, int); int in_fd = va_arg(ap, int); @@ -1173,7 +1174,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_NET) - case SYS_sendmsg: + case __NR_sendmsg: { int sockfd = va_arg(ap, int); const struct msghdr *msg = va_arg(ap, const struct msghdr *); @@ -1184,7 +1185,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_sendto: + case __NR_sendto: { int sockfd = va_arg(ap, int); const void *buf = va_arg(ap, const void *); @@ -1198,7 +1199,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_setegid: + case __NR_setegid: { gid_t egid = va_arg(ap, gid_t); ret = setegid(egid); @@ -1207,7 +1208,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_ENVIRON) - case SYS_setenv: + case __NR_setenv: { const char *name = va_arg(ap, const char *); const char *value = va_arg(ap, const char *); @@ -1218,7 +1219,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_seteuid: + case __NR_seteuid: { uid_t euid = va_arg(ap, uid_t); ret = seteuid(euid); @@ -1227,7 +1228,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_setgid: + case __NR_setgid: { gid_t gid = va_arg(ap, gid_t); ret = setgid(gid); @@ -1235,7 +1236,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sethostname: + case __NR_sethostname: { const char *name = va_arg(ap, const char *); size_t len = va_arg(ap, size_t); @@ -1244,7 +1245,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_setitimer: + case __NR_setitimer: { int which = va_arg(ap, int); const struct itimerval *value = va_arg(ap, const struct itimerval *); @@ -1255,7 +1256,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) && defined(CONFIG_NET_SOCKOPTS) - case SYS_setsockopt: + case __NR_setsockopt: { int sockfd = va_arg(ap, int); int level = va_arg(ap, int); @@ -1267,7 +1268,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_settimeofday: + case __NR_settimeofday: { const struct timeval *tv = va_arg(ap, const struct timeval *); const struct timezone *tz = va_arg(ap, const struct timezone *); @@ -1276,7 +1277,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_SCHED_USER_IDENTITY) - case SYS_setuid: + case __NR_setuid: { uid_t euid = va_arg(ap, uid_t); ret = seteuid(euid); @@ -1285,7 +1286,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MM_SHM) - case SYS_shmctl: + case __NR_shmctl: { int shmid = va_arg(ap, int); int cmd = va_arg(ap, int); @@ -1296,7 +1297,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MM_SHM) - case SYS_shmdt: + case __NR_shmdt: { const void *shmaddr = va_arg(ap, const void *); ret = shmdt(shmaddr); @@ -1305,7 +1306,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MM_SHM) - case SYS_shmget: + case __NR_shmget: { key_t key = va_arg(ap, key_t); size_t size = va_arg(ap, size_t); @@ -1316,7 +1317,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_shutdown: + case __NR_shutdown: { int sockfd = va_arg(ap, int); int how = va_arg(ap, int); @@ -1325,7 +1326,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sigaction: + case __NR_sigaction: { int signo = va_arg(ap, int); const struct sigaction *act = va_arg(ap, const struct sigaction *); @@ -1334,7 +1335,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_signal: + case __NR_signal: { int signo = va_arg(ap, int); _sa_handler_t func = va_arg(ap, _sa_handler_t); @@ -1343,7 +1344,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_SIGNAL_FD) - case SYS_signalfd: + case __NR_signalfd: { int fd = va_arg(ap, int); sigset_t *mask = va_arg(ap, sigset_t *); @@ -1353,14 +1354,14 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sigpending: + case __NR_sigpending: { sigset_t *set = va_arg(ap, sigset_t *); ret = sigpending(set); break; } - case SYS_sigprocmask: + case __NR_sigprocmask: { int how = va_arg(ap, int); const sigset_t *set = va_arg(ap, const sigset_t *); @@ -1369,7 +1370,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sigqueue: + case __NR_sigqueue: { int pid = va_arg(ap, int); int signo = va_arg(ap, int); @@ -1378,14 +1379,14 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sigsuspend: + case __NR_sigsuspend: { const sigset_t *mask = va_arg(ap, sigset_t *); ret = sigsuspend(mask); break; } - case SYS_sigtimedwait: + case __NR_sigtimedwait: { const sigset_t *set = va_arg(ap, sigset_t *); struct siginfo *value = va_arg(ap, struct siginfo *); @@ -1394,7 +1395,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_sigwaitinfo: + case __NR_sigwaitinfo: { const sigset_t *set = va_arg(ap, const sigset_t *); struct siginfo *info = va_arg(ap, struct siginfo *); @@ -1403,7 +1404,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_NET) - case SYS_socket: + case __NR_socket: { int domain = va_arg(ap, int); int type = va_arg(ap, int); @@ -1414,7 +1415,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_NET) - case SYS_socketpair: + case __NR_socketpair: { int domain = va_arg(ap, int); int type = va_arg(ap, int); @@ -1425,7 +1426,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_stat: + case __NR_stat: { const char *path = va_arg(ap, const char *); struct stat *buf = va_arg(ap, struct stat *); @@ -1433,7 +1434,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_statfs: + case __NR_statfs: { const char *path = va_arg(ap, const char *); struct statfs *buf = va_arg(ap, struct statfs *); @@ -1442,7 +1443,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_PSEUDOFS_SOFTLINKS) - case SYS_symlink: + case __NR_symlink: { const char *target = va_arg(ap, const char *); const char *linkpath = va_arg(ap, const char *); @@ -1451,14 +1452,14 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sync: + case __NR_sync: { sync(); break; } #if defined(CONFIG_FS_SHMFS) - case SYS_shm_open: + case __NR_shm_open: { const char *name = va_arg(ap, const char *); int oflag = va_arg(ap, int); @@ -1469,7 +1470,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_FS_SHMFS) - case SYS_shm_unlink: + case __NR_shm_unlink: { const char *name = va_arg(ap, const char *); ret = shm_unlink(name); @@ -1478,7 +1479,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_MM_SHM) - case SYS_shmat: + case __NR_shmat: { int shmid = va_arg(ap, int); const void *shmaddr = va_arg(ap, const void *); @@ -1493,7 +1494,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_sysinfo: + case __NR_sysinfo: { struct sysinfo *info = va_arg(ap, struct sysinfo *); ret = sysinfo(info); @@ -1501,7 +1502,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_BUILD_KERNEL) - case SYS_task_create: + case __NR_task_create: { const char *name = va_arg(ap, const char *); int priority = va_arg(ap, int); @@ -1514,7 +1515,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_BUILD_KERNEL) - case SYS_task_delete: + case __NR_task_delete: { pid_t pid = va_arg(ap, pid_t); ret = task_delete(pid); @@ -1523,7 +1524,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_BUILD_KERNEL) - case SYS_task_restart: + case __NR_task_restart: { pid_t pid = va_arg(ap, pid_t); ret = task_restart(pid); @@ -1532,7 +1533,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_BUILD_KERNEL) - case SYS_task_spawn: + case __NR_task_spawn: { const char *path = va_arg(ap, const char *); main_t entry = va_arg(ap, main_t); @@ -1546,7 +1547,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_tgkill: + case __NR_tgkill: { pid_t pid = va_arg(ap, pid_t); pid_t tid = va_arg(ap, pid_t); @@ -1555,7 +1556,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_time: + case __NR_time: { time_t *timep = va_arg(ap, time_t *); ret = time(timep); @@ -1563,7 +1564,7 @@ int syscall(int syscall_nr, ...) } #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_timer_create: + case __NR_timer_create: { int clockid = va_arg(ap, int); struct sigevent *sevp = va_arg(ap, struct sigevent *); @@ -1574,7 +1575,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_timer_delete: + case __NR_timer_delete: { timer_t timerid = va_arg(ap, timer_t); ret = timer_delete(timerid); @@ -1583,7 +1584,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_timer_getoverrun: + case __NR_timer_getoverrun: { timer_t timerid = va_arg(ap, timer_t); ret = timer_getoverrun(timerid); @@ -1592,7 +1593,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_timer_gettime: + case __NR_timer_gettime: { int clockid = va_arg(ap, int); struct itimerspec *curr_value = va_arg(ap, struct itimerspec *); @@ -1602,7 +1603,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_POSIX_TIMERS) - case SYS_timer_settime: + case __NR_timer_settime: { int clockid = va_arg(ap, int); int flags = va_arg(ap, int); @@ -1615,7 +1616,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_TIMER_FD) - case SYS_timerfd_create: + case __NR_timerfd_create: { int clockid = va_arg(ap, int); int flags = va_arg(ap, int); @@ -1625,7 +1626,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_TIMER_FD) - case SYS_timerfd_gettime: + case __NR_timerfd_gettime: { int fd = va_arg(ap, int); struct itimerspec *curr_value = va_arg(ap, struct itimerspec *); @@ -1635,7 +1636,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_TIMER_FD) - case SYS_timerfd_settime: + case __NR_timerfd_settime: { int fd = va_arg(ap, int); int flags = va_arg(ap, int); @@ -1648,7 +1649,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) - case SYS_umount2: + case __NR_umount2: { const char *target = va_arg(ap, const char *); unsigned int flags = va_arg(ap, unsigned int); @@ -1658,7 +1659,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_MOUNTPOINT) - case SYS_unlink: + case __NR_unlink: { const char *pathname = va_arg(ap, const char *); ret = unlink(pathname); @@ -1667,7 +1668,7 @@ int syscall(int syscall_nr, ...) #endif #if !defined(CONFIG_DISABLE_ENVIRON) - case SYS_unsetenv: + case __NR_unsetenv: { const char *name = va_arg(ap, const char *); ret = unsetenv(name); @@ -1675,13 +1676,13 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_up_fork: + case __NR_up_fork: { ret = up_fork(); break; } - case SYS_utimens: + case __NR_utimens: { const char *path = va_arg(ap, const char *); const struct timespec *times = va_arg(ap, const struct timespec *); @@ -1690,7 +1691,7 @@ int syscall(int syscall_nr, ...) } #if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) - case SYS_wait: + case __NR_wait: { int *stat_loc = va_arg(ap, int *); ret = wait(stat_loc); @@ -1699,7 +1700,7 @@ int syscall(int syscall_nr, ...) #endif #if defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT) - case SYS_waitid: + case __NR_waitid: { idtype_t idtype = (int) va_arg(ap, int); id_t id = va_arg(ap, id_t); @@ -1711,7 +1712,7 @@ int syscall(int syscall_nr, ...) #endif #ifdef CONFIG_SCHED_WAITPID - case SYS_waitpid: + case __NR_waitpid: { pid_t pid = va_arg(ap, pid_t); int *stat_loc = va_arg(ap, int *); @@ -1721,7 +1722,7 @@ int syscall(int syscall_nr, ...) } #endif - case SYS_write: + case __NR_write: { int fd = va_arg(ap, int); const void *buf = va_arg(ap, const void *); @@ -1730,7 +1731,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_futex: + case __NR_futex: { /* nuttx do not support futex */ @@ -1738,7 +1739,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_clock_getres: + case __NR_clock_getres: { clockid_t clockid = va_arg(ap, clockid_t); struct timespec *res = va_arg(ap, struct timespec *); @@ -1746,7 +1747,7 @@ int syscall(int syscall_nr, ...) break; } - case SYS_ext_alarm: + case __NR_ext_alarm: { unsigned int seconds = va_arg(ap, unsigned int); ret = alarm(seconds); diff --git a/testing/ltp/syscalls/nuttx.in b/testing/ltp/syscalls/nuttx.in deleted file mode 100644 index 5816b6d0975..00000000000 --- a/testing/ltp/syscalls/nuttx.in +++ /dev/null @@ -1,449 +0,0 @@ -exit SYS__exit 1 -fork SYS_fork 2 -read SYS_read 3 -write SYS_write 4 -open SYS_open 5 -close SYS_close 6 -creat SYS_creat 8 -link SYS_link 9 -unlink SYS_unlink 10 -execve SYS_execve 11 -chdir SYS_chdir 12 -mknod SYS_mknod 14 -chmod SYS_chmod 15 -lchown SYS_lchown 16 -lseek SYS_lseek 19 -getpid SYS_getpid 20 -mount SYS_mount 21 -setuid SYS_setuid 23 -getuid SYS_getuid 24 -ptrace SYS_ptrace 26 -pause SYS_pause 29 -access SYS_access 33 -nice SYS_nice 34 -sync SYS_sync 36 -kill SYS_kill 37 -rename SYS_rename 38 -mkdir SYS_mkdir 39 -rmdir SYS_rmdir 40 -dup SYS_dup 41 -pipe SYS_pipe 42 -times SYS_times 43 -brk SYS_brk 45 -setgid SYS_setgid 46 -getgid SYS_getgid 47 -geteuid SYS_geteuid 49 -getegid SYS_getegid 50 -acct SYS_acct 51 -umount2 SYS_umount2 52 -ioctl SYS_ioctl 54 -fcntl SYS_fcntl 55 -setpgid SYS_setpgid 57 -umask SYS_umask 60 -chroot SYS_chroot 61 -ustat SYS_ustat 62 -dup2 SYS_dup2 63 -getppid SYS_getppid 64 -getpgrp SYS_getpgrp 65 -setsid SYS_setsid 66 -sigaction SYS_sigaction 67 -setreuid SYS_setreuid 70 -setregid SYS_setregid 71 -sigsuspend SYS_sigsuspend 72 -sigpending SYS_sigpending 73 -sethostname SYS_sethostname 74 -setrlimit SYS_setrlimit 75 -getrusage SYS_getrusage 77 -gettimeofday SYS_gettimeofday 78 -settimeofday SYS_settimeofday 79 -getgroups SYS_getgroups 80 -setgroups SYS_setgroups 81 -symlink SYS_symlink 83 -readlink SYS_readlink 85 -uselib SYS_uselib 86 -swapon SYS_swapon 87 -reboot SYS_reboot 88 -munmap SYS_munmap 91 -truncate SYS_truncate 92 -ftruncate SYS_ftruncate 93 -fchmod SYS_fchmod 94 -fchown SYS_fchown 95 -getpriority SYS_getpriority 96 -setpriority SYS_setpriority 97 -statfs SYS_statfs 99 -fstatfs SYS_fstatfs 100 -syslog SYS_syslog 103 -setitimer SYS_setitimer 104 -getitimer SYS_getitimer 105 -stat SYS_stat 106 -lstat SYS_lstat 107 -fstat SYS_fstat 108 -vhangup SYS_vhangup 111 -wait4 SYS_wait4 114 -swapoff SYS_swapoff 115 -sysinfo SYS_sysinfo 116 -fsync SYS_fsync 118 -sigreturn SYS_sigreturn 119 -clone SYS_clone 120 -setdomainname SYS_setdomainname 121 -uname SYS_uname 122 -adjtimex SYS_adjtimex 124 -mprotect SYS_mprotect 125 -sigprocmask SYS_sigprocmask 126 -init_module SYS_init_module 128 -delete_module SYS_delete_module 129 -quotactl SYS_quotactl 131 -getpgid SYS_getpgid 132 -fchdir SYS_fchdir 133 -bdflush SYS_bdflush 134 -sysfs SYS_sysfs 135 -personality SYS_personality 136 -setfsuid SYS_setfsuid 138 -setfsgid SYS_setfsgid 139 -_llseek SYS__llseek 140 -getdents SYS_getdents 141 -_newselect SYS__newselect 142 -flock SYS_flock 143 -msync SYS_msync 144 -readv SYS_readv 145 -writev SYS_writev 146 -getsid SYS_getsid 147 -fdatasync SYS_fdatasync 148 -_sysctl SYS__sysctl 149 -mlock SYS_mlock 150 -munlock SYS_munlock 151 -mlockall SYS_mlockall 152 -munlockall SYS_munlockall 153 -sched_setparam SYS_sched_setparam 154 -sched_getparam SYS_sched_getparam 155 -sched_setscheduler SYS_sched_setscheduler 156 -sched_getscheduler SYS_sched_getscheduler 157 -sched_yield SYS_sched_yield 158 -sched_get_priority_max SYS_sched_get_priority_max 159 -sched_get_priority_min SYS_sched_get_priority_min 160 -sched_rr_get_interval SYS_sched_rr_get_interval 161 -nanosleep SYS_nanosleep 162 -mremap SYS_mremap 163 -setresuid SYS_setresuid 164 -getresuid SYS_getresuid 165 -poll SYS_poll 168 -nfsservctl SYS_nfsservctl 169 -setresgid SYS_setresgid 170 -getresgid SYS_getresgid 171 -prctl SYS_prctl 172 -rt_sigreturn SYS_rt_sigreturn 173 -rt_sigaction SYS_rt_sigaction 174 -rt_sigprocmask SYS_rt_sigprocmask 175 -rt_sigpending SYS_rt_sigpending 176 -rt_sigtimedwait SYS_rt_sigtimedwait 177 -rt_sigqueueinfo SYS_rt_sigqueueinfo 178 -rt_sigsuspend SYS_rt_sigsuspend 179 -pread64 SYS_pread64 180 -pwrite64 SYS_pwrite64 181 -chown SYS_chown 182 -getcwd SYS_getcwd 183 -capget SYS_capget 184 -capset SYS_capset 185 -sigaltstack SYS_sigaltstack 186 -sendfile SYS_sendfile 187 -vfork SYS_vfork 190 -getrlimit SYS_getrlimit 191 -ugetrlimit SYS_ugetrlimit SYS_getrlimit -mmap2 SYS_mmap2 192 -truncate64 SYS_truncate64 193 -ftruncate64 SYS_ftruncate64 194 -stat64 SYS_stat64 195 -lstat64 SYS_lstat64 196 -fstat64 SYS_fstat64 197 -lchown32 SYS_lchown32 198 -getuid32 SYS_getuid32 199 -getgid32 SYS_getgid32 200 -geteuid32 SYS_geteuid32 201 -getegid32 SYS_getegid32 202 -setreuid32 SYS_setreuid32 203 -setregid32 SYS_setregid32 204 -getgroups32 SYS_getgroups32 205 -setgroups32 SYS_setgroups32 206 -fchown32 SYS_fchown32 207 -setresuid32 SYS_setresuid32 208 -getresuid32 SYS_getresuid32 209 -setresgid32 SYS_setresgid32 210 -getresgid32 SYS_getresgid32 211 -chown32 SYS_chown32 212 -setuid32 SYS_setuid32 213 -setgid32 SYS_setgid32 214 -setfsuid32 SYS_setfsuid32 215 -setfsgid32 SYS_setfsgid32 216 -getdents64 SYS_getdents64 217 -pivot_root SYS_pivot_root 218 -mincore SYS_mincore 219 -madvise SYS_madvise 220 -fcntl64 SYS_fcntl64 221 -gettid SYS_gettid 224 -readahead SYS_readahead 225 -setxattr SYS_setxattr 226 -lsetxattr SYS_lsetxattr 227 -fsetxattr SYS_fsetxattr 228 -getxattr SYS_getxattr 229 -lgetxattr SYS_lgetxattr 230 -fgetxattr SYS_fgetxattr 231 -listxattr SYS_listxattr 232 -llistxattr SYS_llistxattr 233 -flistxattr SYS_flistxattr 234 -removexattr SYS_removexattr 235 -lremovexattr SYS_lremovexattr 236 -fremovexattr SYS_fremovexattr 237 -tkill SYS_tkill 238 -sendfile64 SYS_sendfile64 239 -futex SYS_futex 240 -sched_setaffinity SYS_sched_setaffinity 241 -sched_getaffinity SYS_sched_getaffinity 242 -io_setup SYS_io_setup 243 -io_destroy SYS_io_destroy 244 -io_getevents SYS_io_getevents 245 -io_submit SYS_io_submit 246 -io_cancel SYS_io_cancel 247 -exit_group SYS_exit_group 248 -lookup_dcookie SYS_lookup_dcookie 249 -epoll_create SYS_epoll_create 250 -epoll_ctl SYS_epoll_ctl 251 -epoll_wait SYS_epoll_wait 252 -remap_file_pages SYS_remap_file_pages 253 -set_tid_address SYS_set_tid_address 256 -timer_create SYS_timer_create 257 -timer_settime SYS_timer_settime 258 -timer_gettime SYS_timer_gettime 259 -timer_getoverrun SYS_timer_getoverrun 260 -timer_delete SYS_timer_delete 261 -clock_settime SYS_clock_settime 262 -clock_gettime SYS_clock_gettime 263 -clock_getres SYS_clock_getres 264 -clock_nanosleep SYS_clock_nanosleep 265 -statfs64 SYS_statfs64 266 -fstatfs64 SYS_fstatfs64 267 -tgkill SYS_tgkill 268 -utimes SYS_utimes 269 -arm_fadvise64_64 SYS_arm_fadvise64_64 270 -pciconfig_iobase SYS_pciconfig_iobase 271 -pciconfig_read SYS_pciconfig_read 272 -pciconfig_write SYS_pciconfig_write 273 -mq_open SYS_mq_open 274 -mq_unlink SYS_mq_unlink 275 -mq_timedsend SYS_mq_timedsend 276 -mq_timedreceive SYS_mq_timedreceive 277 -mq_notify SYS_mq_notify 278 -mq_getsetattr SYS_mq_getsetattr 279 -waitid SYS_waitid 280 -socket SYS_socket 281 -bind SYS_bind 282 -connect SYS_connect 283 -listen SYS_listen 284 -accept SYS_accept 285 -getsockname SYS_getsockname 286 -getpeername SYS_getpeername 287 -socketpair SYS_socketpair 288 -send SYS_send 289 -sendto SYS_sendto 290 -recv SYS_recv 291 -recvfrom SYS_recvfrom 292 -shutdown SYS_shutdown 293 -setsockopt SYS_setsockopt 294 -getsockopt SYS_getsockopt 295 -sendmsg SYS_sendmsg 296 -recvmsg SYS_recvmsg 297 -semop SYS_semop 298 -semget SYS_semget 299 -semctl SYS_semctl 300 -msgsnd SYS_msgsnd 301 -msgrcv SYS_msgrcv 302 -msgget SYS_msgget 303 -msgctl SYS_msgctl 304 -shmat SYS_shmat 305 -shmdt SYS_shmdt 306 -shmget SYS_shmget 307 -shmctl SYS_shmctl 308 -add_key SYS_add_key 309 -request_key SYS_request_key 310 -keyctl SYS_keyctl 311 -semtimedop SYS_semtimedop 312 -vserver SYS_vserver 313 -ioprio_set SYS_ioprio_set 314 -ioprio_get SYS_ioprio_get 315 -inotify_init SYS_inotify_init 316 -inotify_add_watch SYS_inotify_add_watch 317 -inotify_rm_watch SYS_inotify_rm_watch 318 -mbind SYS_mbind 319 -get_mempolicy SYS_get_mempolicy 320 -set_mempolicy SYS_set_mempolicy 321 -openat SYS_openat 322 -mkdirat SYS_mkdirat 323 -mknodat SYS_mknodat 324 -fchownat SYS_fchownat 325 -futimesat SYS_futimesat 326 -fstatat SYS_fstatat 327 -fstatat64 SYS_fstatat64 SYS_fstatat -unlinkat SYS_unlinkat 328 -renameat SYS_renameat 329 -linkat SYS_linkat 330 -symlinkat SYS_symlinkat 331 -readlinkat SYS_readlinkat 332 -fchmodat SYS_fchmodat 333 -faccessat SYS_faccessat 334 -pselect6 SYS_pselect6 335 -ppoll SYS_ppoll 336 -unshare SYS_unshare 337 -set_robust_list SYS_set_robust_list 338 -get_robust_list SYS_get_robust_list 339 -splice SYS_splice 340 -arm_sync_file_range SYS_arm_sync_file_range 341 -sync_file_range2 SYS_sync_file_range2 __NR_arm_sync_file_range -tee SYS_tee 342 -vmsplice SYS_vmsplice 343 -move_pages SYS_move_pages 344 -getcpu SYS_getcpu 345 -epoll_pwait SYS_epoll_pwait 346 -kexec_load SYS_kexec_load 347 -utimensat SYS_utimensat 348 -signalfd SYS_signalfd 349 -timerfd_create SYS_timerfd_create 350 -eventfd SYS_eventfd 351 -fallocate SYS_fallocate 352 -timerfd_settime SYS_timerfd_settime 353 -timerfd_gettime SYS_timerfd_gettime 354 -signalfd4 SYS_signalfd4 355 -eventfd2 SYS_eventfd2 356 -epoll_create1 SYS_epoll_create1 357 -dup3 SYS_dup3 358 -pipe2 SYS_pipe2 359 -inotify_init1 SYS_inotify_init1 360 -preadv SYS_preadv 361 -pwritev SYS_pwritev 362 -rt_tgsigqueueinfo SYS_rt_tgsigqueueinfo 363 -perf_event_open SYS_perf_event_open 364 -recvmmsg SYS_recvmmsg 365 -accept4 SYS_accept4 366 -fanotify_init SYS_fanotify_init 367 -fanotify_mark SYS_fanotify_mark 368 -prlimit64 SYS_prlimit64 369 -name_to_handle_at SYS_name_to_handle_at 370 -open_by_handle_at SYS_open_by_handle_at 371 -clock_adjtime SYS_clock_adjtime 372 -syncfs SYS_syncfs 373 -sendmmsg SYS_sendmmsg 374 -setns SYS_setns 375 -process_vm_readv SYS_process_vm_readv 376 -process_vm_writev SYS_process_vm_writev 377 -kcmp SYS_kcmp 378 -finit_module SYS_finit_module 379 -sched_setattr SYS_sched_setattr 380 -sched_getattr SYS_sched_getattr 381 -renameat2 SYS_renameat2 382 -seccomp SYS_seccomp 383 -getrandom SYS_getrandom 384 -memfd_create SYS_memfd_create 385 -bpf SYS_bpf 386 -execveat SYS_execveat 387 -userfaultfd SYS_userfaultfd 388 -membarrier SYS_membarrier 389 -mlock2 SYS_mlock2 390 -copy_file_range SYS_copy_file_range 391 -preadv2 SYS_preadv2 392 -pwritev2 SYS_pwritev2 393 -pkey_mprotect SYS_pkey_mprotect 394 -pkey_alloc SYS_pkey_alloc 395 -pkey_free SYS_pkey_free 396 -statx SYS_statx 397 -rseq SYS_rseq 398 -io_pgetevents SYS_io_pgetevents 399 -migrate_pages SYS_migrate_pages 400 -kexec_file_load SYS_kexec_file_load 401 -clock_gettime64 SYS_clock_gettime64 403 -clock_settime64 SYS_clock_settime64 404 -clock_adjtime64 SYS_clock_adjtime64 405 -clock_getres_time64 SYS_clock_getres_time64 406 -clock_nanosleep_time64 SYS_clock_nanosleep_time64 407 -timer_gettime64 SYS_timer_gettime64 408 -timer_settime64 SYS_timer_settime64 409 -timerfd_gettime64 SYS_timerfd_gettime64 410 -timerfd_settime64 SYS_timerfd_settime64 411 -utimensat_time64 SYS_utimensat_time64 412 -pselect6_time64 SYS_pselect6_time64 413 -ppoll_time64 SYS_ppoll_time64 414 -io_pgetevents_time64 SYS_io_pgetevents_time64 416 -recvmmsg_time64 SYS_recvmmsg_time64 417 -mq_timedsend_time64 SYS_mq_timedsend_time64 418 -mq_timedreceive_time64 SYS_mq_timedreceive_time64 419 -semtimedop_time64 SYS_semtimedop_time64 420 -rt_sigtimedwait_time64 SYS_rt_sigtimedwait_time64 421 -futex_time64 SYS_futex_time64 422 -sched_rr_get_interval_time64 SYS_sched_rr_get_interval_time64 423 -pidfd_send_signal SYS_pidfd_send_signal 424 -io_uring_setup SYS_io_uring_setup 425 -io_uring_enter SYS_io_uring_enter 426 -io_uring_register SYS_io_uring_register 427 -open_tree SYS_open_tree 428 -move_mount SYS_move_mount 429 -fsopen SYS_fsopen 430 -fsconfig SYS_fsconfig 431 -fsmount SYS_fsmount 432 -fspick SYS_fspick 433 -pidfd_open SYS_pidfd_open 434 -clone3 SYS_clone3 435 -openat2 SYS_openat2 437 -pidfd_getfd SYS_pidfd_getfd 438 -readdir SYS_readdir 439 -select SYS_select 440 -stime SYS_stime 441 -_assert SYS__assert 442 -boardctl SYS_boardctl 443 -clearenv SYS_clearenv 444 -clock SYS_clock 445 -exec SYS_exec 446 -futimens SYS_futimens 447 -gethostname SYS_gethostname 448 -lchmod SYS_lchmod 449 -lutimens SYS_lutimens 450 -mmap SYS_mmap 451 -mq_close SYS_mq_close 452 -mq_getattr SYS_mq_getattr 453 -mq_receive SYS_mq_receive 454 -mq_send SYS_mq_send 455 -mq_setattr SYS_mq_setattr 456 -posix_spawn SYS_posix_spawn 457 -pread SYS_pread 458 -pselect SYS_pselect 459 -putenv SYS_putenv 460 -pwrite SYS_pwrite 461 -sched_backtrace SYS_sched_backtrace 462 -sched_getcpu SYS_sched_getcpu 463 -sched_lock SYS_sched_lock 464 -sched_lockcount SYS_sched_lockcount 465 -sched_unlock SYS_sched_unlock 466 -setegid SYS_setegid 467 -setenv SYS_setenv 468 -seteuid SYS_seteuid 469 -signal SYS_signal 470 -sigqueue SYS_sigqueue 471 -sigtimedwait SYS_sigtimedwait 472 -sigwaitinfo SYS_sigwaitinfo 473 -shm_open SYS_shm_open 474 -shm_unlink SYS_shm_unlink 475 -task_create SYS_task_create 476 -task_delete SYS_task_delete 477 -task_restart SYS_task_restart 478 -task_spawn SYS_task_spawn 479 -time SYS_time 480 -unsetenv SYS_unsetenv 481 -up_fork SYS_up_fork 482 -utimens SYS_utimens 483 -wait SYS_wait 484 -waitpid SYS_waitpid 485 -ext_alarm SYS_ext_alarm 486 -aio_cancel SYS_aio_cancel 487 -aio_fsync SYS_aio_fsync 488 -aio_read SYS_aio_read 489 -aio_write SYS_aio_write 490 -arc4random_buf SYS_arc4random_buf 491 -insmod SYS_insmod 492 -modhandle SYS_modhandle 493 -rmmod SYS_rmmod 494 diff --git a/testing/ltp/syscalls/regen.sh b/testing/ltp/syscalls/regen.sh deleted file mode 100644 index 1eb30521d42..00000000000 --- a/testing/ltp/syscalls/regen.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/sh - -# this file is modified from "include/lapi/syscalls/regen.sh", which is belonged to -# ltp project, and using to generate the syscalls.h file. -# Here we using this bash script to generate the syscalls.h that working with -# NuttX syscall number and interfaces - -output="syscalls.h" -rm -f "${output}".[1-9]* -output_pid="${output}.$$" - -max_jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null) -: ${max_jobs:=1} - -srcdir=${0%/*} - -err() { - echo "$*" 1>&2 - exit 1 -} - -cat << EOF > "${output_pid}" -/************************************************ - * GENERATED FILE: DO NOT EDIT/PATCH THIS FILE * - * change your arch specific .in file instead * - ************************************************/ - -/* - * 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__ - -#include -#include -#include -#include "cleanup.c" - -/* the standard syscall() function interface in Linux platform */ - -int syscall(int syscall_nr, ...); - -/* 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 - */ - -EOF - -jobs=0 - -( -echo "Generating data for NuttX ... " - -( -echo -while read line ; do - set -- ${line} - nr="__NR_$1" - shift - if [ $# -eq 0 ] ; then - err "invalid line found: $line" - fi - echo "#ifndef ${nr}" - echo "# define $*" - echo "# define ${nr} $1" - echo "#endif" -done < "${srcdir}/nuttx.in" -echo -) >> "${output_pid}.nuttx" - -) & - -jobs=$(( jobs + 1 )) -if [ ${jobs} -ge ${max_jobs} ] ; then - wait || exit 1 - jobs=0 -fi - -echo "Generating stub list ... " -( -echo -echo "/* Common stubs */" -echo "#define __LTP__NR_INVALID_SYSCALL -1" >> "${output_pid}" -for nr in $(awk '{print $1}' "${srcdir}/"*.in | sort -u) ; do - nr="__NR_${nr}" - echo "#ifndef ${nr}" - echo "# define ${nr} __LTP__NR_INVALID_SYSCALL" - echo "#endif" -done -echo "#endif" -) >> "${output_pid}._footer" - -wait || exit 1 - -printf "Combining them all ... " -for arch in nuttx _footer ; do - cat "${output_pid}.${arch}" -done >> "${output_pid}" -mv "${output_pid}" "../${output}" -rm -f "${output_pid}"* -echo "OK!" From 6c0d60e25bfe60268e7cc3ad4f02a24e2b210d08 Mon Sep 17 00:00:00 2001 From: guoshichao Date: Tue, 4 Mar 2025 16:36:30 +0800 Subject: [PATCH 4/5] ltp/kernel: fix kernel testcases report error on tst_exit() for kernel testcases that using main() method to execute, when invoke tst_exit() on execute finished, will report " executed from newlib!" error, this is caused by two kinds kernel testcases are forbidded linked together, in Linux this is OK, but for NuttX, this is necssary, so we choose to modify the NO_NEWLIB_ASSERT macro's implementation, thus to make kernel testcases can work in NuttX Signed-off-by: guoshichao --- testing/ltp/include/ltp_priv.h | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 testing/ltp/include/ltp_priv.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 */ From c8175c8510988f1b3e8b5d7e23fd6e3c3ccdc5f1 Mon Sep 17 00:00:00 2001 From: guoshichao Date: Mon, 14 Jul 2025 16:31:43 +0800 Subject: [PATCH 5/5] testing/ltp: fix the symbol redefinition link error blacklist nftw64 to resolve symbol duplication errors, the following are the detailed link error info: ``` /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.next_fd+0x0): multiple definition of `__odr_asan.next_fd'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.next_fd+0x0): first defined here /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.visit+0x0): multiple definition of `__odr_asan.visit'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.visit+0x0): first defined here /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.dirlist+0x0): multiple definition of `__odr_asan.dirlist'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.dirlist+0x0): first defined here /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.ebuf+0x0): multiple definition of `__odr_asan.ebuf'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.ebuf+0x0): first defined here /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.s2+0x0): multiple definition of `__odr_asan.s2'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.s2+0x0): first defined here /usr/bin/ld: /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw64.a(nftw64.c.o):(.bss.__odr_asan.temp+0x0): multiple definition of `__odr_asan.temp'; /home/testing/vela/cmake_out/vela_vela/apps/testing/ltp/libapps_ltp_syscalls_nftw_nftw.a(nftw.c.o):(.bss.__odr_asan.temp+0x0): first defined here ``` Signed-off-by: guoshichao --- testing/ltp/CMakeLists.txt | 2 +- testing/ltp/Makefile | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/ltp/CMakeLists.txt b/testing/ltp/CMakeLists.txt index 73a628910dc..0ce70078d94 100644 --- a/testing/ltp/CMakeLists.txt +++ b/testing/ltp/CMakeLists.txt @@ -581,7 +581,7 @@ if(CONFIG_TESTING_LTP) "open_kconfig" "close_kconfig" "firmware" # nuttx do not support linux firmware load framework - ) + "nftw64") list( APPEND diff --git a/testing/ltp/Makefile b/testing/ltp/Makefile index c4f9dffa6b4..47db5a57af4 100644 --- a/testing/ltp/Makefile +++ b/testing/ltp/Makefile @@ -470,6 +470,7 @@ 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