diff options
Diffstat (limited to 'testsuite/lib/anubis.exp')
-rw-r--r-- | testsuite/lib/anubis.exp | 970 |
1 files changed, 0 insertions, 970 deletions
diff --git a/testsuite/lib/anubis.exp b/testsuite/lib/anubis.exp deleted file mode 100644 index a691211..0000000 --- a/testsuite/lib/anubis.exp +++ /dev/null | |||
@@ -1,970 +0,0 @@ | |||
1 | # -*- tcl -*- | ||
2 | # This file is part of GNU Anubis testsuite. | ||
3 | # Copyright (C) 2003-2014 The Anubis Team. | ||
4 | # | ||
5 | # GNU Anubis is free software; you can redistribute it and/or modify it | ||
6 | # under the terms of the GNU General Public License as published by the Free | ||
7 | # Software Foundation; either version 3 of the License, or (at your option) | ||
8 | # any later version. | ||
9 | # | ||
10 | # GNU Anubis is distributed in the hope that it will be useful, | ||
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | # GNU General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License along | ||
16 | # with GNU Anubis. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | # Authmode support | ||
19 | proc repl_port {file port} { | ||
20 | global ANUBIS_RC_DIR | ||
21 | |||
22 | set chan [open $ANUBIS_RC_DIR/$file.in.rc r] | ||
23 | set outchan [open $ANUBIS_RC_DIR/$file.rc w] | ||
24 | for {gets $chan line} {![eof $chan]} {gets $chan line} { | ||
25 | regsub -all "@ANUBIS_PORT@" $line "$port" tmp | ||
26 | puts $outchan $tmp | ||
27 | } | ||
28 | close $chan | ||
29 | close $outchan | ||
30 | } | ||
31 | |||
32 | proc anubis_authmode {} { | ||
33 | global ANUBIS_PID | ||
34 | if ![info exists ANUBIS_PID] { | ||
35 | return 0 | ||
36 | } | ||
37 | verbose "AUTHMODE" | ||
38 | return $ANUBIS_PID | ||
39 | } | ||
40 | |||
41 | proc start_daemon {} { | ||
42 | global ANUBIS_TESTDIR | ||
43 | global ANUBIS_RC_DIR | ||
44 | global ANUBIS_TOOL | ||
45 | global ANUBIS_PORT | ||
46 | global ANUBIS_PID | ||
47 | |||
48 | set port [remote_exec host $ANUBIS_TESTDIR/findport "-c1 -s1024 -f%d"] | ||
49 | set ANUBIS_PORT [lindex $port 1] | ||
50 | repl_port "target" $ANUBIS_PORT | ||
51 | repl_port "interface" $ANUBIS_PORT | ||
52 | set pidfile $ANUBIS_RC_DIR/anubis.pid | ||
53 | file delete $pidfile | ||
54 | remote_exec host "$ANUBIS_TOOL" \ | ||
55 | "--relax-perm-check \ | ||
56 | --pid-file $pidfile \ | ||
57 | --altrc $ANUBIS_RC_DIR/target.rc" | ||
58 | set attempt 0 | ||
59 | while {![file exists $pidfile]} { | ||
60 | incr attempt | ||
61 | if {$attempt > 10} { | ||
62 | fail "Cannot start anubis daemon" | ||
63 | exit 1 | ||
64 | } | ||
65 | sleep 1 | ||
66 | } | ||
67 | set chan [open $pidfile r] | ||
68 | gets $chan ANUBIS_PID | ||
69 | verbose "Daemon PID $ANUBIS_PID" | ||
70 | close $chan | ||
71 | } | ||
72 | |||
73 | proc kill_daemon {} { | ||
74 | global ANUBIS_PID | ||
75 | |||
76 | if {![info exists ANUBIS_PID]} { | ||
77 | return | ||
78 | } | ||
79 | |||
80 | # Tcl has no kill primitive. The following Ruby Goldberg trick is | ||
81 | # borrowed from DejaGNU (see remote.exp) | ||
82 | verbose "Killing anubis daemon $ANUBIS_PID" | ||
83 | exec sh -c "exec > /dev/null 2>&1 && \ | ||
84 | (kill -2 $ANUBIS_PID || kill -2 $ANUBIS_PID) && \ | ||
85 | sleep 5 && (kill -15 $ANUBIS_PID || kill $ANUBIS_PID) && \ | ||
86 | sleep 5 && (kill -9 $ANUBIS_PID || kill -9 $ANUBIS_PID)" &; | ||
87 | } | ||
88 | |||
89 | proc update_config {name} { | ||
90 | global ANUBIS_PORT | ||
91 | global ANUBIS_USR | ||
92 | global ANUBIS_DATA_DIR | ||
93 | global ANUBIS_RC_DIR | ||
94 | global ANUBIS_ETC_DIR | ||
95 | global verbose | ||
96 | |||
97 | set rcname $ANUBIS_RC_DIR/$name | ||
98 | set chan [open $rcname r] | ||
99 | set outchan [open $rcname.tmp w] | ||
100 | for {gets $chan line} {![eof $chan]} {gets $chan line} { | ||
101 | switch -regexp -- "$line" { | ||
102 | "^ *local-mta" { } | ||
103 | ".*" { | ||
104 | puts $outchan "$line" | ||
105 | } | ||
106 | } | ||
107 | } | ||
108 | close $outchan | ||
109 | close $chan | ||
110 | |||
111 | if {$verbose > 2} { | ||
112 | set vopt "-vvv" | ||
113 | } else { | ||
114 | set vopt "" | ||
115 | } | ||
116 | set res [remote_exec host "$ANUBIS_USR" \ | ||
117 | "$vopt --netrc $ANUBIS_ETC_DIR/net.rc \ | ||
118 | --file $rcname.tmp localhost:$ANUBIS_PORT"] | ||
119 | verbose -log "ANUBISUSR RESULT: $res" | ||
120 | if {[llength $res] < 1} { | ||
121 | return -1 | ||
122 | } | ||
123 | return [lindex $res 0] | ||
124 | } | ||
125 | |||
126 | # Run given test script ($name) in authmode. | ||
127 | proc run_in_authmode {name} { | ||
128 | if [anubis_check_capability "GSASL"] { | ||
129 | if [anubis_check_capability "GNUTLS"] { | ||
130 | clone_output "Running $name in authmode over TLS." | ||
131 | } | ||
132 | start_daemon | ||
133 | source $name | ||
134 | kill_daemon | ||
135 | } else { | ||
136 | unsupported "$name in authmode" | ||
137 | } | ||
138 | } | ||
139 | |||
140 | |||
141 | |||
142 | proc anubis_init {args} { | ||
143 | global TOOL_EXECUTABLE | ||
144 | global ANUBIS_TOOL | ||
145 | global ANUBIS_RC_DIR | ||
146 | global ANUBIS_ETC_DIR | ||
147 | global ANUBIS_TOOL_FLAGS | ||
148 | global ANUBIS_DATA_DIR | ||
149 | global ANUBIS_TESTDIR | ||
150 | global ANUBIS_SRCDIR | ||
151 | global ANUBIS_TOP_SRCDIR | ||
152 | global ANUBIS_USR | ||
153 | global ANUBIS_ADM | ||
154 | global ANUBIS_AUTHMODE | ||
155 | global tool | ||
156 | global base_dir | ||
157 | global top_srcdir | ||
158 | global objdir | ||
159 | global host_board | ||
160 | global srcdir | ||
161 | |||
162 | if [info exists TOOL_EXECUTABLE] { | ||
163 | set ANUBIS_TOOL $TOOL_EXECUTABLE | ||
164 | } | ||
165 | |||
166 | if {$args == "-authmode"} { | ||
167 | set ANUBIS_AUTHMODE 1 | ||
168 | } | ||
169 | |||
170 | if ![info exists ANUBIS_TOOL] { | ||
171 | if ![is_remote host] { | ||
172 | set ANUBIS_ADM [findfile $base_dir/../src/anubisadm "$base_dir/../src/anubisadm" [transform anubisadm]] | ||
173 | set ANUBIS_USR [findfile $base_dir/../src/anubisusr "$base_dir/../src/anubisusr" [transform anubisusr]] | ||
174 | set ANUBIS_TOOL [findfile $base_dir/../src/$tool "$base_dir/../src/$tool" [transform $tool]] | ||
175 | set ANUBIS_SRCDIR "$srcdir" | ||
176 | set ANUBIS_TOP_SRCDIR "$top_srcdir" | ||
177 | set ANUBIS_TESTDIR "$objdir" | ||
178 | set ANUBIS_DATA_DIR "$objdir/data" | ||
179 | set ANUBIS_ETC_DIR "$top_srcdir/testsuite/etc" | ||
180 | set ANUBIS_RC_DIR "$objdir/etc" | ||
181 | } else { | ||
182 | if [info exists host_board] { | ||
183 | if [board_info $host_board exists top_builddir] { | ||
184 | append ANUBIS_TOOL "[board_info $host_board top_builddir]/$tool/$tool" | ||
185 | } elseif [board_info $host_board exists top_srcdir] { | ||
186 | append ANUBIS_TOOL "[board_info $host_board top_srcdir]/$tool/$tool" | ||
187 | } | ||
188 | } | ||
189 | |||
190 | if ![info exists ANUBIS_TOOL] { | ||
191 | perror "The test suite is not set up for the remote testing" | ||
192 | perror "Please, read file README in $tool/testsuite subdirectory" | ||
193 | perror "for instructions on how to set up it." | ||
194 | exit 1 | ||
195 | } | ||
196 | set ANUBIS_SRCDIR "[board_info $host_board srcdir]" | ||
197 | set ANUBIS_TOP_SRCDIR "[board_info $host_board top_srcdir]" | ||
198 | set ANUBIS_TESTDIR "[board_info $host_board objdir]" | ||
199 | set ANUBIS_ETC_DIR "[board_info $host_board top_srcdir]/testsuite/etc" | ||
200 | set ANUBIS_DATA_DIR "[board_info $host_board objdir]/data" | ||
201 | set ANUBIS_RC_DIR "[board_info $host_board objdir]/etc" | ||
202 | } | ||
203 | |||
204 | set ANUBIS_TOOL_FLAGS "--norc --relax-perm-check" | ||
205 | } | ||
206 | |||
207 | if {[info exists ANUBIS_AUTHMODE] && $ANUBIS_AUTHMODE} { | ||
208 | start_daemon | ||
209 | } | ||
210 | } | ||
211 | |||
212 | proc default_anubis_start {args} { | ||
213 | global verbose | ||
214 | global ANUBIS_TOOL | ||
215 | global ANUBIS_TOOL_FLAGS | ||
216 | global expect_out | ||
217 | global anubis_spawn_id | ||
218 | |||
219 | if [info exists ANUBIS_TOOL_FLAGS] { | ||
220 | set sw $ANUBIS_TOOL_FLAGS | ||
221 | } else { | ||
222 | set sw "" | ||
223 | } | ||
224 | |||
225 | verbose "SW $sw" | ||
226 | verbose "ARGS $args" | ||
227 | if [llength $args] { | ||
228 | append sw " " $args | ||
229 | } | ||
230 | |||
231 | set cmd "$ANUBIS_TOOL $sw" | ||
232 | verbose "Spawning $cmd" | ||
233 | |||
234 | set anubis_spawn_id [remote_spawn host $cmd] | ||
235 | if { $anubis_spawn_id < 0 || $anubis_spawn_id == "" } { | ||
236 | perror "Spawning $cmd failed." | ||
237 | return 1; | ||
238 | } | ||