summaryrefslogtreecommitdiffstats
path: root/debian/tests/assert.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:35:19 +0000
commitb7e8d5af06ee840cc48217ca4629cf28aeeb3c50 (patch)
tree6aa8dc840b085de50db46e2ad0725eae248fef02 /debian/tests/assert.sh
parentAdding upstream version 252.22. (diff)
downloadsystemd-debian.tar.xz
systemd-debian.zip
Adding debian version 252.22-1~deb12u1.debian/252.22-1_deb12u1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/assert.sh')
-rw-r--r--debian/tests/assert.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/debian/tests/assert.sh b/debian/tests/assert.sh
new file mode 100644
index 0000000..1d47bf4
--- /dev/null
+++ b/debian/tests/assert.sh
@@ -0,0 +1,34 @@
+# utility functions for shell tests
+
+assert_true() {
+ if ! $1; then
+ echo "FAIL: command '$1' failed with exit code $?" >&2
+ exit 1
+ fi
+}
+
+
+assert_eq() {
+ if [ "$1" != "$2" ]; then
+ echo "FAIL: expected: '$2' actual: '$1'" >&2
+ exit 1
+ fi
+}
+
+assert_in() {
+ if ! echo "$2" | grep -q "$1"; then
+ echo "FAIL: '$1' not found in:" >&2
+ echo "$2" >&2
+ exit 1
+ fi
+}
+
+assert_rc() {
+ local exp=$1
+ shift
+ set +e
+ $@
+ RC=$?
+ set -e
+ assert_eq $RC $exp
+}