Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux_kselftest-nolibc-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull nolibc updates from Shuah Khan:

- add support for waitid()

- use waitid() over waitpid()

- use a pipe in vfprintf tests

- skip tests for unimplemented syscalls

- rename riscv to riscv64

- add configurations for riscv32

- add detecting missing toolchain to run-tests.sh

* tag 'linux_kselftest-nolibc-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/nolibc: add configurations for riscv32
selftests/nolibc: rename riscv to riscv64
selftests/nolibc: skip tests for unimplemented syscalls
selftests/nolibc: use a pipe to in vfprintf tests
selftests/nolibc: use waitid() over waitpid()
tools/nolibc: add support for waitid()
selftests/nolibc: run-tests.sh: detect missing toolchain

+63 -19
+18
tools/include/nolibc/sys.h
··· 23 23 #include <linux/prctl.h> 24 24 #include <linux/resource.h> 25 25 #include <linux/utsname.h> 26 + #include <linux/signal.h> 26 27 27 28 #include "arch.h" 28 29 #include "errno.h" ··· 1223 1222 pid_t waitpid(pid_t pid, int *status, int options) 1224 1223 { 1225 1224 return __sysret(sys_wait4(pid, status, options, NULL)); 1225 + } 1226 + 1227 + 1228 + /* 1229 + * int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); 1230 + */ 1231 + 1232 + static __attribute__((unused)) 1233 + int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage) 1234 + { 1235 + return my_syscall5(__NR_waitid, which, pid, infop, options, rusage); 1236 + } 1237 + 1238 + static __attribute__((unused)) 1239 + int waitid(int which, pid_t pid, siginfo_t *infop, int options) 1240 + { 1241 + return __sysret(sys_waitid(which, pid, infop, options, NULL)); 1226 1242 } 1227 1243 1228 1244
+11
tools/testing/selftests/nolibc/Makefile
··· 43 43 # configure default variants for target kernel supported architectures 44 44 XARCH_powerpc = ppc 45 45 XARCH_mips = mips32le 46 + XARCH_riscv = riscv64 46 47 XARCH = $(or $(XARCH_$(ARCH)),$(ARCH)) 47 48 48 49 # map from user input variants to their kernel supported architectures ··· 52 51 ARCH_ppc64le = powerpc 53 52 ARCH_mips32le = mips 54 53 ARCH_mips32be = mips 54 + ARCH_riscv32 = riscv 55 + ARCH_riscv64 = riscv 55 56 ARCH := $(or $(ARCH_$(XARCH)),$(XARCH)) 56 57 57 58 # kernel image names by architecture ··· 68 65 IMAGE_ppc64 = vmlinux 69 66 IMAGE_ppc64le = arch/powerpc/boot/zImage 70 67 IMAGE_riscv = arch/riscv/boot/Image 68 + IMAGE_riscv32 = arch/riscv/boot/Image 69 + IMAGE_riscv64 = arch/riscv/boot/Image 71 70 IMAGE_s390 = arch/s390/boot/bzImage 72 71 IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi 73 72 IMAGE = $(objtree)/$(IMAGE_$(XARCH)) ··· 87 82 DEFCONFIG_ppc64 = powernv_be_defconfig 88 83 DEFCONFIG_ppc64le = powernv_defconfig 89 84 DEFCONFIG_riscv = defconfig 85 + DEFCONFIG_riscv32 = rv32_defconfig 86 + DEFCONFIG_riscv64 = defconfig 90 87 DEFCONFIG_s390 = defconfig 91 88 DEFCONFIG_loongarch = defconfig 92 89 DEFCONFIG = $(DEFCONFIG_$(XARCH)) ··· 111 104 QEMU_ARCH_ppc64 = ppc64 112 105 QEMU_ARCH_ppc64le = ppc64 113 106 QEMU_ARCH_riscv = riscv64 107 + QEMU_ARCH_riscv32 = riscv32 108 + QEMU_ARCH_riscv64 = riscv64 114 109 QEMU_ARCH_s390 = s390x 115 110 QEMU_ARCH_loongarch = loongarch64 116 111 QEMU_ARCH = $(QEMU_ARCH_$(XARCH)) ··· 139 130 QEMU_ARGS_ppc64 = -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 140 131 QEMU_ARGS_ppc64le = -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 141 132 QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 133 + QEMU_ARGS_riscv32 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 134 + QEMU_ARGS_riscv64 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 142 135 QEMU_ARGS_s390 = -M s390-ccw-virtio -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 143 136 QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)" 144 137 QEMU_ARGS = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)
+26 -18
tools/testing/selftests/nolibc/nolibc-test.c
··· 302 302 { 303 303 int ret = 0; 304 304 305 - if (expr) { 305 + if (errno == ENOSYS) { 306 + llen += printf(" = ENOSYS"); 307 + result(llen, SKIPPED); 308 + } else if (expr) { 306 309 ret = 1; 307 310 llen += printf(" = %d %s ", expr, errorname(errno)); 308 311 result(llen, FAIL); ··· 345 342 { 346 343 int ret = 0; 347 344 348 - if (expr == val) { 345 + if (errno == ENOSYS) { 346 + llen += printf(" = ENOSYS"); 347 + result(llen, SKIPPED); 348 + } else if (expr == val) { 349 349 ret = 1; 350 350 llen += printf(" = %d %s ", expr, errorname(errno)); 351 351 result(llen, FAIL); ··· 373 367 int _errno = errno; 374 368 375 369 llen += printf(" = %d %s ", expr, errorname(_errno)); 376 - if (expr != expret || (_errno != experr1 && _errno != experr2)) { 370 + if (errno == ENOSYS) { 371 + result(llen, SKIPPED); 372 + } else if (expr != expret || (_errno != experr1 && _errno != experr2)) { 377 373 ret = 1; 378 374 if (experr2 == 0) 379 375 llen += printf(" != (%d %s) ", expret, errorname(experr1)); ··· 1237 1229 1238 1230 static int expect_vfprintf(int llen, int c, const char *expected, const char *fmt, ...) 1239 1231 { 1240 - int ret, fd; 1232 + int ret, pipefd[2]; 1241 1233 ssize_t w, r; 1242 1234 char buf[100]; 1243 1235 FILE *memfile; 1244 1236 va_list args; 1245 1237 1246 - fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600); 1247 - if (fd == -1) { 1248 - result(llen, SKIPPED); 1249 - return 0; 1238 + ret = pipe(pipefd); 1239 + if (ret == -1) { 1240 + llen += printf(" pipe() != %s", strerror(errno)); 1241 + result(llen, FAIL); 1242 + return 1; 1250 1243 } 1251 1244 1252 - memfile = fdopen(fd, "w+"); 1245 + memfile = fdopen(pipefd[1], "w"); 1253 1246 if (!memfile) { 1254 1247 result(llen, FAIL); 1255 1248 return 1; ··· 1266 1257 return 1; 1267 1258 } 1268 1259 1269 - fflush(memfile); 1270 - lseek(fd, 0, SEEK_SET); 1271 - 1272 - r = read(fd, buf, sizeof(buf) - 1); 1273 - 1274 1260 fclose(memfile); 1261 + 1262 + r = read(pipefd[0], buf, sizeof(buf) - 1); 1275 1263 1276 1264 if (r != w) { 1277 1265 llen += printf(" written(%d) != read(%d)", (int)w, (int)r); ··· 1329 1323 int max __attribute__((unused))) 1330 1324 { 1331 1325 pid_t pid; 1332 - int llen = 0, status; 1326 + int llen = 0, ret; 1327 + siginfo_t siginfo = {}; 1333 1328 struct rlimit rlimit = { 0, 0 }; 1334 1329 1335 1330 llen += printf("0 -fstackprotector "); ··· 1368 1361 return 1; 1369 1362 1370 1363 default: 1371 - pid = waitpid(pid, &status, 0); 1364 + ret = waitid(P_PID, pid, &siginfo, WEXITED); 1372 1365 1373 - if (pid == -1 || !WIFSIGNALED(status) || WTERMSIG(status) != SIGABRT) { 1374 - llen += printf("waitpid()"); 1366 + if (ret != 0 || siginfo.si_signo != SIGCHLD || 1367 + siginfo.si_code != CLD_KILLED || siginfo.si_status != SIGABRT) { 1368 + llen += printf("waitid()"); 1375 1369 result(llen, FAIL); 1376 1370 return 1; 1377 1371 }
+8 -1
tools/testing/selftests/nolibc/run-tests.sh
··· 17 17 test_mode=system 18 18 werror=1 19 19 llvm= 20 - archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv s390 loongarch" 20 + archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv32 riscv64 s390 loongarch" 21 21 22 22 TEMP=$(getopt -o 'j:d:c:b:a:m:pelh' -n "$0" -- "$@") 23 23 ··· 143 143 arch=$1 144 144 ct_arch=$(crosstool_arch "$arch") 145 145 ct_abi=$(crosstool_abi "$1") 146 + 147 + if [ ! -d "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/." ]; then 148 + echo "No toolchain found in ${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}." 149 + echo "Did you install the toolchains or set the correct arch ? Rerun with -h for help." 150 + return 1 151 + fi 152 + 146 153 cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-") 147 154 build_dir="${build_location}/${arch}" 148 155 if [ "$werror" -ne 0 ]; then