* 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.
This commit is contained in:
Daniel Jacobowitz 2007-09-17 15:38:05 +00:00
parent eff4f95e29
commit 18ecae3831
3 changed files with 44 additions and 22 deletions

View File

@ -1,3 +1,10 @@
2007-09-17 Daniel Jacobowitz <dan@codesourcery.com>
* 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.
2007-09-14 Maciej W. Rozycki <macro@mips.com> 2007-09-14 Maciej W. Rozycki <macro@mips.com>
* gdb.mi/mi-watch.exp (test_watchpoint_all): Pass the watchpoint * gdb.mi/mi-watch.exp (test_watchpoint_all): Pass the watchpoint

View File

@ -22,7 +22,7 @@
void *thread_function(void *arg); /* Pointer to function executed by each thread */ void *thread_function(void *arg); /* Pointer to function executed by each thread */
#define NUM 5 #define NUM 1
unsigned int args[NUM+1]; unsigned int args[NUM+1];
@ -32,7 +32,7 @@ int main() {
void *thread_result; void *thread_result;
long i; long i;
for (i = 0; i < NUM; i++) for (i = 1; i <= NUM; i++)
{ {
args[i] = 1; args[i] = 1;
res = pthread_create(&threads[i], res = pthread_create(&threads[i],
@ -42,8 +42,8 @@ int main() {
} }
/* schedlock.exp: last thread start. */ /* schedlock.exp: last thread start. */
args[i] = 1; args[0] = 1;
thread_function ((void *) i); thread_function ((void *) 0);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }

View File

@ -32,6 +32,9 @@ set testfile "schedlock"
set srcfile ${testfile}.c set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile} 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}"]] != "" } { if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
return -1 return -1
} }
@ -44,11 +47,11 @@ proc get_args { } {
send_gdb "print args\n" send_gdb "print args\n"
gdb_expect { 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] set list_count [expr $list_count + 1]
pass "listed args ($list_count)" 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" -re "$gdb_prompt"
{ {
@ -112,7 +115,7 @@ proc my_continue { msg } {
stop_process "stop all threads ($msg)" stop_process "stop all threads ($msg)"
# Make sure we're in one of the non-main looping threads. # 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)" gdb_continue_to_breakpoint "return to loop ($msg)"
delete_breakpoints delete_breakpoints
} }
@ -198,13 +201,17 @@ my_continue "initial"
set cont_args [get_args] 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]} { if {[lindex $start_args $i] == [lindex $cont_args $i]} {
fail "thread $i ran (didn't run)" set ok 0
} else {
pass "thread $i ran"
} }
} }
if { $ok } {
pass "all threads alive"
} else {
fail "all threads alive"
}
# We can't change threads, unfortunately, in current GDB. Use # We can't change threads, unfortunately, in current GDB. Use
# whichever we stopped in. # whichever we stopped in.
@ -230,7 +237,7 @@ set start_args $cont_args
set cont_args [get_args] set cont_args [get_args]
set num_other_threads 0 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 {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} { if {$i == $curthread} {
fail "current thread stepped (didn't run)" 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} { if {$num_other_threads > 0} {
pass "other threads ran (1)" pass "other threads ran - unlocked"
} else { } else {
fail "other threads ran (no other threads ran) (1)" fail "other threads ran - unlocked"
} }
# Test continue with scheduler locking # Test continue with scheduler locking
@ -269,21 +276,25 @@ if {$curthread == $newthread} {
set start_args $cont_args set start_args $cont_args
set cont_args [get_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 {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} { if {$i == $curthread} {
fail "current thread ran (didn't run)" fail "current thread ran (didn't run)"
} else {
pass "other thread $i didn't run"
} }
} else { } else {
if {$i == $curthread} { if {$i == $curthread} {
pass "current thread ran" pass "current thread ran"
} else { } 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 # Test stepping with scheduler locking
step_ten_loops "locked" step_ten_loops "locked"
@ -299,12 +310,11 @@ if {$curthread == $newthread} {
set start_args $cont_args set start_args $cont_args
set cont_args [get_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 {[lindex $start_args $i] == [lindex $cont_args $i]} {
if {$i == $curthread} { if {$i == $curthread} {
fail "current thread stepped locked (didn't run)" fail "current thread stepped locked (didn't run)"
} else {
pass "other thread $i didn't run (stepping)"
} }
} else { } else {
if {$i == $curthread} { 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)" fail "current thread stepped locked (wrong amount)"
} }
} else { } 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 return 0