pm3_tests: cosmetic

This commit is contained in:
Philippe Teuwen 2020-05-23 23:59:10 +02:00
parent 4df2727ab7
commit 6e5de1090a

View file

@ -23,8 +23,9 @@ while (( "$#" )); do
case "$1" in case "$1" in
-h|--help) -h|--help)
echo """ echo """
Usage: $0 [--long] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|fpga_compress|bootrom|armsrc|client|recovery|common] Usage: $0 [--long] [--gpu] [--clientbin /path/to/proxmark3] [mfkey|nonce2key|mf_nonce_brute|fpga_compress|bootrom|armsrc|client|recovery|common]
--long: Enable slow tests --long: Enable slow tests
--gpu: Enable tests requiring GPU
--clientbin ...: Specify path to proxmark3 binary to test --clientbin ...: Specify path to proxmark3 binary to test
If no target given, all targets will be tested If no target given, all targets will be tested
""" """
@ -119,17 +120,19 @@ C_NC='\033[0m' # No Color
# title, file name or file wildcard to check # title, file name or file wildcard to check
function CheckFileExist() { function CheckFileExist() {
printf "%-40s" "$1 "
if [ -f "$2" ]; then if [ -f "$2" ]; then
echo -e "$1 ${C_GREEN}[OK]${C_NC}" echo -e "${C_GREEN}[OK]${C_NC}"
return 0 return 0
fi fi
if ls "$2" 1> /dev/null 2>&1; then if ls "$2" 1> /dev/null 2>&1; then
echo -e "$1 ${C_GREEN}[OK]${C_NC}" echo -e "${C_GREEN}[OK]${C_NC}"
return 0 return 0
fi fi
echo -e "$1 ${C_RED}[Fail]${C_NC}" echo -e "${C_RED}[FAIL]${C_NC}"
return 1 return 1
} }
@ -164,12 +167,14 @@ function CheckExecute() {
local IGNOREFAILURE=false local IGNOREFAILURE=false
fi fi
printf "%-40s" "$1 "
if $SLOWTEST && ! $SLOWTESTS; then if $SLOWTEST && ! $SLOWTESTS; then
echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (slow)\n" echo -e "${C_YELLOW}[SKIPPED]${C_NC} (slow)\n"
return 0 return 0
fi fi
if $GPUTEST && ! $GPUTESTS; then if $GPUTEST && ! $GPUTESTS; then
echo -e "$1 ${C_YELLOW}[SKIPPED]${C_NC} (gpu)\n" echo -e "${C_YELLOW}[SKIPPED]${C_NC} (gpu)\n"
return 0 return 0
fi fi
@ -177,18 +182,18 @@ function CheckExecute() {
do do
RES=$(eval "$2") RES=$(eval "$2")
if echo "$RES" | grep -q "$3"; then if echo "$RES" | grep -q "$3"; then
echo -e "$1 ${C_GREEN}[OK]${C_NC}" echo -e "${C_GREEN}[OK]${C_NC}"
return 0 return 0
fi fi
if [ ! $I == "e" ]; then echo "retry $I"; fi if [ ! $I == "e" ]; then echo "retry $I"; fi
done done
if $IGNOREFAILURE; then if $IGNOREFAILURE; then
echo -e "$1 ${C_YELLOW}[Ignored]${C_NC}" echo -e "${C_YELLOW}[IGNORED]${C_NC}"
return 0 return 0
fi fi
echo -e "$1 ${C_RED}[Fail]${C_NC}" echo -e "${C_RED}[FAIL]${C_NC}"
echo -e "Execution trace:\n$RES" echo -e "Execution trace:\n$RES"
return 1 return 1
} }