35 lines
456 B
Bash
35 lines
456 B
Bash
|
#!/usr/bin/env bash
|
||
|
# Common functions for running various tests
|
||
|
|
||
|
PASSED=0
|
||
|
FAILED=0
|
||
|
|
||
|
# Results
|
||
|
result() {
|
||
|
echo "--- Results ---"
|
||
|
echo "${PASSED}/$((PASSED+FAILED))"
|
||
|
if (( FAILED == 0 )); then
|
||
|
return 0
|
||
|
else
|
||
|
return 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# Runs a command, increments test passed/failed
|
||
|
# Args: Command
|
||
|
cmd() {
|
||
|
# Run command
|
||
|
echo "CMD: $@"
|
||
|
$@
|
||
|
local RET=$?
|
||
|
|
||
|
# Check command
|
||
|
if [[ ${RET} -ne 0 ]]; then
|
||
|
((FAILED++))
|
||
|
else
|
||
|
((PASSED++))
|
||
|
fi
|
||
|
|
||
|
return ${RET}
|
||
|
}
|