Imported Upstream version 4.7.2
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.test-framework / test-framework.exp
1 # Copyright (c) 2002, 2003, 2004, 2005, 2007, 2009
2 # Free Software Foundation, Inc.
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3.  If not see
16 # <http://www.gnu.org/licenses/>.
17
18 # Based on gcc/testsuite/gcc.dg/dg.exp.
19
20 # Don't run these tests unless an environment variable is defined.
21 if { ![info exists env(CHECK_TEST_FRAMEWORK)] } {
22     verbose "skipping test framework tests, CHECK_TEST_FRAMEWORK is not defined" 0
23     return
24 }
25
26 load_lib gcc-dg.exp
27
28 proc dg-require-true { args } {
29     verbose "dg-require-true" 2
30 }
31
32 proc dg-require-false { args } {
33     verbose "dg-require-false" 2
34     upvar dg-do-what dg-do-what
35     set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
36 }
37
38 proc check_effective_target_yes { args } {
39     return 1
40 }
41
42 proc check_effective_target_no { args } {
43     return 0
44 }
45
46 proc check_effective_target_def_nocache { } {
47     return [check_no_compiler_messages_nocache def_nocache object {
48         #ifdef DEFINED
49         int dummy;
50         #else
51         #error DEFINED is not defined
52         #endif
53     } [current_compiler_flags]]
54 }
55
56 global dg-do-what-default
57 set save-dg-do-what-default ${dg-do-what-default}
58 set dg-do-what-default compile
59
60 dg-init
61
62 # Run tests from the source directory.
63 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/dg-*.c]] "" ""
64
65 # Skip generated tests unless CHECK_TEST_FRAMEWORK is 1.
66 if { $env(CHECK_TEST_FRAMEWORK) != 1 } {
67     verbose "skipping generated test framework tests, CHECK_TEST_FRAMEWORK is not 1" 0
68     return
69 }
70
71 # Generate additional tests.
72 set tstobjdir "$tmpdir/gcc.test-framework"
73 set generator "$srcdir/$subdir/gen_directive_tests"
74 file delete -force $tstobjdir
75 file mkdir $tstobjdir
76 set status [remote_exec host "$generator $tstobjdir"]
77 set status [lindex $status 0]
78 if { $status == 0 } {
79     # Run the generated tests.
80     dg-runtest [lsort [find $tstobjdir *.c]] "" "-DY1 -DY2"
81 } else {
82     warning "Could not generate test framework tests"
83 }
84
85 dg-finish
86 set dg-do-what-default ${save-dg-do-what-default}