forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -1251,12 +1251,12 @@ CLEANFILES = common/version.c common/version.c-stamp \
|
|||||||
testsuite/common/bits32m31.c testsuite/common/bits64m0.c \
|
testsuite/common/bits32m31.c testsuite/common/bits64m0.c \
|
||||||
testsuite/common/bits64m63.c
|
testsuite/common/bits64m63.c
|
||||||
DISTCLEANFILES =
|
DISTCLEANFILES =
|
||||||
MOSTLYCLEANFILES = core $(am__append_5) site-srcdir.exp testrun.log \
|
MOSTLYCLEANFILES = core $(am__append_5) site-sim-config.exp \
|
||||||
testrun.sum $(am__append_7) $(am__append_10) $(am__append_12) \
|
testrun.log testrun.sum $(am__append_7) $(am__append_10) \
|
||||||
$(am__append_15) $(am__append_17) $(am__append_19) \
|
$(am__append_12) $(am__append_15) $(am__append_17) \
|
||||||
$(am__append_21) $(am__append_24) $(am__append_26) \
|
$(am__append_19) $(am__append_21) $(am__append_24) \
|
||||||
$(am__append_29) $(am__append_31) $(am__append_33) \
|
$(am__append_26) $(am__append_29) $(am__append_31) \
|
||||||
$(am__append_36) $(am__append_38)
|
$(am__append_33) $(am__append_36) $(am__append_38)
|
||||||
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
|
AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
|
||||||
AM_CPPFLAGS = -I$(srcroot)/include $(SIM_INLINE) -I$(srcdir)/common
|
AM_CPPFLAGS = -I$(srcroot)/include $(SIM_INLINE) -I$(srcdir)/common
|
||||||
COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS) $(CFLAGS_FOR_BUILD)
|
COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS) $(CFLAGS_FOR_BUILD)
|
||||||
@@ -1336,7 +1336,7 @@ common_libcommon_a_SOURCES = \
|
|||||||
|
|
||||||
|
|
||||||
# Tweak the site.exp so it works with plain `runtest` from user.
|
# 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?).
|
# Custom verbose test variables that automake doesn't provide (yet?).
|
||||||
AM_V_RUNTEST = $(AM_V_RUNTEST_@AM_V@)
|
AM_V_RUNTEST = $(AM_V_RUNTEST_@AM_V@)
|
||||||
@@ -2662,8 +2662,11 @@ common/version.c-stamp: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(src
|
|||||||
@SIM_ENABLE_IGEN_TRUE@igen/%-main.o: igen/%.c
|
@SIM_ENABLE_IGEN_TRUE@igen/%-main.o: igen/%.c
|
||||||
@SIM_ENABLE_IGEN_TRUE@ $(AM_V_CC)$(COMPILE_FOR_BUILD) -DMAIN -c $< -o $@
|
@SIM_ENABLE_IGEN_TRUE@ $(AM_V_CC)$(COMPILE_FOR_BUILD) -DMAIN -c $< -o $@
|
||||||
|
|
||||||
site-srcdir.exp: Makefile
|
site-sim-config.exp: Makefile
|
||||||
$(AM_V_GEN)echo "set srcdir \"$(srcdir)/testsuite\"" > $@
|
$(AM_V_GEN)( \
|
||||||
|
echo "set builddir \"$(builddir)\""; \
|
||||||
|
echo "set srcdir \"$(srcdir)/testsuite\""; \
|
||||||
|
) > $@
|
||||||
|
|
||||||
check-DEJAGNU: site.exp
|
check-DEJAGNU: site.exp
|
||||||
$(AM_V_RUNTEST)LC_ALL=C; export LC_ALL; \
|
$(AM_V_RUNTEST)LC_ALL=C; export LC_ALL; \
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ if [istarget bfin-*-elf] {
|
|||||||
# all machines
|
# all machines
|
||||||
set all_machs "bfin"
|
set all_machs "bfin"
|
||||||
|
|
||||||
|
global objdir
|
||||||
|
|
||||||
# See if we have a preprocessor available.
|
# 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"]] == "" } {
|
[list "incdir=$srcdir/$subdir"]] == "" } {
|
||||||
set has_cpp 1
|
set has_cpp 1
|
||||||
} {
|
} {
|
||||||
@@ -14,7 +16,7 @@ if [istarget bfin-*-elf] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# See if we have a compiler available.
|
# 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"]] == "" } {
|
[list "incdir=$srcdir/$subdir" "additional_flags=-msim"]] == "" } {
|
||||||
set has_cc 1
|
set has_cc 1
|
||||||
} {
|
} {
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ if [istarget cris*-*-elf] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Using target_compile, since it is less noisy,
|
# 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" "" ] == "" } {
|
"executable" "" ] == "" } {
|
||||||
set has_cc 1
|
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
|
# detrimental effects on the executable from the specs and
|
||||||
# -static in the board ldflags, we just add -Bdynamic.
|
# -static in the board ldflags, we just add -Bdynamic.
|
||||||
if [regexp "(.*/lib)/libc.so" \
|
if [regexp "(.*/lib)/libc.so" \
|
||||||
[target_compile $srcdir/$subdir/hello.c compilercheck.x \
|
[target_compile $srcdir/$subdir/hello.c $objdir/compilercheck.x \
|
||||||
"executable" \
|
"executable" \
|
||||||
"ldflags=-print-file-name=libc.so -Wl,-Bdynamic"] \
|
"ldflags=-print-file-name=libc.so -Wl,-Bdynamic"] \
|
||||||
xxx libcsodir] {
|
xxx libcsodir] {
|
||||||
@@ -169,7 +170,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
|
|||||||
|
|
||||||
verbose -log "Compiling $src with $opts(cc)"
|
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
|
unresolved $testname
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -192,7 +193,7 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
|
|||||||
eval setup_kfail $opts(kfail)
|
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 return_code [lindex $result 0]
|
||||||
set output [lindex $result 1]
|
set output [lindex $result 1]
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ int main (int argc, char *argv[])
|
|||||||
if (fnam == NULL)
|
if (fnam == NULL)
|
||||||
abort ();
|
abort ();
|
||||||
strcpy (fnam, "/");
|
strcpy (fnam, "/");
|
||||||
strcat (fnam, argv[0]);
|
strcat (fnam, basename (argv[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
f = fopen (fnam, "rb");
|
f = fopen (fnam, "rb");
|
||||||
|
|||||||
@@ -17,12 +17,6 @@ void err (const char *s)
|
|||||||
|
|
||||||
int main (int argc, char *argv[])
|
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
|
if (rename (argv[0], NULL) != -1
|
||||||
|| errno != EFAULT)
|
|| errno != EFAULT)
|
||||||
err ("rename 1 ");
|
err ("rename 1 ");
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ int main (int argc, char *argv[])
|
|||||||
char path[1024] = "/";
|
char path[1024] = "/";
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
strcat (path, argv[0]);
|
strcat (path, basename (argv[0]));
|
||||||
if (stat (".", &buf) != 0
|
if (stat (".", &buf) != 0
|
||||||
|| !S_ISDIR (buf.st_mode))
|
|| !S_ISDIR (buf.st_mode))
|
||||||
abort ();
|
abort ();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
proc sim_has_rv_and_cris {} {
|
proc sim_has_rv_and_cris {} {
|
||||||
global srcdir
|
global srcdir
|
||||||
global subdir
|
global subdir
|
||||||
|
global objdir
|
||||||
global SIMFLAGS_FOR_TARGET
|
global SIMFLAGS_FOR_TARGET
|
||||||
|
|
||||||
# We need to assemble and link a trivial program and pass that, in
|
# 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 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"]
|
"-I$srcdir/$subdir"]
|
||||||
|
|
||||||
if ![string match "" $comp_output] {
|
if ![string match "" $comp_output] {
|
||||||
@@ -43,7 +44,7 @@ proc sim_has_rv_and_cris {} {
|
|||||||
return 0
|
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] {
|
if ![string match "" $comp_output] {
|
||||||
verbose -log "$comp_output" 3
|
verbose -log "$comp_output" 3
|
||||||
@@ -52,7 +53,7 @@ proc sim_has_rv_and_cris {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set result \
|
set result \
|
||||||
[sim_run quit.x \
|
[sim_run $objdir/quit.x \
|
||||||
"$SIMFLAGS_FOR_TARGET --hw-device rv --hw-device cris --hw-info" \
|
"$SIMFLAGS_FOR_TARGET --hw-device rv --hw-device cris --hw-info" \
|
||||||
"" "" ""]
|
"" "" ""]
|
||||||
set return_code [lindex $result 0]
|
set return_code [lindex $result 0]
|
||||||
@@ -117,8 +118,8 @@ if [istarget cris*-*-*] {
|
|||||||
# See the logic in sim-defs.exp for more details.
|
# See the logic in sim-defs.exp for more details.
|
||||||
set sim [board_info target sim]
|
set sim [board_info target sim]
|
||||||
if [string equal "" $sim] {
|
if [string equal "" $sim] {
|
||||||
global objdir
|
global builddir
|
||||||
set rvdummy "$objdir/cris/rvdummy"
|
set rvdummy "$builddir/cris/rvdummy"
|
||||||
} else {
|
} else {
|
||||||
set rvdummy "[file dirname [board_info target sim]]/rvdummy"
|
set rvdummy "[file dirname [board_info target sim]]/rvdummy"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ proc sim_tool_path {} {
|
|||||||
global sim_path
|
global sim_path
|
||||||
set sim "$sim_path"
|
set sim "$sim_path"
|
||||||
if [string equal "" $sim] {
|
if [string equal "" $sim] {
|
||||||
global objdir
|
global builddir
|
||||||
global subdir
|
global subdir
|
||||||
set arch "$subdir"
|
set arch "$subdir"
|
||||||
while { [file dirname $arch] != "." } {
|
while { [file dirname $arch] != "." } {
|
||||||
set arch [file dirname $arch]
|
set arch [file dirname $arch]
|
||||||
}
|
}
|
||||||
return "$objdir/$arch/run"
|
return "$builddir/$arch/run"
|
||||||
}
|
}
|
||||||
return "$sim"
|
return "$sim"
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ proc sim_run { prog sim_opts prog_opts redir options } {
|
|||||||
# optional for xfail.
|
# optional for xfail.
|
||||||
|
|
||||||
proc run_sim_test { name requested_machs } {
|
proc run_sim_test { name requested_machs } {
|
||||||
global subdir srcdir
|
global subdir srcdir objdir
|
||||||
global opts
|
global opts
|
||||||
global cpu_option
|
global cpu_option
|
||||||
global cpu_option_sep
|
global cpu_option_sep
|
||||||
@@ -328,16 +328,16 @@ proc run_sim_test { name requested_machs } {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [string match "*.c" $sourcefile] {
|
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)"]]
|
[list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options $c_ld_options $opts(cc,$mach)"]]
|
||||||
set method "compiling/linking"
|
set method "compiling/linking"
|
||||||
} else {
|
} else {
|
||||||
if [string match "*.S" $sourcefile] {
|
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"]]
|
[list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options"]]
|
||||||
set method "compiling"
|
set method "compiling"
|
||||||
} else {
|
} 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"
|
set method "assembling"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ proc run_sim_test { name requested_machs } {
|
|||||||
continue
|
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"
|
set method "linking"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +368,7 @@ proc run_sim_test { name requested_machs } {
|
|||||||
set options "$options timeout=$opts(timeout)"
|
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 return_code [lindex $result 0]
|
||||||
set output [lindex $result 1]
|
set output [lindex $result 1]
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ proc run_sim_test { name requested_machs } {
|
|||||||
if { "$opts(xerror)" == "no" } {
|
if { "$opts(xerror)" == "no" } {
|
||||||
if [string match $opts(output) $output] {
|
if [string match $opts(output) $output] {
|
||||||
pass "$mach $testname"
|
pass "$mach $testname"
|
||||||
file delete ${name}.o ${name}.x
|
file delete $objdir/${name}.o $objdir/${name}.x
|
||||||
} else {
|
} else {
|
||||||
verbose -log "status: $return_code" 3
|
verbose -log "status: $return_code" 3
|
||||||
verbose -log "output: $output" 3
|
verbose -log "output: $output" 3
|
||||||
@@ -400,7 +400,7 @@ proc run_sim_test { name requested_machs } {
|
|||||||
} else {
|
} else {
|
||||||
if [string match $opts(output) $output] {
|
if [string match $opts(output) $output] {
|
||||||
pass "$mach $testname"
|
pass "$mach $testname"
|
||||||
file delete ${name}.o ${name}.x
|
file delete $objdir/${name}.o $objdir/${name}.x
|
||||||
} else {
|
} else {
|
||||||
verbose -log "status: $return_code" 3
|
verbose -log "status: $return_code" 3
|
||||||
verbose -log "output: $output" 3
|
verbose -log "output: $output" 3
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Tweak the site.exp so it works with plain `runtest` from user.
|
# 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?).
|
# Custom verbose test variables that automake doesn't provide (yet?).
|
||||||
AM_V_RUNTEST = $(AM_V_RUNTEST_@AM_V@)
|
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_0 = @echo " RUNTEST $(RUNTESTFLAGS)";
|
||||||
AM_V_RUNTEST_1 =
|
AM_V_RUNTEST_1 =
|
||||||
|
|
||||||
site-srcdir.exp: Makefile
|
site-sim-config.exp: Makefile
|
||||||
$(AM_V_GEN)echo "set srcdir \"$(srcdir)/testsuite\"" > $@
|
$(AM_V_GEN)( \
|
||||||
|
echo "set builddir \"$(builddir)\""; \
|
||||||
|
echo "set srcdir \"$(srcdir)/testsuite\""; \
|
||||||
|
) > $@
|
||||||
|
|
||||||
check-DEJAGNU: site.exp
|
check-DEJAGNU: site.exp
|
||||||
$(AM_V_RUNTEST)LC_ALL=C; export LC_ALL; \
|
$(AM_V_RUNTEST)LC_ALL=C; export LC_ALL; \
|
||||||
@@ -37,6 +40,6 @@ check-DEJAGNU: site.exp
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
MOSTLYCLEANFILES += \
|
MOSTLYCLEANFILES += \
|
||||||
site-srcdir.exp testrun.log testrun.sum
|
site-sim-config.exp testrun.log testrun.sum
|
||||||
|
|
||||||
include %D%/common/local.mk
|
include %D%/common/local.mk
|
||||||
|
|||||||
Reference in New Issue
Block a user