mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-09 18:45:54 +02:00
tests: Add bash lib
This allows use to write test with less effort as we can reuse functions Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
committed by
Michael Tremer
parent
b7f2cb0a44
commit
6f4e782356
27
tests/lib.sh
Normal file
27
tests/lib.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Get the path of this file.
|
||||
# This ist rather complex as we do not want the calling script file
|
||||
# That why we use BASH_SOURCE[0]
|
||||
LIB_DIR="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||
# In LIB_DIR is currently saved the path to this file you are currently reading
|
||||
# but we need the directory where it is located so:
|
||||
LIB_DIR="$(dirname "${LIB_DIR}")"
|
||||
|
||||
|
||||
. ${LIB_DIR}/lib_color.sh
|
||||
|
||||
test_command() {
|
||||
|
||||
if ! "$@" ; then
|
||||
echo -e "${CLR_RED_BG} Test failed: ${*} ${CLR_RESET}"
|
||||
return 1
|
||||
else
|
||||
echo -e "${CLR_GREEN_BG} Test succeded: ${*} ${CLR_RESET}"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
var_has_value() {
|
||||
[[ "${!1}" == "${2}" ]]
|
||||
}
|
||||
Reference in New Issue
Block a user