summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-11 01:18:49 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-11 16:25:18 +0100
commit8a44fd062ab24155e9438f72de75cd5eb2e3af58 (patch)
treef5ac14119809bf430dbd256f71201e844990526a
parent66b9b36805d7a932001983903ae2f7f5ce0c6107 (diff)
btrfs-progs: tests: add assertion helper
Helper to extend sanity checks in various functions. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--tests/common18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/common b/tests/common
index c20fec88..320b023f 100644
--- a/tests/common
+++ b/tests/common
@@ -3,6 +3,24 @@
# Common routines for all tests
#
+# assert that argument is not empty and is an existing path (file or directory)
+_assert_path()
+{
+ local path
+
+ path="$1"
+ if [ -z "$path" ]; then
+ echo "ASSERTION FAIL: $path is not valid"
+ exit 1
+ fi
+
+ if [ -f "$path" -o -d "$path" -o -b "$path" ]; then
+ return 0
+ fi
+ echo "ASSERTION FAIL: $path is not valid"
+ exit 1
+}
+
_fail()
{
echo "$*" | tee -a $RESULTS