[RFC] Run tests in sub dir of testsuite/

Yao Qi yao@codesourcery.com
Thu Dec 25 02:46:00 GMT 2014


Yao Qi <yao@codesourcery.com> writes:

> This patch is to run testsuite in a subdirectory of testsuite/, in
> order to facilitate 'make clean'.  In sequential testing, directory
> testsuite/sequential-tests is created, and in parallel testing,
> directory testsuite/parallel-tests is created.  Testing artifacts
> (such as directory gdb.base, gdb.ada, object files, shared libraries
> and executables) are stored in it.
>
> In testsuite/Makefile.in, we set OUTPUTDIR to either sequential-tests
> or parallel-tests, determined by whether we run tests in parallel.
> Makefile passes OUTPUTDIR to dejagnu, and lib/gdb.exp return the
> expected file path according to OUTPUTDIR.
>
> This patch changes the location of gdb.sum, so some build/test scripts
> are affected.

Here is the V2, to address the comments I've got.

-- 
Yao (齐尧)

Subject: [PATCH] Run tests in sub dir of testsuite/

Here is the V2, in which we have two changes,

 1. Don't change the location of gdb.sum and gdb.log,
 2. Rename sequential-tests by sequential-run.

----------------------------------------------------------------

This patch is to run testsuite in a subdirectory of testsuite/, in
order to facilitate 'make clean'.  In sequential testing, directory
testsuite/sequential-run is created, and in parallel testing,
directory testsuite/parallel-run is created.  Testing artifacts
(such as directory gdb.base, gdb.ada, object files, shared libraries
and executables) are stored in it.

In testsuite/Makefile.in, we set OUTPUTDIR to either sequential-run
or parallel-run, determined by whether we run tests in parallel.
Makefile passes OUTPUTDIR to dejagnu, and lib/gdb.exp return the
expected file path according to OUTPUTDIR.

This patch doesn't changes the location of gdb.sum.

gdb/testsuite:

2014-12-25  Yao Qi  <yao@codesourcery.com>

	* Makefile.in: Set OUTPUTDIR.
	(check-single): Create dir OUTPUTDIR and pass $(OUTPUTDIR) to
	runtest.
	(check-parallel): Use $(OUTPUTDIR).
	(check/%.exp): Pass $(OUTPUTDIR) to runtest.
	(check-perf): Likewise.
	(clean): Remove directory sequential-run and parallel-run.
	* lib/gdb.exp (standard_output_file): Return file path name
	according to new directory structure.
	(gdb_init): Use $OUTPUTDIR instead of outputs.
	(top-level): Create directory $OUTPUTDIR.
	* lib/trace-support.exp (get_in_proc_agent): Don't use $objdir
	in the path of inprocagent.
	* gdb.base/completion.exp: Use ${OUTPUTDIR}.
	* gdb.base/hashline1.exp: Use [pwd] instead of $objdir.

diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in
index 07d3942..6233fd2 100644
--- a/gdb/testsuite/Makefile.in
+++ b/gdb/testsuite/Makefile.in
@@ -145,8 +145,12 @@ installcheck:
 # given.  If RUNTESTFLAGS is not empty, then by default the tests will
 # be serialized.  This can be overridden by setting FORCE_PARALLEL to
 # any non-empty value.  For a non-GNU make, do not parallelize.
+# If we run tests in parallel, set the OUTPUTDIR parallel-run, otherwise
+# set it sequential-run.
 @GMAKE_TRUE@CHECK_TARGET = $(if $(FORCE_PARALLEL),check-parallel,$(if $(RUNTESTFLAGS),check-single,$(if $(saw_dash_j),check-parallel,check-single)))
+@GMAKE_TRUE@OUTPUTDIR = $(if $(FORCE_PARALLEL),parallel-run,$(if $(RUNTESTFLAGS),sequential-run,$(if $(saw_dash_j),parallel-run,sequential-run)))
 @GMAKE_FALSE@CHECK_TARGET = check-single
+@GMAKE_FALSE@OUTPUTDIR = sequential-run
 
 # Note that we must resort to a recursive make invocation here,
 # because GNU make 3.82 has a bug preventing MAKEFLAGS from being used
@@ -193,15 +197,16 @@ DO_RUNTEST = \
 @GMAKE_TRUE@	$(MAKE) check TESTS="gdb.$*/*.exp"
 
 check-single:
-	$(DO_RUNTEST) $(RUNTESTFLAGS) $(expanded_tests_or_none)
+	-mkdir -p $(OUTPUTDIR)
+	$(DO_RUNTEST) OUTPUTDIR=$(OUTPUTDIR) $(RUNTESTFLAGS) $(expanded_tests_or_none)
 
 check-parallel:
-	-rm -rf cache outputs temp
+	-rm -rf cache $(OUTPUTDIR) temp
 	$(MAKE) -k do-check-parallel; \
 	$(SHELL) $(srcdir)/dg-extract-results.sh \
-	  `find outputs -name gdb.sum -print` > gdb.sum; \
+	  `find $(OUTPUTDIR) -name gdb.sum -print` > gdb.sum; \
 	$(SHELL) $(srcdir)/dg-extract-results.sh -L \
-	  `find outputs -name gdb.log -print` > gdb.log
+	  `find $(OUTPUTDIR) -name gdb.log -print` > gdb.log
 	@sed -n '/=== gdb Summary ===/,$$ p' gdb.sum
 
 # Turn a list of .exp files into "check/" targets.  Only examine .exp
@@ -226,8 +231,8 @@ do-check-parallel: $(TEST_TARGETS)
 	@:
 
 @GMAKE_TRUE@check/%.exp:
-@GMAKE_TRUE@	-mkdir -p outputs/$*
-@GMAKE_TRUE@	@$(DO_RUNTEST) GDB_PARALLEL=yes --outdir=outputs/$* $*.exp $(RUNTESTFLAGS)
+@GMAKE_TRUE@	-mkdir -p $(OUTPUTDIR)/$*
+@GMAKE_TRUE@	@$(DO_RUNTEST) GDB_PARALLEL=yes OUTPUTDIR=$(OUTPUTDIR) --outdir=$(OUTPUTDIR)/$* $*.exp $(RUNTESTFLAGS)
 
 check/no-matching-tests-found:
 	@echo ""
@@ -235,8 +240,8 @@ check/no-matching-tests-found:
 	@echo ""
 
 check-perf: all $(abs_builddir)/site.exp
-	@if test ! -d gdb.perf; then mkdir gdb.perf; fi
-	$(DO_RUNTEST) --directory=gdb.perf --outdir gdb.perf GDB_PERFTEST_MODE=both $(RUNTESTFLAGS)
+	@if test ! -d $(OUTPUTDIR)/gdb.perf; then mkdir $(OUTPUTDIR)/gdb.perf; fi
+	$(DO_RUNTEST) --directory=gdb.perf --outdir $(OUTPUTDIR)/gdb.perf GDB_PERFTEST_MODE=both OUTPUTDIR=$(OUTPUTDIR) $(RUNTESTFLAGS)
 
 force:;
 
@@ -244,7 +249,7 @@ clean mostlyclean:
 	-rm -f *~ core *.o a.out xgdb *.x *.grt bigcore.corefile .gdb_history
 	-rm -f core.* *.tf *.cl *.py tracecommandsscript copy1.txt zzz-gdbscript
 	-rm -f *.dwo *.dwp
-	-rm -rf outputs temp cache
+	-rm -rf sequential-run parallel-run temp cache
 	-rm -f read1.so expect-read1
 	if [ x"${ALL_SUBDIRS}" != x ] ; then \
 	    for dir in ${ALL_SUBDIRS}; \
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 9c79a29..3a9fba2 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -108,7 +108,7 @@ gdb_test_multiple "target ctf" "" {
 # is a parallel run or not.  Firstly check file exists, and then
 # do the test on file completion.
 
-foreach dir1 [ list "./gdb.base" "./outputs/gdb.base/completion" ] {
+foreach dir1 [ list "${OUTPUTDIR}/gdb.base" "${OUTPUTDIR}/gdb.base/completion" ] {
     if { [remote_file host exists ${dir1}/completion]
 	 && [remote_file host exists ${dir1}/completion0.o]
 	 && [remote_file host exists ${dir1}/completion1.o] } {
diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp
index 1260b80..32290cd 100644
--- a/gdb/testsuite/gdb.base/hashline1.exp
+++ b/gdb/testsuite/gdb.base/hashline1.exp
@@ -31,7 +31,7 @@ close $fd
 
 # The choice of path name for the source file is important in order to trigger
 # the bug.  Using $new_srcfile here won't trigger the bug.
-set compile_name [relative_filename $objdir $new_srcfile]
+set compile_name [relative_filename [pwd] $new_srcfile]
 if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } {
     untested hashline1.exp
     return -1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 08087f2..6905c77 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3726,15 +3726,16 @@ proc default_gdb_init { test_file_name } {
 # the directory is returned.
 
 proc standard_output_file {basename} {
-    global objdir subdir gdb_test_file_name GDB_PARALLEL
+    global objdir subdir gdb_test_file_name GDB_PARALLEL OUTPUTDIR
 
+    set dir [file join $objdir $OUTPUTDIR $subdir]
     if {[info exists GDB_PARALLEL]} {
-	set dir [file join $objdir outputs $subdir $gdb_test_file_name]
-	file mkdir $dir
-	return [file join $dir $basename]
-    } else {
-	return [file join $objdir $subdir $basename]
+	set dir [file join $dir $gdb_test_file_name]
     }
+
+    file mkdir $dir
+
+    return [file join $dir $basename]
 }
 
 # Return the name of a file in our standard temporary directory.
@@ -3863,9 +3864,9 @@ proc gdb_init { test_file_name } {
     # inotify-tools package to use this.
     global GDB_INOTIFY inotify_pid
     if {[info exists GDB_INOTIFY] && ![info exists inotify_pid]} {
-	global outdir tool inotify_log_file
+	global outdir tool inotify_log_file OUTPUTDIR
 
-	set exclusions {outputs temp gdb[.](log|sum) cache}
+	set exclusions {$OUTPUTDIR temp gdb[.](log|sum) cache}
 	set exclusion_re ([join $exclusions |])
 
 	set inotify_log_file [standard_temp_file inotify.out]
@@ -4859,10 +4860,12 @@ if {[info exists GDB_PARALLEL]} {
     if {[is_remote host]} {
 	unset GDB_PARALLEL
     } else {
-	file mkdir outputs temp cache
+	file mkdir temp cache
     }
 }
 
+file mkdir $OUTPUTDIR
+
 proc core_find {binfile {deletefiles {}} {arg ""}} {
     global objdir subdir
 
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
index a076bac..f090bfa 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -319,12 +319,11 @@ proc gdb_find_recursion_test_baseline { filename } {
 # Return the location of the IPA library.
 
 proc get_in_proc_agent {} {
-    global objdir
 
     if [target_info exists in_proc_agent] {
 	return [target_info in_proc_agent]
     } else {
-	return $objdir/../gdbserver/libinproctrace.so
+	return ../gdbserver/libinproctrace.so
     }
 }
 



More information about the Gdb-patches mailing list