diff options
author | Mike Frysinger <vapier@gentoo.org> | 2021-11-21 03:06:20 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2021-11-26 19:27:21 -0500 |
commit | e1e1ae6e9b5e76daed22c8b2eb79fa3b5ade3335 (patch) | |
tree | 205dafa026bd39afbe1d4d2897ce1300edd3ad83 /sim/testsuite | |
parent | 03c0f9c2057d361a1d9e717624ab94e4b7d67bf2 (diff) | |
download | gdb-e1e1ae6e9b5e76daed22c8b2eb79fa3b5ade3335.zip gdb-e1e1ae6e9b5e76daed22c8b2eb79fa3b5ade3335.tar.gz gdb-e1e1ae6e9b5e76daed22c8b2eb79fa3b5ade3335.tar.bz2 |
sim: testsuite: fix objdir handling
The tests assume that the cwd is the objdir directory and write its
intermediates to there all the time. When using runtest's --objdir
setting though, this puts the files in the wrong place. This isn't
a big problem currently as we never change --objdir, but in order to
support parallel test execution, we're going to start setting that
option, so clean up the code ahead of time.
We also have to tweak some of the cris tests which were making
assumptions about the argv[0] value.
Diffstat (limited to 'sim/testsuite')
-rw-r--r-- | sim/testsuite/bfin/allinsn.exp | 6 | ||||
-rw-r--r-- | sim/testsuite/cris/c/c.exp | 9 | ||||
-rw-r--r-- | sim/testsuite/cris/c/openpf1.c | 2 | ||||
-rw-r--r-- | sim/testsuite/cris/c/rename2.c | 6 | ||||
-rw-r--r-- | sim/testsuite/cris/c/stat3.c | 2 | ||||
-rw-r--r-- | sim/testsuite/cris/hw/rv-n-cris/rvc.exp | 11 | ||||
-rw-r--r-- | sim/testsuite/lib/sim-defs.exp | 20 | ||||
-rw-r--r-- | sim/testsuite/local.mk | 11 |
8 files changed, 34 insertions, 33 deletions
diff --git a/sim/testsuite/bfin/allinsn.exp b/sim/testsuite/bfin/allinsn.exp index aa304ea..f250d23 100644 --- a/sim/testsuite/bfin/allinsn.exp +++ b/sim/testsuite/bfin/allinsn.exp @@ -4,8 +4,10 @@ if [istarget bfin-*-elf] { # all machines set all_machs "bfin" + global objdir + # See if we have a preprocessor available. - if { [target_compile $srcdir/$subdir/usp.S compilercheck.x "preprocess" \ + if { [target_compile $srcdir/$subdir/usp.S $objdir/compilercheck.x "preprocess" \ [list "incdir=$srcdir/$subdir"]] == "" } { set has_cpp 1 } { @@ -14,7 +16,7 @@ if [istarget bfin-*-elf] { } # See if we have a compiler available. - if { [target_compile $srcdir/$subdir/argc.c compilercheck.x "executable" \ + if { [target_compile $srcdir/$subdir/argc.c $objdir/compilercheck.x "executable" \ [list "incdir=$srcdir/$subdir" "additional_flags=-msim"]] == "" } { set has_cc 1 } { diff --git a/sim/testsuite/cris/c/c.exp b/sim/testsuite/cris/c/c.exp index 233ed85..bd51d73 100644 --- a/sim/testsuite/cris/c/c.exp +++ b/sim/testsuite/cris/c/c.exp @@ -31,7 +31,8 @@ if [istarget cris*-*-elf] { } # Using target_compile, since it is less noisy, -if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \ +global objdir +if { [target_compile $srcdir/$subdir/hello.c $objdir/compilercheck.x \ "executable" "" ] == "" } { set has_cc 1 @@ -43,7 +44,7 @@ if { [target_compile $srcdir/$subdir/hello.c compilercheck.x \ # detrimental effects on the executable from the specs and # -static in the board ldflags, we just add -Bdynamic. if [regexp "(.*/lib)/libc.so" \ - [target_compile $srcdir/$subdir/hello.c compilercheck.x \ + [target_compile $srcdir/$subdir/hello.c $objdir/compilercheck.x \ "executable" \ "ldflags=-print-file-name=libc.so -Wl,-Bdynamic"] \ xxx libcsodir] { @@ -169,7 +170,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { verbose -log "Compiling $src with $opts(cc)" - if { [target_compile $src "$testname.x" "executable" "$opts(cc)" ] != "" } { + if { [target_compile $src "$objdir/$testname.x" "executable" "$opts(cc)" ] != "" } { unresolved $testname continue } @@ -192,7 +193,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { eval setup_kfail $opts(kfail) } - set result [sim_run "$testname.x" "$opts(sim,$mach)" "$opts(progoptions)" \ + set result [sim_run "$objdir/$testname.x" "$opts(sim,$mach)" "$opts(progoptions)" \ "" ""] set return_code [lindex $result 0] set output [lindex $result 1] diff --git a/sim/testsuite/cris/c/openpf1.c b/sim/testsuite/cris/c/openpf1.c index fe767f7..92d12bf 100644 --- a/sim/testsuite/cris/c/openpf1.c +++ b/sim/testsuite/cris/c/openpf1.c @@ -21,7 +21,7 @@ int main (int argc, char *argv[]) if (fnam == NULL) abort (); strcpy (fnam, "/"); - strcat (fnam, argv[0]); + strcat (fnam, basename (argv[0])); } f = fopen (fnam, "rb"); diff --git a/sim/testsuite/cris/c/rename2.c b/sim/testsuite/cris/c/rename2.c index 39387d1..3b62837 100644 --- a/sim/testsuite/cris/c/rename2.c +++ b/sim/testsuite/cris/c/rename2.c @@ -17,12 +17,6 @@ void err (const char *s) int main (int argc, char *argv[]) { - /* Avoid getting files with random characters due to errors - elsewhere. */ - if (argc != 1 - || (argv[0][0] != '.' && argv[0][0] != '/' && argv[0][0] != 'r')) - abort (); - if (rename (argv[0], NULL) != -1 || errno != EFAULT) err ("rename 1 "); diff --git a/sim/testsuite/cris/c/stat3.c b/sim/testsuite/cris/c/stat3.c index fa9fcc1..eac4da9 100644 --- a/sim/testsuite/cris/c/stat3.c +++ b/sim/testsuite/cris/c/stat3.c @@ -13,7 +13,7 @@ int main (int argc, char *argv[]) char path[1024] = "/"; struct stat buf; - strcat (path, argv[0]); + strcat (path, basename (argv[0])); if (stat (".", &buf) != 0 || !S_ISDIR (buf.st_mode)) abort (); diff --git a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp index 5d7126c..42de37d 100644 --- a/sim/testsuite/cris/hw/rv-n-cris/rvc.exp +++ b/sim/testsuite/cris/hw/rv-n-cris/rvc.exp @@ -21,6 +21,7 @@ proc sim_has_rv_and_cris {} { global srcdir global subdir + global objdir global SIMFLAGS_FOR_TARGET # We need to assemble and link a trivial program and pass that, in @@ -34,7 +35,7 @@ proc sim_has_rv_and_cris {} { set SIMFLAGS_FOR_TARGET "" } - set comp_output [target_assemble $srcdir/$subdir/quit.s quit.o \ + set comp_output [target_assemble $srcdir/$subdir/quit.s $objdir/quit.o \ "-I$srcdir/$subdir"] if ![string match "" $comp_output] { @@ -43,7 +44,7 @@ proc sim_has_rv_and_cris {} { return 0 } - set comp_output [target_link quit.o quit.x ""] + set comp_output [target_link $objdir/quit.o $objdir/quit.x ""] if ![string match "" $comp_output] { verbose -log "$comp_output" 3 @@ -52,7 +53,7 @@ proc sim_has_rv_and_cris {} { } set result \ - [sim_run quit.x \ + [sim_run $objdir/quit.x \ "$SIMFLAGS_FOR_TARGET --hw-device rv --hw-device cris --hw-info" \ "" "" ""] set return_code [lindex $result 0] @@ -117,8 +118,8 @@ if [istarget cris*-*-*] { # See the logic in sim-defs.exp for more details. set sim [board_info target sim] if [string equal "" $sim] { - global objdir - set rvdummy "$objdir/cris/rvdummy" + global builddir + set rvdummy "$builddir/cris/rvdummy" } else { set rvdummy "[file dirname [board_info target sim]]/rvdummy" } diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp index d10246e..405f1b7 100644 --- a/sim/testsuite/lib/sim-defs.exp +++ b/sim/testsuite/lib/sim-defs.exp @@ -40,13 +40,13 @@ proc sim_tool_path {} { global sim_path set sim "$sim_path" if [string equal "" $sim] { - global objdir + global builddir global subdir set arch "$subdir" while { [file dirname $arch] != "." } { set arch [file dirname $arch] } - return "$objdir/$arch/run" + return "$builddir/$arch/run" } return "$sim" } @@ -181,7 +181,7 @@ proc sim_run { prog sim_opts prog_opts redir options } { # optional for xfail. proc run_sim_test { name requested_machs } { - global subdir srcdir + global subdir srcdir objdir global opts global cpu_option global cpu_option_sep @@ -328,16 +328,16 @@ proc run_sim_test { name requested_machs } { } if [string match "*.c" $sourcefile] { - set comp_output [target_compile $sourcefile ${name}.x "executable" \ + set comp_output [target_compile $sourcefile $objdir/${name}.x "executable" \ [list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options $c_ld_options $opts(cc,$mach)"]] set method "compiling/linking" } else { if [string match "*.S" $sourcefile] { - set comp_output [target_compile $sourcefile ${name}.o "object" \ + set comp_output [target_compile $sourcefile $objdir/${name}.o "object" \ [list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options"]] set method "compiling" } else { - set comp_output [target_assemble $sourcefile ${name}.o "$as_options"] + set comp_output [target_assemble $sourcefile $objdir/${name}.o "$as_options"] set method "assembling" } @@ -347,7 +347,7 @@ proc run_sim_test { name requested_machs } { continue } - set comp_output [target_link ${name}.o ${name}.x "$opts(ld,$mach)"] + set comp_output [target_link $objdir/${name}.o $objdir/${name}.x "$opts(ld,$mach)"] set method "linking" } @@ -368,7 +368,7 @@ proc run_sim_test { name requested_machs } { set options "$options timeout=$opts(timeout)" } - set result [sim_run ${name}.x "$opts(sim,$mach) $SIMFLAGS_FOR_TARGET" "$opts(progopts)" "" "$options"] + set result [sim_run $objdir/${name}.x "$opts(sim,$mach) $SIMFLAGS_FOR_TARGET" "$opts(progopts)" "" "$options"] set return_code [lindex $result 0] set output [lindex $result 1] @@ -383,7 +383,7 @@ proc run_sim_test { name requested_machs } { if { "$opts(xerror)" == "no" } { if [string match $opts(output) $output] { pass "$mach $testname" - file delete ${name}.o ${name}.x + file delete $objdir/${name}.o $objdir/${name}.x } else { verbose -log "status: $return_code" 3 verbose -log "output: $output" 3 @@ -400,7 +400,7 @@ proc run_sim_test { name requested_machs } { } else { if [string match $opts(output) $output] { pass "$mach $testname" - file delete ${name}.o ${name}.x + file delete $objdir/${name}.o $objdir/${name}.x } else { verbose -log "status: $return_code" 3 verbose -log "output: $output" 3 diff --git a/sim/testsuite/local.mk b/sim/testsuite/local.mk index 4da63ea..5ffa9ec 100644 --- a/sim/testsuite/local.mk +++ b/sim/testsuite/local.mk @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Tweak the site.exp so it works with plain `runtest` from user. -EXTRA_DEJAGNU_SITE_CONFIG = site-srcdir.exp +EXTRA_DEJAGNU_SITE_CONFIG = site-sim-config.exp # Custom verbose test variables that automake doesn't provide (yet?). AM_V_RUNTEST = $(AM_V_RUNTEST_@AM_V@) @@ -24,8 +24,11 @@ AM_V_RUNTEST_ = $(AM_V_RUNTEST_@AM_DEFAULT_V@) AM_V_RUNTEST_0 = @echo " RUNTEST $(RUNTESTFLAGS)"; AM_V_RUNTEST_1 = -site-srcdir.exp: Makefile - $(AM_V_GEN)echo "set srcdir \"$(srcdir)/testsuite\"" > $@ +site-sim-config.exp: Makefile + $(AM_V_GEN)( \ + echo "set builddir \"$(builddir)\""; \ + echo "set srcdir \"$(srcdir)/testsuite\""; \ + ) > $@ check-DEJAGNU: site.exp $(AM_V_RUNTEST)LC_ALL=C; export LC_ALL; \ @@ -37,6 +40,6 @@ check-DEJAGNU: site.exp fi MOSTLYCLEANFILES += \ - site-srcdir.exp testrun.log testrun.sum + site-sim-config.exp testrun.log testrun.sum include %D%/common/local.mk |