]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/testsuite/gdb.threads/print-threads.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / print-threads.exp
index a671479c930fcd48d0ef75ae39ab47bde77e73de..fef71dbedd19e5d76610439bf7343c89835e5e1a 100644 (file)
@@ -1,5 +1,4 @@
-# Copyright (C) 1996, 1997, 2002, 2003, 2007, 2008, 2009, 2010
-# Free Software Foundation, Inc.
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # It tests miscellaneous actions with multiple threads, including
 # handling for thread exit.
 
-if $tracelevel then {
-       strace $tracelevel
-}
-
 
-set testfile "print-threads"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile
 
 # regexp for "horizontal" text (i.e. doesn't include newline or
 # carriage return)
 set horiz "\[^\n\r\]*"
 
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
     return -1
 }
 
 # Now we can proceed with the real testing.
 
-# Start with a fresh gdb.
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+clean_restart ${binfile}
 
-gdb_test "set print sevenbit-strings" ""
-#gdb_test "set print address off" ""
-gdb_test "set width 0" ""
+gdb_test_no_output "set print sevenbit-strings"
+#gdb_test_no_output "set print address off"
+gdb_test_no_output "set width 0"
 
 # We'll need this when we send_gdb a ^C to GDB.  Need to do it before we
 # run the program and gdb starts saving and restoring tty states.
 # On Ultrix, we don't need it and it is really slow (because shell_escape
 # doesn't use vfork).
 if ![istarget "*-*-ultrix*"] then {
-    gdb_test "shell stty intr '^C'" ""
+    gdb_test "shell stty intr '^C'" ".*"
 }
 
 proc test_all_threads { name kill } {
-    global gdb_prompt
+    global gdb_prompt inferior_exited_re
 
     set i 0
     set j 0
-    send_gdb "continue\n"
-    gdb_expect {
+    gdb_test_multiple "continue" "all threads ran once" {
        -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
            set i [expr $i + 1]
            pass "Hit thread_function breakpoint, $i ($name)"
@@ -81,7 +68,7 @@ proc test_all_threads { name kill } {
            send_gdb "continue\n"
            exp_continue
        }
-       -re "Program exited normally\\.\[\r\n\]+$gdb_prompt" {
+       -re "$inferior_exited_re normally.\[\r\n\]+$gdb_prompt" {
            pass "program exited normally"
            if {$i == 5} {
                pass "all threads ran once ($name)"
@@ -96,29 +83,32 @@ proc test_all_threads { name kill } {
                fail "Running threads ($name) (unknown output)"
            }
        }
-       -re "$gdb_prompt" {
-           fail "Running threads ($name) (unknown output)"
-       }
-       timeout {
-           fail "Running threads ($name) (timeout)"
-       }
     }
 }
 
+# Record the old timeout, we need to extend it for slower tests.
+set oldtimeout $timeout
+
 runto_main
 gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\."
-gdb_test "set var slow = 0" ""
+gdb_test_no_output "set var slow = 0"
 test_all_threads "fast" 0
 
 runto_main
 gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)"
-gdb_test "set var slow = 1" ""
+gdb_test_no_output "set var slow = 1"
+# Extend the timeout for slower tests.
+set timeout [expr $oldtimeout + 120]
 test_all_threads "slow" 0
+set timeout $oldtimeout
 
 runto_main
 gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)"
-gdb_test "set var slow = 1" "" "set var slow = 1 (2)"
+gdb_test_no_output "set var slow = 1" "set var slow = 1 (2)"
 gdb_breakpoint "kill"
+# Extend the timeout for slower tests.
+set timeout [expr $oldtimeout + 120]
 test_all_threads "slow with kill breakpoint" 1
+set timeout $oldtimeout
 
 return 0