1 # Copyright (c) 2017 Jilles Tjoelker <jilles@FreeBSD.org>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions
7 # 1. Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
13 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 atf_test_case uncompress_file_1
28 uncompress_file_1_head()
31 "Test uncompress without options, filename with .Z"
33 uncompress_file_1_body()
35 printf '%01000d\n' 7 >expectfile1
37 \037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\
38 \310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\
39 \152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\
40 \050\123\252\134\211\360\206\002" >file1.Z
41 atf_check uncompress file1.Z
42 atf_check cmp file1 expectfile1
43 atf_check test ! -e file1.Z
46 atf_test_case uncompress_file_2
47 uncompress_file_2_head()
50 "Test uncompress without options, filename without .Z"
52 uncompress_file_2_body()
54 printf '%01000d\n' 7 >expectfile1
56 \037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\
57 \310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\
58 \152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\
59 \050\123\252\134\211\360\206\002" >file1.Z
60 atf_check uncompress file1
61 atf_check cmp file1 expectfile1
62 atf_check test ! -e file1.Z
65 atf_test_case uncompress_stdio_1
66 uncompress_stdio_1_head()
69 "Test uncompress without parameters"
71 uncompress_stdio_1_body()
73 printf '%01000d\n' 7 >expectfile1
75 \037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\
76 \310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\
77 \152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\
78 \050\123\252\134\211\360\206\002" >file1.Z
79 atf_check -o file:expectfile1 -x 'uncompress <file1.Z'
82 atf_test_case uncompress_minusc_1
83 uncompress_minusc_1_head()
86 "Test uncompress with -c"
88 uncompress_minusc_1_body()
90 printf '%01000d\n' 7 >expectfile1
92 \037\235\220\060\002\012\034\110\260\240\301\203\010\023\052\134\
93 \310\260\241\303\207\020\043\112\234\110\261\242\305\213\030\063\
94 \152\334\310\261\243\307\217\040\103\212\034\111\262\244\311\223\
95 \050\123\252\134\211\360\206\002" >file1.Z
96 atf_check -o file:expectfile1 uncompress -c file1.Z
97 atf_check test -e file1.Z
98 atf_check test ! -e file1
101 atf_test_case compress_uncompress_stdio_1
102 compress_uncompress_stdio_1_head()
105 "Test compressing and uncompressing some data, using stdio"
107 compress_uncompress_stdio_1_body()
109 printf '%01000d\n' 7 8 >expectfile1
110 atf_check -x 'compress <expectfile1 >file1.Z'
111 atf_check -o file:expectfile1 uncompress -c file1.Z
114 atf_test_case compress_uncompress_minusc_1
115 compress_uncompress_minusc_1_head()
118 "Test compressing and uncompressing some data, using -c"
120 compress_uncompress_minusc_1_body()
122 printf '%01000d\n' 7 8 >expectfile1
123 atf_check -x 'compress -c expectfile1 >file1.Z'
124 atf_check -o file:expectfile1 uncompress -c file1.Z
127 atf_test_case compress_uncompress_file_1
128 compress_uncompress_file_1_head()
131 "Test compressing and uncompressing some data, passing one filename"
133 compress_uncompress_file_1_body()
135 printf '%01000d\n' 7 8 >expectfile1
137 atf_check compress file1
138 atf_check -s exit:1 cmp -s file1.Z expectfile1
139 atf_check uncompress file1.Z
140 atf_check cmp file1 expectfile1
143 atf_test_case compress_uncompress_file_2
144 compress_uncompress_file_2_head()
147 "Test compressing and uncompressing some data, passing two filenames"
149 compress_uncompress_file_2_body()
151 printf '%01000d\n' 7 8 >expectfile1
152 printf '%01000d\n' 8 7 >expectfile2
155 atf_check compress file1 file2
156 atf_check -s exit:1 cmp -s file1.Z expectfile1
157 atf_check -s exit:1 cmp -s file2.Z expectfile2
158 atf_check -s exit:1 cmp -s file1.Z file2.Z
159 atf_check uncompress file1.Z file2.Z
160 atf_check cmp file1 expectfile1
161 atf_check cmp file2 expectfile2
164 atf_test_case compress_uncompress_file_minusc_1
165 compress_uncompress_file_minusc_1_head()
168 "Test compressing and uncompressing some data, passing two filenames to uncompress -c"
170 compress_uncompress_file_minusc_1_body()
172 printf '%01000d\n' 7 8 >expectfile1
173 printf '%01000d\n' 8 7 >expectfile2
176 atf_check compress file1 file2
177 atf_check -s exit:1 cmp -s file1.Z expectfile1
178 atf_check -s exit:1 cmp -s file2.Z expectfile2
179 atf_check -s exit:1 cmp -s file1.Z file2.Z
180 atf_check -x 'uncompress -c file1.Z file2.Z >all'
181 atf_check -x 'cat expectfile1 expectfile2 >expectall'
182 atf_check cmp all expectall
185 atf_init_test_cases()
187 atf_add_test_case uncompress_file_1
188 atf_add_test_case uncompress_file_2
189 atf_add_test_case uncompress_stdio_1
190 atf_add_test_case uncompress_minusc_1
191 atf_add_test_case compress_uncompress_stdio_1
192 atf_add_test_case compress_uncompress_minusc_1
193 atf_add_test_case compress_uncompress_file_1
194 atf_add_test_case compress_uncompress_file_2
195 atf_add_test_case compress_uncompress_file_minusc_1