aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.threads/schedlock.exp
diff options
context:
space:
mode:
authorDaniel Jacobowitz <drow@false.org>2007-09-17 15:38:05 +0000
committerDaniel Jacobowitz <drow@false.org>2007-09-17 15:38:05 +0000
commit18ecae383162b8c1be40030cddd69f12d718c689 (patch)
treee1e055f7aa4c4f513383fa7e888ff949207b64eb /gdb/testsuite/gdb.threads/schedlock.exp
parenteff4f95e29ab873b801945b3e6478089b0c1a934 (diff)
downloadbinutils-18ecae383162b8c1be40030cddd69f12d718c689.zip
binutils-18ecae383162b8c1be40030cddd69f12d718c689.tar.gz
binutils-18ecae383162b8c1be40030cddd69f12d718c689.tar.bz2
* schedlock.c (NUM): Change to 1.
(main): Use args[0] for the main thread. * schedlock.exp: Only expect two threads. Only issue one pass or fail regardless of the number of threads.
Diffstat (limited to 'gdb/testsuite/gdb.threads/schedlock.exp')
-rw-r--r--gdb/testsuite/gdb.threads/schedlock.exp51
1 files changed, 33 insertions, 18 deletions
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index cc9a53b..c2ec57a 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -32,6 +32,9 @@ set testfile "schedlock"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
+# The number of threads, including the main thread.
+set NUM 2
+
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
return -1
}
@@ -44,11 +47,11 @@ proc get_args { } {
send_gdb "print args\n"
gdb_expect {
- -re "\\\$\[0-9\]+ = {(\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+), (\[0-9\]+)}.*$gdb_prompt"
+ -re "\\\$\[0-9\]+ = {(\[0-9\]+), (\[0-9\]+)}.*$gdb_prompt"
{
set list_count [expr $list_count + 1]
pass "listed args ($list_count)"
- return [list $expect_out(1,string) $expect_out(2,string) $expect_out(3,string) $expect_out(4,string) $expect_out(5,string) $expect_out(6,string)]
+ return [list $expect_out(1,string) $expect_out(2,string)]
}
-re "$gdb_prompt"
{
@@ -112,7 +115,7 @@ proc my_continue { msg } {
stop_process "stop all threads ($msg)"
# Make sure we're in one of the non-main looping threads.
- gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 5"]
+ gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"]
gdb_continue_to_breakpoint "return to loop ($msg)"
delete_breakpoints
}
@@ -198,13 +201,17 @@ my_continue "initial"
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set ok 1
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
- fail "thread $i ran (didn't run)"
- } else {
- pass "thread $i ran"
+ set ok 0
}
}
+if { $ok } {
+ pass "all threads alive"
+} else {
+ fail "all threads alive"
+}
# We can't change threads, unfortunately, in current GDB. Use
# whichever we stopped in.
@@ -230,7 +237,7 @@ set start_args $cont_args
set cont_args [get_args]
set num_other_threads 0
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread stepped (didn't run)"
@@ -248,9 +255,9 @@ for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
}
}
if {$num_other_threads > 0} {
- pass "other threads ran (1)"
+ pass "other threads ran - unlocked"
} else {
- fail "other threads ran (no other threads ran) (1)"
+ fail "other threads ran - unlocked"
}
# Test continue with scheduler locking
@@ -269,21 +276,25 @@ if {$curthread == $newthread} {
set start_args $cont_args
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set num_other_threads 0
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread ran (didn't run)"
- } else {
- pass "other thread $i didn't run"
}
} else {
if {$i == $curthread} {
pass "current thread ran"
} else {
- fail "other thread $i didn't run (ran)"
+ incr num_other_threads
}
}
}
+if {$num_other_threads > 0} {
+ fail "other threads didn't run - locked"
+} else {
+ pass "other threads didn't run - locked"
+}
# Test stepping with scheduler locking
step_ten_loops "locked"
@@ -299,12 +310,11 @@ if {$curthread == $newthread} {
set start_args $cont_args
set cont_args [get_args]
-for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
+set num_other_threads 0
+for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} {
fail "current thread stepped locked (didn't run)"
- } else {
- pass "other thread $i didn't run (stepping)"
}
} else {
if {$i == $curthread} {
@@ -314,9 +324,14 @@ for {set i 0} {[expr $i < 6]} {set i [expr $i + 1]} {
fail "current thread stepped locked (wrong amount)"
}
} else {
- fail "other thread $i didn't run (stepping) (ran)"
+ incr num_other_threads
}
}
}
+if {$num_other_threads > 0} {
+ fail "other threads didn't run - step locked"
+} else {
+ pass "other threads didn't run - step locked"
+}
return 0