Skip to content

Commit

Permalink
[gdb/testsuite] Use early-out style in gdb.base/break-probes.exp
Browse files Browse the repository at this point in the history
Reduce indentation and improve readability in test-case
gdb.base/break-probes.exp by replacing:
...
if { <cond> } {
  <lots-of-code>
}
...
with:
...
if { ! <cond> } {
  return -1
}
<lots-of-code>
...

Tested on x86_64-linux.
  • Loading branch information
vries committed Sep 23, 2021
1 parent 9b8efa2 commit 04739cc
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions gdb/testsuite/gdb.base/break-probes.exp
Original file line number Diff line number Diff line change
Expand Up @@ -60,34 +60,36 @@ gdb_test_multiple "bt" $test {
}
}

if { $using_probes } {
set sysroot ""
set test "show sysroot"
gdb_test_multiple $test $test {
-re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
set sysroot $expect_out(1,string)
}
if { ! $using_probes } {
return -1
}

set sysroot ""
set test "show sysroot"
gdb_test_multiple $test $test {
-re "The current system root is \"(.*)\"\..*${gdb_prompt} $" {
set sysroot $expect_out(1,string)
}
}

# GDB strips "target:" from the start of filenames
# when operating on the local filesystem
regsub "^target:" "$sysroot" "(target:)?" sysroot
# GDB strips "target:" from the start of filenames
# when operating on the local filesystem
regsub "^target:" "$sysroot" "(target:)?" sysroot

# Run til it loads our library
set test "run til our library loads"
set not_loaded_library 1
while { $not_loaded_library } {
set not_loaded_library 0
gdb_test_multiple "c" $test {
-re "Inferior loaded $sysroot$binfile_lib\\M.*$gdb_prompt $" {
pass $test
}
-re "Stopped due to shared library event\\M.*$gdb_prompt $" {
set not_loaded_library 1
}
# Run til it loads our library
set test "run til our library loads"
set not_loaded_library 1
while { $not_loaded_library } {
set not_loaded_library 0
gdb_test_multiple "c" $test {
-re "Inferior loaded $sysroot$binfile_lib\\M.*$gdb_prompt $" {
pass $test
}
-re "Stopped due to shared library event\\M.*$gdb_prompt $" {
set not_loaded_library 1
}
}

# Call something to ensure that relocation occurred
gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"
}

# Call something to ensure that relocation occurred
gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"

0 comments on commit 04739cc

Please sign in to comment.