summaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r--tests/zfs-tests/include/libtest.shlib32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index 8918dd885..464b59d3f 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -3109,6 +3109,21 @@ function wait_scrubbed
return 1
}
+# Backup the zed.rc in our test directory so that we can edit it for our test.
+#
+# Returns: Backup file name. You will need to pass this to zed_rc_restore().
+function zed_rc_backup
+{
+ zedrc_backup="$(mktemp)"
+ cp $ZEDLET_DIR/zed.rc $zedrc_backup
+ echo $zedrc_backup
+}
+
+function zed_rc_restore
+{
+ mv $1 $ZEDLET_DIR/zed.rc
+}
+
#
# Setup custom environment for the ZED.
#
@@ -3247,6 +3262,23 @@ function zed_events_drain
done
}
+# Set a variable in zed.rc to something, un-commenting it in the process.
+#
+# $1 variable
+# $2 value
+function zed_rc_set
+{
+ var="$1"
+ val="$2"
+ # Remove the line
+ cmd="'/$var/d'"
+ eval sed -i $cmd $ZEDLET_DIR/zed.rc
+
+ # Add it at the end
+ echo "$var=$val" >> $ZEDLET_DIR/zed.rc
+}
+
+
#
# Check is provided device is being active used as a swap device.
#