1 # $NetBSD: t_modload.sh,v 1.4 2009/01/04 17:56:57 jmmv Exp $
3 # Copyright (c) 2008 The NetBSD Foundation, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
29 echo "${1} = ${2}" >expout
30 atf_check
-s eq
:0 -o file:expout
-e empty sysctl
${1}
35 atf_set
"descr" "Test load without arguments"
36 atf_set
"require.user" "root"
40 modload: No such file or directory
42 atf_check
-s eq
:1 -o empty
-e ignore modload non-existent.o
44 atf_check
-s eq
:0 -o empty
-e empty \
45 modload $
(atf_get_srcdir
)/k_helper
/k_helper.kmod
46 check_sysctl vendor.k_helper.present
1
47 check_sysctl vendor.k_helper.prop_int_ok
0
48 check_sysctl vendor.k_helper.prop_str_ok
0
49 atf_check
-s eq
:0 -o empty
-e empty modunload k_helper
52 modunload k_helper
>/dev
/null
2>&1
57 atf_set
"descr" "Test the -b flag"
58 atf_set
"require.user" "root"
61 echo "Checking error conditions"
63 atf_check
-s eq
:1 -o empty
-e save
:stderr \
64 modload
-b foo k_helper.kmod
65 atf_check
-s eq
:0 -o ignore
-e empty \
66 grep 'Invalid parameter.*foo' stderr
68 atf_check
-s eq
:1 -o empty
-e save
:stderr \
69 modload
-b foo
= k_helper.kmod
70 atf_check
-s eq
:0 -o ignore
-e empty \
71 grep 'Invalid boolean value' stderr
73 atf_check
-s eq
:1 -o empty
-e save
:stderr \
74 modload
-b foo
=bar k_helper.kmod
75 atf_check
-s eq
:0 -o ignore
-e empty \
76 grep 'Invalid boolean value.*bar' stderr
78 atf_check
-s eq
:1 -o empty
-e save
:stderr \
79 modload
-b foo
=falsea k_helper.kmod
80 atf_check
-s eq
:0 -o ignore
-e empty \
81 grep 'Invalid boolean value.*falsea' stderr
83 atf_check
-s eq
:1 -o empty
-e save
:stderr \
84 modload
-b foo
=truea k_helper.kmod
85 atf_check
-s eq
:0 -o ignore
-e empty \
86 grep 'Invalid boolean value.*truea' stderr
88 # TODO Once sysctl(8) supports CTLTYPE_BOOL nodes.
89 #echo "Checking valid values"
92 modunload k_helper
>/dev
/null
2>&1
97 atf_set
"descr" "Test the -i flag"
98 atf_set
"require.user" "root"
101 echo "Checking error conditions"
103 atf_check
-s eq
:1 -o empty
-e save
:stderr modload
-i foo \
104 k_helper
/k_helper.kmod
105 atf_check
-s eq
:0 -o ignore
-e empty \
106 grep 'Invalid parameter.*foo' stderr
108 atf_check
-s eq
:1 -o empty
-e save
:stderr modload
-i foo
= \
109 k_helper
/k_helper.kmod
110 atf_check
-s eq
:0 -o ignore
-e empty \
111 grep 'Invalid integer value' stderr
113 atf_check
-s eq
:1 -o empty
-e save
:stderr \
114 modload
-i foo
=bar k_helper
/k_helper.kmod
115 atf_check
-s eq
:0 -o ignore
-e empty \
116 grep 'Invalid integer value.*bar' stderr
118 atf_check
-s eq
:1 -o empty
-e save
:stderr \
119 modload
-i foo
=123a k_helper
/k_helper.kmod
120 atf_check
-s eq
:0 -o ignore
-e empty \
121 grep 'Invalid integer value.*123a' stderr
123 echo "Checking valid values"
126 atf_check
-s eq
:0 -o empty
-e empty \
127 modload
-i prop_int
="${v}" \
128 $
(atf_get_srcdir
)/k_helper
/k_helper.kmod
129 check_sysctl vendor.k_helper.prop_int_ok
1
130 check_sysctl vendor.k_helper.prop_int_val
"${v}"
131 atf_check
-s eq
:0 -o empty
-e empty modunload k_helper
135 modunload k_helper
>/dev
/null
2>&1
140 atf_set
"descr" "Test the -s flag"
141 atf_set
"require.user" "root"
144 echo "Checking error conditions"
146 atf_check
-s eq
:1 -o empty
-e save
:stderr modload
-s foo \
147 k_helper
/k_helper.kmod
148 atf_check
-s eq
:0 -o ignore
-e empty \
149 grep 'Invalid parameter.*foo' stderr
151 echo "Checking valid values"
153 for v
in '1st string' '2nd string'; do
154 atf_check
-s eq
:0 -o empty
-e empty \
155 modload
-s prop_str
="${v}" \
156 $
(atf_get_srcdir
)/k_helper
/k_helper.kmod
157 check_sysctl vendor.k_helper.prop_str_ok
1
158 check_sysctl vendor.k_helper.prop_str_val
"${v}"
159 atf_check
-s eq
:0 -o empty
-e empty modunload k_helper
163 modunload k_helper
>/dev
/null
2>&1
166 atf_init_test_cases
()
168 atf_add_test_case plain
169 atf_add_test_case bflag
170 atf_add_test_case iflag
171 atf_add_test_case sflag