btrfs-progs: tests: add assertion helper

Helper to extend sanity checks in various functions.

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-11-11 01:18:49 +01:00
parent 66b9b36805
commit 8a44fd062a
1 changed files with 18 additions and 0 deletions

View File

@ -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