summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@mnx.io>2022-10-10 11:24:29 -0400
committerDan McDonald <danmcd@mnx.io>2022-10-10 11:36:51 -0400
commitd804ec5b59613dd1347cf8165bbe507d0b02bf95 (patch)
tree154cb2ea5be25c12d70ad22308ee4b6ef3e697d0
parent817bd35d41ab7cefcdb55b2b34b353c7d2749441 (diff)
downloadillumos-joyent-d804ec5b59613dd1347cf8165bbe507d0b02bf95.tar.gz
OS-8415 smartos-test execution should run ZFS test suite if DISKS and KEEP are set
-rwxr-xr-xusr/src/test/smartos-test/smartos-test.sh36
1 files changed, 35 insertions, 1 deletions
diff --git a/usr/src/test/smartos-test/smartos-test.sh b/usr/src/test/smartos-test/smartos-test.sh
index 8bb28887a6..740b75c169 100755
--- a/usr/src/test/smartos-test/smartos-test.sh
+++ b/usr/src/test/smartos-test/smartos-test.sh
@@ -263,10 +263,12 @@ export KEEP
EOF
if [[ -n "$DISKS" ]]; then
+ # NOTE: This will be enough to make this script's execute-tests
+ # invocation run the ZFS test suite.
echo "DISKS=\"$DISKS\"" >> $zprofile
echo "export DISKS" >> $zprofile
else
- msg="echo Please set \$DISKS appropriate before running zfstest"
+ msg='echo Please set \$DISKS appropriate before running zfstest'
echo $msg >> $zprofile
fi
@@ -279,6 +281,37 @@ EOF
fi
}
+function zfs_test_check {
+ # DISKS is set either in our environment, or in the .profile of ~ztest.
+ zprofile=/zones/global/ztest/.profile
+ zdisksvar=$(su - ztest -c 'echo $DISKS')
+
+ # Check for KEEP too.
+ grep -q ^KEEP= $zprofile || \
+ fatal "Cannot run ZFS test, you need KEEP set in your ztest's environment"
+
+ # If neither are set DO NOT RUN the ztests.
+ if [[ -z $DISKS && -z $zdisksvar ]]; then
+ fatal "Cannot run ZFS test, you need DISKS set in your or ztest's environment"
+ fi
+
+ # Check if they are both non-zero and different.
+ if [[ -n "$DISKS" && -n "$zdisksvar" && "$DISKS" != "$zdisksvar" ]]; then
+ log "DISKS in current root environment: $DISKS"
+ log "DISKS in user ztest's environment: $zdisksvar"
+ fatal "Pleast reconcile these two before running the ZFS tests."
+ fi
+
+ if [[ -z "$zdisksvar" ]]; then
+ # put DISKS into ztest's .profile.
+ echo "DISKS=\"$DISKS\"" >> $zprofile
+ echo "export DISKS" >> $zprofile
+ fi
+
+ # OKAY, now we can run it!
+ log_test zfstest su - ztest -c /opt/zfs-test/bin/zfstest
+}
+
#
# By using log_test or log_testrunner, we accumulate the exit codes from each
# test run to $RESULT.
@@ -296,6 +329,7 @@ function execute_tests {
log_test vndtest /opt/vndtest/bin/vndtest -a
log_testrunner util-tests /opt/util-tests/runfiles/default.run
log_testrunner os-tests /opt/os-tests/runfiles/default.run
+ zfs_test_check
if [[ -n "$FAILED_TESTS" ]]; then
echo ""