Module Name:    src
Committed By:   riastradh
Date:           Thu Jan 25 00:30:58 UTC 2024

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/etc/mtree: NetBSD.dist.tests
        src/tests/usr.bin: Makefile
Added Files:
        src/tests/usr.bin/mtree: Makefile t_sets.sh

Log Message:
mtree(8): Test the installed sets.

Except etc and xetc, which likely won't match for reasons that aren't
great, like etc including empty log files which in an installed
system have probably changed.

This test will probably fail, but we should make sure it doesn't!

PR misc/57877


To generate a diff of this commit:
cvs rdiff -u -r1.1299 -r1.1300 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.201 -r1.202 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/mtree/Makefile \
    src/tests/usr.bin/mtree/t_sets.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1299 src/distrib/sets/lists/tests/mi:1.1300
--- src/distrib/sets/lists/tests/mi:1.1299	Tue Jan 23 22:07:23 2024
+++ src/distrib/sets/lists/tests/mi	Thu Jan 25 00:30:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1299 2024/01/23 22:07:23 rillig Exp $
+# $NetBSD: mi,v 1.1300 2024/01/25 00:30:57 riastradh Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6378,6 +6378,7 @@
 ./usr/tests/usr.bin/mkdep/h_findcc			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/mkdep/t_findcc			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/mkdep/t_mkdep			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/mtree/t_sets			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/nbperf				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/nbperf/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/nbperf/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.201 src/etc/mtree/NetBSD.dist.tests:1.202
--- src/etc/mtree/NetBSD.dist.tests:1.201	Sat Aug 26 10:06:16 2023
+++ src/etc/mtree/NetBSD.dist.tests	Thu Jan 25 00:30:57 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.201 2023/08/26 10:06:16 rillig Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.202 2024/01/25 00:30:57 riastradh Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -462,6 +462,7 @@
 ./usr/tests/usr.bin/make/unit-tests
 ./usr/tests/usr.bin/mixerctl
 ./usr/tests/usr.bin/mkdep
+./usr/tests/usr.bin/mtree
 ./usr/tests/usr.bin/nbperf
 ./usr/tests/usr.bin/netpgpverify
 ./usr/tests/usr.bin/patch

Index: src/tests/usr.bin/Makefile
diff -u src/tests/usr.bin/Makefile:1.38 src/tests/usr.bin/Makefile:1.39
--- src/tests/usr.bin/Makefile:1.38	Sat Aug 26 10:06:16 2023
+++ src/tests/usr.bin/Makefile	Thu Jan 25 00:30:57 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.38 2023/08/26 10:06:16 rillig Exp $
+#	$NetBSD: Makefile,v 1.39 2024/01/25 00:30:57 riastradh Exp $
 #
 
 .include <bsd.own.mk>
@@ -7,7 +7,7 @@ TESTSDIR=       ${TESTSBASE}/usr.bin
 
 TESTS_SUBDIRS=	awk basename bzip2 cc cmp compress config cpio col cut \
 		diff dirname error find fstat gdb grep gzip id indent \
-		infocmp jot ld locale m4 make mixerctl mkdep nbperf \
+		infocmp jot ld locale m4 make mixerctl mkdep mtree nbperf \
 		netpgpverify patch pkill pr printf pwhash realpath rump_server \
 		shmif_dumpbus sdiff sed sort tar tmux tr unifdef uniq \
 		vmstat xlint ztest

Added files:

Index: src/tests/usr.bin/mtree/Makefile
diff -u /dev/null src/tests/usr.bin/mtree/Makefile:1.1
--- /dev/null	Thu Jan 25 00:30:58 2024
+++ src/tests/usr.bin/mtree/Makefile	Thu Jan 25 00:30:57 2024
@@ -0,0 +1,8 @@
+#	$NetBSD: Makefile,v 1.1 2024/01/25 00:30:57 riastradh Exp $
+#
+
+TESTSDIR=	${TESTSBASE}/usr.bin/mtree
+
+TESTS_SH+=	t_sets
+
+.include <bsd.test.mk>
Index: src/tests/usr.bin/mtree/t_sets.sh
diff -u /dev/null src/tests/usr.bin/mtree/t_sets.sh:1.1
--- /dev/null	Thu Jan 25 00:30:58 2024
+++ src/tests/usr.bin/mtree/t_sets.sh	Thu Jan 25 00:30:57 2024
@@ -0,0 +1,92 @@
+#	$NetBSD: t_sets.sh,v 1.1 2024/01/25 00:30:57 riastradh Exp $
+#
+# Copyright (c) 2024 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+check_mtree()
+{
+	local set=$1
+
+	echo check_mtree >&2
+
+	cd /
+	atf_check -o empty -s eq:0 \
+		mtree -e </etc/mtree/set."$set"
+}
+
+set_case()
+{
+	local set=$1
+
+	eval "set_${set}_head() { atf_set descr \"/etc/mtree/set.${set}\"; }"
+	eval "set_${set}_body() { check_mtree ${set}; }"
+}
+
+set_case base
+set_case comp
+set_case debug
+set_case dtb
+#set_case etc
+set_case games
+set_case gpufw
+set_case man
+set_case misc
+set_case modules
+set_case rescue
+set_case tests
+set_case text
+set_case xbase
+set_case xcomp
+set_case xdebug
+#set_case xetc
+set_case xfont
+set_case xserver
+
+atf_init_test_cases()
+{
+
+	# base is always installed -- hard-code this in case we make a
+	# mistake with the automatic set detection.
+	atf_add_test_case set_base
+
+	# Test all of the sets that are installed, except for some
+	# special cases.
+	for mtree in /etc/mtree/set.*; do
+		set=${mtree#/etc/mtree/set.}
+		case $set in
+		base)	# Handled above already.
+			continue
+			;;
+		etc|xetc)
+			# etc and xetc have files that may be modified
+			# on installation, and also contain log files,
+			# so let's skip them for now.
+			continue
+			;;
+		*)	;;
+		esac
+		atf_add_test_case set_"${set}"
+	done
+}

Reply via email to