t_pr_19722.sh revision 1.1 1 1.1 rillig # $NetBSD: t_pr_19722.sh,v 1.1 2022/05/22 17:55:08 rillig Exp $
2 1.1 rillig #
3 1.1 rillig # Copyright (c) 2022 The NetBSD Foundation, Inc.
4 1.1 rillig # All rights reserved.
5 1.1 rillig #
6 1.1 rillig # Redistribution and use in source and binary forms, with or without
7 1.1 rillig # modification, are permitted provided that the following conditions
8 1.1 rillig # are met:
9 1.1 rillig # 1. Redistributions of source code must retain the above copyright
10 1.1 rillig # notice, this list of conditions and the following disclaimer.
11 1.1 rillig # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 rillig # notice, this list of conditions and the following disclaimer in the
13 1.1 rillig # documentation and/or other materials provided with the distribution.
14 1.1 rillig #
15 1.1 rillig # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 rillig # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 rillig # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 rillig # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 rillig # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 rillig # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 rillig # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 rillig # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 rillig # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 rillig # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 rillig # POSSIBILITY OF SUCH DAMAGE.
26 1.1 rillig #
27 1.1 rillig
28 1.1 rillig # https://gnats.netbsd.org/19722
29 1.1 rillig #
30 1.1 rillig # Before TODO:rev from TODO:date, trying to uncompress a nonexistent or
31 1.1 rillig # malformed source file resulted in a truncated target file.
32 1.1 rillig
33 1.1 rillig
34 1.1 rillig atf_test_case 'no_source_no_target'
35 1.1 rillig no_source_no_target_body()
36 1.1 rillig {
37 1.1 rillig
38 1.1 rillig atf_check \
39 1.1 rillig -s 'not-exit:0' \
40 1.1 rillig -e 'inline:uncompress: file.Z: No such file or directory\n' \
41 1.1 rillig uncompress -f 'file'
42 1.1 rillig
43 1.1 rillig # FIXME: The target file must not be created.
44 1.1 rillig atf_check cat 'file'
45 1.1 rillig atf_check test ! -f 'nonexistent.Z'
46 1.1 rillig }
47 1.1 rillig
48 1.1 rillig
49 1.1 rillig atf_test_case 'no_source_existing_target'
50 1.1 rillig no_source_existing_target_body()
51 1.1 rillig {
52 1.1 rillig
53 1.1 rillig echo 'before' > 'file'
54 1.1 rillig
55 1.1 rillig atf_check \
56 1.1 rillig -s 'not-exit:0' \
57 1.1 rillig -e 'inline:uncompress: file.Z: No such file or directory\n' \
58 1.1 rillig uncompress -f 'file'
59 1.1 rillig
60 1.1 rillig # FIXME: The target file must not be truncated.
61 1.1 rillig atf_check cat 'file'
62 1.1 rillig }
63 1.1 rillig
64 1.1 rillig
65 1.1 rillig atf_test_case 'broken_source_existing_target'
66 1.1 rillig broken_source_existing_target_body()
67 1.1 rillig {
68 1.1 rillig # If the source file is not compressed, preserve the target file.
69 1.1 rillig
70 1.1 rillig echo 'broken' > 'file.Z'
71 1.1 rillig echo 'before' > 'file'
72 1.1 rillig
73 1.1 rillig atf_check \
74 1.1 rillig -s 'not-exit:0' \
75 1.1 rillig -e 'inline:uncompress: file.Z: Inappropriate file type or format\n' \
76 1.1 rillig uncompress -f 'file.Z'
77 1.1 rillig
78 1.1 rillig # FIXME: Must not be removed, must not be truncated.
79 1.1 rillig atf_check test ! -f 'file'
80 1.1 rillig }
81 1.1 rillig
82 1.1 rillig
83 1.1 rillig atf_init_test_cases()
84 1.1 rillig {
85 1.1 rillig
86 1.1 rillig atf_add_test_case no_source_no_target
87 1.1 rillig atf_add_test_case no_source_existing_target
88 1.1 rillig atf_add_test_case broken_source_existing_target
89 1.1 rillig }
90