]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix gdb.gdb/unittest.exp for remote host
authorTom de Vries <tdevries@suse.de>
Mon, 27 Mar 2023 15:40:06 +0000 (17:40 +0200)
committerTom de Vries <tdevries@suse.de>
Mon, 27 Mar 2023 15:40:06 +0000 (17:40 +0200)
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

index a0e918c36f6904a05a47253b359d434ff263a050..5434a1a0941f68cfb21808911250adbf35bd0e84 100644 (file)
@@ -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}