svn commit: r292356 - in projects/zfsd/head/tests/sys/cddl/zfs: bin include

Alan Somers asomers at FreeBSD.org
Wed Dec 16 19:55:55 UTC 2015


Author: asomers
Date: Wed Dec 16 19:55:53 2015
New Revision: 292356
URL: https://svnweb.freebsd.org/changeset/base/292356

Log:
  Add a testenv wrapper script for the ZFS test suite.  This makes it easier
  to test changes to the test suite's common libraries by creating a ksh93
  subshell to run ksh93 functions in.
  
  tests/sys/cddl/zfs/include/constants.cfg:
  tests/sys/cddl/zfs/include/default.cfg.in:
  	- Split default.cfg.in so that general constants live in constants.cfg.
  
  tests/sys/cddl/zfs/include/testenv.kshlib:
  	- Generate the environment-dependent constants ($DISKS and $KEEP),
  	  and pull in constants.cfg for the rest.
  
  tests/sys/cddl/zfs/bin/testenv.ksh:
  	- The script.  Detects the current path and generates $STF_SUITE.
  	  Once done, invokes ksh93, reading in include/testenv.kshlib.
  
  tests/sys/cddl/zfs/bin/Makefile:
  tests/sys/cddl/zfs/include/Makefile:
  	- Add the new files.
  
  Submitted by:	Will
  Sponsored by:	Spectra Logic Corp

Added:
  projects/zfsd/head/tests/sys/cddl/zfs/bin/testenv.ksh
  projects/zfsd/head/tests/sys/cddl/zfs/include/constants.cfg
  projects/zfsd/head/tests/sys/cddl/zfs/include/testenv.ksh
Modified:
  projects/zfsd/head/tests/sys/cddl/zfs/bin/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile
  projects/zfsd/head/tests/sys/cddl/zfs/include/default.cfg.in

Modified: projects/zfsd/head/tests/sys/cddl/zfs/bin/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/bin/Makefile	Wed Dec 16 19:48:03 2015	(r292355)
+++ projects/zfsd/head/tests/sys/cddl/zfs/bin/Makefile	Wed Dec 16 19:55:53 2015	(r292356)
@@ -21,6 +21,7 @@ SCRIPTS+=	groupmod.ksh
 SCRIPTS+=	groupshow.ksh
 SCRIPTS+=	svcs.ksh
 SCRIPTS+=	swap.ksh
+SCRIPTS+=	testenv.ksh
 SCRIPTS+=	useradd.ksh
 SCRIPTS+=	userdel.ksh
 SCRIPTS+=	usermod.ksh

Added: projects/zfsd/head/tests/sys/cddl/zfs/bin/testenv.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/bin/testenv.ksh	Wed Dec 16 19:55:53 2015	(r292356)
@@ -0,0 +1,6 @@
+#!/usr/bin/env ksh93
+script=$(realpath $0)
+export STF_BIN=$(dirname ${script})
+export STF_SUITE=$(dirname ${STF_BIN})
+
+env ENV=${STF_SUITE}/include/testenv.kshlib ksh93 -E -l

Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile	Wed Dec 16 19:48:03 2015	(r292355)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/Makefile	Wed Dec 16 19:55:53 2015	(r292356)
@@ -6,11 +6,13 @@ STFSUITEDIR=${TESTSBASE}/sys/cddl/zfs
 
 MAN=
 FILESDIR=	${TESTSBASE}/sys/cddl/zfs/include
+FILES+=		constants.cfg
 FILES+=		libremote.kshlib
 FILES+=		libsas.kshlib
 FILES+=		logapi.kshlib
 FILES+=		libtest.kshlib
 FILES+=		stf.shlib
+FILES+=		testenv.kshlib
 
 FILES+=		commands.cfg
 CLEANFILES+=	commands.cfg

Added: projects/zfsd/head/tests/sys/cddl/zfs/include/constants.cfg
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/constants.cfg	Wed Dec 16 19:55:53 2015	(r292356)
@@ -0,0 +1,110 @@
+#!/usr/bin/env ksh93
+
+# Add test-specific binaries to PATH
+export PATH=${STF_SUITE}/bin:${PATH}
+export TMPDIR=${TMPDIR-/tmp}
+
+# Set default value of TMPDIR
+export TMPDIR=${TMPDIR-/tmp}
+
+# Define run length constants
+export RT_LONG="3"
+export RT_MEDIUM="2"
+export RT_SHORT="1"
+
+# Define macro for zone test
+export ZONE_POOL="zonepool"
+export ZONE_CTR="zonectr"
+
+# Test Suite Specific Commands
+export DEVNAME2DEVID="devname2devid"
+export FILE_WRITE="file_write"
+export FILE_CHECK="file_check"
+export LARGEST_FILE="largest_file"
+export MMAPWRITE="mmapwrite"
+export READMMAP="readmmap"
+export FILE_TRUNC="file_trunc"
+export CHG_USR_EXEC="chg_usr_exec"
+export MKTREE="mktree"
+export RANDFREE_FILE="randfree_file"
+export DIR_RD_UPDATE="dir_rd_update"
+export RM_LNKCNT_ZERO_FILE="rm_lnkcnt_zero_file"
+export RENAME_DIR="rename_dir"
+
+# ensure we're running in the C locale, since
+# localised messages may result in test failures
+export LC_ALL="C"
+export LANG="C"
+
+#
+# pattern to ignore from 'zpool list'. 
+#
+export NO_POOLS="no pools available"
+
+# pattern to ignore from 'zfs list'.
+export NO_DATASETS="no datasets available"
+
+export TEST_BASE_DIR="/"
+
+# Default to compression ON
+export COMPRESSION_PROP=on
+
+# Default to using the checksum
+export CHECKSUM_PROP=on
+
+# some common variables used by test scripts :
+
+export TESTCASE_ID=${TESTCASE_ID:-$$}
+# some test pool names
+export TESTPOOL=testpool.${TESTCASE_ID}
+export TESTPOOL1=testpool1.${TESTCASE_ID}
+export TESTPOOL2=testpool2.${TESTCASE_ID}
+export TESTPOOL3=testpool3.${TESTCASE_ID}
+
+# some test file system names
+export TESTCTR=testctr${TESTCASE_ID}
+export TESTFS=testfs.${TESTCASE_ID}
+export TESTFS1=testfs1.${TESTCASE_ID}
+export TESTFS2=testfs2.${TESTCASE_ID}
+export TESTFS3=testfs3.${TESTCASE_ID}
+
+# some test directory names
+export TESTDIR=${TEST_BASE_DIR%%/}/testdir${TESTCASE_ID}
+export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0${TESTCASE_ID}
+export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1${TESTCASE_ID}
+export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2${TESTCASE_ID}
+
+# Default to limit disks to be checked
+export MAX_FINDDISKSNUM=100
+
+# For iscsi target support
+export ISCSITGTFILE=$TMPDIR/iscsitgt_file
+export ISCSITGT_FMRI=svc:/system/iscsitgt:default
+
+if [ -n "$SVCS" ]; then
+    export AUTO_SNAP=$($SVCS -a | $GREP auto-snapshot | $GREP online | $AWK '{print $3}')
+fi
+
+# zfs upgrade should output the first line as:
+# This system is currently running ZFS filesystem version 2.
+# .
+
+ZFS_VERSION=
+$ZFS upgrade -v > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	export ZFS_VERSION=$($ZFS upgrade | $HEAD -1 | $AWK '{print $NF}' \
+		| $SED -e 's/\.//g')
+fi
+
+if [ -n "$ZFS_VERSION" ]; then
+	i=1
+	ZFS_ALL_VERSIONS=""
+	while [ "$i" -le "$ZFS_VERSION" ]; do
+		eval 'export ZFS_VERSION_$i="v${i}-fs"'
+		ZFS_ALL_VERSIONS="$ZFS_ALL_VERSIONS $i"
+		i=$(( i + 1 ))
+	done
+	export ZFS_ALL_VERSIONS
+fi
+
+$TRUE

Modified: projects/zfsd/head/tests/sys/cddl/zfs/include/default.cfg.in
==============================================================================
--- projects/zfsd/head/tests/sys/cddl/zfs/include/default.cfg.in	Wed Dec 16 19:48:03 2015	(r292355)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/default.cfg.in	Wed Dec 16 19:55:53 2015	(r292356)
@@ -35,121 +35,14 @@ export STF_SUITE=%%STFSUITEDIR%%
 # source the autogenerated commands.cfg file (built from the commands.txt file
 . $STF_SUITE/include/commands.cfg
 
-# Add test-specific binaries to PATH
-export PATH=$STF_SUITE/bin:$PATH
-
 # Turn ATF variables into environment variables
 export DISKS=`atf_config_get disks ""`
 export KEEP=`atf_config_get keep_pools "" | ${SED} -E 's/ +/|/g'`
 
-# Set default value of TMPDIR
-export TMPDIR=${TMPDIR-/tmp}
-
-# Define run length constants
-export RT_LONG="3"
-export RT_MEDIUM="2"
-export RT_SHORT="1"
-
-# Define macro for zone test
-export ZONE_POOL="zonepool"
-export ZONE_CTR="zonectr"
-
-# Test Suite Specific Commands
-export DEVNAME2DEVID="devname2devid"
-export FILE_WRITE="file_write"
-export FILE_CHECK="file_check"
-export LARGEST_FILE="largest_file"
-export MMAPWRITE="mmapwrite"
-export READMMAP="readmmap"
-export FILE_TRUNC="file_trunc"
-export CHG_USR_EXEC="chg_usr_exec"
-export MKTREE="mktree"
-export RANDFREE_FILE="randfree_file"
-export DIR_RD_UPDATE="dir_rd_update"
-export RM_LNKCNT_ZERO_FILE="rm_lnkcnt_zero_file"
-export RENAME_DIR="rename_dir"
-
-# ensure we're running in the C locale, since
-# localised messages may result in test failures
-export LC_ALL="C"
-export LANG="C"
-
-#
-# pattern to ignore from 'zpool list'. 
-#
-export NO_POOLS="no pools available"
-
-# pattern to ignore from 'zfs list'.
-export NO_DATASETS="no datasets available"
-
-export TEST_BASE_DIR="/"
-
-# Default to compression ON
-export COMPRESSION_PROP=on
-
-# Default to using the checksum
-export CHECKSUM_PROP=on
-
-# some common variables used by test scripts :
-
-export TESTCASE_ID=${TESTCASE_ID:-$$}
-# some test pool names
-export TESTPOOL=testpool.${TESTCASE_ID}
-export TESTPOOL1=testpool1.${TESTCASE_ID}
-export TESTPOOL2=testpool2.${TESTCASE_ID}
-export TESTPOOL3=testpool3.${TESTCASE_ID}
+. $STF_SUITE/include/constants.cfg
 
-# some test file system names
-export TESTCTR=testctr${TESTCASE_ID}
-export TESTFS=testfs.${TESTCASE_ID}
-export TESTFS1=testfs1.${TESTCASE_ID}
-export TESTFS2=testfs2.${TESTCASE_ID}
-export TESTFS3=testfs3.${TESTCASE_ID}
-
-# some test directory names
-export TESTDIR=${TEST_BASE_DIR%%/}/testdir${TESTCASE_ID}
-export TESTDIR0=${TEST_BASE_DIR%%/}/testdir0${TESTCASE_ID}
-export TESTDIR1=${TEST_BASE_DIR%%/}/testdir1${TESTCASE_ID}
-export TESTDIR2=${TEST_BASE_DIR%%/}/testdir2${TESTCASE_ID}
-
-# Default to limit disks to be checked
-export MAX_FINDDISKSNUM=100
-
-# For iscsi target support
-export ISCSITGTFILE=$TMPDIR/iscsitgt_file
-export ISCSITGT_FMRI=svc:/system/iscsitgt:default
-
-if [ -n "$SVCS" ]; then
-    export AUTO_SNAP=$($SVCS -a | $GREP auto-snapshot | $GREP online | $AWK '{print $3}')
-fi
-
-#
 # finally, if we're running in a local zone
 # we take some additional actions
 if ! is_global_zone; then
 	reexport_pool
 fi
-
-# zfs upgrade should output the first line as:
-# This system is currently running ZFS filesystem version 2.
-# .
-
-ZFS_VERSION=
-$ZFS upgrade -v > /dev/null 2>&1
-if [ $? -eq 0 ]; then
-	export ZFS_VERSION=$($ZFS upgrade | $HEAD -1 | $AWK '{print $NF}' \
-		| $SED -e 's/\.//g')
-fi
-
-if [ -n "$ZFS_VERSION" ]; then
-	i=1
-	ZFS_ALL_VERSIONS=""
-	while [ "$i" -le "$ZFS_VERSION" ]; do
-		eval 'export ZFS_VERSION_$i="v${i}-fs"'
-		ZFS_ALL_VERSIONS="$ZFS_ALL_VERSIONS $i"
-		i=$(( i + 1 ))
-	done
-	export ZFS_ALL_VERSIONS
-fi
-
-$TRUE

Added: projects/zfsd/head/tests/sys/cddl/zfs/include/testenv.ksh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/zfsd/head/tests/sys/cddl/zfs/include/testenv.ksh	Wed Dec 16 19:55:53 2015	(r292356)
@@ -0,0 +1,19 @@
+. ${STF_SUITE}/include/libtest.kshlib
+. ${STF_SUITE}/include/commands.cfg
+
+# Environment-dependent constants.
+for d in `geom disk list | awk '/Name:/ {print $3}'`; do
+	# Clear the GPT label first to avoid spurious create failures.
+	gpart destroy -F $d >/dev/null 2>&1
+	if gpart create -s gpt $d >/dev/null 2>&1 ; then
+		gpart destroy $d >/dev/null 2>&1 || continue
+		DISKS=("${DISKS[@]}" "/dev/$d") #"$DISKS $d"
+	fi
+	# Don't bother testing any more if we have enough already.
+	# Currently we use at most 5 disks plus 1 for temporary disks.
+	[ ${#DISKS[@]} -eq 6 ] && break
+done
+export KEEP="$(zpool list -H -o name)"
+
+# Pull in constants.
+. ${STF_SUITE}/include/constants.cfg


More information about the svn-src-projects mailing list