Add a have_native_target helper function for use with require.
authorJohn Baldwin <jhb@FreeBSD.org>
Fri, 14 Jul 2023 15:39:24 +0000 (08:39 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Fri, 14 Jul 2023 15:39:24 +0000 (08:39 -0700)
Move logic from auto-connect-native-target.exp into this helper.

gdb/testsuite/gdb.base/auto-connect-native-target.exp
gdb/testsuite/lib/gdb.exp

index 002a6d6112642457258b173d31a975e44c1a0384..0586cd4baf465d47b9568185f75f80b212ca747d 100644 (file)
@@ -22,23 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
     return -1
 }
 
-# Whether this GDB is configured with a "native" target.
-set have_native 0
-
-set test "help target native"
-gdb_test_multiple $test $test {
-    -re "Undefined target command.*$gdb_prompt $" {
-       set have_native 0
-    }
-    -re "Native process.*$gdb_prompt $" {
-       set have_native 1
-    }
-}
-
-if { !$have_native } {
-    unsupported "no \"target native\" support."
-    return
-}
+require have_native_target
 
 # Returns the topmost target pushed on the target stack.  TEST is used
 # as test message.
index bf8cdbd750c2538c6e67b0f36e3a55926b4d4dcc..66c04a2efe233eb881779d6076bc4b7b54d819a1 100644 (file)
@@ -9837,6 +9837,20 @@ gdb_caching_proc have_compile_and_link_flag { flag } {
                additional_flags=$flag]
 }
 
+# Return 1 if this GDB is configured with a "native" target.
+
+gdb_caching_proc have_native_target {} {
+    gdb_test_multiple "help target native" "" {
+       -re -wrap "Undefined target command.*" {
+           return 0
+       }
+       -re -wrap "Native process.*" {
+           return 1
+       }
+    }
+    return 0
+}
+
 # Handle include file $srcdir/$subdir/FILE.
 
 proc include_file { file } {