]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/kyua/integration/global_test.sh
Merge tcsh 6.22.03-ceccc7f
[FreeBSD/FreeBSD.git] / contrib / kyua / integration / global_test.sh
1 # Copyright 2011 The Kyua Authors.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 #   notice, this list of conditions and the following disclaimer.
10 # * 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 # * Neither the name of Google Inc. nor the names of its contributors
14 #   may be used to endorse or promote products derived from this software
15 #   without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29
30 utils_test_case no_args
31 no_args_body() {
32     cat >experr <<EOF
33 Usage error: No command provided.
34 Type 'kyua help' for usage information.
35 EOF
36
37     atf_check -s exit:3 -o empty -e file:experr kyua
38 }
39
40
41 utils_test_case unknown_option
42 unknown_option_body() {
43     cat >experr <<EOF
44 Usage error: Unknown option --this_is_unknown.
45 Type 'kyua help' for usage information.
46 EOF
47
48     atf_check -s exit:3 -o empty -e file:experr kyua --this_is_unknown
49 }
50
51
52 utils_test_case unknown_command
53 unknown_command_body() {
54     cat >experr <<EOF
55 Usage error: Unknown command 'i_am_not_known'.
56 Type 'kyua help' for usage information.
57 EOF
58
59     atf_check -s exit:3 -o empty -e file:experr kyua i_am_not_known
60 }
61
62
63 utils_test_case logfile__default
64 logfile__default_body() {
65     atf_check -s exit:0 test ! -d .kyua/logs/
66     atf_check -s exit:3 -o empty -e ignore kyua
67     atf_check -s exit:0 test -d .kyua/logs/
68 }
69
70
71 utils_test_case logfile__override
72 logfile__override_body() {
73     atf_check -s exit:0 test ! -f test.log
74     atf_check -s exit:3 -o empty -e ignore kyua --logfile=test.log
75
76     atf_check -s exit:0 test ! -d .kyua/logs/
77     atf_check -s exit:0 test -f test.log
78
79     grep ' E .* No command provided' test.log || atf_fail "Log file does" \
80         "contain required message"
81 }
82
83
84 utils_test_case loglevel__default
85 loglevel__default_body() {
86     atf_check -s exit:0 test ! -f test.log
87     atf_check -s exit:3 -o empty -e ignore kyua --logfile=test.log
88
89     atf_check -s exit:0 test ! -d .kyua/logs/
90     atf_check -s exit:0 test -f test.log
91
92     grep ' E .* No command provided' test.log || atf_fail "Log file does" \
93         "contain required message"
94     if grep ' D ' test.log; then
95         atf_fail "Log file contains debug messages but it should not"
96     fi
97 }
98
99
100 utils_test_case loglevel__lower
101 loglevel__lower_body() {
102     atf_check -s exit:0 test ! -f test.log
103     atf_check -s exit:3 -o empty -e ignore kyua --logfile=test.log \
104         --loglevel=warning
105
106     atf_check -s exit:0 test ! -d .kyua/logs/
107     atf_check -s exit:0 test -f test.log
108
109     grep ' E .* No command provided' test.log || atf_fail "Log file does" \
110         "contain required message"
111     if grep ' I ' test.log; then
112         atf_fail "Log file contains info messages but it should not"
113     fi
114 }
115
116
117 utils_test_case loglevel__higher
118 loglevel__higher_body() {
119     atf_check -s exit:0 test ! -f test.log
120     atf_check -s exit:3 -o empty -e ignore kyua --logfile=test.log \
121         --loglevel=debug
122
123     atf_check -s exit:0 test ! -d .kyua/logs/
124     atf_check -s exit:0 test -f test.log
125
126     grep ' E .* No command provided' test.log || atf_fail "Log file does" \
127         "contain required message"
128     grep ' D ' test.log || atf_fail "Log file does not contain debug messages"
129 }
130
131
132 atf_init_test_cases() {
133     atf_add_test_case no_args
134     atf_add_test_case unknown_option
135     atf_add_test_case unknown_command
136
137     atf_add_test_case logfile__default
138     atf_add_test_case logfile__override
139
140     atf_add_test_case loglevel__default
141     atf_add_test_case loglevel__lower
142     atf_add_test_case loglevel__higher
143
144     # Tests for the global configuration-related flags are found in the
145     # cmd_config_test test program.
146 }