diff mbox series

[committed] jit: add a way to preserve testsuite executables

Message ID 1509482701-31510-1-git-send-email-dmalcolm@redhat.com
State New
Headers show
Series [committed] jit: add a way to preserve testsuite executables | expand

Commit Message

David Malcolm Oct. 31, 2017, 8:45 p.m. UTC
The jit documentation has instructions on running testsuite executables
under the debugger, but I realize now that the executables were always
being deleted after being run, and I've always been hacking up my jit.exp
to prevent this, to allow for debugging them.

This patch adds a PRESERVE_EXECUTABLES environment variable to jit.exp
to provide a simple, documented way to do this.

Committed to trunk as r254282.

gcc/jit/ChangeLog:
	* docs/internals/index.rst (Running the test suite): Document
	PRESERVE_EXECUTABLES.
	(Running under valgrind): Add markup to RUN_UNDER_VALGRIND.
	* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
	* jit.dg/jit.exp (jit-dg-test): If PRESERVE_EXECUTABLES is set in
	the environment, don't delete the generated executable.
---
 gcc/jit/docs/internals/index.rst | 10 +++++++---
 gcc/testsuite/jit.dg/jit.exp     |  9 +++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/jit/docs/internals/index.rst b/gcc/jit/docs/internals/index.rst
index cadf362..4ad7f61 100644
--- a/gcc/jit/docs/internals/index.rst
+++ b/gcc/jit/docs/internals/index.rst
@@ -103,7 +103,9 @@  and detailed logs in:
 
   jit/build/gcc/testsuite/jit/jit.log
 
-The test executables can be seen as:
+The test executables are normally deleted after each test is run.  For
+debugging, they can be preserved by setting :envvar:`PRESERVE_EXECUTABLES`
+in the environment.  If so, they can then be seen as:
 
 .. code-block:: console
 
@@ -115,7 +117,9 @@  You can compile and run individual tests by passing "jit.exp=TESTNAME" to RUNTES
 
 .. code-block:: console
 
-   [gcc] $ make check-jit RUNTESTFLAGS="-v -v -v jit.exp=test-factorial.c"
+   [gcc] $ PRESERVE_EXECUTABLES= \
+             make check-jit \
+               RUNTESTFLAGS="-v -v -v jit.exp=test-factorial.c"
 
 and once a test has been compiled, you can debug it directly:
 
@@ -130,7 +134,7 @@  and once a test has been compiled, you can debug it directly:
 Running under valgrind
 **********************
 
-The jit testsuite detects if RUN_UNDER_VALGRIND is present in the
+The jit testsuite detects if :envvar:`RUN_UNDER_VALGRIND` is present in the
 environment (with any value).  If it is present, it runs the test client
 code under `valgrind <http://valgrind.org>`_,
 specifcally, the default
diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index 39e37c2..869d9f6 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -580,6 +580,15 @@  proc jit-dg-test { prog do_what extra_tool_flags } {
 	verbose "$name is not meant to generate a reproducer"
     }
 
+    # Normally we would return $comp_output and $output_file to the
+    # caller, which would delete $output_file, the generated executable.
+    # If we need to debug, it's handy to be able to suppress this behavior,
+    # keeping the executable around.
+    set preserve_executables [info exists env(PRESERVE_EXECUTABLES)]
+    if $preserve_executables {
+	set output_file ""
+    }
+    
     return [list $comp_output $output_file]
 }