Thu Jun 25 15:43:27 2020 UTC ()
Fix pastos.


(jruoho)
diff -r1.1 -r1.2 src/tests/sbin/ifconfig/t_tap.sh
diff -r1.2 -r1.3 src/tests/usr.sbin/cpuctl/t_cpuctl.sh

cvs diff -r1.1 -r1.2 src/tests/sbin/ifconfig/t_tap.sh (switch to unified diff)

--- src/tests/sbin/ifconfig/t_tap.sh 2020/06/25 14:24:46 1.1
+++ src/tests/sbin/ifconfig/t_tap.sh 2020/06/25 15:43:26 1.2
@@ -1,101 +1,101 @@ @@ -1,101 +1,101 @@
1# $NetBSD: t_tap.sh,v 1.1 2020/06/25 14:24:46 jruoho Exp $ 1# $NetBSD: t_tap.sh,v 1.2 2020/06/25 15:43:26 jruoho Exp $
2# 2#
3# Copyright (c) 2020 The NetBSD Foundation, Inc. 3# Copyright (c) 2020 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Jukka Ruohonen. 7# by Jukka Ruohonen.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29# 29#
30taps="/tmp/taps" 30taps="/tmp/taps"
31 31
32atf_test_case manytaps cleanup 32atf_test_case manytaps cleanup
33manytaps_head() { 33manytaps_head() {
34 atf_set "require.user" "root" 34 atf_set "require.user" "root"
35 atf_set "descr" "Test creating many, many tap(4)'s (PR kern/55417)" 35 atf_set "descr" "Test creating many, many tap(4)'s (PR kern/55417)"
36} 36}
37 37
38manytaps_body() { 38manytaps_body() {
39 39
40 atf_skip "The test causes a panic (PR kern/55417)" 40 atf_skip "The test causes a panic (PR kern/55417)"
41 seq 65535 64000 > $taps 41 seq 65535 64000 > $taps
42 42
43 while read tap; do 43 while read tap; do
44 44
45 ifconfig "tap$tap" 45 ifconfig "tap$tap"
46 46
47 if [ $? -eq 0 ]; then 47 if [ $? -eq 0 ]; then
48 echo "Skipping existing tap$tap" 48 echo "Skipping existing tap$tap"
49 continue 49 continue
50 fi 50 fi
51 51
52 ifconfig "tap$tap" create 52 ifconfig "tap$tap" create
53 echo "Created $tap" 53 echo "Created tap$tap"
54 54
55 done < $taps 55 done < $taps
56} 56}
57 57
58manytaps_cleanup() { 58manytaps_cleanup() {
59 59
60 if [ -f $taps ]; then 60 if [ -f $taps ]; then
61 61
62 while read tap; do 62 while read tap; do
63 63
64 ifconfig "tap$tap" 64 ifconfig "tap$tap"
65 65
66 if [ $? -eq 0 ]; then 66 if [ $? -eq 0 ]; then
67 ifconfig "tap$tap" destroy 67 ifconfig "tap$tap" destroy
68 echo "Destroyed tap$tap" 68 echo "Destroyed tap$tap"
69 fi 69 fi
70 70
71 done < $taps 71 done < $taps
72 72
73 rm $taps 73 rm $taps
74 fi 74 fi
75} 75}
76 76
77atf_test_case overflow cleanup 77atf_test_case overflow cleanup
78overflow_head() { 78overflow_head() {
79 atf_set "require.user" "root" 79 atf_set "require.user" "root"
80 atf_set "descr" "Test creating a tap(4) with a " \ 80 atf_set "descr" "Test creating a tap(4) with a " \
81 "negative device number (PR kern/53546)" 81 "negative device number (PR kern/53546)"
82} 82}
83 83
84overflow_body() { 84overflow_body() {
85 atf_skip "The test causes a panic (PR kern/53546)" 85 atf_skip "The test causes a panic (PR kern/53546)"
86 ifconfig tap65537 create 86 ifconfig tap65537 create
87} 87}
88 88
89overflow_cleanup() { 89overflow_cleanup() {
90 90
91 ifconfig tap65537 91 ifconfig tap65537
92 92
93 if [ $? -eq 0 ]; then 93 if [ $? -eq 0 ]; then
94 ifconfig tap65537 destroy 94 ifconfig tap65537 destroy
95 fi 95 fi
96} 96}
97 97
98atf_init_test_cases() { 98atf_init_test_cases() {
99 atf_add_test_case manytaps 99 atf_add_test_case manytaps
100 atf_add_test_case overflow 100 atf_add_test_case overflow
101} 101}

cvs diff -r1.2 -r1.3 src/tests/usr.sbin/cpuctl/t_cpuctl.sh (switch to unified diff)

--- src/tests/usr.sbin/cpuctl/t_cpuctl.sh 2020/06/24 10:07:13 1.2
+++ src/tests/usr.sbin/cpuctl/t_cpuctl.sh 2020/06/25 15:43:26 1.3
@@ -1,240 +1,240 @@ @@ -1,240 +1,240 @@
1# $NetBSD: t_cpuctl.sh,v 1.2 2020/06/24 10:07:13 jruoho Exp $ 1# $NetBSD: t_cpuctl.sh,v 1.3 2020/06/25 15:43:26 jruoho Exp $
2# 2#
3# Copyright (c) 2020 The NetBSD Foundation, Inc. 3# Copyright (c) 2020 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Jukka Ruohonen. 7# by Jukka Ruohonen.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 17#
18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE. 28# POSSIBILITY OF SUCH DAMAGE.
29# 29#
30tmp="/tmp/cpuctl.txt" 30tmp="/tmp/cpuctl.txt"
31 31
32setcpu() { 32setcpu() {
33 33
34 ncpu=$(sysctl -n hw.ncpu) 34 ncpu=$(sysctl -n hw.ncpu)
35 35
36 if [ $ncpu -eq 1 ]; then 36 if [ $ncpu -eq 1 ]; then
37 atf_pass 37 atf_pass
38 fi 38 fi
39 39
40 # Skip the boot processor. Disabling interrupts 40 # Skip the boot processor. Disabling interrupts
41 # on it will hang the system (PR kern/45117). 41 # on it will hang the system (PR kern/45117).
42 # 42 #
43 while [ $ncpu -gt 1 ]; do 43 while [ $ncpu -gt 1 ]; do
44 44
45 cpuid=$(expr $ncpu - 1) 45 cpuid=$(expr $ncpu - 1)
46 cpuctl $1 $cpuid >/dev/null 2>&1 46 cpuctl $1 $cpuid >/dev/null 2>&1
47 47
48 if [ ! $? -eq 0 ]; then 48 if [ ! $? -eq 0 ]; then
49 $2 $3 49 $2 $3
50 fi 50 fi
51 51
52 ncpu=$(expr $ncpu - 1) 52 ncpu=$(expr $ncpu - 1)
53 done 53 done
54} 54}
55 55
56clean() { 56clean() {
57 57
58 i=0 58 i=0
59 59
60 while read line; do 60 while read line; do
61 61
62 i=$(expr $i + 1) 62 i=$(expr $i + 1)
63 63
64 if [ $i -lt 3 ]; then 64 if [ $i -lt 3 ]; then
65 continue 65 continue
66 fi 66 fi
67 67
68 cpuid=$(echo $line | awk '{print $1}') 68 cpuid=$(echo $line | awk '{print $1}')
69 online=$(echo $line | awk '{print $3}') 69 online=$(echo $line | awk '{print $3}')
70 intr=$(echo $line | awk '{print $4}') 70 intr=$(echo $line | awk '{print $4}')
71 71
72 cpuctl $online $cpuid 72 cpuctl $online $cpuid
73 cpuctl $intr $cpuid 73 cpuctl $intr $cpuid
74 74
75 done < $tmp 75 done < $tmp
76 76
77 rm $tmp 77 rm $tmp
78} 78}
79 79
80# ncpu. 80# ncpu.
81# 81#
82atf_test_case ncpu 82atf_test_case ncpu
83ncpu_head() { 83ncpu_head() {
84 atf_require_prog cpuctl 84 atf_require_prog cpuctl
85 atf_set "descr" "Test that cpuctl(8) returns the " \ 85 atf_set "descr" "Test that cpuctl(8) returns the " \
86 "same number of CPUs as sysctl(8)" 86 "same number of CPUs as sysctl(8)"
87} 87}
88 88
89ncpu_body() { 89ncpu_body() {
90 90
91 lst=$(cpuctl list | wc -l) 91 lst=$(cpuctl list | wc -l)
92 ncpu=$(expr $lst - 2) 92 ncpu=$(expr $lst - 2)
93 93
94 if [ $ncpu -eq 1 ]; then 94 if [ $ncpu -eq 1 ]; then
95 atf_pass 95 atf_pass
96 fi 96 fi
97 97
98 if [ $(sysctl -n hw.ncpu) -eq $ncpu ]; then 98 if [ $(sysctl -n hw.ncpu) -eq $ncpu ]; then
99 atf_pass 99 atf_pass
100 fi 100 fi
101 101
102 atf_fail "Different number of CPUs" 102 atf_fail "Different number of CPUs"
103} 103}
104 104
105# err 105# err
106# 106#
107atf_test_case err cleanup 107atf_test_case err cleanup
108err_head() { 108err_head() {
109 atf_require_prog cpuctl 109 atf_require_prog cpuctl
110 atf_set "require.user" "root" 110 atf_set "require.user" "root"
111 atf_set "descr" "Test invalid parameters to cpuctl(8)" 111 atf_set "descr" "Test invalid parameters to cpuctl(8)"
112} 112}
113 113
114err_body() { 114err_body() {
115 115
116 cpuctl list > $tmp 116 cpuctl list > $tmp
117 ncpu=$(sysctl -n hw.ncpu) 117 ncpu=$(sysctl -n hw.ncpu)
118 118
119 atf_check -s exit:1 -e ignore \ 119 atf_check -s exit:1 -e ignore \
120 -o empty -x cpuctl identify -1 120 -o empty -x cpuctl identify -1
121 121
122 atf_check -s exit:1 -e ignore \ 122 atf_check -s exit:1 -e ignore \
123 -o empty -x cpuctl offline -1 123 -o empty -x cpuctl offline -1
124 124
125 atf_check -s exit:1 -e ignore \ 125 atf_check -s exit:1 -e ignore \
126 -o empty -x cpuctl nointr -1 126 -o empty -x cpuctl nointr -1
127 127
128 atf_check -s exit:1 -e ignore \ 128 atf_check -s exit:1 -e ignore \
129 -o empty -x cpuctl identify $(exp ncpu + 1) 129 -o empty -x cpuctl identify $(expr ncpu + 1)
130 130
131 atf_check -s exit:1 -e ignore \ 131 atf_check -s exit:1 -e ignore \
132 -o empty -x cpuctl offline $(exp ncpu + 1) 132 -o empty -x cpuctl offline $(expr ncpu + 1)
133 133
134 atf_check -s exit:1 -e ignore \ 134 atf_check -s exit:1 -e ignore \
135 -o empty -x cpuctl nointr $(exp ncpu + 1) 135 -o empty -x cpuctl nointr $(expr ncpu + 1)
136} 136}
137 137
138err_cleanup() { 138err_cleanup() {
139 clean 139 clean
140} 140}
141 141
142# identify 142# identify
143# 143#
144atf_test_case identify 144atf_test_case identify
145identify_head() { 145identify_head() {
146 atf_require_prog cpuctl 146 atf_require_prog cpuctl
147 atf_set "descr" "Test that cpuctl(8) identifies at least " \ 147 atf_set "descr" "Test that cpuctl(8) identifies at least " \
148 "something without segfaulting (PR bin/54220)" 148 "something without segfaulting (PR bin/54220)"
149} 149}
150 150
151identify_body() { 151identify_body() {
152 152
153 ncpu=$(sysctl -n hw.ncpu) 153 ncpu=$(sysctl -n hw.ncpu)
154 154
155 while [ $ncpu -gt 0 ]; do 155 while [ $ncpu -gt 0 ]; do
156 cpuid=$(expr $ncpu - 1) 156 cpuid=$(expr $ncpu - 1)
157 atf_check -s exit:0 -o not-empty -x cpuctl identify $cpuid 157 atf_check -s exit:0 -o not-empty -x cpuctl identify $cpuid
158 ncpu=$(expr $ncpu - 1) 158 ncpu=$(expr $ncpu - 1)
159 done 159 done
160 160
161 atf_pass 161 atf_pass
162} 162}
163 163
164# offline 164# offline
165# 165#
166atf_test_case offline cleanup 166atf_test_case offline cleanup
167offline_head() { 167offline_head() {
168 atf_require_prog cpuctl 168 atf_require_prog cpuctl
169 atf_set "require.user" "root" 169 atf_set "require.user" "root"
170 atf_set "descr" "Test setting CPUs offline" 170 atf_set "descr" "Test setting CPUs offline"
171} 171}
172 172
173offline_body() { 173offline_body() {
174 174
175 cpuctl list > $tmp 175 cpuctl list > $tmp
176 setcpu "offline" atf_fail "error in setting a CPU offline" 176 setcpu "offline" atf_fail "error in setting a CPU offline"
177 177
178 # Additional check that the boot processor cannot be 178 # Additional check that the boot processor cannot be
179 # set offline, as noted in the cpuctl(8) manual page. 179 # set offline, as noted in the cpuctl(8) manual page.
180 # 180 #
181 cpuctl offline 0 >/dev/null 2>&1 181 cpuctl offline 0 >/dev/null 2>&1
182 182
183 if [ $? -eq 0 ]; then 183 if [ $? -eq 0 ]; then
184 $2 $3 184 $2 $3
185 fi 185 fi
186} 186}
187 187
188offline_cleanup() { 188offline_cleanup() {
189 clean 189 clean
190} 190}
191 191
192atf_test_case offline_perm 192atf_test_case offline_perm
193offline_perm_head() { 193offline_perm_head() {
194 atf_require_prog cpuctl 194 atf_require_prog cpuctl
195 atf_set "require.user" "unprivileged" 195 atf_set "require.user" "unprivileged"
196 atf_set "descr" "Test setting CPUs offline as a user" 196 atf_set "descr" "Test setting CPUs offline as a user"
197} 197}
198 198
199offline_perm_body() { 199offline_perm_body() {
200 setcpu "offline" atf_pass 200 setcpu "offline" atf_pass
201} 201}
202 202
203# nointr 203# nointr
204# 204#
205atf_test_case nointr cleanup 205atf_test_case nointr cleanup
206nointr_head() { 206nointr_head() {
207 atf_require_prog cpuctl 207 atf_require_prog cpuctl
208 atf_set "require.user" "root" 208 atf_set "require.user" "root"
209 atf_set "descr" "Test disabling interrupts for CPUs" 209 atf_set "descr" "Test disabling interrupts for CPUs"
210} 210}
211 211
212nointr_body() { 212nointr_body() {
213 cpuctl list > $tmp 213 cpuctl list > $tmp
214 setcpu "nointr" atf_fail "error in disabling interrupts" 214 setcpu "nointr" atf_fail "error in disabling interrupts"
215} 215}
216 216
217nointr_cleanup() { 217nointr_cleanup() {
218 clean 218 clean
219} 219}
220 220
221atf_test_case nointr_perm 221atf_test_case nointr_perm
222nointr_perm_head() { 222nointr_perm_head() {
223 atf_require_prog cpuctl 223 atf_require_prog cpuctl
224 atf_set "require.user" "unprivileged" 224 atf_set "require.user" "unprivileged"
225 atf_set "descr" "Test disabling interrupts as a user" 225 atf_set "descr" "Test disabling interrupts as a user"
226} 226}
227 227
228nointr_perm_body() { 228nointr_perm_body() {
229 setcpu "nointr" atf_pass 229 setcpu "nointr" atf_pass
230} 230}
231 231
232atf_init_test_cases() { 232atf_init_test_cases() {
233 atf_add_test_case ncpu 233 atf_add_test_case ncpu
234 atf_add_test_case err 234 atf_add_test_case err
235 atf_add_test_case identify 235 atf_add_test_case identify
236 atf_add_test_case offline 236 atf_add_test_case offline
237 atf_add_test_case offline_perm 237 atf_add_test_case offline_perm
238 atf_add_test_case nointr 238 atf_add_test_case nointr
239 atf_add_test_case nointr_perm 239 atf_add_test_case nointr_perm
240} 240}