Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.sbin/opensnoop Check that DTrace's execsnoop and o...



details:   https://anonhg.NetBSD.org/src/rev/d98a117c36ee
branches:  trunk
changeset: 935333:d98a117c36ee
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Tue Jun 30 14:30:49 2020 +0000

description:
Check that DTrace's execsnoop and opensnoop work (cf. PR kern/53417).

diffstat:

 distrib/sets/lists/tests/mi             |  10 ++++-
 etc/mtree/NetBSD.dist.tests             |   4 +-
 tests/usr.sbin/Makefile                 |  12 ++++-
 tests/usr.sbin/execsnoop/Makefile       |   8 +++
 tests/usr.sbin/execsnoop/t_execsnoop.sh |  69 +++++++++++++++++++++++++++++++++
 tests/usr.sbin/opensnoop/Makefile       |   8 +++
 tests/usr.sbin/opensnoop/t_opensnoop.sh |  69 +++++++++++++++++++++++++++++++++
 7 files changed, 176 insertions(+), 4 deletions(-)

diffs (242 lines):

diff -r 95812fcf5fee -r d98a117c36ee distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Tue Jun 30 13:14:21 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Tue Jun 30 14:30:49 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.864 2020/06/30 11:48:20 jruoho Exp $
+# $NetBSD: mi,v 1.865 2020/06/30 14:30:49 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4788,6 +4788,10 @@
 ./usr/tests/usr.sbin/cpuctl/Atffile            tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/cpuctl/Kyuafile           tests-usr.sbin-tests    compattestfile,atf,kyua
 ./usr/tests/usr.sbin/cpuctl/t_cpuctl           tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/execsnoop                 tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/execsnoop/Atffile         tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/execsnoop/Kyuafile                tests-usr.sbin-tests    compattestfile,atf,kyua
+./usr/tests/usr.sbin/execsnoop/t_execsnoop     tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/mtree                     tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/mtree/Atffile             tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/mtree/Kyuafile            tests-usr.sbin-tests    compattestfile,atf,kyua
@@ -4803,6 +4807,10 @@
 ./usr/tests/usr.sbin/mtree/mtree_d_create.out  tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/mtree/netbsd6_d_create.out        tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/mtree/t_mtree             tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/opensnoop                 tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/opensnoop/Atffile         tests-usr.sbin-tests    compattestfile,atf
+./usr/tests/usr.sbin/opensnoop/Kyuafile                tests-usr.sbin-tests    compattestfile,atf,kyua
+./usr/tests/usr.sbin/opensnoop/t_opensnoop     tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/stdethers                 tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/stdethers/Atffile         tests-usr.sbin-tests    compattestfile,atf
 ./usr/tests/usr.sbin/stdethers/Kyuafile                tests-usr.sbin-tests    compattestfile,atf,kyua
diff -r 95812fcf5fee -r d98a117c36ee etc/mtree/NetBSD.dist.tests
--- a/etc/mtree/NetBSD.dist.tests       Tue Jun 30 13:14:21 2020 +0000
+++ b/etc/mtree/NetBSD.dist.tests       Tue Jun 30 14:30:49 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: NetBSD.dist.tests,v 1.169 2020/06/27 05:20:34 jruoho Exp $
+#      $NetBSD: NetBSD.dist.tests,v 1.170 2020/06/30 14:30:49 jruoho Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -446,7 +446,9 @@
 ./usr/tests/usr.bin/ztest
 ./usr/tests/usr.sbin
 ./usr/tests/usr.sbin/cpuctl
+./usr/tests/usr.sbin/execsnoop
 ./usr/tests/usr.sbin/mtree
+./usr/tests/usr.sbin/opensnoop
 ./usr/tests/usr.sbin/stdethers
 ./usr/tests/usr.sbin/stdhosts
 ./usr/tests/usr.sbin/tcpdump
diff -r 95812fcf5fee -r d98a117c36ee tests/usr.sbin/Makefile
--- a/tests/usr.sbin/Makefile   Tue Jun 30 13:14:21 2020 +0000
+++ b/tests/usr.sbin/Makefile   Tue Jun 30 14:30:49 2020 +0000
@@ -1,8 +1,16 @@
-# $NetBSD: Makefile,v 1.5 2020/06/24 12:31:26 jruoho Exp $
+# $NetBSD: Makefile,v 1.6 2020/06/30 14:30:49 jruoho Exp $
 .include <bsd.own.mk>
 
 TESTSDIR=       ${TESTSBASE}/usr.sbin
 
-TESTS_SUBDIRS+= cpuctl mtree stdethers stdhosts tcpdump traceroute useradd
+TESTS_SUBDIRS+= cpuctl
+TESTS_SUBDIRS+= execsnoop
+TESTS_SUBDIRS+= mtree
+TESTS_SUBDIRS+= opensnoop
+TESTS_SUBDIRS+= stdethers
+TESTS_SUBDIRS+= stdhosts
+TESTS_SUBDIRS+= tcpdump
+TESTS_SUBDIRS+= traceroute
+TESTS_SUBDIRS+= useradd
 
 .include <bsd.test.mk>
diff -r 95812fcf5fee -r d98a117c36ee tests/usr.sbin/execsnoop/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.sbin/execsnoop/Makefile Tue Jun 30 14:30:49 2020 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2020/06/30 14:30:49 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/usr.sbin/execsnoop
+TESTS_SH=      t_execsnoop
+
+.include <bsd.test.mk>
diff -r 95812fcf5fee -r d98a117c36ee tests/usr.sbin/execsnoop/t_execsnoop.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.sbin/execsnoop/t_execsnoop.sh   Tue Jun 30 14:30:49 2020 +0000
@@ -0,0 +1,69 @@
+# $NetBSD: t_execsnoop.sh,v 1.1 2020/06/30 14:30:49 jruoho Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+tmp="/tmp/execsnoop"
+
+atf_test_case basic cleanup
+basic_head() {
+       atf_set "require.user" "root"
+       atf_set "require.progs" "execsnoop"
+       atf_set "descr" "Test that DTrace's execsnoop works (cf. kern/53417)"
+}
+
+basic_body() {
+
+       n=10
+       atf_check -s exit:0 -o ignore -e empty -x "execsnoop > $tmp &"
+       sleep 1
+
+       while [ $n -gt 0 ]; do
+               whoami
+               n=$(expr $n - 1)
+       done
+
+       sleep 1
+       pkill -9 execsnoop
+
+       if [ ! $(cat $tmp | grep "whoami" | wc -l) -eq 10 ]; then
+               atf_fail "execsnoop does not work"
+       fi
+
+       atf_pass
+}
+
+basic_cleanup() {
+
+       if [ -f $tmp ]; then
+               rm $tmp
+       fi
+}
+
+atf_init_test_cases() {
+       atf_add_test_case basic
+}
diff -r 95812fcf5fee -r d98a117c36ee tests/usr.sbin/opensnoop/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.sbin/opensnoop/Makefile Tue Jun 30 14:30:49 2020 +0000
@@ -0,0 +1,8 @@
+# $NetBSD: Makefile,v 1.1 2020/06/30 14:30:50 jruoho Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR=      ${TESTSBASE}/usr.sbin/opensnoop
+TESTS_SH=      t_opensnoop
+
+.include <bsd.test.mk>
diff -r 95812fcf5fee -r d98a117c36ee tests/usr.sbin/opensnoop/t_opensnoop.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.sbin/opensnoop/t_opensnoop.sh   Tue Jun 30 14:30:49 2020 +0000
@@ -0,0 +1,69 @@
+# $NetBSD: t_opensnoop.sh,v 1.1 2020/06/30 14:30:50 jruoho Exp $
+#
+# Copyright (c) 2020 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jukka Ruohonen.
+#
+# 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+#
+tmp="/tmp/opensnoop"
+
+atf_test_case basic cleanup
+basic_head() {
+       atf_set "require.user" "root"
+       atf_set "require.progs" "opensnoop"
+       atf_set "descr" "Test that DTrace's opensnoop works (cf. kern/53417)"
+}
+
+basic_body() {
+
+       n=10
+       atf_check -s exit:0 -o ignore -e empty -x "opensnoop > $tmp &"
+       sleep 1
+
+       while [ $n -gt 0 ]; do
+               whoami
+               n=$(expr $n - 1)
+       done
+
+       sleep 1
+       pkill -9 opensnoop
+
+       if [ ! $(cat $tmp | grep "/etc/spwd.db" | wc -l) -eq 10 ]; then
+               atf_fail "opensnoop does not work"
+       fi
+
+       atf_pass
+}
+
+basic_cleanup() {
+
+       if [ -f $tmp ]; then
+               rm $tmp
+       fi
+}
+
+atf_init_test_cases() {
+       atf_add_test_case basic
+}



Home | Main Index | Thread Index | Old Index