1 # This harness is for tests that should be run at all optimisation levels.
5 # Disable on darwin until radr://7264615 is resolved.
6 if { [istarget *-*-darwin*] } {
10 proc check_guality {args} {
11 set result [eval check_compile guality_check executable $args "-g -O0"]
12 set lines [lindex $result 0]
13 set output [lindex $result 1]
15 if {[string match "" $lines]} {
16 set execout [gcc_load "./$output"]
17 set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout]
19 remote_file build delete $output
23 # Utility for testing variable values using gdb, invoked via dg-final.
24 # Call pass if variable has the desired value, otherwise fail.
26 # Argument 0 is the line number on which to put a breakpoint
27 # Argument 1 is the name of the variable to be checked
28 # Argument 2 is the expected value of the variable
29 # Argument 3 handles expected failures and the like
30 proc gdb-test { args } {
31 if { ![isnative] || [is_remote target] } { return }
33 if { [llength $args] >= 4 } {
34 switch [dg-process-target [lindex $args 3]] {
37 "F" { setup_xfail "*-*-*" }
42 # This assumes that we are three frames down from dg-test, and that
43 # it still stores the filename of the testcase in a local variable "name".
44 # A cleaner solution would require a new DejaGnu release.
48 set gdb_name $::env(GUALITY_GDB_NAME)
49 set testname "$testcase line [lindex $args 0] [lindex $args 1] == [lindex $args 2]"
50 set output_file "[file rootname [file tail $prog]].exe"
51 set cmd_file "[file rootname [file tail $prog]].gdb"
53 set fd [open $cmd_file "w"]
54 puts $fd "break [lindex $args 0]"
56 puts $fd "print [lindex $args 1]"
57 puts $fd "print [lindex $args 2]"
61 send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$output_file\n"
62 set res [remote_spawn target "$gdb_name -nx -nw -quiet -x $cmd_file ./$output_file"]
63 if { $res < 0 || $res == "" } {
64 unsupported "$testname"
68 remote_expect target [timeout_value] {
69 -re {[\n\r]\$1 = ([^\n\r]*)[\n\r]+\$2 = ([^\n\r]*)[\n\r]} {
70 set first $expect_out(1,string)
71 set second $expect_out(2,string)
72 if { $first == $second } {
75 send_log "$first != $second\n"
82 -re "Unhandled dwarf expression|Error in sourced command file" {
83 unsupported "$testname"
88 unsupported "$testname"
95 unsupported "$testname"
102 if ![info exists ::env(GUALITY_GDB_NAME)] {
103 if [info exists GDB] {
104 set guality_gdb_name "$GDB"
106 set guality_gdb_name "[transform gdb]"
108 setenv GUALITY_GDB_NAME "$guality_gdb_name"
112 #include \"$srcdir/$subdir/guality.h\"
113 volatile long int varl = 6;
114 int main (int argc, char *argv\[\])
120 gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
123 if [info exists guality_gdb_name] {
124 unsetenv GUALITY_GDB_NAME