t_errors.sh revision 1.1 1 #! /bin/sh
2 # $NetBSD: t_errors.sh,v 1.1 2021/10/13 23:33:52 rillig Exp $
3 #
4 # Copyright (c) 2021 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
27 #
28 # $FreeBSD$
29
30 indent=$(atf_config_get usr.bin.indent.test_indent /usr/bin/indent)
31 nl='
32 '
33
34 atf_test_case 'option_unknown'
35 option_unknown_body()
36 {
37 atf_check -s 'exit:1' \
38 -e 'inline:indent: Command line: unknown option "-Z-unknown"'"$nl" \
39 "$indent" -Z-unknown
40 }
41
42 atf_test_case 'option_bool_trailing_garbage'
43 option_bool_trailing_garbage_body()
44 {
45 atf_check -s 'exit:1' \
46 -e 'inline:indent: Command line: unknown option "-bacchus"'"$nl" \
47 "$indent" -bacchus
48 }
49
50 atf_test_case 'option_int_missing_parameter'
51 option_int_missing_parameter_body()
52 {
53 atf_check -s 'exit:1' \
54 -e 'inline:indent: Command line: option "-ts" requires an integer parameter'"$nl" \
55 "$indent" -tsx
56 }
57
58 atf_init_test_cases()
59 {
60 atf_add_test_case 'option_unknown'
61 atf_add_test_case 'option_bool_trailing_garbage'
62 atf_add_test_case 'option_int_missing_parameter'
63 }
64