Debian Codegraph @

testsuite/lib/runtest.exp

raw
1 # Copyright (C) 1992-2016, 2018, 2020, 2021 Free Software Foundation, Inc.
2 #
3 # This file is part of DejaGnu.
4 #
5 # DejaGnu is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # DejaGnu is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
19 # This file was written by Rob Savoye <[email protected]>.
20
21 if { ![info exists RUNTEST] } {
22 set RUNTEST [file join [file dirname [testsuite file -source -top]] runtest]
23 }
24
25 if { ![info exists EXPECT] } {
26 if { [info exists ::env(EXPECT)] } {
27 set EXPECT $::env(EXPECT)
28 } else {
29 set EXPECT expect
30 }
31 verbose "EXPECT defaulting to $EXPECT" 2
32 }
33
34 if { [which $RUNTEST] == 0 } {
35 perror "Can't find RUNTEST = $RUNTEST"
36 exit 2
37 }
38 if { [which $EXPECT] == 0 } {
39 perror "Can't find EXPECT = $EXPECT"
40 exit 2
41 }
42
43 #
44 # support procedures for running items in a nested testsuite
45 #
46 # Note that these procedures establish and use a "tmpdir" variable in the
47 # caller's context.
48 proc runtest_setup_nested_testsuite {} {
49 global host_triplet
50 upvar 1 tmpdir tmpdir
51
52 if {![info exists tmpdir]} {
53 set tmpdir [testsuite file -object -top tmpdir]
54 }
55
56 set fd [open nested-init.exp w]
57 puts $fd "set host_triplet $host_triplet"
58 puts $fd "set srcdir [testsuite file -source -test nested]"
59 puts $fd "set objdir [testsuite file -object -test nested]"
60 puts $fd "set tmpdir $tmpdir"
61 puts $fd "set outdir $tmpdir"
62 close $fd
63
64 if {![file isdirectory $tmpdir]} {
65 catch {file mkdir $tmpdir}
66 }
67
68 if {![file isdirectory [testsuite file -object -test nested]]} {
69 catch {file mkdir [testsuite file -object -test nested]}
70 }
71 }
72
73 proc runtest_copy_nested_testsuite_log { tool } {
74 verbose -log -- "---- ${tool}.log from failed test ----"
75 spawn -open [open [testsuite file -object -top tmpdir "${tool}.log"]]
76 expect { .+ { exp_continue } }
77 verbose -log -- "---- end ${tool}.log ----"
78 }
79
80 proc runtest_cleanup_nested_testsuite {} {
81 upvar 1 tmpdir tmpdir
82
83 file delete -force $tmpdir
84 }
85
86
87 #
88 # runtest_version -- extract and print the version number
89 #
90 proc runtest_version { } {
91 global RUNTEST
92
93 catch {exec $RUNTEST -V} tmp
94 if { [info exists tmp] } {
95 clone_output "$tmp\n"
96 }
97 }
98
99 #
100 # runtest_load -- loads the program. For runtest, this is just a stub
101 #
102 proc runtest_load { arg } {
103 }
104
105 #
106 # runtest_exit -- exit the test driver for expect
107 #
108 proc runtest_exit { } {
109 }