git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCHv2 1/2] tests: create an interactive gdb session with the 'debug' helper

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Mar 18, 2017, 16:13 UTC
Message-ID
<20170318161400.19753-1-szeder.dev@gmail.com>
In-Reply-To
<CAM0VKj=k8kygEPpfX+-n0ODd70A8PEYAviKosvc0D34jT02N5w@mail.gmail.com>

The 'debug' test helper is supposed to facilitate debugging by running a command of the test suite under gdb. Unfortunately, its usefulness is severely limited, because that gdb session is not interactive, since the test's, and thus gdb's standard input is redirected from /dev/null (for a good reason, see 781f76b15 (test-lib: redirect stdin of tests, 2011-12-15)).

Redirect gdb's standard file descriptors from/to the test environment's stdin, stdout and stderr in the 'debug' helper, thus creating an interactive gdb session (even in non-verbose mode), which is much, much more useful.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/test-lib-functions.sh | 2 +-
 t/test-lib.sh           | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index bd357704c..4a50a6104 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -154,7 +154,7 @@ test_pause () {
 #
 # Example: "debug git checkout master".
 debug () {
-	 GIT_TEST_GDB=1 "$@"
+	 GIT_TEST_GDB=1 "$@" <&6 >&5 2>&7
 }
 
 # Call test_commit with the arguments
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 86d77c16d..23c29bce6 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -342,6 +342,7 @@ fi
 
 exec 5>&1
 exec 6<&0
+exec 7>&2
 if test "$verbose_log" = "t"
 then
 	exec 3>>"$GIT_TEST_TEE_OUTPUT_FILE" 4>&3
-- 
2.12.0.377.g15f6ffe90
Previous: SZEDER GáborNext: SZEDER Gábor
Message 4 of 9 in “tests: create an interactive gdb session with the 'debug' helper”
  1. tests: create an interactive gdb session with the 'debug' helperSZEDER Gábor, Mar 17, 2017
  2. Jeff KingMar 17, 2017
  3. SZEDER GáborMar 18, 2017
  4. 1/2 tests: create an interactive gdb session with the 'debug' helperSZEDER Gábor, Mar 18, 2017
  5. 2/2 tests: make the 'test_pause' helper work in non-verbose modeSZEDER Gábor, Mar 18, 2017
  6. Jeff KingMar 20, 2017
  7. Jeff KingMar 20, 2017
  8. Johannes SchindelinMar 21, 2017
  9. Jeff KingMar 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.