From owner-svn-src-all@freebsd.org Thu Mar 21 22:23:56 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99BA315517FC; Thu, 21 Mar 2019 22:23:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4046183A66; Thu, 21 Mar 2019 22:23:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1A182F658; Thu, 21 Mar 2019 22:23:56 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2LMNuqi048587; Thu, 21 Mar 2019 22:23:56 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2LMNrAT048569; Thu, 21 Mar 2019 22:23:53 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201903212223.x2LMNrAT048569@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Thu, 21 Mar 2019 22:23:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r345394 - in stable/11/tests/sys/geom/class: . eli mirror X-SVN-Group: stable-11 X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in stable/11/tests/sys/geom/class: . eli mirror X-SVN-Commit-Revision: 345394 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4046183A66 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.970,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Mar 2019 22:23:56 -0000 Author: asomers Date: Thu Mar 21 22:23:52 2019 New Revision: 345394 URL: https://svnweb.freebsd.org/changeset/base/345394 Log: MFC r341390, r341392, r341667 r341390: Remove some dead code from the geli tests This is detritus in the Makefile, leftover from 327662. r341392: Unbreak geli/gmirror testcases if their geom classes cannot be loaded The problem with the logic prior to this commit was twofold: 1. The wrong set of idioms (TAP-compatible) were being applied to the ATF testcases when run, resulting in confusing ATF failure results on setup. 2. The cleanup subroutines were broken when the geom classes could not be loaded as they exited with 0 unexpectedly. This commit changes the test code to source the class-specific configuration (conf.sh) once globally, instead of sourcing it per testcase and per cleanup subroutine, and to call the ATF-specific setup subroutine(s) inline in the testcases. The refactoring done is effectively a no-op for the TAP testcases, modulo any refactoring done to create common code between the ATF and TAP testcases. This unbreaks the geli testcases converted to ATF in r327662 and r327683, and the gmirror testcases added in r327780, respectively, when the geom class could not be loaded. tests/sys/geom/class/mirror/... While here, ignore errors when turning debug failpoint sysctl off, which could occur if the gmirror class was not loaded. Submitted by: ngie Pull Request: https://github.com/freebsd/freebsd/pull/241 r341667: geom tests: Fix cleanup of ATF tests since r341392 r341392 changed common test cleanup routines in a way that allowed them to be used by TAP tests as well as ATF tests. However, a late change made during code review resulted in cleanup being broken for ATF tests, which source geom_subr.sh separately during the body and cleanup phases of the test. The result was that md(4) devices wouldn't get cleaned up. X-MFC-With: 341392 Modified: stable/11/tests/sys/geom/class/eli/Makefile stable/11/tests/sys/geom/class/eli/attach_test.sh stable/11/tests/sys/geom/class/eli/conf.sh stable/11/tests/sys/geom/class/eli/configure_test.sh stable/11/tests/sys/geom/class/eli/delkey_test.sh stable/11/tests/sys/geom/class/eli/detach_test.sh stable/11/tests/sys/geom/class/eli/init_test.sh stable/11/tests/sys/geom/class/eli/integrity_test.sh stable/11/tests/sys/geom/class/eli/kill_test.sh stable/11/tests/sys/geom/class/eli/misc_test.sh stable/11/tests/sys/geom/class/eli/onetime_test.sh stable/11/tests/sys/geom/class/eli/resize_test.sh stable/11/tests/sys/geom/class/eli/setkey_test.sh stable/11/tests/sys/geom/class/geom_subr.sh stable/11/tests/sys/geom/class/mirror/sync_error.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/geom/class/eli/Makefile ============================================================================== --- stable/11/tests/sys/geom/class/eli/Makefile Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/Makefile Thu Mar 21 22:23:52 2019 (r345394) @@ -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= \ Modified: stable/11/tests/sys/geom/class/eli/attach_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/attach_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/attach_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/conf.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/conf.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/conf.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 Modified: stable/11/tests/sys/geom/class/eli/configure_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/configure_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/configure_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/delkey_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/delkey_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/delkey_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/detach_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/detach_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/detach_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/init_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/init_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/integrity_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/integrity_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/integrity_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/kill_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/kill_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/kill_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/misc_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/misc_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/misc_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 ] && \ @@ -166,12 +168,5 @@ disk_cleanup() disk=${disks%% *} if [ -n "$disk" ]; then 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 } Modified: stable/11/tests/sys/geom/class/eli/onetime_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/onetime_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/onetime_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/eli/resize_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/resize_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/resize_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 ] && \ Modified: stable/11/tests/sys/geom/class/eli/setkey_test.sh ============================================================================== --- stable/11/tests/sys/geom/class/eli/setkey_test.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/eli/setkey_test.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 } Modified: stable/11/tests/sys/geom/class/geom_subr.sh ============================================================================== --- stable/11/tests/sys/geom/class/geom_subr.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/geom_subr.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 "1..0 # SKIP could not load module for geom class=${class}" + # 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 +} + +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 Modified: stable/11/tests/sys/geom/class/mirror/sync_error.sh ============================================================================== --- stable/11/tests/sys/geom/class/mirror/sync_error.sh Thu Mar 21 22:18:22 2019 (r345393) +++ stable/11/tests/sys/geom/class/mirror/sync_error.sh Thu Mar 21 22:23:52 2019 (r345394) @@ -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 }