linux_kselftest-nolibc-6.14-rc1

- adds support for waitid()
 - uses waitid() over waitpid()
 - uses a pipe to in vfprintf tests
 - skips tests for unimplemented syscalls
 - renames riscv to riscv64
 - adds configurations for riscv32
 - adds detecting missing toolchain to run-tests.sh
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAmeQGFQACgkQCwJExA0N
 QxzStg/9H8ZSEtoGkMEtgW6jbXGTfmUZWOK/4KN6LJDiCl6Hrvyj9Tf5f4nFOhL2
 8eR9hYMGxx3kawY3qoGgQaotj2thlBLUGQVY8vLMnBIrA2r2mMmFOwwK4FtxBHHf
 jI37bvXvfIx8DzaUllZfDMs+hLSeteS1Qcq8n6nnuVTyrG8/Zt32Dal7pOf+rGh4
 C81L82n0vwOrj69vlfGIOBrhzoy0XWIvHWTxBY5EUzIpmRonAo3Us/pkMmTndU4K
 xFLzDldttIjtIrKI0qKPhipKrx5tmIzQbpTN3K+u8dgeFEGASsi7NdyctW5SRcYc
 efAvZxt91bQ9WpysSC+KWKpsO56nQ0MrpqLCnVK+fL5QrDqjAimRES3J6Aij9+Hs
 ojliXn6AO1aA7mXm/nLvcJIMV0i9CufVv/H2ZfVMxgCObN5mzlXmsEESI4fkROK4
 ZnkvYVMQBvQTtdoILOwFqu6mDKWwNitjNNvlePMtSFxFRkzMxal+LitV6cB0LFV5
 OIqh8w69MShBD1jTA1TQJOA9G1HMiB9Fm+kjT4U6H9sgSJaKzV4+n1XeFpVTWM6B
 TpI/kFL99V9pkPbZH17jRjIOg+0o3T2acs4FZsJ+jDt8hEk6qVy5sN1a4G6GTxyl
 +Oc204YJEQ9hLNiXljSiEzYrAvFIa055PzEuni3PFBxMisNKTjM=
 =jwYX
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2025-01-22 12:36:16 -08:00
commit 7004a2e46d
4 changed files with 63 additions and 19 deletions

View File

@ -23,6 +23,7 @@
#include <linux/prctl.h>
#include <linux/resource.h>
#include <linux/utsname.h>
#include <linux/signal.h>
#include "arch.h"
#include "errno.h"
@ -1225,6 +1226,23 @@ pid_t waitpid(pid_t pid, int *status, int options)
}
/*
* int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);
*/
static __attribute__((unused))
int sys_waitid(int which, pid_t pid, siginfo_t *infop, int options, struct rusage *rusage)
{
return my_syscall5(__NR_waitid, which, pid, infop, options, rusage);
}
static __attribute__((unused))
int waitid(int which, pid_t pid, siginfo_t *infop, int options)
{
return __sysret(sys_waitid(which, pid, infop, options, NULL));
}
/*
* ssize_t write(int fd, const void *buf, size_t count);
*/

View File

@ -43,6 +43,7 @@ cc-option = $(call __cc-option, $(CC),$(CLANG_CROSS_FLAGS),$(1),$(2))
# configure default variants for target kernel supported architectures
XARCH_powerpc = ppc
XARCH_mips = mips32le
XARCH_riscv = riscv64
XARCH = $(or $(XARCH_$(ARCH)),$(ARCH))
# map from user input variants to their kernel supported architectures
@ -51,6 +52,8 @@ ARCH_ppc64 = powerpc
ARCH_ppc64le = powerpc
ARCH_mips32le = mips
ARCH_mips32be = mips
ARCH_riscv32 = riscv
ARCH_riscv64 = riscv
ARCH := $(or $(ARCH_$(XARCH)),$(XARCH))
# kernel image names by architecture
@ -65,6 +68,8 @@ IMAGE_ppc = vmlinux
IMAGE_ppc64 = vmlinux
IMAGE_ppc64le = arch/powerpc/boot/zImage
IMAGE_riscv = arch/riscv/boot/Image
IMAGE_riscv32 = arch/riscv/boot/Image
IMAGE_riscv64 = arch/riscv/boot/Image
IMAGE_s390 = arch/s390/boot/bzImage
IMAGE_loongarch = arch/loongarch/boot/vmlinuz.efi
IMAGE = $(objtree)/$(IMAGE_$(XARCH))
@ -82,6 +87,8 @@ DEFCONFIG_ppc = pmac32_defconfig
DEFCONFIG_ppc64 = powernv_be_defconfig
DEFCONFIG_ppc64le = powernv_defconfig
DEFCONFIG_riscv = defconfig
DEFCONFIG_riscv32 = rv32_defconfig
DEFCONFIG_riscv64 = defconfig
DEFCONFIG_s390 = defconfig
DEFCONFIG_loongarch = defconfig
DEFCONFIG = $(DEFCONFIG_$(XARCH))
@ -104,6 +111,8 @@ QEMU_ARCH_ppc = ppc
QEMU_ARCH_ppc64 = ppc64
QEMU_ARCH_ppc64le = ppc64
QEMU_ARCH_riscv = riscv64
QEMU_ARCH_riscv32 = riscv32
QEMU_ARCH_riscv64 = riscv64
QEMU_ARCH_s390 = s390x
QEMU_ARCH_loongarch = loongarch64
QEMU_ARCH = $(QEMU_ARCH_$(XARCH))
@ -130,6 +139,8 @@ QEMU_ARGS_ppc = -M g3beige -append "console=ttyS0 panic=-1 $(TEST:%=NOLIB
QEMU_ARGS_ppc64 = -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_ppc64le = -M powernv -append "console=hvc0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_riscv = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_riscv32 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_riscv64 = -M virt -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_s390 = -M s390-ccw-virtio -append "console=ttyS0 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS_loongarch = -M virt -append "console=ttyS0,115200 panic=-1 $(TEST:%=NOLIBC_TEST=%)"
QEMU_ARGS = -m 1G $(QEMU_ARGS_$(XARCH)) $(QEMU_ARGS_BIOS) $(QEMU_ARGS_EXTRA)

View File

@ -302,7 +302,10 @@ int expect_syszr(int expr, int llen)
{
int ret = 0;
if (expr) {
if (errno == ENOSYS) {
llen += printf(" = ENOSYS");
result(llen, SKIPPED);
} else if (expr) {
ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno));
result(llen, FAIL);
@ -342,7 +345,10 @@ int expect_sysne(int expr, int llen, int val)
{
int ret = 0;
if (expr == val) {
if (errno == ENOSYS) {
llen += printf(" = ENOSYS");
result(llen, SKIPPED);
} else if (expr == val) {
ret = 1;
llen += printf(" = %d %s ", expr, errorname(errno));
result(llen, FAIL);
@ -367,7 +373,9 @@ int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen)
int _errno = errno;
llen += printf(" = %d %s ", expr, errorname(_errno));
if (expr != expret || (_errno != experr1 && _errno != experr2)) {
if (errno == ENOSYS) {
result(llen, SKIPPED);
} else if (expr != expret || (_errno != experr1 && _errno != experr2)) {
ret = 1;
if (experr2 == 0)
llen += printf(" != (%d %s) ", expret, errorname(experr1));
@ -1229,19 +1237,20 @@ int run_stdlib(int min, int max)
static int expect_vfprintf(int llen, int c, const char *expected, const char *fmt, ...)
{
int ret, fd;
int ret, pipefd[2];
ssize_t w, r;
char buf[100];
FILE *memfile;
va_list args;
fd = open("/tmp", O_TMPFILE | O_EXCL | O_RDWR, 0600);
if (fd == -1) {
result(llen, SKIPPED);
return 0;
ret = pipe(pipefd);
if (ret == -1) {
llen += printf(" pipe() != %s", strerror(errno));
result(llen, FAIL);
return 1;
}
memfile = fdopen(fd, "w+");
memfile = fdopen(pipefd[1], "w");
if (!memfile) {
result(llen, FAIL);
return 1;
@ -1257,13 +1266,10 @@ static int expect_vfprintf(int llen, int c, const char *expected, const char *fm
return 1;
}
fflush(memfile);
lseek(fd, 0, SEEK_SET);
r = read(fd, buf, sizeof(buf) - 1);
fclose(memfile);
r = read(pipefd[0], buf, sizeof(buf) - 1);
if (r != w) {
llen += printf(" written(%d) != read(%d)", (int)w, (int)r);
result(llen, FAIL);
@ -1323,7 +1329,8 @@ static int run_protection(int min __attribute__((unused)),
int max __attribute__((unused)))
{
pid_t pid;
int llen = 0, status;
int llen = 0, ret;
siginfo_t siginfo = {};
struct rlimit rlimit = { 0, 0 };
llen += printf("0 -fstackprotector ");
@ -1361,10 +1368,11 @@ static int run_protection(int min __attribute__((unused)),
return 1;
default:
pid = waitpid(pid, &status, 0);
ret = waitid(P_PID, pid, &siginfo, WEXITED);
if (pid == -1 || !WIFSIGNALED(status) || WTERMSIG(status) != SIGABRT) {
llen += printf("waitpid()");
if (ret != 0 || siginfo.si_signo != SIGCHLD ||
siginfo.si_code != CLD_KILLED || siginfo.si_status != SIGABRT) {
llen += printf("waitid()");
result(llen, FAIL);
return 1;
}

View File

@ -17,7 +17,7 @@ perform_download=0
test_mode=system
werror=1
llvm=
archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv s390 loongarch"
archs="i386 x86_64 arm64 arm mips32le mips32be ppc ppc64 ppc64le riscv32 riscv64 s390 loongarch"
TEMP=$(getopt -o 'j:d:c:b:a:m:pelh' -n "$0" -- "$@")
@ -143,6 +143,13 @@ test_arch() {
arch=$1
ct_arch=$(crosstool_arch "$arch")
ct_abi=$(crosstool_abi "$1")
if [ ! -d "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/." ]; then
echo "No toolchain found in ${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}."
echo "Did you install the toolchains or set the correct arch ? Rerun with -h for help."
return 1
fi
cross_compile=$(realpath "${download_location}gcc-${crosstool_version}-nolibc/${ct_arch}-${ct_abi}/bin/${ct_arch}-${ct_abi}-")
build_dir="${build_location}/${arch}"
if [ "$werror" -ne 0 ]; then