sim: testsuite: initial support for OS-specific tests

We usually test against the newlib/libgloss environment, but for a
few ports that also support Linux apps, we want to test that logic
too.  A lot of the C code is written such that it works with either
newlib/libgloss or glibc/linux toolchains, but we have some tests
that end up being Linux-specific.  Cris has been using the target
tuple as a rough proxy for this (where cris*-*-elf is assumed to be
newlib/libgloss, and everything else is glibc/linux), but that is a
bit too rough, and it doesn't work in a multitarget build.

So lets create a few stub files that we can do compile tests with
to detect the different setups, and then let tests declare which
one they require (if they require any at all).
This commit is contained in:
Mike Frysinger 2021-11-11 00:29:41 -05:00
parent 264dcc17cc
commit 1214c97666
107 changed files with 158 additions and 107 deletions

View file

@ -1,5 +1,5 @@
/* Check access(2) trivially. Newlib doesn't have it.
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: *: could not load ELF interpreter `*' for program `*'\n
*/

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
#xerror:
#cc: additional_flags=-Wl,-dynamic-linker,/dev/null
#output: *: could not load ELF interpreter `*' for program `*'\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
#xerror:
#cc: additional_flags=-Wl,-dynamic-linker,/compilercheck.x
#sim: --sysroot=$pwd

View file

@ -34,6 +34,7 @@ if [istarget cris*-*-elf] {
# Using target_compile, since it is less noisy,
global global_cc_works
global global_cc_os
if { $global_cc_works == 1 } {
# Now check if we can link a program dynamically, and where
# libc.so is located. If it is, we provide a sym link to the
@ -103,6 +104,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
set opts(sim) ""
set opts(output) ""
set opts(progoptions) ""
set opts(progos) ""
set opts(timeout) ""
set opts(mach) ""
set opts(xerror) "no"
@ -164,6 +166,11 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
continue
}
if { $opts(progos) != "" && $opts(progos) != $global_cc_os } {
untested $testname
continue
}
# If no machine specific options, default to the general version.
if ![info exists opts(sim,$mach)] {
set opts(sim,$mach) $opts(sim)

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
#output: got: a\nthen: bc\nexit: 0\n
*/

View file

@ -1,5 +1,5 @@
/* Make sure the thread system trivially works with trace output.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-trace=basic --trace-file=$pwd/clone2.tmp
#output: got: a\nthen: bc\nexit: 0\n
*/

View file

@ -1,5 +1,5 @@
/* Check that exiting from a parent thread does not kill the child.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/* Check that TRT happens when we reach the #threads implementation limit.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/* Check that unimplemented clone syscalls get the right treatment.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented clone syscall *
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/* Compiler options:
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#output: Starting process a\naaaaaaaaStarting process b\nababbbbbbbbb

View file

@ -1,7 +1,7 @@
/* Check exit_group(2) trivially. Newlib doesn't have it and the
pre-v32 glibc requires updated headers we'd have to check or adjust
for.
#notarget: cris-*-* *-*-elf
#progos: linux
#output: exit_group\n
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Check exit_group(2) trivially with non-zero status.
#notarget: cris-*-* *-*-elf
#progos: linux
#output: exit_group\n
#xerror:
*/

View file

@ -1,5 +1,5 @@
/* Check that we get the expected message for unsupported fcntl calls.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented fcntl*
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/* Check that the ftruncate syscall works trivially.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
/* Check that we get a proper error indication if trying ftruncate on a

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -2,7 +2,7 @@
works. Jump through a few hoops to avoid reading the host
ld.so.cache (having no absolute path specified for the executable
falls back on loading through the same mechanisms as a DSO).
#notarget: *-*-elf
#progos: linux
#sim: --sysroot=$pwd $pwd/lib/ld.so.1 --library-path /
*/
#include "hello.c"

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#define _GNU_SOURCE

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#define _GNU_SOURCE

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#define _GNU_SOURCE

View file

@ -1,5 +1,5 @@
/* Just check that MAP_DENYWRITE is "honored" (ignored).
#notarget: cris*-*-elf
#progos: linux
*/
#define MMAP_FLAGS (MAP_PRIVATE|MAP_DENYWRITE)
#include "mmap1.c"

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#define _GNU_SOURCE

View file

@ -1,6 +1,6 @@
/* Check that mmapping specifying a previously mmapped address without
MAP_FIXED works; that we just don't get the same address.
#notarget: cris*-*-elf
#progos: linux
*/
#define NO_MUNMAP
#define MMAP_FLAGS2 MAP_PRIVATE

View file

@ -1,7 +1,7 @@
/* Check that mmapping a page-aligned size, larger than the file,
works.
#notarget: cris*-*-elf
#progos: linux
*/
/* Make sure we get an address where the size fits. */

View file

@ -1,6 +1,6 @@
/* Check that mmapping 0 using MAP_FIXED works, both with/without
there being previously mmapped contents.
#notarget: cris*-*-elf
#progos: linux
*/
#define MMAP_FLAGS1 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED
#define NO_MUNMAP

View file

@ -1,5 +1,5 @@
/* Check unimplemented-output for mprotect call.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented mprotect call (0x0, 0x2001, 0x4)\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/* Check that TRT happens when error on too many opened files.
#notarget: cris*-*-elf
#progos: linux
#sim: --sysroot=$pwd
*/
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/* Check for proper pipe semantics at corner cases.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/* Check that closing a pipe with a nonempty buffer works.
#notarget: cris*-*-elf
#progos: linux
#output: got: a\ngot: b\nexit: 0\n
*/

View file

@ -1,5 +1,5 @@
/* Check that TRT happens when error on pipe call.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stddef.h>

View file

@ -1,5 +1,5 @@
/* Check that TRT happens for pipe corner cases.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stddef.h>
#include <signal.h>

View file

@ -1,5 +1,5 @@
/* Check that TRT happens for pipe corner cases (for our definition of TRT).
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Terminating simulation due to writing pipe * from one single thread\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* Check that writing an inordinate amount of data works (somewhat).
#notarget: cris*-*-elf
#progos: linux
#output: got: a\nexit: 0\n
This test-case will *not* work on host (or for real): the first
pipemax+1 bytes will be successfully written. It's just for

View file

@ -1,5 +1,5 @@
/* Check for proper pipe semantics at corner cases.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Check that odd cases of readlink work.
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* As readlink5.c (sic), but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet --argv0 ./readlink11.c.x
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Simulator options:
#notarget: cris*-*-elf
#progos: linux
#sim: --sysroot=$pwd
*/
#define SYSROOTED 1

View file

@ -1,5 +1,5 @@
/* Check for corner case: readlink of too-long name.
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Check that unsupported readlink calls don't cause the simulator to abort.
#notarget: cris*-*-elf
#progos: linux
#sim: --argv0 ./readlink5.c.x
#xerror:
#output: Unimplemented readlink syscall (*)\n

View file

@ -1,5 +1,5 @@
/* Check that rare readlink calls don't cause the simulator to abort.
#notarget: cris*-*-elf
#progos: linux
#sim: --argv0 $pwd/readlink6.c.x
*/
#include "readlink2.c"

View file

@ -1,5 +1,5 @@
/* Check that rare readlink calls don't cause the simulator to abort.
#notarget: cris*-*-elf
#progos: linux
#sim: --env-unset PWD
*/
#include "readlink2.c"

View file

@ -1,5 +1,5 @@
/* Check that rare readlink calls don't cause the simulator to abort.
#notarget: cris*-*-elf
#progos: linux
#sim: --sysroot=$pwd --env-unset PWD
*/
#define SYSROOTED 1

View file

@ -1,5 +1,5 @@
/* Check that odd cases of readlink work.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-DX="$pwd"
*/

View file

@ -1,5 +1,5 @@
/* Compiler options:
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Unimplemented rt_sigprocmask syscall (0x3, 0x0, 0x3dff*\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n

View file

@ -1,5 +1,5 @@
/* Test that TRT happens for invalid rt_sigsuspend calls. Single-thread.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented rt_sigsuspend syscall arguments (0x1, 0x2)\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/* Check corner error case: specifying invalid PID.
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/* Check corner error case: specifying invalid PID.
#notarget: cris*-*-elf
#progos: linux
*/
#include <string.h>
#include <sched.h>

View file

@ -1,5 +1,5 @@
/* Check corner error case: specifying invalid scheduling policy.
#notarget: cris*-*-elf
#progos: linux
*/
#include <sched.h>

View file

@ -1,5 +1,5 @@
/* Check corner error case: specifying unimplemented resource.
#notarget: cris*-*-elf
#progos: linux
*/
#include <sys/time.h>
#include <sys/resource.h>

View file

@ -1,5 +1,5 @@
/* Check that the syscall set_thread_area is supported and does the right thing.
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Check that TRT happens when trying to IGN an non-ignorable signal, more than one thread.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Exiting pid 42 due to signal 9\n

View file

@ -1,5 +1,5 @@
/* Check that TRT happens when getting a non-standard (realtime) signal, more than one thread.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Unimplemented signal: 77\n

View file

@ -1,6 +1,6 @@
/* Check that TRT happens for a signal sent to a non-existent process/thread, more than one thread.
#cc: additional_flags=-pthread
#notarget: cris*-*-elf
#progos: linux
*/
#include <stdlib.h>

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <stdio.h>

View file

@ -1,5 +1,5 @@
/* Check that TRT happens at an abort (3) call, more than one thread.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Exiting pid 42 due to signal 6\n

View file

@ -1,5 +1,5 @@
/* Check that TRT happens at an non-abort non-caught signal, more than one thread.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Exiting pid 42 due to signal 7\n

View file

@ -1,5 +1,5 @@
/* Check unsupported case of sigaction syscall.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented rt_sigaction syscall (0x8, 0x3df*\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* Check that TRT happens at an non-abort ignored signal, more than one thread.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
*/

View file

@ -1,5 +1,5 @@
/* Test that TRT happens for spurious sigreturn calls. Single-thread.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Invalid sigreturn syscall: no signal handler active (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* Check that TRT happens for spurious sigreturn calls. Multiple threads.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#xerror:
#output: Invalid sigreturn syscall: no signal handler active (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sys/types.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sys/types.h>

View file

@ -1,5 +1,5 @@
/* Simulator options:
#notarget: cris*-*-elf
#progos: linux
#sim: --sysroot=$pwd
*/

View file

@ -1,5 +1,5 @@
/* Check that lstat:ing an nonexistent file works as expected.
#notarget: cris*-*-elf
#progos: linux
*/
#include <sys/types.h>

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <sys/types.h>

View file

@ -1,6 +1,6 @@
/* For this test, we need to do the lstat syscall directly, or else
glibc gets a SEGV.
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* Test unknown-syscall output.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* Test unknown-syscall output.
#notarget: cris*-*-elf
#progos: linux
#xerror:
#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n
#output: program stopped with signal 4 (*).\n

View file

@ -1,5 +1,5 @@
/* As the included file, just actually specifying the default.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=stop
#xerror:
#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n

View file

@ -1,5 +1,5 @@
/* As the included file, just actually specifying the default.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=stop
#xerror:
#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying ENOSYS with message.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys
#output: Unimplemented syscall: 166 (0x1, 0x2, 0x3, 0x4, 0x5, 0x6)\n
#output: ENOSYS\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying ENOSYS with message.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys
#output: Unimplemented syscall: 0 (0x3, 0x2, 0x1, 0x4, 0x6, 0x5)\n
#output: ENOSYS\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,5 +1,5 @@
/*
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -2,7 +2,7 @@
#xerror:
#output: Unimplemented _sysctl syscall *\n
#output: program stopped with signal 4 (*).\n
#notarget: cris*-*-elf
#progos: linux
*/
#include <unistd.h>

View file

@ -1,5 +1,5 @@
/* As the included file, but specifying silent ENOSYS.
#notarget: cris*-*-elf
#progos: linux
#sim: --cris-unknown-syscall=enosys-quiet
#output: ENOSYS\n
#output: xyzzy\n

View file

@ -1,6 +1,6 @@
/* Compiler options:
#cc: additional_flags=-pthread
#notarget: cris*-*-elf
#progos: linux
A sanity check for syscalls resulting from
pthread_getschedparam and pthread_setschedparam. */

View file

@ -1,6 +1,6 @@
/* Compiler options:
#cc: additional_flags=-pthread
#notarget: cris*-*-elf
#progos: linux
To test sched_yield in the presencs of threads. Core from ex1.c. */

View file

@ -1,5 +1,5 @@
/* Compiler options:
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#output: abb ok\n

View file

@ -1,5 +1,5 @@
/* Compiler options:
#notarget: cris*-*-elf
#progos: linux
#cc: additional_flags=-pthread
#output: abbb ok\n

View file

@ -1,5 +1,5 @@
/* Check that the truncate syscall works trivially.
#notarget: cris*-*-elf
#progos: linux
*/
#include <stdio.h>

View file

@ -1,6 +1,6 @@
/*
#sim: --sysroot=$pwd
#notarget: cris*-*-elf
#progos: linux
*/
#define PREFIX "/"
#include "truncate1.c"

Some files were not shown because too many files have changed in this diff Show more