public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed 2/2] [gdb/testsuite] Fix gdb.gdb/unittest.exp for remote host
Date: Mon, 27 Mar 2023 17:40:20 +0200	[thread overview]
Message-ID: <20230327154020.26151-2-tdevries@suse.de> (raw)
In-Reply-To: <20230327154020.26151-1-tdevries@suse.de>

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


      reply	other threads:[~2023-03-27 15:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 15:40 [pushed 1/2] [gdb/testsuite] Skip do_self_tests on " Tom de Vries
2023-03-27 15:40 ` Tom de Vries [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230327154020.26151-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).