1 # Copyright (C) 2018 Free Software Foundation, Inc.
3 # This file is part of DejaGnu.
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.
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.
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.
19 # This file was written by Jacob Bachmeyer.
21 # each element: { launcher_alias
22 # { name args envars exit_code output_re... }... }
27 { "dejagnu foo as Tcl"
28 {foo -v -v} {EXPECT=true TCLSH=true } 0
29 "Found subcommand foo with variants: tcl sh\n"
30 "Selected variant tcl" }
31 { "dejagnu foo as Tcl via Expect"
32 {foo -v -v} {EXPECT=true TCLSH=bogus} 0
33 "Found subcommand foo with variants: tcl sh\n"
34 "Selected variant tcl" }
35 { "dejagnu foo as shell"
36 {foo -v -v} {EXPECT=bogus TCLSH=bogus} 0
37 "Found subcommand foo with variants: tcl sh\n"
38 "Selected variant sh" }
40 { "dejagnu bar as Awk"
41 {bar -v -v} {AWK=true GAWK=true } 0
42 "Found subcommand bar with variants: awk sh\n"
43 "Selected variant awk" }
44 { "dejagnu bar as Awk via GNU Awk"
45 {bar -v -v} {AWK=bogus GAWK=true } 0
46 "Found subcommand bar with variants: awk sh\n"
47 "Selected variant awk" }
48 { "dejagnu bar as shell"
49 {bar -v -v} {AWK=bogus GAWK=bogus} 0
50 "Found subcommand bar with variants: awk sh\n"
51 "Selected variant sh" }
53 { "dejagnu bar shadows bar-baz"
54 {bar baz -v -v} {AWK=true} 0
55 "Found subcommand bar with variants: awk sh" }
56 { "dejagnu bar-baz works"
57 {bar-baz -v -v} {AWK=true} 0
58 "Found subcommand bar-baz with variants: awk" }
59 { "dejagnu bar-baz fails without Awk"
60 {bar-baz -v -v} {AWK=bogus GAWK=bogus} 2
61 "Found subcommand bar-baz with variants: awk\n"
62 "ERROR: no variant of bar-baz was selected" }
64 { "dejagnu baz-quux works"
65 {baz-quux -v -v} {GAWK=true} 0
66 "Found subcommand baz-quux with variants: gawk\n"
67 "Selected variant gawk" }
68 { "dejagnu baz quux works"
69 {baz quux -v -v} {GAWK=true} 0
70 "Found subcommand baz-quux with variants: gawk\n"
71 "Selected variant gawk" }
73 { "#" "bug #33817: ensure that the failure is 'no variant'"
74 " rather than 'could not resolve command'" }
75 { "dejagnu baz-quux is resolved but fails without GNU Awk (bug #33817)"
76 {baz-quux} {GAWK=bogus} 2
77 "ERROR: no variant of baz-quux was selected" }
78 { "dejagnu baz quux is resolved but fails without GNU Awk (bug #33817)"
79 {baz quux} {GAWK=bogus} 2
80 "ERROR: no variant of baz-quux was selected" }
82 { "#" invalid direct calls }
84 { "dejagnu -v bar fails" {-v bar} {} 2
85 "Running nothing.\nERROR: no command given" }
87 { "dejagnu \"\" bar fails" {"" bar} {} 2 "ERROR: " }
88 { "dejagnu \"\" \"\" bar fails" {"" "" bar} {} 2 "ERROR: " }
90 { "dejagnu baz \"\" quux fails" {baz "" quux} {GAWK=true} 2 "ERROR: " }
92 { "dejagnu bar \"\" baz finds bar subcommand"
93 {--DGTimpl echo bar "" baz} {} 0
94 "command: bar\nargs: baz" }
98 { "dejagnu --help works" {--help} {} 0 "Usage: dejagnu" }
100 { "dejagnu foo --help works if shell variant selected"
101 {foo --help} {EXPECT=bogus TCLSH=bogus} 0
102 "foo.sh help message" }
103 { "dejagnu foo --help fails if Tcl variant selected"
104 {foo --help} {EXPECT=true TCLSH=true } 2
105 "does not contain a help message" }
107 { "dejagnu foo --help fails if no POSIX Awk available"
108 {foo --help} {EXPECT=bogus TCLSH=bogus AWK=bogus GAWK=bogus} 2
109 "requires POSIX Awk" }
110 { "dejagnu foo --help recognizes dummy GNU Awk as Awk"
111 {foo --help} {EXPECT=bogus TCLSH=bogus AWK=bogus GAWK=true } 2
112 "does not contain a help message" }
114 # The above still fails, because true(1) does not actually
115 # evaluate Awk programs and the Awk program that tests if a help
116 # message is present returns true if the launcher should abort.
122 { "#" calls via dejagnu-foo link }
123 { "dejagnu-foo as Tcl"
124 {-v -v} {EXPECT=true TCLSH=true } 0
125 "Found subcommand foo with variants: tcl sh\n"
126 "Selected variant tcl" }
127 { "dejagnu-foo as Tcl via Expect"
128 {-v -v} {EXPECT=true TCLSH=bogus} 0
129 "Found subcommand foo with variants: tcl sh\n"
130 "Selected variant tcl" }
131 { "dejagnu-foo as shell"
132 {-v -v} {EXPECT=bogus TCLSH=bogus} 0
133 "Found subcommand foo with variants: tcl sh\n"
134 "Selected variant sh" }
138 { "#" calls via dejagnu-bar link }
139 { "dejagnu-bar as Awk"
140 {-v -v} {AWK=true GAWK=true } 0
141 "Found subcommand bar with variants: awk sh\n"
142 "Selected variant awk" }
143 { "dejagnu-bar as Awk via GNU Awk"
144 {-v -v} {AWK=bogus GAWK=true } 0
145 "Found subcommand bar with variants: awk sh\n"
146 "Selected variant awk" }
147 { "dejagnu-bar as shell"
148 {-v -v} {AWK=bogus GAWK=bogus} 0
149 "Found subcommand bar with variants: awk sh\n"
150 "Selected variant sh" }
152 { "#" false hybrid: bar shadows bar-baz }
153 { "dejagnu-bar as Awk shadows bar-baz"
154 {baz -v -v} {AWK=true} 0
155 "Found subcommand bar with variants: awk sh\n"
156 "Selected variant awk" }
160 { "#" calls via dejagnu-bar-baz link }
161 { "dejagnu-bar-baz as Awk"
162 {-v -v} {AWK=true GAWK=true } 0
163 "Found subcommand bar-baz with variants: awk\n"
164 "Selected variant awk" }
165 { "dejagnu-bar-baz as Awk via GNU Awk"
166 {-v -v} {AWK=bogus GAWK=true } 0
167 "Found subcommand bar-baz with variants: awk\n"
168 "Selected variant awk" }
169 { "dejagnu-bar-baz fails without Awk"
170 {-v -v} {AWK=bogus GAWK=bogus} 2
171 "Found subcommand bar-baz with variants: awk\n"
172 "ERROR: no variant of bar-baz was selected" }
176 { "#" hybrid: link as prefix }
177 { "dejagnu-baz quux as GNU Awk"
178 {quux -v -v} {GAWK=true} 0
179 "Found subcommand baz-quux with variants: gawk\n"
180 "Selected variant gawk" }
181 { "dejagnu-baz quux fails without GNU Awk"
182 {quux -v -v} {GAWK=bogus AWK=true} 2
183 "Found subcommand baz-quux with variants: gawk\n"
184 "ERROR: no variant of baz-quux was selected" }
189 # Build the test environment.
191 # This must be done at run-time in the build directory because symbolic
192 # links are not allowed in GNU source tarballs.
194 link_dejagnu_launcher_test_item \
195 [testsuite file -object -test command share dejagnu commands] \
196 [testsuite file -source -test command commands]
197 foreach alias_item $tests {
198 link_dejagnu_launcher_test_item \
199 [testsuite file -object -test command bin [lindex $alias_item 0]] \
203 [testsuite file -object -test command share dejagnu commands]] } {
204 foreach alias_set $tests {
205 skip_dejagnu_launcher_tests \
206 "Could not set up test environment." \
207 unsupported [lrange $alias_set 1 end]
214 if { [which true] == 0 || [which bogus] != 0 } {
215 foreach alias_set $tests {
216 skip_dejagnu_launcher_tests \
217 "Either 'true' is not on PATH or 'bogus' is." \
218 unresolved [lrange $alias_set 1 end]
221 foreach alias_set $tests {
222 run_dejagnu_launcher_tests \
223 [testsuite file -object -test command bin [lindex $alias_set 0]] \
224 [lrange $alias_set 1 end]