OSDN Git Service

Unify implementations of __builtin_mem_*_fence and __sync_synchronize.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / gcc-simulate-thread.exp
1 #   Copyright (C) 2011 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3.  If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # Utility for running a given test through the simulate-thread harness
18 # using gdb.  This is invoked via dg-final.
19 #
20 # Adapted from the guality harness.
21 #
22 # Call 'fail' if a given test printed "FAIL:", otherwise call 'pass'.
23
24 proc simulate-thread { args } {
25
26     # ??? Exit immediately if this is alpha*-*-* target, single-stepping
27     # executable between ldl_l and stl_c insns in gdb breaks LL/SC chaining.
28     if { [istarget alpha*-*-*] } { return }
29     
30     # GNU gdb 6.3 on powerpc-darwin also  on these (and expect does not appear
31     # to be able to terminate them).
32     if { [istarget powerpc*-*-darwin*] } { return }
33
34     if { ![isnative] || [is_remote target] } { return }
35
36     if { [llength $args] == 1 } {
37         switch [dg-process-target [lindex $args 0]] {
38                 "F" { setup_xfail "*-*-*" }
39         }
40     }
41
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.
45     upvar 2 name testcase
46     upvar 2 prog prog
47     upvar 2 srcdir testsuite_dir
48
49     set gdb_name $::env(GDB_FOR_GCC_TESTING)
50     set exec_file "[file rootname [file tail $prog]].exe"
51     set cmd_file "$testsuite_dir/gcc.dg/simulate-thread/simulate-thread.gdb"
52
53     if ![file exists $exec_file] {
54         return
55     }
56
57     send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$exec_file\n"
58     set res [remote_spawn target "$gdb_name -nx -nw  -x $cmd_file ./$exec_file"]
59     if { $res < 0 || $res == "" } {
60         unsupported "$testcase"
61         return
62     }
63
64     set gdb_worked 0
65     remote_expect target [timeout_value] {
66         # Too old GDB
67         -re "Unhandled dwarf expression|Error in sourced command file" {
68             unsupported "$testcase"
69             remote_close target
70             return
71         }
72         -re "FAIL:" {
73             fail "$testcase"
74             remote_close target
75             return
76         }
77         # If the gdb output contained simulate_thread_main, assume
78         # that at the very least, we had a working gdb that was able
79         # to break in simulate_thread_main.
80         -re "simulate_thread_main" {
81             set gdb_worked 1
82             exp_continue
83         }
84         timeout {
85             unsupported "$testcase"
86             remote_close target
87             return
88         }
89     }
90
91     remote_close target
92     if {$gdb_worked} {
93         pass "$testcase"
94     } else {
95         # Fail in the absence of a sane GDB.
96         fail "$testcase"
97     }
98     return
99 }