]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/rs/tests/rs_test.sh
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / usr.bin / rs / tests / rs_test.sh
1 #
2 # Copyright 2017 Shivansh
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD$
27 #
28
29 atf_test_case c_flag
30 c_flag_head()
31 {
32         atf_set "descr" "Verify the usage of option 'c'"
33 }
34
35 c_flag_body()
36 {
37         atf_check -s exit:0 -o empty rs -c < /dev/null
38 }
39
40 atf_test_case s_flag
41 s_flag_head()
42 {
43         atf_set "descr" "Verify the usage of option 's'"
44 }
45
46 s_flag_body()
47 {
48         atf_check -s exit:0 -o empty rs -s < /dev/null
49 }
50
51 atf_test_case C_flag
52 C_flag_head()
53 {
54         atf_set "descr" "Verify the usage of option 'C'"
55 }
56
57 C_flag_body()
58 {
59         atf_check -s exit:0 -o empty rs -C < /dev/null
60 }
61
62 atf_test_case S_flag
63 S_flag_head()
64 {
65         atf_set "descr" "Verify the usage of option 'S'"
66 }
67
68 S_flag_body()
69 {
70         atf_check -s exit:0 -o empty rs -S < /dev/null
71 }
72
73 atf_test_case t_flag
74 t_flag_head()
75 {
76         atf_set "descr" "Verify the usage of option 't'"
77 }
78
79 t_flag_body()
80 {
81         atf_check -s exit:0 -o empty rs -t < /dev/null
82 }
83
84 atf_test_case T_flag
85 T_flag_head()
86 {
87         atf_set "descr" "Verify the usage of option 'T'"
88 }
89
90 T_flag_body()
91 {
92         atf_check -s exit:0 -o empty rs -T < /dev/null
93 }
94
95 atf_test_case k_flag
96 k_flag_head()
97 {
98         atf_set "descr" "Verify the usage of option 'k'"
99 }
100
101 k_flag_body()
102 {
103         atf_check -s exit:0 -o empty rs -k < /dev/null
104 }
105
106 atf_test_case K_flag
107 K_flag_head()
108 {
109         atf_set "descr" "Verify the usage of option 'K'"
110 }
111
112 K_flag_body()
113 {
114         atf_check -s exit:0 -o inline:"
115 " rs -K < /dev/null
116 }
117
118 atf_test_case g_flag
119 g_flag_head()
120 {
121         atf_set "descr" "Verify the usage of option 'g'"
122 }
123
124 g_flag_body()
125 {
126         atf_check -s exit:0 -o empty rs -g < /dev/null
127 }
128
129 atf_test_case G_flag
130 G_flag_head()
131 {
132         atf_set "descr" "Verify the usage of option 'G'"
133 }
134
135 G_flag_body()
136 {
137         atf_check -s exit:0 -o empty rs -G < /dev/null
138 }
139
140 atf_test_case e_flag
141 e_flag_head()
142 {
143         atf_set "descr" "Verify the usage of option 'e'"
144 }
145
146 e_flag_body()
147 {
148         atf_check -s exit:0 -o inline:"
149 " rs -e < /dev/null
150 }
151
152 atf_test_case n_flag
153 n_flag_head()
154 {
155         atf_set "descr" "Verify the usage of option 'n'"
156 }
157
158 n_flag_body()
159 {
160         atf_check -s exit:0 -o empty rs -n < /dev/null
161 }
162
163 atf_test_case y_flag
164 y_flag_head()
165 {
166         atf_set "descr" "Verify the usage of option 'y'"
167 }
168
169 y_flag_body()
170 {
171         atf_check -s exit:0 -o empty rs -y < /dev/null
172 }
173
174 atf_test_case h_flag
175 h_flag_head()
176 {
177         atf_set "descr" "Verify the usage of option 'h'"
178 }
179
180 h_flag_body()
181 {
182         atf_check -s exit:0 -o inline:"1 0
183 " rs -h < /dev/null
184 }
185
186 atf_test_case H_flag
187 H_flag_head()
188 {
189         atf_set "descr" "Verify the usage of option 'H'"
190 }
191
192 H_flag_body()
193 {
194         atf_check -s exit:0 -o inline:" 0 line 1
195 1 0
196 " rs -H < /dev/null
197 }
198
199 atf_test_case j_flag
200 j_flag_head()
201 {
202         atf_set "descr" "Verify the usage of option 'j'"
203 }
204
205 j_flag_body()
206 {
207         atf_check -s exit:0 -o empty rs -j < /dev/null
208 }
209
210 atf_test_case m_flag
211 m_flag_head()
212 {
213         atf_set "descr" "Verify the usage of option 'm'"
214 }
215
216 m_flag_body()
217 {
218         atf_check -s exit:0 -o empty rs -m < /dev/null
219 }
220
221 atf_test_case z_flag
222 z_flag_head()
223 {
224         atf_set "descr" "Verify the usage of option 'z'"
225 }
226
227 z_flag_body()
228 {
229         atf_check -s exit:0 -o empty rs -z < /dev/null
230 }
231
232 atf_test_case invalid_usage
233 invalid_usage_head()
234 {
235         atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
236 }
237
238 invalid_usage_body()
239 {
240         atf_check -s not-exit:0 -e inline:"rs: width must be a positive integer
241 " rs -w
242 }
243
244 atf_test_case no_arguments
245 no_arguments_head()
246 {
247         atf_set "descr" "Verify that rs(1) executes successfully and produces a valid output when invoked without any arguments"
248 }
249
250 no_arguments_body()
251 {
252         atf_check -s exit:0 -o inline:"
253 " rs < /dev/null
254 }
255
256 atf_init_test_cases()
257 {
258         atf_add_test_case c_flag
259         atf_add_test_case s_flag
260         atf_add_test_case C_flag
261         atf_add_test_case S_flag
262         atf_add_test_case t_flag
263         atf_add_test_case T_flag
264         atf_add_test_case k_flag
265         atf_add_test_case K_flag
266         atf_add_test_case g_flag
267         atf_add_test_case G_flag
268         atf_add_test_case e_flag
269         atf_add_test_case n_flag
270         atf_add_test_case y_flag
271         atf_add_test_case h_flag
272         atf_add_test_case H_flag
273         atf_add_test_case j_flag
274         atf_add_test_case m_flag
275         atf_add_test_case z_flag
276         atf_add_test_case invalid_usage
277         atf_add_test_case no_arguments
278 }