public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/2] [gdb/testsuite] Skip do_self_tests on remote host
@ 2023-03-27 15:40 Tom de Vries
  2023-03-27 15:40 ` [pushed 2/2] [gdb/testsuite] Fix gdb.gdb/unittest.exp for " Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-03-27 15:40 UTC (permalink / raw)
  To: gdb-patches

In do_self_tests we try to find out the location of the gdb to debug, which
will then be copied and renamed to xgdb.

In principle, the host board specifies the location of GDB, on host.

With remote host, we could upload that gdb from host to build/target, but we
would miss the data directory (which is listed as the reason to skip
do_self_tests for remote target).

We could fix that by instead taking the gdb from build instead, but that
wouldn't work with installed testing.

It seems easier to just skip this on remote host.

It could be made to work for the "[is_remote host] && [is_remote target]
&& host == target" scenario (see board local-remote-host-native.exp), but
that doesn't seem worth the effort.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/selftest-support.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 61379f59bb4..1e7a2cea8b7 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -100,7 +100,7 @@ proc do_self_tests {function body} {
     # Are we testing with a remote board?  In that case, the target
     # won't have access to the GDB's auxilliary data files
     # (data-directory, etc.).  It's simpler to just skip.
-    if [is_remote target] {
+    if { [is_remote target]  || [is_remote host] } {
 	return
     }
 

base-commit: 2215170485845673379b59d3e4e5e1a9ac01ba41
-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pushed 2/2] [gdb/testsuite] Fix gdb.gdb/unittest.exp for remote host
  2023-03-27 15:40 [pushed 1/2] [gdb/testsuite] Skip do_self_tests on remote host Tom de Vries
@ 2023-03-27 15:40 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2023-03-27 15:40 UTC (permalink / raw)
  To: gdb-patches

Fix test-case gdb.gdb/unittest.exp for remote host, by:
- disabling the completion tests if readline is not used, and
- not using with_gdb_cwd $dir for remote host (because it does
  not support changing to ".").

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.gdb/unittest.exp | 75 ++++++++++++++++++------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index a0e918c36f6..5434a1a0941 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -27,9 +27,38 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-proc run_selftests { binfile } {
+proc run_selftests_1 {} {
     global decimal gdb_prompt
 
+    set enabled 1
+    set num_ran 0
+
+    set test "maintenance selftest"
+    gdb_test_multiple $test $test {
+	-re ".*Running selftest \[^\n\r\]+\." {
+	    # The selftests can take some time to complete.  To prevent
+	    # timeout spot the 'Running ...' lines going past, so long as
+	    # these are produced quickly enough then the overall test will
+	    # not timeout.
+	    exp_continue
+	}
+	-re "Ran ($decimal) unit tests, ($decimal) failed\r\n$gdb_prompt $" {
+	    set num_ran $expect_out(1,string)
+	    set num_failed $expect_out(2,string)
+	    gdb_assert "$num_ran > 0" "$test, ran some tests"
+	    gdb_assert "$num_failed == 0" "$test, failed none"
+	}
+	-re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {
+	    unsupported $test
+	    set num_ran 0
+	    set enabled 0
+	}
+    }
+
+    return [list $enabled $num_ran]
+}
+
+proc run_selftests { binfile } {
     if { $binfile == "" } {
 	gdb_exit
 	gdb_start
@@ -37,38 +66,18 @@ proc run_selftests { binfile } {
 	clean_restart ${binfile}
     }
 
-    # Some of the selftests create temporary files in GDB's current
-    # directory.  So, while running the selftests, switch to the
-    # test's output directory to avoid leaving clutter in the
-    # gdb/testsuite root directory.
-    set dir [standard_output_file ""]
-    set enabled 1
-    set num_ran 0
-    with_gdb_cwd $dir {
-	set test "maintenance selftest"
-	gdb_test_multiple $test $test {
-	    -re ".*Running selftest \[^\n\r\]+\." {
-		# The selftests can take some time to complete.  To prevent
-		# timeout spot the 'Running ...' lines going past, so long as
-		# these are produced quickly enough then the overall test will
-		# not timeout.
-		exp_continue
-	    }
-	    -re "Ran ($decimal) unit tests, ($decimal) failed\r\n$gdb_prompt $" {
-		set num_ran $expect_out(1,string)
-		set num_failed $expect_out(2,string)
-		gdb_assert "$num_ran > 0" "$test, ran some tests"
-		gdb_assert "$num_failed == 0" "$test, failed none"
-	    }
-	    -re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {
-		unsupported $test
-		set num_ran 0
-		set enabled 0
-	    }
+    if { [is_remote host] } {
+	return [run_selftests_1]
+    } else {
+	# Some of the selftests create temporary files in GDB's current
+	# directory.  So, while running the selftests, switch to the
+	# test's output directory to avoid leaving clutter in the
+	# gdb/testsuite root directory.
+	set dir [standard_output_file ""]
+	with_gdb_cwd $dir {
+	    return [run_selftests_1]
 	}
     }
-
-    return [list $enabled $num_ran]
 }
 
 # Test completion of command "maintenance selftest".
@@ -78,6 +87,10 @@ proc_with_prefix test_completion {} {
 
     clean_restart
 
+    if { ![readline_is_used] } {
+	return
+    }
+
     if { $self_tests_enabled } {
 	test_gdb_complete_tab_multiple "maintenance selftest copy" "_" \
 	    {copy_bitwise copy_integer_to_size}
-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-27 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 15:40 [pushed 1/2] [gdb/testsuite] Skip do_self_tests on remote host Tom de Vries
2023-03-27 15:40 ` [pushed 2/2] [gdb/testsuite] Fix gdb.gdb/unittest.exp for " Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).