]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: fix some more duplicate test names in gdb.trace/
authorAndrew Burgess <aburgess@redhat.com>
Thu, 1 Feb 2024 12:49:02 +0000 (12:49 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 5 Mar 2024 16:35:23 +0000 (16:35 +0000)
This commit fixes some duplicate test names in the gdb.trace/
directory when run with the native-gdbserver and
native-extended-gdbserver boards.  In this case the duplicates relate
to the calls to gdb_compile_pthreads which emits a fixed PASS message,
as there are two calls to gdb_compile_pthreads we get a duplicate PASS
message.

In both cases the problem is fixed by adding a with_test_prefix around
one of the compilations, however, I've made additional changes to
clean up the tests a little while I was working on them:

  1. Switch to use prepare_for_testing instead of
  gdb_compile_pthreads.  By passing the 'pthreads' option this does
  call gdb_compile_pthreads under the hood, but using the standard
  compile function is cleaner,

  2. Using prepare_for_testing removes the need to call clean_restart
  immediately afterwards, so those calls are removed,

  3. I removed the unneeded $executable and $expfile globals, where
  the $executable global was used I've replaced this with $binfile,

  4. When we compile two executables I've now given these different
  names so that both exist at the end of the test run,

  5. Removed a gdb_reinitialize_dir call, this is covered by
  clean_restart,

  6. Use gdb_test_no_output where it makes sense.

I now see no duplicate test names when running these test scripts.
There should be no change in what is being tested after this commit.

gdb/testsuite/gdb.trace/ftrace-lock.exp
gdb/testsuite/gdb.trace/trace-mt.exp

index eb0d0f0293376a7158d67e1be48b604a2dc747ae..ce2b890229aa225a095e9bee8a7ba88cd4c778c8 100644 (file)
@@ -16,9 +16,10 @@ load_lib "trace-support.exp"
 
 require allow_shlib_tests
 
+# Check that the target supports trace.
+require gdb_trace_common_supports_arch
+
 standard_testfile
-set executable $testfile
-set expfile $testfile.exp
 
 # make check RUNTESTFLAGS='gdb.trace/ftrace-lock.exp NUM_THREADS=2'
 if ![info exists NUM_THREADS] {
@@ -27,25 +28,23 @@ if ![info exists NUM_THREADS] {
 
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
-set options [list debug [gdb_target_symbol_prefix_flags] \
+set options [list debug pthreads [gdb_target_symbol_prefix_flags] \
             additional_flags=-DNUM_THREADS=$NUM_THREADS]
 
-# Check that the target supports trace.
-require gdb_trace_common_supports_arch
-if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
-    untested "failed to compile"
-    return -1
-}
-
-clean_restart ${testfile}
+with_test_prefix "runtime trace support check" {
+    if { [prepare_for_testing "prepare for testing" ${binfile}-check \
+             $srcfile $options] } {
+       return
+    }
 
-if ![runto_main] {
-    return -1
-}
+    if ![runto_main] {
+       return -1
+    }
 
-if ![gdb_target_supports_trace] {
-    unsupported "target does not support trace"
-    return -1
+    if ![gdb_target_supports_trace] {
+       unsupported "target does not support trace"
+       return -1
+    }
 }
 
 # Compile the test case with the in-process agent library.
@@ -54,13 +53,11 @@ set remote_libipa [gdb_load_shlib $libipa]
 
 lappend options shlib=$libipa
 
-if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $options] != "" } {
-    untested "failed to compile with in-process agent library"
-    return -1
+if { [prepare_for_testing "prepare for testing with libipa" \
+         $binfile $srcfile $options] } {
+    return
 }
 
-clean_restart ${executable}
-
 if ![runto_main] {
     return -1
 }
@@ -76,7 +73,7 @@ gdb_breakpoint "fail" qualified
 gdb_test "ftrace set_point" "Fast tracepoint .*" \
     "fast tracepoint at a long insn"
 
-gdb_test "tstart" ""
+gdb_test_no_output "tstart"
 
 # If NUM_THREADS is high then this test case may timeout.  Increase the
 # timeout temporarily.
@@ -86,4 +83,4 @@ with_timeout_factor $NUM_THREADS {
        "do not hit the fail function"
 }
 
-gdb_test "tstop" ""
+gdb_test_no_output "tstop"
index bfa66dd88eeebc3d4af07947b5696b9c37acdaf7..e56064bbe8baf2933fdbfdb2e6cbe647e0aa86b1 100644 (file)
 load_lib "trace-support.exp"
 
 standard_testfile
-set executable $testfile
-set expfile $testfile.exp
 
 # Some targets have leading underscores on assembly symbols.
 set additional_flags [gdb_target_symbol_prefix_flags]
 
 require gdb_trace_common_supports_arch
 
-if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
-         executable [list debug $additional_flags] ] != "" } {
-    # gdb_compile_pthreads provides an appropriate unsupported message.
-    return -1
-}
-
-clean_restart ${testfile}
+with_test_prefix "runtime trace support check" {
+    if { [prepare_for_testing "prepare for testing" ${binfile} $srcfile \
+             [list debug pthreads $additional_flags]] } {
+       return
+    }
 
-if ![runto_main] {
-    return -1
-}
+    if ![runto_main] {
+       return -1
+    }
 
-if ![gdb_target_supports_trace] {
-    unsupported "target does not support trace"
-    return -1
+    if ![gdb_target_supports_trace] {
+       unsupported "target does not support trace"
+       return -1
+    }
 }
 
-proc step_over_tracepoint { trace_type } \
+proc step_over_tracepoint { binfile trace_type } \
 {with_test_prefix "step over $trace_type" \
 {
-    global executable
     global hex
 
     # Start with a fresh gdb.
-    clean_restart ${executable}
+    clean_restart $binfile
+
     # Make sure inferior is running in all-stop mode.
     gdb_test_no_output "set non-stop 0"
     if ![runto_main] {
@@ -66,14 +63,13 @@ proc step_over_tracepoint { trace_type } \
 
 # Set breakpoint and tracepoint at the same address.
 
-proc break_trace_same_addr { trace_type option } \
+proc break_trace_same_addr { binfile trace_type option } \
 {with_test_prefix "$trace_type $option" \
 {
-    global executable
     global hex
 
     # Start with a fresh gdb.
-    clean_restart ${executable}
+    clean_restart $binfile
     if ![runto_main] {
        return -1
     }
@@ -100,10 +96,10 @@ proc break_trace_same_addr { trace_type option } \
 }}
 
 foreach break_always_inserted { "on" "off" } {
-    break_trace_same_addr "trace" ${break_always_inserted}
+    break_trace_same_addr $binfile "trace" ${break_always_inserted}
 }
 
-step_over_tracepoint "trace"
+step_over_tracepoint $binfile "trace"
 
 require allow_shlib_tests
 
@@ -111,24 +107,22 @@ set libipa [get_in_proc_agent]
 set remote_libipa [gdb_load_shlib $libipa]
 
 # Compile test case again with IPA.
-if { [gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
-         executable [list debug $additional_flags shlib=$libipa] ] != "" } {
-    untested "failed to compile with in-process agent library"
-    return -1
+set binfile_ipa ${binfile}-ipa
+if { [prepare_for_testing "prepare for testing" $binfile_ipa $srcfile \
+         [list debug pthreads $additional_flags shlib=$libipa]] } {
+    return
 }
-clean_restart ${executable}
 
 if ![runto_main] {
     return 0
 }
 
-gdb_reinitialize_dir $srcdir/$subdir
 if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 } {
     untested "could not find IPA lib loaded"
 } else {
     foreach break_always_inserted { "on" "off" } {
-       break_trace_same_addr "ftrace" ${break_always_inserted}
+       break_trace_same_addr $binfile_ipa "ftrace" ${break_always_inserted}
     }
 
-    step_over_tracepoint "ftrace"
+    step_over_tracepoint $binfile_ipa "ftrace"
 }