aboutsummaryrefslogtreecommitdiff
path: root/contrib/atf/atf-sh/libatf-sh.subr
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-02-04 14:48:10 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-02-04 15:03:05 +0000
commitc203bd70b5957f85616424b6fa374479372d06e3 (patch)
tree5a810500e4cf44b327516db0553157bd3ea1f0a6 /contrib/atf/atf-sh/libatf-sh.subr
parentcb7cc72c546e0f87598961c3860e17391f42866c (diff)
parenta3330ae736606c1812b9e9c4b9dcfdfb1a150dde (diff)
downloadsrc-c203bd70b5957f85616424b6fa374479372d06e3.tar.gz
src-c203bd70b5957f85616424b6fa374479372d06e3.zip
Import atf 0.22 snapshot ca73d08c3fc1ecffc1f1c97458c31ab82c12bb01
This includes improvements to the atf-sh helper functions that significantly reduce the number of spawned processes for each test and therefore speeds up running the testsuite noticeably.
Diffstat (limited to 'contrib/atf/atf-sh/libatf-sh.subr')
-rw-r--r--contrib/atf/atf-sh/libatf-sh.subr32
1 files changed, 30 insertions, 2 deletions
diff --git a/contrib/atf/atf-sh/libatf-sh.subr b/contrib/atf/atf-sh/libatf-sh.subr
index a078975400af..a2478b6a9be1 100644
--- a/contrib/atf/atf-sh/libatf-sh.subr
+++ b/contrib/atf/atf-sh/libatf-sh.subr
@@ -101,6 +101,23 @@ atf_check_equal()
}
#
+# atf_check_not_equal expected_expression actual_expression
+#
+# Checks that expected_expression's value does not match actual_expression's
+# and, if it does, raises an error. Ideally expected_expression and
+# actual_expression should be provided quoted (not expanded) so that
+# the error message is helpful; otherwise it will only show the values,
+# not the expressions themselves.
+#
+atf_check_not_equal()
+{
+ eval _val1=\"${1}\"
+ eval _val2=\"${2}\"
+ test "${_val1}" != "${_val2}" || \
+ atf_fail "${1} == ${2} (${_val1} == ${_val2})"
+}
+
+#
# atf_config_get varname [defvalue]
#
# Prints the value of a configuration variable. If it is not
@@ -536,7 +553,18 @@ _atf_list_tcs()
#
_atf_normalize()
{
- echo ${1} | tr .- __
+ # Check if the string contains any of the forbidden characters using
+ # POSIX parameter expansion (the ${var//} string substitution is
+ # unfortunately not supported in POSIX sh) and only use tr(1) then.
+ # tr(1) is generally not a builtin, so doing the substring check first
+ # avoids unnecessary fork()+execve() calls. As this function is called
+ # many times in each test script startup, those overheads add up
+ # (especially when running on emulated platforms such as QEMU).
+ if [ "${1#*[.-]}" != "$1" ]; then
+ echo "$1" | tr .- __
+ else
+ echo "$1"
+ fi
}
#
@@ -734,7 +762,7 @@ main()
;;
esac
done
- shift `expr ${OPTIND} - 1`
+ shift $((OPTIND - 1))
case ${Source_Dir} in
/*)