aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/geom/class/eli/Makefile4
-rw-r--r--tests/sys/geom/class/eli/attach_test.sh11
-rw-r--r--tests/sys/geom/class/eli/conf.sh8
-rw-r--r--tests/sys/geom/class/eli/configure_test.sh5
-rw-r--r--tests/sys/geom/class/eli/delkey_test.sh8
-rw-r--r--tests/sys/geom/class/eli/detach_test.sh5
-rw-r--r--tests/sys/geom/class/eli/init_test.sh23
-rw-r--r--tests/sys/geom/class/eli/integrity_test.sh13
-rw-r--r--tests/sys/geom/class/eli/kill_test.sh8
-rw-r--r--tests/sys/geom/class/eli/misc_test.sh25
-rw-r--r--tests/sys/geom/class/eli/onetime_test.sh13
-rw-r--r--tests/sys/geom/class/eli/resize_test.sh7
-rw-r--r--tests/sys/geom/class/eli/setkey_test.sh11
-rw-r--r--tests/sys/geom/class/geom_subr.sh50
-rw-r--r--tests/sys/geom/class/mirror/Makefile1
-rwxr-xr-xtests/sys/geom/class/mirror/component_selection.sh133
-rw-r--r--tests/sys/geom/class/mirror/conf.sh31
-rw-r--r--tests/sys/geom/class/mirror/sync_error.sh17
-rw-r--r--tests/sys/kern/Makefile1
-rw-r--r--tests/sys/kern/sigaltstack.c117
-rw-r--r--tests/sys/kqueue/libkqueue/kqueue_test.sh3
-rw-r--r--tests/sys/kqueue/libkqueue/main.c44
-rw-r--r--tests/sys/kqueue/libkqueue/proc.c2
-rw-r--r--tests/sys/kqueue/libkqueue/signal.c16
-rw-r--r--tests/sys/kqueue/libkqueue/timer.c173
-rw-r--r--tests/sys/kqueue/libkqueue/user.c4
-rw-r--r--tests/sys/kqueue/libkqueue/vnode.c20
-rw-r--r--tests/sys/netpfil/pf/Makefile1
-rwxr-xr-xtests/sys/netpfil/pf/names.sh34
-rwxr-xr-xtests/sys/netpfil/pf/pass_block.sh10
-rwxr-xr-xtests/sys/netpfil/pf/pfsync.sh28
31 files changed, 584 insertions, 242 deletions
diff --git a/tests/sys/geom/class/eli/Makefile b/tests/sys/geom/class/eli/Makefile
index 6e34b3e6974a..b5ab81b08f42 100644
--- a/tests/sys/geom/class/eli/Makefile
+++ b/tests/sys/geom/class/eli/Makefile
@@ -21,10 +21,6 @@ ATF_TESTS_SH+= setkey_test
${PACKAGE}FILES+= conf.sh
-.for t in ${TAP_TESTS_SH}
-TEST_METADATA.$t+= required_user="root"
-.endfor
-
CFLAGS.pbkdf2_test= -I${SRCTOP}/sys
SRCS.pbkdf2_test= \
diff --git a/tests/sys/geom/class/eli/attach_test.sh b/tests/sys/geom/class/eli/attach_test.sh
index 42230059ac2d..94c7e88ada3d 100644
--- a/tests/sys/geom/class/eli/attach_test.sh
+++ b/tests/sys/geom/class/eli/attach_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case attach_d cleanup
attach_d_head()
{
@@ -8,7 +10,7 @@ attach_d_head()
}
attach_d_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -35,7 +37,6 @@ attach_d_body()
}
attach_d_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -47,7 +48,7 @@ attach_r_head()
}
attach_r_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -64,7 +65,6 @@ attach_r_body()
}
attach_r_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -76,7 +76,7 @@ nokey_head()
}
nokey_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -88,7 +88,6 @@ nokey_body()
}
nokey_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/conf.sh b/tests/sys/geom/class/eli/conf.sh
index 52885a186ff0..1a37f806d74a 100644
--- a/tests/sys/geom/class/eli/conf.sh
+++ b/tests/sys/geom/class/eli/conf.sh
@@ -4,7 +4,6 @@
class="eli"
base=$(atf_get ident)
MAX_SECSIZE=8192
-TEST_MDS_FILE=md.devs
attach_md()
{
@@ -82,7 +81,6 @@ for_each_geli_config_nointegrity() {
done
}
-
geli_test_cleanup()
{
if [ -f "$TEST_MDS_FILE" ]; then
@@ -95,4 +93,10 @@ geli_test_cleanup()
true
}
+geli_test_setup()
+{
+ geom_atf_test_setup
+}
+
+ATF_TEST=true
. `dirname $0`/../geom_subr.sh
diff --git a/tests/sys/geom/class/eli/configure_test.sh b/tests/sys/geom/class/eli/configure_test.sh
index da060e6119ea..a90a3da3e4d0 100644
--- a/tests/sys/geom/class/eli/configure_test.sh
+++ b/tests/sys/geom/class/eli/configure_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case configure_b_B cleanup
configure_b_B_head()
{
@@ -8,7 +10,7 @@ configure_b_B_head()
}
configure_b_B_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -49,7 +51,6 @@ configure_b_B_body()
}
configure_b_B_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/delkey_test.sh b/tests/sys/geom/class/eli/delkey_test.sh
index 9542e0166a9f..46c73aef8816 100644
--- a/tests/sys/geom/class/eli/delkey_test.sh
+++ b/tests/sys/geom/class/eli/delkey_test.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case delkey cleanup
delkey_head()
{
@@ -9,7 +11,7 @@ delkey_head()
}
delkey_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -76,7 +78,6 @@ delkey_body()
}
delkey_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -88,7 +89,7 @@ delkey_readonly_head()
}
delkey_readonly_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -103,7 +104,6 @@ delkey_readonly_body()
}
delkey_readonly_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/detach_test.sh b/tests/sys/geom/class/eli/detach_test.sh
index 1a3bd3887e8d..0901f327dc8f 100644
--- a/tests/sys/geom/class/eli/detach_test.sh
+++ b/tests/sys/geom/class/eli/detach_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case detach_l cleanup
detach_l_head()
{
@@ -8,7 +10,7 @@ detach_l_head()
}
detach_l_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -36,7 +38,6 @@ detach_l_body()
}
detach_l_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/init_test.sh b/tests/sys/geom/class/eli/init_test.sh
index b07d8532deb4..e60a103dd6e8 100644
--- a/tests/sys/geom/class/eli/init_test.sh
+++ b/tests/sys/geom/class/eli/init_test.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
init_test()
{
cipher=$1
@@ -39,7 +41,7 @@ init_head()
}
init_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=32
@@ -50,7 +52,6 @@ init_body()
}
init_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -62,7 +63,7 @@ init_B_head()
}
init_B_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
@@ -104,7 +105,6 @@ init_B_body()
}
init_B_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -116,7 +116,7 @@ init_J_head()
}
init_J_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -223,7 +223,6 @@ init_J_body()
}
init_J_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -260,7 +259,7 @@ init_a_head()
}
init_a_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
@@ -272,7 +271,6 @@ init_a_body()
}
init_a_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -304,7 +302,7 @@ init_alias_head()
}
init_alias_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
md=$(attach_md -t malloc -s 1024k)
atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
@@ -330,7 +328,6 @@ init_alias_body()
}
init_alias_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -342,7 +339,7 @@ init_i_P_head()
}
init_i_P_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -354,7 +351,6 @@ init_i_P_body()
}
init_i_P_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -366,7 +362,7 @@ nokey_head()
}
nokey_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -376,7 +372,6 @@ nokey_body()
}
nokey_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/integrity_test.sh b/tests/sys/geom/class/eli/integrity_test.sh
index f2bc8a32fd8d..583a9c2f29e5 100644
--- a/tests/sys/geom/class/eli/integrity_test.sh
+++ b/tests/sys/geom/class/eli/integrity_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
copy_test() {
cipher=$1
aalgo=$2
@@ -51,18 +53,17 @@ copy_head()
}
copy_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=2
atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
-
+
for_each_geli_config copy_test backing_file
}
copy_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -98,7 +99,7 @@ data_head()
}
data_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=2
@@ -108,7 +109,6 @@ data_body()
}
data_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -143,7 +143,7 @@ hmac_head()
}
hmac_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=2
@@ -153,7 +153,6 @@ hmac_body()
}
hmac_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/kill_test.sh b/tests/sys/geom/class/eli/kill_test.sh
index ef7f06893cda..9a49db8a6a4f 100644
--- a/tests/sys/geom/class/eli/kill_test.sh
+++ b/tests/sys/geom/class/eli/kill_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case kill cleanup
kill_head()
{
@@ -8,7 +10,7 @@ kill_head()
}
kill_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -61,7 +63,6 @@ kill_body()
}
kill_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -73,7 +74,7 @@ kill_readonly_head()
}
kill_readonly_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -91,7 +92,6 @@ kill_readonly_body()
}
kill_readonly_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/misc_test.sh b/tests/sys/geom/class/eli/misc_test.sh
index 2dd60a4d8019..24bdc303add6 100644
--- a/tests/sys/geom/class/eli/misc_test.sh
+++ b/tests/sys/geom/class/eli/misc_test.sh
@@ -24,6 +24,8 @@
#
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case preserve_props cleanup
preserve_props_head()
{
@@ -33,7 +35,8 @@ preserve_props_head()
}
preserve_props_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
+
md=$(attach_md -s1m)
atf_check geli onetime /dev/${md}
md_secsize=$(diskinfo ${md} | cut -wf 2)
@@ -45,7 +48,6 @@ preserve_props_body()
}
preserve_props_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -59,7 +61,8 @@ preserve_disk_props_head()
}
preserve_disk_props_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
+
disks=`atf_config_get disks`
disk=${disks%% *}
if [ -z "$disk" ]; then
@@ -82,7 +85,6 @@ preserve_disk_props_body()
}
preserve_disk_props_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
disk_cleanup
geli_test_cleanup
}
@@ -96,8 +98,10 @@ physpath_head()
}
physpath_body()
{
- . $(atf_get_srcdir)/conf.sh
- load_gnop
+ geli_test_setup
+ if ! error_message=$(geom_load_class_if_needed nop); then
+ atf_skip "$error_message"
+ fi
md=$(attach_md -s1m)
# If the underlying device has no physical path, then geli should not
@@ -116,8 +120,6 @@ physpath_body()
}
physpath_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
-
if [ -f "$TEST_MDS_FILE" ]; then
while read md; do
[ -c /dev/${md}.nop.eli ] && \
@@ -168,10 +170,3 @@ disk_cleanup()
geli kill ${disk} 2>/dev/null
fi
}
-
-load_gnop()
-{
- if ! kldstat -q -m g_nop; then
- geom nop load || atf_skip "could not load module for geom nop"
- fi
-}
diff --git a/tests/sys/geom/class/eli/onetime_test.sh b/tests/sys/geom/class/eli/onetime_test.sh
index fff1a1fa396b..65939db5761c 100644
--- a/tests/sys/geom/class/eli/onetime_test.sh
+++ b/tests/sys/geom/class/eli/onetime_test.sh
@@ -1,5 +1,7 @@
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
onetime_test()
{
cipher=$1
@@ -35,7 +37,8 @@ onetime_head()
}
onetime_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
+
sectors=100
dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none
@@ -43,7 +46,6 @@ onetime_body()
}
onetime_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -78,7 +80,8 @@ onetime_a_head()
}
onetime_a_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
+
sectors=8
atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=$sectors \
@@ -87,7 +90,6 @@ onetime_a_body()
}
onetime_a_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -99,7 +101,7 @@ onetime_d_head()
}
onetime_d_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s $sectors)
@@ -125,7 +127,6 @@ onetime_d_body()
}
onetime_d_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/eli/resize_test.sh b/tests/sys/geom/class/eli/resize_test.sh
index 21406a495892..c94e64caca74 100644
--- a/tests/sys/geom/class/eli/resize_test.sh
+++ b/tests/sys/geom/class/eli/resize_test.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case resize cleanup
resize_head()
{
@@ -9,7 +11,8 @@ resize_head()
}
resize_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
+
BLK=512
BLKS_PER_MB=2048
@@ -67,8 +70,6 @@ resize_body()
}
resize_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
-
if [ -f "$TEST_MDS_FILE" ]; then
while read md; do
[ -c /dev/${md}a.eli ] && \
diff --git a/tests/sys/geom/class/eli/setkey_test.sh b/tests/sys/geom/class/eli/setkey_test.sh
index bd5e2dcedd8e..63acd5e58488 100644
--- a/tests/sys/geom/class/eli/setkey_test.sh
+++ b/tests/sys/geom/class/eli/setkey_test.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# $FreeBSD$
+. $(atf_get_srcdir)/conf.sh
+
atf_test_case setkey cleanup
setkey_head()
{
@@ -9,7 +11,7 @@ setkey_head()
}
setkey_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -88,7 +90,6 @@ setkey_body()
}
setkey_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -100,7 +101,7 @@ setkey_readonly_head()
}
setkey_readonly_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -114,7 +115,6 @@ setkey_readonly_body()
}
setkey_readonly_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
@@ -126,7 +126,7 @@ nokey_head()
}
nokey_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geli_test_setup
sectors=100
md=$(attach_md -t malloc -s `expr $sectors + 1`)
@@ -152,7 +152,6 @@ nokey_body()
}
nokey_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
geli_test_cleanup
}
diff --git a/tests/sys/geom/class/geom_subr.sh b/tests/sys/geom/class/geom_subr.sh
index 3283d1b3356e..71ed4a15540f 100644
--- a/tests/sys/geom/class/geom_subr.sh
+++ b/tests/sys/geom/class/geom_subr.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# $FreeBSD$
+TEST_MDS_FILE="${TMPDIR}/test_mds.$(basename $0)"
+
devwait()
{
while :; do
@@ -40,30 +42,40 @@ geom_test_cleanup()
echo "# Removing test memory disk: $test_md"
mdconfig -d -u $test_md
done < $TEST_MDS_FILE
+ rm -f "$TEST_MDS_FILE"
fi
- rm -f "$TEST_MDS_FILE"
}
-if [ $(id -u) -ne 0 ]; then
- echo '1..0 # SKIP tests must be run as root'
- exit 0
-fi
+geom_load_class_if_needed()
+{
+ local class=$1
+
+ # If the geom class isn't already loaded, try loading it.
+ if ! kldstat -q -m g_${class}; then
+ if ! geom ${class} load; then
+ echo "could not load module for geom class=${class}"
+ return 1
+ fi
+ fi
+ return 0
+}
-# If the geom class isn't already loaded, try loading it.
-if ! kldstat -q -m g_${class}; then
- if ! geom ${class} load; then
- echo "1..0 # SKIP could not load module for geom class=${class}"
+geom_atf_test_setup()
+{
+ if ! error_message=$(geom_load_class_if_needed $class); then
+ atf_skip "$error_message"
+ fi
+}
+
+geom_tap_test_setup()
+{
+ if ! error_message=$(geom_load_class_if_needed $class); then
+ echo "1..0 # SKIP $error_message"
exit 0
fi
-fi
+}
-# Need to keep track of the test md devices to avoid the scenario where a test
-# failing will cause the other tests to bomb out, or a test failing will leave
-# a large number of md(4) devices lingering around
-: ${TMPDIR=/tmp}
-export TMPDIR
-if ! TEST_MDS_FILE=$(mktemp ${TMPDIR}/test_mds.XXXXXX); then
- echo 'Failed to create temporary file for tracking the test md(4) devices'
- echo 'Bail out!'
- exit 1
+: ${ATF_TEST=false}
+if ! $ATF_TEST; then
+ geom_tap_test_setup
fi
diff --git a/tests/sys/geom/class/mirror/Makefile b/tests/sys/geom/class/mirror/Makefile
index 817d5d66e971..f719d7542964 100644
--- a/tests/sys/geom/class/mirror/Makefile
+++ b/tests/sys/geom/class/mirror/Makefile
@@ -18,6 +18,7 @@ TAP_TESTS_SH+= 11_test
TAP_TESTS_SH+= 12_test
TAP_TESTS_SH+= 13_test
+ATF_TESTS_SH+= component_selection
ATF_TESTS_SH+= sync_error
${PACKAGE}FILES+= conf.sh
diff --git a/tests/sys/geom/class/mirror/component_selection.sh b/tests/sys/geom/class/mirror/component_selection.sh
new file mode 100755
index 000000000000..53237b14e257
--- /dev/null
+++ b/tests/sys/geom/class/mirror/component_selection.sh
@@ -0,0 +1,133 @@
+# $FreeBSD$
+
+atf_test_case run_latest_genid cleanup
+run_latest_genid_head()
+{
+ atf_set "descr" \
+ "Ensure that we properly select components (latest genid) during STARTING."
+ atf_set "require.user" "root"
+}
+run_latest_genid_body()
+{
+ . $(atf_get_srcdir)/conf.sh
+
+ f1=$(mktemp ${base}.XXXXXX)
+ f2=$(mktemp ${base}.XXXXXX)
+ f3=$(mktemp ${base}.XXXXXX)
+ rnd1=$(mktemp ${base}.XXXXXX)
+ rnd2=$(mktemp ${base}.XXXXXX)
+
+ atf_check truncate -s 2M $f1
+ atf_check truncate -s 2M $f2
+ atf_check truncate -s 2M $f3
+ dd if=/dev/urandom bs=512 count=1 of="$rnd1"
+ dd if=/dev/urandom bs=512 count=1 of="$rnd2"
+
+ md1=$(attach_md -t vnode -f ${f1})
+ md2=$(attach_md -t vnode -f ${f2})
+ md3=$(attach_md -t vnode -f ${f3})
+
+ # Use a gnop for md1 just for consistency; it's not used for anything.
+ atf_check gnop create $md1
+ atf_check gnop create $md2
+ atf_check gnop create $md3
+ # Hardcode component names so that the non-.nop device isn't tasted
+ # instead.
+ atf_check gmirror label -h $name ${md1}.nop
+ devwait
+
+ atf_check gmirror insert -h $name ${md2}.nop
+ atf_check gmirror insert -h $name ${md3}.nop
+ syncwait
+
+ # Fail mirror 3, writing known contents to mirror 1+2 block 1
+ atf_check -s exit:0 -e empty -o empty \
+ gnop configure -w 100 ${md3}.nop
+ atf_check -s exit:0 dd if="$rnd1" bs=512 count=1 oseek=1 conv=notrunc \
+ of=/dev/mirror/$name status=none
+
+ disconnectwait nop "${md3}.nop"
+
+ # Should have two mirrors remaining after md3 was evicted
+ atf_check [ $(gmirror status -s $name | wc -l) -eq 2 ]
+ atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \
+ gmirror status -s $name
+ atf_check -s exit:0 -o match:"DEGRADED ${md2}.nop \(ACTIVE\)" \
+ gmirror status -s $name
+
+ # Repeat:
+ # Fail mirror 2, writing known contents to mirror 1 block 2
+ atf_check -s exit:0 -e empty -o empty \
+ gnop configure -w 100 ${md2}.nop
+ atf_check -s exit:0 dd if="$rnd2" bs=512 count=2 oseek=1 conv=notrunc \
+ of=/dev/mirror/$name status=none
+
+ disconnectwait nop "${md2}.nop"
+
+ # Should have one mirror remaining after md2 was evicted
+ atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ]
+ atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \
+ gmirror status -s $name
+
+ # Stop the mirror and remove the pieces so gmirror can't see them.
+ atf_check gmirror stop $name
+ atf_check gnop destroy ${md1}.nop
+ atf_check gnop destroy ${md2}.nop
+ atf_check gnop destroy ${md3}.nop
+
+ # Rebuild; spin up "disk" with lowest genid
+ atf_check gnop create $md3
+ md3gen=$(gmirror dump /dev/${md3}.nop | grep genid | cut -d: -f2)
+ # Assert gmirror is referencing this component for now:
+ atf_check [ $(consumerrefs nop ${md3}.nop) = "r1w1e1" ]
+
+ # Adding newer genid should kick out old component
+ atf_check gnop create $md2
+ md2gen=$(gmirror dump /dev/${md2}.nop | grep genid | cut -d: -f2)
+ atf_check [ $md2gen -gt $md3gen ]
+
+ disconnectwait nop "${md3}.nop"
+
+ # Can't test this because 'status' doesn't exist until RUNNING:
+ #atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ]
+ # But as a substitute, assert gmirror has dropped reference to staler
+ # component in favor of newer component:
+ atf_check [ $(consumerrefs nop ${md2}.nop) = "r1w1e1" ]
+
+ # ditto
+ atf_check gnop create $md1
+ md1gen=$(gmirror dump /dev/${md1}.nop | grep genid | cut -d: -f2)
+ atf_check [ $md1gen -gt $md2gen ]
+
+ disconnectwait nop "${md2}.nop"
+
+ # Assert gmirror has dropped reference to stale component in favor of
+ # newer component:
+ atf_check [ $(consumerrefs nop ${md1}.nop) = "r1w1e1" ]
+
+ # gmirror won't start the mirror automatically with only one component
+ # ($md0) of configured three, so this waits out the
+ # kern.geom.mirror.timeout:
+ devwait
+
+ atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ]
+ atf_check -s exit:0 -o match:"DEGRADED ${md1}.nop \(ACTIVE\)" \
+ gmirror status -s $name
+}
+run_latest_genid_cleanup()
+{
+ . $(atf_get_srcdir)/conf.sh
+
+ if [ -f "$TEST_MDS_FILE" ]; then
+ while read test_md; do
+ echo "# Removing test gnop: ${test_md}.nop"
+ gnop destroy -f "${test_md}.nop" 2>/dev/null || :
+ done < "$TEST_MDS_FILE"
+ fi
+ gmirror_test_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case run_latest_genid
+}
diff --git a/tests/sys/geom/class/mirror/conf.sh b/tests/sys/geom/class/mirror/conf.sh
index 1cb785e5113f..cee2b10e9ff6 100644
--- a/tests/sys/geom/class/mirror/conf.sh
+++ b/tests/sys/geom/class/mirror/conf.sh
@@ -19,4 +19,35 @@ syncwait()
done
}
+consumerrefs()
+{
+ gclass=$1
+ geom=$2
+
+ if [ $# -ne 2 ]; then
+ echo "Bad usage consumerrefs" >&2
+ exit 1
+ fi
+
+ geom "${gclass}" list "${geom}" | \
+ grep -A5 ^Consumers | \
+ grep Mode | \
+ cut -d: -f2
+}
+
+disconnectwait()
+{
+ gclass=$1
+ geom=$2
+
+ if [ $# -ne 2 ]; then
+ echo "Bad usage disconnectwait" >&2
+ exit 1
+ fi
+
+ while [ $(consumerrefs "$gclass" "$geom") != r0w0e0 ]; do
+ sleep 0.05
+ done
+}
+
. `dirname $0`/../geom_subr.sh
diff --git a/tests/sys/geom/class/mirror/sync_error.sh b/tests/sys/geom/class/mirror/sync_error.sh
index 89fd31e9d935..b5f138aaf8a0 100644
--- a/tests/sys/geom/class/mirror/sync_error.sh
+++ b/tests/sys/geom/class/mirror/sync_error.sh
@@ -1,5 +1,8 @@
# $FreeBSD$
+ATF_TEST=true
+. $(atf_get_srcdir)/conf.sh
+
REG_READ_FP=debug.fail_point.g_mirror_regular_request_read
atf_test_case sync_read_error_2_disks cleanup
@@ -11,7 +14,7 @@ sync_read_error_2_disks_head()
}
sync_read_error_2_disks_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geom_atf_test_setup
f1=$(mktemp ${base}.XXXXXX)
f2=$(mktemp ${base}.XXXXXX)
@@ -25,7 +28,7 @@ sync_read_error_2_disks_body()
atf_check gmirror label $name $md1
devwait
- atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}='1*return(5)'
+ atf_check -s ignore -e empty -o not-empty sysctl ${REG_READ_FP}='1*return(5)'
# If a read error occurs while synchronizing and the mirror contains
# a single active disk, gmirror has no choice but to fail the
@@ -39,9 +42,7 @@ sync_read_error_2_disks_body()
}
sync_read_error_2_disks_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
-
- atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}='off'
+ atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'
gmirror_test_cleanup
}
@@ -54,7 +55,7 @@ sync_read_error_3_disks_head()
}
sync_read_error_3_disks_body()
{
- . $(atf_get_srcdir)/conf.sh
+ geom_atf_test_setup
f1=$(mktemp ${base}.XXXXXX)
f2=$(mktemp ${base}.XXXXXX)
@@ -97,9 +98,7 @@ sync_read_error_3_disks_body()
}
sync_read_error_3_disks_cleanup()
{
- . $(atf_get_srcdir)/conf.sh
-
- atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}='off'
+ atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'
gmirror_test_cleanup
}
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index 0ab4a70a41b8..c4f01ff8925a 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -10,6 +10,7 @@ ATF_TESTS_C+= kern_descrip_test
ATF_TESTS_C+= ptrace_test
TEST_METADATA.ptrace_test+= timeout="15"
ATF_TESTS_C+= reaper
+ATF_TESTS_C+= sigaltstack
PLAIN_TESTS_C+= subr_unit_test
ATF_TESTS_C+= sys_getrandom
ATF_TESTS_C+= unix_passfd_test
diff --git a/tests/sys/kern/sigaltstack.c b/tests/sys/kern/sigaltstack.c
new file mode 100644
index 000000000000..a66ca8f578ba
--- /dev/null
+++ b/tests/sys/kern/sigaltstack.c
@@ -0,0 +1,117 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2018 Eric van Gyzen
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <atf-c.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdlib.h>
+
+/*
+ * TODO add tests for:
+ *
+ * - all error cases
+ * - SS_DISABLE
+ * - no effect without SA_ONSTACK
+ */
+
+static sig_atomic_t disabled_correct = 1;
+static sig_atomic_t level1_correct = -1;
+static sig_atomic_t level2_correct = -1;
+
+static void
+sig_handler(int signo, siginfo_t *info __unused, void *ucp)
+{
+ ucontext_t *uc = ucp;
+
+ // The alternate signal stack is enabled.
+ disabled_correct = disabled_correct &&
+ (uc->uc_stack.ss_flags & SS_DISABLE) == 0;
+ if (signo == SIGUSR1) {
+ // The thread was NOT running on the alternate signal
+ // stack when this signal arrived.
+ level1_correct = (uc->uc_stack.ss_flags & SS_ONSTACK) == 0;
+ raise(SIGUSR2);
+ } else {
+ // The thread WAS running on the alternate signal
+ // stack when this signal arrived.
+ level2_correct = (uc->uc_stack.ss_flags & SS_ONSTACK) != 0;
+ }
+}
+
+ATF_TC(ss_onstack);
+
+ATF_TC_HEAD(ss_onstack, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Test reporting of SS_ONSTACK");
+}
+
+ATF_TC_BODY(ss_onstack, tc)
+{
+ stack_t ss = {
+ .ss_size = SIGSTKSZ,
+ };
+ stack_t oss = {
+ .ss_size = 0,
+ };
+
+ ss.ss_sp = malloc(ss.ss_size);
+ ATF_REQUIRE(ss.ss_sp != NULL);
+ ATF_REQUIRE(sigaltstack(&ss, &oss) == 0);
+
+ // There should be no signal stack currently configured.
+ ATF_CHECK(oss.ss_sp == NULL);
+ ATF_CHECK(oss.ss_size == 0);
+ ATF_CHECK((oss.ss_flags & SS_DISABLE) != 0);
+ ATF_CHECK((oss.ss_flags & SS_ONSTACK) == 0);
+
+ struct sigaction sa = {
+ .sa_sigaction = sig_handler,
+ .sa_flags = SA_ONSTACK | SA_SIGINFO,
+ };
+ ATF_REQUIRE(sigemptyset(&sa.sa_mask) == 0);
+ ATF_REQUIRE(sigaction(SIGUSR1, &sa, NULL) == 0);
+ ATF_REQUIRE(sigaction(SIGUSR2, &sa, NULL) == 0);
+ ATF_REQUIRE(raise(SIGUSR1) == 0);
+
+ ATF_CHECK(level1_correct != -1);
+ ATF_CHECK(level1_correct == 1);
+ ATF_CHECK(level2_correct != -1);
+ ATF_CHECK(level2_correct == 1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, ss_onstack);
+
+ return (atf_no_error());
+}
diff --git a/tests/sys/kqueue/libkqueue/kqueue_test.sh b/tests/sys/kqueue/libkqueue/kqueue_test.sh
index 3185d826c7dd..5cca674305cb 100644
--- a/tests/sys/kqueue/libkqueue/kqueue_test.sh
+++ b/tests/sys/kqueue/libkqueue/kqueue_test.sh
@@ -2,7 +2,8 @@
# $FreeBSD$
i=1
-"$(dirname $0)/kqtest" | while read line; do
+# Temporarily disable evfilt_proc tests: https://bugs.freebsd.org/233586
+"$(dirname $0)/kqtest" --no-proc | while read line; do
echo $line | grep -q passed
if [ $? -eq 0 ]; then
echo "ok - $i $line"
diff --git a/tests/sys/kqueue/libkqueue/main.c b/tests/sys/kqueue/libkqueue/main.c
index 455a236183b3..d2e45c40d894 100644
--- a/tests/sys/kqueue/libkqueue/main.c
+++ b/tests/sys/kqueue/libkqueue/main.c
@@ -85,7 +85,7 @@ kevent_get(int kqfd)
struct kevent *kev;
if ((kev = calloc(1, sizeof(*kev))) == NULL)
- err(1, "out of memory");
+ err(1, "out of memory");
nfds = kevent(kqfd, NULL, 0, kev, 1, NULL);
if (nfds < 1)
@@ -103,7 +103,7 @@ kevent_get_timeout(int kqfd, int seconds)
struct timespec timeout = {seconds, 0};
if ((kev = calloc(1, sizeof(*kev))) == NULL)
- err(1, "out of memory");
+ err(1, "out of memory");
nfds = kevent(kqfd, NULL, 0, kev, 1, &timeout);
if (nfds < 0) {
@@ -123,10 +123,10 @@ kevent_fflags_dump(struct kevent *kev)
#define KEVFFL_DUMP(attrib) \
if (kev->fflags & attrib) \
- strncat(buf, #attrib" ", 64);
+ strncat(buf, #attrib" ", 64);
if ((buf = calloc(1, 1024)) == NULL)
- abort();
+ abort();
/* Not every filter has meaningful fflags */
if (kev->filter == EVFILT_PROC) {
@@ -160,7 +160,7 @@ kevent_fflags_dump(struct kevent *kev)
#endif
buf[strlen(buf) - 1] = ')';
} else {
- snprintf(buf, 1024, "fflags = %x", kev->fflags);
+ snprintf(buf, 1024, "fflags = %x", kev->fflags);
}
return (buf);
@@ -173,10 +173,10 @@ kevent_flags_dump(struct kevent *kev)
#define KEVFL_DUMP(attrib) \
if (kev->flags & attrib) \
- strncat(buf, #attrib" ", 64);
+ strncat(buf, #attrib" ", 64);
if ((buf = calloc(1, 1024)) == NULL)
- abort();
+ abort();
snprintf(buf, 1024, "flags = %d (", kev->flags);
KEVFL_DUMP(EV_ADD);
@@ -208,17 +208,17 @@ kevent_to_str(struct kevent *kev)
snprintf(&buf[0], sizeof(buf),
"[ident=%ju, filter=%d, %s, %s, data=%jd, udata=%p, "
- "ext=[%jx %jx %jx %jx]",
+ "ext=[%jx %jx %jx %jx]",
(uintmax_t) kev->ident,
kev->filter,
flags_str,
fflags_str,
(uintmax_t)kev->data,
kev->udata,
- (uintmax_t)kev->ext[0],
- (uintmax_t)kev->ext[1],
- (uintmax_t)kev->ext[2],
- (uintmax_t)kev->ext[3]);
+ (uintmax_t)kev->ext[0],
+ (uintmax_t)kev->ext[1],
+ (uintmax_t)kev->ext[2],
+ (uintmax_t)kev->ext[3]);
free(flags_str);
free(fflags_str);
@@ -239,10 +239,10 @@ kevent_add(int kqfd, struct kevent *kev,
EV_SET(kev, ident, filter, flags, fflags, data, NULL);
if (kevent(kqfd, kev, 1, NULL, 0, NULL) < 0) {
- kev_str = kevent_to_str(kev);
- printf("Unable to add the following kevent:\n%s\n",
- kev_str);
- free(kev_str);
+ kev_str = kevent_to_str(kev);
+ printf("Unable to add the following kevent:\n%s\n",
+ kev_str);
+ free(kev_str);
err(1, "kevent(): %s", strerror(errno));
}
}
@@ -265,12 +265,12 @@ kevent_cmp(struct kevent *k1, struct kevent *k2)
k1->data != k2->data || k1->udata != k2->udata ||
k1->ext[0] != k2->ext[0] || k1->ext[1] != k2->ext[1] ||
k1->ext[0] != k2->ext[2] || k1->ext[0] != k2->ext[3]) {
- kev1_str = kevent_to_str(k1);
- kev2_str = kevent_to_str(k2);
- printf("kevent_cmp: mismatch:\n %s !=\n %s\n",
- kev1_str, kev2_str);
- free(kev1_str);
- free(kev2_str);
+ kev1_str = kevent_to_str(k1);
+ kev2_str = kevent_to_str(k2);
+ printf("kevent_cmp: mismatch:\n %s !=\n %s\n",
+ kev1_str, kev2_str);
+ free(kev1_str);
+ free(kev2_str);
abort();
}
}
diff --git a/tests/sys/kqueue/libkqueue/proc.c b/tests/sys/kqueue/libkqueue/proc.c
index 4f97eacdc1a0..32735454b8b2 100644
--- a/tests/sys/kqueue/libkqueue/proc.c
+++ b/tests/sys/kqueue/libkqueue/proc.c
@@ -45,7 +45,7 @@ add_and_delete(void)
struct stat s;
if (fstat(kqfd, &s) != -1)
errx(1, "kqueue inherited across fork! (%s() at %s:%d)",
- __func__, __FILE__, __LINE__);
+ __func__, __FILE__, __LINE__);
pause();
exit(2);
diff --git a/tests/sys/kqueue/libkqueue/signal.c b/tests/sys/kqueue/libkqueue/signal.c
index 14e751db95c2..df620f14b841 100644
--- a/tests/sys/kqueue/libkqueue/signal.c
+++ b/tests/sys/kqueue/libkqueue/signal.c
@@ -188,12 +188,12 @@ test_kevent_signal_oneshot(void)
void
test_evfilt_signal()
{
- kqfd = kqueue();
- test_kevent_signal_add();
- test_kevent_signal_del();
- test_kevent_signal_get();
- test_kevent_signal_disable();
- test_kevent_signal_enable();
- test_kevent_signal_oneshot();
- close(kqfd);
+ kqfd = kqueue();
+ test_kevent_signal_add();
+ test_kevent_signal_del();
+ test_kevent_signal_get();
+ test_kevent_signal_disable();
+ test_kevent_signal_enable();
+ test_kevent_signal_oneshot();
+ close(kqfd);
}
diff --git a/tests/sys/kqueue/libkqueue/timer.c b/tests/sys/kqueue/libkqueue/timer.c
index 51e1cdf1ac82..d1d92691c177 100644
--- a/tests/sys/kqueue/libkqueue/timer.c
+++ b/tests/sys/kqueue/libkqueue/timer.c
@@ -34,11 +34,10 @@ int kqfd;
static long
now(void)
{
-
- struct timeval tv;
+ struct timeval tv;
- gettimeofday(&tv, NULL);
- return SEC_TO_US(tv.tv_sec) + tv.tv_usec;
+ gettimeofday(&tv, NULL);
+ return SEC_TO_US(tv.tv_sec) + tv.tv_usec;
}
/* Sleep for a given number of milliseconds. The timeout is assumed to
@@ -47,13 +46,12 @@ now(void)
void
mssleep(int t)
{
+ struct timespec stime = {
+ .tv_sec = 0,
+ .tv_nsec = US_TO_NS(MS_TO_US(t)),
+ };
- struct timespec stime = {
- .tv_sec = 0,
- .tv_nsec = US_TO_NS(MS_TO_US(t)),
- };
-
- nanosleep(&stime, NULL);
+ nanosleep(&stime, NULL);
}
/* Sleep for a given number of microseconds. The timeout is assumed to
@@ -62,13 +60,12 @@ mssleep(int t)
void
ussleep(int t)
{
+ struct timespec stime = {
+ .tv_sec = 0,
+ .tv_nsec = US_TO_NS(t),
+ };
- struct timespec stime = {
- .tv_sec = 0,
- .tv_nsec = US_TO_NS(t),
- };
-
- nanosleep(&stime, NULL);
+ nanosleep(&stime, NULL);
}
void
@@ -241,7 +238,7 @@ test_abstime(void)
kevent_cmp(&kev, kevent_get(kqfd));
stop = time(NULL);
if (stop < start + timeout)
- err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout));
+ err(1, "too early %jd %jd", (intmax_t)stop, (intmax_t)(start + timeout));
/* Check if the event occurs again */
sleep(3);
@@ -264,16 +261,16 @@ test_update(void)
/* First set the timer to 1 second */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, SEC_TO_US(1), (void *)1);
+ NOTE_USECONDS, SEC_TO_US(1), (void *)1);
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Now reduce the timer to 1 ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), (void *)2);
+ NOTE_USECONDS, MS_TO_US(1), (void *)2);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -288,9 +285,9 @@ test_update(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
if (elapsed > SEC_TO_US(1))
- errx(1, "late timer expiration: %ld us", elapsed);
+ errx(1, "late timer expiration: %ld us", elapsed);
success();
}
@@ -309,9 +306,9 @@ test_update_equal(void)
/* First set the timer to 1 ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
+ NOTE_USECONDS, MS_TO_US(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Sleep for a significant fraction of the timeout. */
ussleep(600);
@@ -319,7 +316,7 @@ test_update_equal(void)
/* Now re-add the timer with the same parameters */
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -334,7 +331,7 @@ test_update_equal(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
success();
}
@@ -353,9 +350,9 @@ test_update_expired(void)
/* Set the timer to 1ms */
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
+ NOTE_USECONDS, MS_TO_US(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for 2 ms to give the timer plenty of time to expire. */
mssleep(2);
@@ -363,7 +360,7 @@ test_update_expired(void)
/* Now re-add the timer */
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Wait for the event */
kev.flags |= EV_CLEAR;
@@ -378,7 +375,7 @@ test_update_expired(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
/* Make sure the re-added timer does not fire. In other words,
* test that the event received above was the only event from the
@@ -405,7 +402,7 @@ test_update_periodic(void)
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, SEC_TO_MS(1), NULL);
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Retrieve the event */
kev.flags = EV_ADD | EV_CLEAR;
@@ -420,7 +417,7 @@ test_update_periodic(void)
EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD, 0, SEC_TO_MS(2), NULL);
start = now();
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
/* Retrieve the event */
kev.flags = EV_ADD | EV_CLEAR;
@@ -434,12 +431,12 @@ test_update_periodic(void)
*/
printf("timer expired after %ld us\n", elapsed);
if (elapsed < MS_TO_US(2))
- errx(1, "early timer expiration: %ld us", elapsed);
+ errx(1, "early timer expiration: %ld us", elapsed);
/* Delete the event */
kev.flags = EV_DELETE;
if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
+ err(1, "%s", test_id);
success();
}
@@ -467,46 +464,46 @@ test_update_timing(void)
* received is from the update and not the original timer add.
*/
for (sleeptime = MIN_SLEEP, iteration = 1;
- sleeptime < MAX_SLEEP;
- ++sleeptime, ++iteration) {
-
- /* First set the timer to 1 ms */
- EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
- NOTE_USECONDS, MS_TO_US(1), NULL);
- if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
-
- /* Delay; the delay ranges from less than to greater than the
- * timer period.
- */
- ussleep(sleeptime);
+ sleeptime < MAX_SLEEP;
+ ++sleeptime, ++iteration) {
+
+ /* First set the timer to 1 ms */
+ EV_SET(&kev, vnode_fd, EVFILT_TIMER, EV_ADD | EV_ONESHOT,
+ NOTE_USECONDS, MS_TO_US(1), NULL);
+ if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
+ err(1, "%s", test_id);
+
+ /* Delay; the delay ranges from less than to greater than the
+ * timer period.
+ */
+ ussleep(sleeptime);
- /* Now re-add the timer with the same parameters */
- start = now();
- if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
- err(1, "%s", test_id);
-
- /* Wait for the event */
- kev.flags |= EV_CLEAR;
- kev.fflags &= ~NOTE_USECONDS;
- kev.data = 1;
- kevent_cmp(&kev, kevent_get(kqfd));
- stop = now();
- elapsed = stop - start;
-
- /* Check that the timer expired after at least 1 ms. This
- * check is to make sure that the timer re-started and that
- * the event is not from the original add of the timer.
- */
- if (elapsed < MS_TO_US(1))
- errx(1, "early timer expiration: %ld us", elapsed);
-
- /* Make sure the re-added timer does not fire. In other words,
- * test that the event received above was the only event from
- * the add and re-add of the timer.
- */
- mssleep(2);
- test_no_kevents_quietly();
+ /* Now re-add the timer with the same parameters */
+ start = now();
+ if (kevent(kqfd, &kev, 1, NULL, 0, NULL) < 0)
+ err(1, "%s", test_id);
+
+ /* Wait for the event */
+ kev.flags |= EV_CLEAR;
+ kev.fflags &= ~NOTE_USECONDS;
+ kev.data = 1;
+ kevent_cmp(&kev, kevent_get(kqfd));
+ stop = now();
+ elapsed = stop - start;
+
+ /* Check that the timer expired after at least 1 ms. This
+ * check is to make sure that the timer re-started and that
+ * the event is not from the original add of the timer.
+ */
+ if (elapsed < MS_TO_US(1))
+ errx(1, "early timer expiration: %ld us", elapsed);
+
+ /* Make sure the re-added timer does not fire. In other words,
+ * test that the event received above was the only event from
+ * the add and re-add of the timer.
+ */
+ mssleep(2);
+ test_no_kevents_quietly();
}
success();
@@ -515,18 +512,18 @@ test_update_timing(void)
void
test_evfilt_timer()
{
- kqfd = kqueue();
- test_kevent_timer_add();
- test_kevent_timer_del();
- test_kevent_timer_get();
- test_oneshot();
- test_periodic();
- test_abstime();
- test_update();
- test_update_equal();
- test_update_expired();
- test_update_timing();
- test_update_periodic();
- disable_and_enable();
- close(kqfd);
+ kqfd = kqueue();
+ test_kevent_timer_add();
+ test_kevent_timer_del();
+ test_kevent_timer_get();
+ test_oneshot();
+ test_periodic();
+ test_abstime();
+ test_update();
+ test_update_equal();
+ test_update_expired();
+ test_update_timing();
+ test_update_periodic();
+ disable_and_enable();
+ close(kqfd);
}
diff --git a/tests/sys/kqueue/libkqueue/user.c b/tests/sys/kqueue/libkqueue/user.c
index 9ba25f9df4d3..51ccac672ae6 100644
--- a/tests/sys/kqueue/libkqueue/user.c
+++ b/tests/sys/kqueue/libkqueue/user.c
@@ -117,7 +117,7 @@ oneshot(void)
void
test_evfilt_user()
{
- kqfd = kqueue();
+ kqfd = kqueue();
add_and_delete();
event_wait();
@@ -125,5 +125,5 @@ test_evfilt_user()
oneshot();
/* TODO: try different fflags operations */
- close(kqfd);
+ close(kqfd);
}
diff --git a/tests/sys/kqueue/libkqueue/vnode.c b/tests/sys/kqueue/libkqueue/vnode.c
index 55d5b3f5edc2..418cd2e3d64b 100644
--- a/tests/sys/kqueue/libkqueue/vnode.c
+++ b/tests/sys/kqueue/libkqueue/vnode.c
@@ -251,16 +251,16 @@ test_kevent_vnode_dispatch(void)
void
test_evfilt_vnode()
{
- kqfd = kqueue();
- test_kevent_vnode_add();
- test_kevent_vnode_del();
- test_kevent_vnode_disable_and_enable();
+ kqfd = kqueue();
+ test_kevent_vnode_add();
+ test_kevent_vnode_del();
+ test_kevent_vnode_disable_and_enable();
#if HAVE_EV_DISPATCH
- test_kevent_vnode_dispatch();
+ test_kevent_vnode_dispatch();
#endif
- test_kevent_vnode_note_write();
- test_kevent_vnode_note_attrib();
- test_kevent_vnode_note_rename();
- test_kevent_vnode_note_delete();
- close(kqfd);
+ test_kevent_vnode_note_write();
+ test_kevent_vnode_note_attrib();
+ test_kevent_vnode_note_rename();
+ test_kevent_vnode_note_delete();
+ close(kqfd);
}
diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile
index b9484e0a5c55..3d0f861f0a16 100644
--- a/tests/sys/netpfil/pf/Makefile
+++ b/tests/sys/netpfil/pf/Makefile
@@ -9,6 +9,7 @@ ATF_TESTS_SH+= anchor \
pass_block \
forward \
fragmentation \
+ names \
set_tos \
route_to \
synproxy \
diff --git a/tests/sys/netpfil/pf/names.sh b/tests/sys/netpfil/pf/names.sh
new file mode 100755
index 000000000000..f73a149f8e90
--- /dev/null
+++ b/tests/sys/netpfil/pf/names.sh
@@ -0,0 +1,34 @@
+# $FreeBSD$
+
+. $(atf_get_srcdir)/utils.subr
+
+atf_test_case "names" "cleanup"
+names_head()
+{
+ atf_set descr 'Test overlapping names'
+ atf_set require.user root
+}
+
+names_body()
+{
+ pft_init
+
+ epair=$(pft_mkepair)
+
+ pft_mkjail alcatraz ${epair}b
+ ifconfig ${epair}a name foo
+ jexec alcatraz ifconfig ${epair}b name foo
+
+ jail -r alcatraz
+ ifconfig foo destroy
+}
+
+names_cleanup()
+{
+ pft_cleanup
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case "names"
+}
diff --git a/tests/sys/netpfil/pf/pass_block.sh b/tests/sys/netpfil/pf/pass_block.sh
index d0d1e426378e..d7a41b98f2c6 100755
--- a/tests/sys/netpfil/pf/pass_block.sh
+++ b/tests/sys/netpfil/pf/pass_block.sh
@@ -107,21 +107,21 @@ noalias_body()
| cut -d % -f 1)
# Sanity check
- atf_check -s exit:0 -o ignore ping6 -c 1 -x 1 2001:db8:42::2
- atf_check -s exit:0 -o ignore ping6 -c 1 -x 1 ${linklocaladdr}%${epair}a
+ atf_check -s exit:0 -o ignore ping6 -c 3 -x 1 2001:db8:42::2
+ atf_check -s exit:0 -o ignore ping6 -c 3 -x 1 ${linklocaladdr}%${epair}a
jexec alcatraz pfctl -e
pft_set_rules alcatraz "block out inet6 from (${epair}b:0) to any"
- atf_check -s exit:2 -o ignore ping6 -c 1 -x 1 2001:db8:42::2
+ atf_check -s exit:2 -o ignore ping6 -c 3 -x 1 2001:db8:42::2
# We should still be able to ping the link-local address
- atf_check -s exit:0 -o ignore ping6 -c 1 -x 1 ${linklocaladdr}%${epair}a
+ atf_check -s exit:0 -o ignore ping6 -c 3 -x 1 ${linklocaladdr}%${epair}a
pft_set_rules alcatraz "block out inet6 from (${epair}b) to any"
# We cannot ping to the link-local address
- atf_check -s exit:2 -o ignore ping6 -c 1 -x 1 ${linklocaladdr}%${epair}a
+ atf_check -s exit:2 -o ignore ping6 -c 3 -x 1 ${linklocaladdr}%${epair}a
}
noalias_cleanup()
diff --git a/tests/sys/netpfil/pf/pfsync.sh b/tests/sys/netpfil/pf/pfsync.sh
index c4e453274b67..17b73a0f098b 100755
--- a/tests/sys/netpfil/pf/pfsync.sh
+++ b/tests/sys/netpfil/pf/pfsync.sh
@@ -7,12 +7,16 @@ basic_head()
{
atf_set descr 'Basic pfsync test'
atf_set require.user root
-
- atf_set require.progs scapy
}
basic_body()
{
+ common_body
+}
+
+common_body()
+{
+ defer=$1
pfsynct_init
epair_sync=$(pft_mkepair)
@@ -28,12 +32,14 @@ basic_body()
jexec one ifconfig pfsync0 \
syncdev ${epair_sync}a \
maxupd 1 \
+ $defer \
up
jexec two ifconfig ${epair_two}a 198.51.100.2/24 up
jexec two ifconfig ${epair_sync}b 192.0.2.2/24 up
jexec two ifconfig pfsync0 \
syncdev ${epair_sync}b \
maxupd 1 \
+ $defer \
up
# Enable pf!
@@ -64,7 +70,25 @@ basic_cleanup()
pfsynct_cleanup
}
+atf_test_case "defer" "cleanup"
+defer_head()
+{
+ atf_set descr 'Defer mode pfsync test'
+ atf_set require.user root
+}
+
+defer_body()
+{
+ common_body defer
+}
+
+defer_cleanup()
+{
+ pfsynct_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "basic"
+ atf_add_test_case "defer"
}