aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/lib
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-11 00:29:41 -0500
committerMike Frysinger <vapier@gentoo.org>2021-11-26 20:06:55 -0500
commit1214c97666139d06fd1d1301af05844f7771f377 (patch)
tree820e41dfbd93c33a10e3f4f7ea1282a1fac618ef /sim/testsuite/lib
parent264dcc17cc4d2252d58bda347dfd78c1b78517da (diff)
downloadgdb-1214c97666139d06fd1d1301af05844f7771f377.zip
gdb-1214c97666139d06fd1d1301af05844f7771f377.tar.gz
gdb-1214c97666139d06fd1d1301af05844f7771f377.tar.bz2
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).
Diffstat (limited to 'sim/testsuite/lib')
-rw-r--r--sim/testsuite/lib/linuxcheck.c9
-rw-r--r--sim/testsuite/lib/newlibcheck.c10
-rw-r--r--sim/testsuite/lib/sim-defs.exp33
3 files changed, 48 insertions, 4 deletions
diff --git a/sim/testsuite/lib/linuxcheck.c b/sim/testsuite/lib/linuxcheck.c
new file mode 100644
index 0000000..d1f4bc1
--- /dev/null
+++ b/sim/testsuite/lib/linuxcheck.c
@@ -0,0 +1,9 @@
+/* Used by the test harness to see if toolchain targets Linux. */
+#ifdef __linux__
+int main()
+{
+ return 0;
+}
+#else
+# error "not linux"
+#endif
diff --git a/sim/testsuite/lib/newlibcheck.c b/sim/testsuite/lib/newlibcheck.c
new file mode 100644
index 0000000..ea1d864
--- /dev/null
+++ b/sim/testsuite/lib/newlibcheck.c
@@ -0,0 +1,10 @@
+/* Used by the test harness to see if toolchain uses newlib. */
+#include <newlib.h>
+#if defined(__NEWLIB__) || defined(_NEWLIB_VERSION)
+int main()
+{
+ return 0;
+}
+#else
+# error "not newlib"
+#endif
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index f399d2f..535f76c 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -48,16 +48,33 @@ proc sim_init_toolchain {} {
global srcdir
global global_cpp_works
global global_cc_works
+ global global_cc_os
# See if we have a preprocessor available.
set result [target_compile $srcdir/lib/compilercheck.c \
$objdir/compilercheck.x "preprocess" ""]
set global_cpp_works [string equal "" "$result"]
- # See if we have a compiler available.
- set result [target_compile $srcdir/lib/compilercheck.c \
- $objdir/compilercheck.x "executable" ""]
- set global_cc_works [string equal "" "$result"]
+ # See if we have a compiler available, and which environment it's targeting.
+ if { [target_compile $srcdir/lib/newlibcheck.c \
+ $objdir/compilercheck.x "executable" ""] == "" } {
+ verbose -log "Found newlib C compiler"
+ set global_cc_works 1
+ set global_cc_os "newlib"
+ } elseif { [target_compile $srcdir/lib/linuxcheck.c \
+ $objdir/compilercheck.x "executable" ""] == "" } {
+ verbose -log "Found Linux C compiler"
+ set global_cc_works 1
+ set global_cc_os "linux"
+ } elseif { [target_compile $srcdir/lib/compilercheck.c \
+ $objdir/compilercheck.x "executable" ""] == "" } {
+ verbose -log "Found C compiler, but unknown OS"
+ set global_cc_works 1
+ set global_cc_os ""
+ } {
+ verbose -log "Can't execute C compiler"
+ set global_cc_works 0
+ }
file delete $objdir/compilercheck.x
}
@@ -189,6 +206,7 @@ proc sim_run { prog sim_opts prog_opts redir options } {
# cc[(mach-list)]: <compiler options>
# sim[(mach-list)]: <simulator options>
# progopts: <arguments to the program being simulated>
+# progos: OS required for the test
# status: program exit status to treat as "pass"
# output: program output pattern to match with string-match
# xerror: program is expected to return with a "failure" exit code
@@ -211,6 +229,7 @@ proc run_sim_test { name requested_machs } {
global SIMFLAGS_FOR_TARGET
global global_cpp_works
global global_cc_works
+ global global_cc_os
if ![file exists $sim_path] {
unsupported "$name: missing simulator $sim_path"
@@ -234,6 +253,7 @@ proc run_sim_test { name requested_machs } {
set opts(ld) ""
set opts(cc) ""
set opts(progopts) ""
+ set opts(progos) ""
set opts(sim) ""
set opts(status) "0"
set opts(output) ""
@@ -291,6 +311,11 @@ proc run_sim_test { name requested_machs } {
}
}
+ if { $opts(progos) != "" && $opts(progos) != $global_cc_os } {
+ untested $subdir/$name
+ return
+ }
+
set testname $name
set sourcefile $file
if { $seen_output == 0 } {