1 # This harness is for tests that should be run at all optimisation levels.
5 proc check_guality {args} {
6 set result [eval check_compile guality_check executable $args "-g -O0"]
7 set lines [lindex $result 0]
8 set output [lindex $result 1]
10 if {[string match "" $lines]} {
11 set execout [gcc_load "./$output"]
12 set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout]
14 remote_file build delete $output
18 # Utility for testing variable values using gdb, invoked via dg-final.
19 # Call pass if variable has the desired value, otherwise fail.
21 # Argument 0 is the line number on which to put a breakpoint
22 # Argument 1 is the name of the variable to be checked
23 # Argument 2 is the expected value of the variable
24 # Argument 3 handles expected failures and the like
25 proc gdb-test { args } {
26 if { ![isnative] || [is_remote target] } { return }
28 if { [llength $args] >= 4 } {
29 switch [dg-process-target [lindex $args 3]] {
32 "F" { setup_xfail "*-*-*" }
37 # This assumes that we are three frames down from dg-test, and that
38 # it still stores the filename of the testcase in a local variable "name".
39 # A cleaner solution would require a new DejaGnu release.
43 set gdb_name $::env(GUALITY_GDB_NAME)
44 set testname "$testcase line [lindex $args 0] [lindex $args 1] == [lindex $args 2]"
45 set output_file "[file rootname [file tail $prog]].exe"
46 set cmd_file "[file rootname [file tail $prog]].gdb"
48 set fd [open $cmd_file "w"]
49 puts $fd "break [lindex $args 0]"
51 puts $fd "print [lindex $args 1]"
52 puts $fd "print [lindex $args 2]"
56 send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$output_file\n"
57 set res [remote_spawn target "$gdb_name -nx -nw -quiet -x $cmd_file ./$output_file"]
58 if { $res < 0 || $res == "" } {
59 unsupported "$testname"
63 remote_expect target [timeout_value] {
64 -re {[\n\r]\$1 = ([^\n\r]*)[\n\r]+\$2 = ([^\n\r]*)[\n\r]} {
65 set first $expect_out(1,string)
66 set second $expect_out(2,string)
67 if { $first == $second } {
70 send_log "$first != $second\n"
77 -re "Unhandled dwarf expression|Error in sourced command file" {
78 unsupported "$testname"
83 unsupported "$testname"
90 unsupported "$testname"
97 if ![info exists ::env(GUALITY_GDB_NAME)] {
98 if [info exists GDB] {
99 set guality_gdb_name "$GDB"
101 set guality_gdb_name "[transform gdb]"
103 setenv GUALITY_GDB_NAME "$guality_gdb_name"
107 #include \"$srcdir/$subdir/guality.h\"
108 volatile long int varl = 6;
109 int main (int argc, char *argv\[\])
115 gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
118 if [info exists guality_gdb_name] {
119 unsetenv GUALITY_GDB_NAME