Merge pull request #1658 from stefanrueger/update-test-script

Update test script
This commit is contained in:
Stefan Rueger
2024-02-06 10:30:46 +13:00
committed by GitHub

View File

@@ -144,6 +144,7 @@ if [[ ${#pgm_and_target[@]} -eq 0 ]]; then
fi
arraylength=${#pgm_and_target[@]}
type "$avrdude_bin" >/dev/null 2>&1 || { echo "$progname: cannot execute $avrdude_bin"; exit 1; }
echo -n "Testing $avrdude_bin"
$avrdude_bin -v 2>&1 | grep Version | cut -f2- -d: | sed s/Version/version/
@@ -158,14 +159,15 @@ trap "rm -f $status $logfile $outfile $tmpfile $resfile" EXIT
TIMEFORMAT=%R # time built-in only returns elapsed wall-clock time
elapsed=-1 # Global variable holding time of last execute command in seconds
command=(sleep 0.1) # Array with AVRDUDE command
emulated=0 # Is programmer dryrun or dryboot, ie, programming is emulated?
# Execute args as command, set $elapsed and return exit value of command; don't call in a subshell
execute () {
if [[ $list_only -eq 1 ]]; then
echo "\$ ${command[@]}" | tr -s " "
echo "\$ ${command[@]}" | sed "s/ -l [^ ]* / /" | tr -s " "
return 0;
fi
[[ $programmer != -cdry* && $elapsed -ne -1 ]] && sleep "$delay"
[[ $emulated -eq 0 && $elapsed != -1 ]] && sleep "$delay"
# These shenanigans keep stdout, stderr and the exit code of the command
{ read elapsed < <({ time { eval "$@"; echo $? >"$status"; } 2>&4 4>&-; } 4>&2 2>&1 >&3 3>&-); } 3>&1
return $(cat "$status")
@@ -184,7 +186,7 @@ result () {
echo "\$ ${command[@]}" | tr -s " "
FAIL=true
exitstate=1
[[ $programmer != -cdry* ]] && sleep 4 # Let the hw settle down before next test
[[ $emulated -eq 0 ]] && sleep 4 # Let the hw settle down before next test
fi
[[ $verbose -eq 1 ]] && { cat $logfile $outfile; }
else
@@ -208,6 +210,8 @@ for (( p=0; p<$arraylength; p++ )); do
# Isolate programmer and part (assumes -c prog or -cprog but not sth more tricky such as -qc prog)
programmer=$(echo ${pgm_and_target[$p]} | sed 's/ *\([^-]\)/\1/g' | tr \ \\n | grep ^-c | tr A-Z a-z)
part=$(echo ${pgm_and_target[$p]} | sed 's/ *\([^-]\)/\1/g' | tr \ \\n | grep ^-p | tr A-Z a-z)
emulated=0
[[ "$programmer" == -cdryrun || "$programmer" == -cdryboot ]] && emulated=1
if [[ $list_only -eq 1 ]]; then
[[ p -ne 0 ]] && echo
@@ -216,12 +220,12 @@ for (( p=0; p<$arraylength; p++ )); do
else
echo "Prepare \"${pgm_and_target[$p]}\" and press 'enter' or 'space' to continue. Press any other key to skip"
read -n1 -s -r -p $'' key
[[ $programmer != -cdry* ]] && sleep 0.15 # Debounce key when not using dryrun/dryboot
[[ $emulated -eq 0 ]] && sleep 0.15 # Debounce key when not using dryrun/dryboot
fi
if [ "$key" == '' ]; then
FAIL=false
avrdude=($avrdude_bin $avrdude_conf -qq ${pgm_and_target[$p]} -l $logfile)
avrdude=($avrdude_bin -l $logfile $avrdude_conf -qq ${pgm_and_target[$p]})
# Get flash and EEPROM size in bytes and make sure the numbers are in dec form
FLASH_SIZE=$(${avrdude[@]} -cdryrun -T 'part -m' 2>/dev/null | grep flash | awk '{print $2}')
@@ -321,16 +325,16 @@ for (( p=0; p<$arraylength; p++ )); do
execute "${command[@]}" > $outfile
fusebit=$(grep ^config $outfile | awk '{print $4}')
sed -e/^config/d -e/"> "/d $outfile > ${outfile}-2
result [[ '"$fusebit"' == 1 '&&' ! -s ${outfile}-2 '&&' ! -s $logfile ]]
rm ${outfile}-2
mv ${outfile}-2 $outfile
result [[ '"$fusebit"' == 1 '&&' ! -s $outfile '&&' ! -s $logfile ]]
if [ -n "$EE_SIZE" ]; then
specify="fuse access: set eesave fusebit to delete EEPROM on chip erase"
command=(${avrdude[@]} -T '"config eesave=ee*erased"')
execute "${command[@]}" > $outfile
sed -e/^config/d -e/"> "/d $outfile > ${outfile}-2
result [[ ! -s ${outfile}-2 '&&' ! -s $logfile ]]
rm ${outfile}-2
mv ${outfile}-2 $outfile
result [[ ! -s $outfile '&&' ! -s $logfile ]]
fi
fi