Fix and improve mftest
This commit is contained in:
parent
44c8f29e47
commit
d4c210f21b
@ -14,8 +14,10 @@ TESTPATH=buildroot/share/tests
|
|||||||
|
|
||||||
shopt -s extglob nocasematch
|
shopt -s extglob nocasematch
|
||||||
|
|
||||||
# Get test, allowing shorthand
|
# Get test
|
||||||
TESTENV=${1:-"mega"}
|
TESTENV=${1:-'-'}
|
||||||
|
|
||||||
|
# Allow shorthand for test name
|
||||||
case $TESTENV in
|
case $TESTENV in
|
||||||
due) TESTENV='DUE' ;;
|
due) TESTENV='DUE' ;;
|
||||||
esp) TESTENV='esp32' ;;
|
esp) TESTENV='esp32' ;;
|
||||||
@ -26,6 +28,7 @@ case $TESTENV in
|
|||||||
stm) TESTENV='STM32F1' ;;
|
stm) TESTENV='STM32F1' ;;
|
||||||
t35) TESTENV='teensy35' ;;
|
t35) TESTENV='teensy35' ;;
|
||||||
teensy) TESTENV='teensy35' ;;
|
teensy) TESTENV='teensy35' ;;
|
||||||
|
-) ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Matching patterns
|
# Matching patterns
|
||||||
@ -34,7 +37,7 @@ ISCMD='^(restore|opt|exec|use|pins|env)_'
|
|||||||
ISEXEC='^exec_'
|
ISEXEC='^exec_'
|
||||||
|
|
||||||
# List available tests and ask for selection
|
# List available tests and ask for selection
|
||||||
if [[ $1 == '-' ]]; then
|
if [[ $TESTENV == '-' ]]; then
|
||||||
IND=0
|
IND=0
|
||||||
NAMES=()
|
NAMES=()
|
||||||
for FILE in $( ls -1 $TESTPATH/*-tests )
|
for FILE in $( ls -1 $TESTPATH/*-tests )
|
||||||
@ -43,6 +46,7 @@ if [[ $1 == '-' ]]; then
|
|||||||
TNAME=${FILE/-tests/}
|
TNAME=${FILE/-tests/}
|
||||||
TNAME=${TNAME/$TESTPATH\//}
|
TNAME=${TNAME/$TESTPATH\//}
|
||||||
NAMES+=($TNAME)
|
NAMES+=($TNAME)
|
||||||
|
(( IND < 10 )) && echo -n " "
|
||||||
echo " $IND) $TNAME"
|
echo " $IND) $TNAME"
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -50,8 +54,8 @@ if [[ $1 == '-' ]]; then
|
|||||||
for (( ; ; ))
|
for (( ; ; ))
|
||||||
do
|
do
|
||||||
read -p "Select a test to apply (1-$IND) : " NAMEIND
|
read -p "Select a test to apply (1-$IND) : " NAMEIND
|
||||||
[[ -z "$NAMEIND" ]] && { echo "Quitting." ; exit 1 ; }
|
[[ -z "$NAMEIND" ]] && { echo '(canceled)' ; exit 1 ; }
|
||||||
[[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; break ; }
|
[[ $NAMEIND =~ $ISNUM ]] && ((NAMEIND >= 1 && NAMEIND <= IND)) && { TESTENV=${NAMES[$NAMEIND-1]} ; echo ; break ; }
|
||||||
echo "Invalid selection."
|
echo "Invalid selection."
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -66,17 +70,33 @@ TESTCOUNT=$( awk "/$ISEXEC/{a++}END{print a}" <<<"$OUT" )
|
|||||||
# Get the entered or interactive test index
|
# Get the entered or interactive test index
|
||||||
CHOICE=${2:-0}
|
CHOICE=${2:-0}
|
||||||
|
|
||||||
if [[ $TESTCOUNT > 1 && ( $CHOICE == 0 || $1 == '-' ) ]]; then
|
# User entered a number?
|
||||||
for (( ; ; ))
|
(( CHOICE && CHOICE > TESTCOUNT )) && { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
|
||||||
do
|
|
||||||
read -p "Test '$TESTENV' index (1-$TESTCOUNT) : " CHOICE
|
if [[ $CHOICE == 0 ]]; then
|
||||||
[[ -z "$CHOICE" ]] && CHOICE=1
|
# List test descriptions with numbers
|
||||||
[[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
|
echo "Available '$TESTENV' tests:" ; echo "$OUT" | {
|
||||||
echo "Invalid test index '$CHOICE'."
|
IND=0
|
||||||
done
|
SED=$(which gsed || which sed)
|
||||||
else
|
while IFS= read -r LINE
|
||||||
# Confirm a manually-entered test index
|
do
|
||||||
((CHOICE >= 1 && CHOICE <= TESTCOUNT)) || { echo "Invalid test index '$CHOICE' (1-$TESTCOUNT)." ; exit 1 ; }
|
if [[ $LINE =~ $ISEXEC ]]; then
|
||||||
|
DESC=$( "$SED" -E 's/^.+"(.*)".*$/\1/g' <<<"$LINE" )
|
||||||
|
(( ++IND < 10 )) && echo -n " "
|
||||||
|
echo " $IND) $DESC"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
CHOICE=1
|
||||||
|
if [[ $TESTCOUNT > 1 ]]; then
|
||||||
|
for (( ; ; ))
|
||||||
|
do
|
||||||
|
read -p "Select a '$TESTENV' test (1-$TESTCOUNT) : " CHOICE
|
||||||
|
[[ -z "$CHOICE" ]] && { echo '(canceled)' ; exit 1 ; }
|
||||||
|
[[ $CHOICE =~ $ISNUM ]] && ((CHOICE >= 1 && CHOICE <= TESTCOUNT)) && break
|
||||||
|
echo ">>> Invalid test index '$CHOICE'."
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Finally, run the specified test lines
|
# Finally, run the specified test lines
|
||||||
|
Loading…
Reference in New Issue
Block a user