summaryrefslogtreecommitdiffstats
path: root/tests/deckard/contrib/libfaketime/test/testframe.inc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:55:53 +0000
commit3d0386f27ca66379acf50199e1d1298386eeeeb8 (patch)
treef87bd4a126b3a843858eb447e8fd5893c3ee3882 /tests/deckard/contrib/libfaketime/test/testframe.inc
parentInitial commit. (diff)
downloadknot-resolver-upstream.tar.xz
knot-resolver-upstream.zip
Adding upstream version 3.2.1.upstream/3.2.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/deckard/contrib/libfaketime/test/testframe.inc55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/deckard/contrib/libfaketime/test/testframe.inc b/tests/deckard/contrib/libfaketime/test/testframe.inc
new file mode 100644
index 0000000..b5f66a3
--- /dev/null
+++ b/tests/deckard/contrib/libfaketime/test/testframe.inc
@@ -0,0 +1,55 @@
+# framework common functions for use in test suites and test cases
+
+#
+# run a test and keep stats on success/failure.
+# arguments: a command, possibly a shell function.
+# return value: 0 on success, 1 on failure.
+# side effects: increments global var NSUCC on success, NFAIL on failure.
+#
+run_testcase()
+{
+ if "$@"; then
+ ((NSUCC++))
+ return 0
+ else
+ ((NFAIL++))
+ return 1
+ fi
+}
+
+#
+# verbosely check that the test output matches the expected value.
+# arguments: the test output, the expected value, and a description.
+# return value: 0 on if test output equals expected value; 1 otherwise.
+# side effects: prints a descriptive message.
+#
+asserteq()
+{
+ typeset out="$1" expected="$2" desc="$3"
+ echo -n "out=$out $desc"
+ if [ "$out" = "$expected" ]; then
+ echo " - ok"
+ return 0
+ else
+ echo " expected=$expected - bad"
+ return 1
+ fi
+}
+
+#
+# verbosely check that the test output doesn't match the reference value.
+# return value: 1 on if test output equals expected value; 0 if not equal.
+# side effects: prints descriptive message.
+#
+assertneq()
+{
+ typeset out="$1" ref="$2" desc="$3"
+ echo -n "out=$out $desc"
+ if [ "$out" = "$ref" ]; then
+ echo " ref=$ref - bad"
+ return 1
+ else
+ echo " ref=$ref - ok"
+ return 0
+ fi
+}