From a3050af164293f52ecef746cf88a5fa305f30bed Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 29 Aug 2002 22:36:52 +0000 Subject: * gdb.threads/pthreads.exp: Move the portable thread compilation code into a function in lib/gdb.exp, and call that from here. * lib/gdb.exp (gdb_compile_pthreads): New function. --- gdb/testsuite/ChangeLog | 6 ++++++ gdb/testsuite/gdb.threads/pthreads.exp | 32 +++--------------------------- gdb/testsuite/lib/gdb.exp | 36 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 29 deletions(-) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e29220ce2e0..cd9adf8d510 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2002-08-29 Jim Blandy + + * gdb.threads/pthreads.exp: Move the portable thread compilation + code into a function in lib/gdb.exp, and call that from here. + * lib/gdb.exp (gdb_compile_pthreads): New function. + 2002-08-29 Keith Seitz * lib/mi-support.exp (mi_gdb_test): Add global declaration for diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp index 0703395d78b..dc9b7a838f0 100644 --- a/gdb/testsuite/gdb.threads/pthreads.exp +++ b/gdb/testsuite/gdb.threads/pthreads.exp @@ -39,42 +39,16 @@ set binfile ${objdir}/${subdir}/${testfile} # carriage return) set horiz "\[^\n\r\]*" -set built_binfile 0 if [istarget "*-*-linux"] then { set target_cflags "-D_MIT_POSIX_THREADS" } else { set target_cflags "" } -set why_msg "unrecognized error" -foreach lib {-lpthreads -lpthread -lthread} { - set options "debug" - lappend options "incdir=${objdir}/${subdir}" - lappend options "libs=$lib" - set ccout [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $options] - switch -regexp -- $ccout { - ".*no posix threads support.*" { - set why_msg "missing threads include file" - break - } - ".*cannot open -lpthread.*" { - set why_msg "missing runtime threads library" - } - ".*Can't find library for -lpthread.*" { - set why_msg "missing runtime threads library" - } - {^$} { - pass "successfully compiled posix threads test case" - set built_binfile 1 - break - } - } -} -if {$built_binfile == "0"} { - unsupported "Couldn't compile ${srcfile}, ${why_msg}" - return -1 + +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}/${subdir}"]] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -# Now we can proceed with the real testing. # Start with a fresh gdb. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index b4a0b8a0bd0..8949910b9ec 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1171,6 +1171,42 @@ proc gdb_compile {source dest type options} { return $result; } + +# This is just like gdb_compile, above, except that it tries compiling +# against several different thread libraries, to see which one this +# system has. +proc gdb_compile_pthreads {source dest type options} { + set build_binfile 0 + set why_msg "unrecognized error" + foreach lib {-lpthreads -lpthread -lthread} { + # This kind of wipes out whatever libs the caller may have + # set. Or maybe theirs will override ours. How infelicitous. + set options_with_lib [concat $options [list libs=$lib]] + set ccout [gdb_compile $source $dest $type $options_with_lib] + switch -regexp -- $ccout { + ".*no posix threads support.*" { + set why_msg "missing threads include file" + break + } + ".*cannot open -lpthread.*" { + set why_msg "missing runtime threads library" + } + ".*Can't find library for -lpthread.*" { + set why_msg "missing runtime threads library" + } + {^$} { + pass "successfully compiled posix threads test case" + set built_binfile 1 + break + } + } + } + if {$built_binfile == "0"} { + unsupported "Couldn't compile $source: ${why_msg}" + return -1 + } +} + proc send_gdb { string } { global suppress_flag; if { $suppress_flag } { -- cgit v1.2.1