summaryrefslogtreecommitdiffstats
path: root/scripts/common.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/common.sh.in')
-rw-r--r--scripts/common.sh.in69
1 files changed, 67 insertions, 2 deletions
diff --git a/scripts/common.sh.in b/scripts/common.sh.in
index 00418696c..0a8399f18 100644
--- a/scripts/common.sh.in
+++ b/scripts/common.sh.in
@@ -26,6 +26,8 @@ RAID0S=()
RAID10S=()
RAIDZS=()
RAIDZ2S=()
+TESTS_RUN=${TESTS_RUN:-'*'}
+TESTS_SKIP=${TESTS_SKIP:-}
prefix=@prefix@
exec_prefix=@exec_prefix@
@@ -58,6 +60,24 @@ SYSCTL=${SYSCTL:-/sbin/sysctl}
UDEVADM=${UDEVADM:-/sbin/udevadm}
AWK=${AWK:-/usr/bin/awk}
+COLOR_BLACK="\033[0;30m"
+COLOR_DK_GRAY="\033[1;30m"
+COLOR_BLUE="\033[0;34m"
+COLOR_LT_BLUE="\033[1;34m"
+COLOR_GREEN="\033[0;32m"
+COLOR_LT_GREEN="\033[1;32m"
+COLOR_CYAN="\033[0;36m"
+COLOR_LT_CYAN="\033[1;36m"
+COLOR_RED="\033[0;31m"
+COLOR_LT_RED="\033[1;31m"
+COLOR_PURPLE="\033[0;35m"
+COLOR_LT_PURPLE="\033[1;35m"
+COLOR_BROWN="\033[0;33m"
+COLOR_YELLOW="\033[1;33m"
+COLOR_LT_GRAY="\033[0;37m"
+COLOR_WHITE="\033[1;37m"
+COLOR_RESET="\033[0m"
+
die() {
echo -e "${PROG}: $1" >&2
exit 1
@@ -70,14 +90,18 @@ msg() {
}
pass() {
- echo "PASS"
+ echo -e "${COLOR_GREEN}Pass${COLOR_RESET}"
}
fail() {
- echo "FAIL ($1)"
+ echo -e "${COLOR_RED}Fail${COLOR_RESET} ($1)"
exit $1
}
+skip() {
+ echo -e "${COLOR_BROWN}Skip${COLOR_RESET}"
+}
+
spl_dump_log() {
${SYSCTL} -w kernel.spl.debug.dump=1 &>/dev/null
local NAME=`dmesg | tail -n 1 | cut -f5 -d' '`
@@ -371,3 +395,44 @@ udev_raidz2_setup() {
return 0
}
+
+run_one_test() {
+ local TEST_NUM=$1
+ local TEST_NAME=$2
+
+ printf "%-4d %-36s " ${TEST_NUM} "${TEST_NAME}"
+ test_${TEST_NUM}
+}
+
+skip_one_test() {
+ local TEST_NUM=$1
+ local TEST_NAME=$2
+
+ printf "%-4d %-36s " ${TEST_NUM} "${TEST_NAME}"
+ skip
+}
+
+run_test() {
+ local TEST_NUM=$1
+ local TEST_NAME=$2
+
+ for i in ${TESTS_SKIP[@]}; do
+ if [[ $i == ${TEST_NUM} ]] ; then
+ skip_one_test ${TEST_NUM} "${TEST_NAME}"
+ return 0
+ fi
+ done
+
+ if [ "${TESTS_RUN[0]}" = "*" ]; then
+ run_one_test ${TEST_NUM} "${TEST_NAME}"
+ else
+ for i in ${TESTS_RUN[@]}; do
+ if [[ $i == ${TEST_NUM} ]] ; then
+ run_one_test ${TEST_NUM} "${TEST_NAME}"
+ return 0
+ fi
+ done
+
+ skip_one_test ${TEST_NUM} "${TEST_NAME}"
+ fi
+}