mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-22 00:56:21 +03:00
Merge pull request #1651 from stefanrueger/tmpfiles
Create test-avrdude's temporary files in the script itself
This commit is contained in:
@@ -14,6 +14,7 @@ list_only=0 # Normal run
|
||||
declare -a pgm_and_target=() # Array with test option strings, eg, "-c dryrun -p m328p"
|
||||
skip_eeprom=0 # Do not skip EEPROM tests for bootloaders by default
|
||||
tmp=/dev/shm # Temporary RAM directory
|
||||
addtests=0 # Add dryrun/dryboot test cases?
|
||||
verbose=0 # Do not show AVRDUDE errors and warnings by default
|
||||
|
||||
Usage() {
|
||||
@@ -28,6 +29,7 @@ Options:
|
||||
-p <programmer/part specs> can be used multiple times, overrides default tests
|
||||
-s skip EEPROM tests for bootloaders
|
||||
-t <dir> temporary directory
|
||||
-T Add dryrun/dryboot test cases to test $progname
|
||||
-v verbose: show AVRDUDE error and warning messages
|
||||
-? or -h show this help text
|
||||
Example:
|
||||
@@ -35,7 +37,7 @@ Example:
|
||||
END
|
||||
}
|
||||
|
||||
while getopts ":\?hc:d:e:lp:st:v" opt; do
|
||||
while getopts ":\?hc:d:e:lp:st:Tv" opt; do
|
||||
case ${opt} in
|
||||
c) avrdude_conf="$OPTARG"
|
||||
;;
|
||||
@@ -51,6 +53,8 @@ while getopts ":\?hc:d:e:lp:st:v" opt; do
|
||||
;;
|
||||
t) tmp="$OPTARG"
|
||||
;;
|
||||
T) addtests=1
|
||||
;;
|
||||
v) verbose=1
|
||||
;;
|
||||
--) shift;
|
||||
@@ -69,11 +73,55 @@ while getopts ":\?hc:d:e:lp:st:v" opt; do
|
||||
done
|
||||
shift $((OPTIND -1))
|
||||
|
||||
if [[ $addtests -eq 1 ]]; then
|
||||
pgm_and_target+=(
|
||||
"-c dryrun -p at89s51" "-c dryrun -p at89s52" "-c dryboot -p at90can32"
|
||||
"-c dryrun -p at90can32" "-c dryboot -p at90s1200" "-c dryboot -p at90s2313"
|
||||
"-c dryrun -p at90s2313" "-c dryboot -p at90s4414" "-c dryrun -p at90s4414"
|
||||
"-c dryboot -p at90s8515" "-c dryrun -p at90s8515" "-c dryboot -p atmega103"
|
||||
"-c dryrun -p atmega103" "-c dryboot -p atmega128rfr2" "-c dryrun -p atmega128rfr2"
|
||||
"-c dryboot -p atmega163" "-c dryrun -p atmega163" "-c dryboot -p atmega16"
|
||||
"-c dryrun -p atmega16" "-c dryboot -p atmega16hva" "-c dryrun -p atmega16hva"
|
||||
"-c dryboot -p atmega2560" "-c dryrun -p atmega2560" "-c dryboot -p atmega256rfr2"
|
||||
"-c dryrun -p atmega256rfr2" "-c dryboot -p atmega406" "-c dryrun -p atmega406"
|
||||
"-c dryboot -p atmega4808" "-c dryrun -p atmega4808" "-c dryboot -p atmega640"
|
||||
"-c dryrun -p atmega640" "-c dryboot -p atmega64" "-c dryrun -p atmega64"
|
||||
"-c dryboot -p atmega64hve2" "-c dryrun -p atmega64hve2" "-c dryboot -p atmega64rfr2"
|
||||
"-c dryrun -p atmega64rfr2" "-c dryboot -p atmega808" "-c dryrun -p atmega808"
|
||||
"-c dryboot -p atmega8" "-c dryrun -p atmega8" "-c dryrun -p attiny11"
|
||||
"-c dryboot -p attiny13" "-c dryrun -p attiny13" "-c dryboot -p attiny1604"
|
||||
"-c dryrun -p attiny1604" "-c dryboot -p attiny202" "-c dryrun -p attiny202"
|
||||
"-c dryrun -p attiny20" "-c dryboot -p attiny261" "-c dryrun -p attiny26"
|
||||
"-c dryrun -p attiny28" "-c dryboot -p attiny3216" "-c dryrun -p attiny3216"
|
||||
"-c dryboot -p attiny3224" "-c dryrun -p attiny3224" "-c dryboot -p attiny402"
|
||||
"-c dryrun -p attiny402" "-c dryrun -p attiny40" "-c dryboot -p attiny461"
|
||||
"-c dryrun -p attiny461" "-c dryboot -p attiny48" "-c dryrun -p attiny48"
|
||||
"-c dryrun -p attiny4" "-c dryboot -p attiny804" "-c dryrun -p attiny804"
|
||||
"-c dryboot -p attiny828" "-c dryrun -p attiny828" "-c dryboot -p attiny88"
|
||||
"-c dryrun -p attiny88" "-c dryrun -p attiny9" "-c dryboot -p atxmega128a4"
|
||||
"-c dryrun -p atxmega128a4" "-c dryboot -p atxmega128a4u" "-c dryrun -p atxmega128a4u"
|
||||
"-c dryboot -p atxmega128c3" "-c dryrun -p atxmega128c3" "-c dryboot -p atxmega16a4u"
|
||||
"-c dryrun -p atxmega16a4u" "-c dryboot -p atxmega16e5" "-c dryrun -p atxmega16e5"
|
||||
"-c dryboot -p atxmega192a1" "-c dryrun -p atxmega192a1" "-c dryboot -p atxmega192c3"
|
||||
"-c dryrun -p atxmega192c3" "-c dryboot -p atxmega256a1" "-c dryrun -p atxmega256a1"
|
||||
"-c dryboot -p atxmega256c3" "-c dryrun -p atxmega256c3" "-c dryboot -p atxmega32a4u"
|
||||
"-c dryrun -p atxmega32a4u" "-c dryboot -p atxmega32e5" "-c dryrun -p atxmega32e5"
|
||||
"-c dryboot -p atxmega384c3" "-c dryrun -p atxmega384c3" "-c dryboot -p atxmega64a4"
|
||||
"-c dryrun -p atxmega64a4" "-c dryboot -p atxmega64a4u" "-c dryrun -p atxmega64a4u"
|
||||
"-c dryboot -p atxmega8e5" "-c dryrun -p atxmega8e5" "-c dryboot -p avr128da28"
|
||||
"-c dryrun -p avr128da28" "-c dryboot -p avr16ea28" "-c dryrun -p avr16ea28"
|
||||
"-c dryboot -p avr32da28" "-c dryrun -p avr32da28" "-c dryboot -p avr32ea28"
|
||||
"-c dryrun -p avr32ea28" "-c dryboot -p avr64da28" "-c dryrun -p avr64da28"
|
||||
"-c dryboot -p avr64dd14" "-c dryrun -p avr64dd14" "-c dryboot -p avr64du28"
|
||||
"-c dryrun -p avr64du28" "-c dryboot -p avr64ea28" "-c dryrun -p avr64ea28"
|
||||
"-c dryboot -p avr8ea28" "-c dryrun -p avr8ea28" "-c dryboot -p lgt8f328p"
|
||||
"-c dryrun -p lgt8f328p"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ ${#pgm_and_target[@]} -eq 0 ]]; then
|
||||
# Default tests in absence of -p
|
||||
pgm_and_target+=(
|
||||
"-cdryrun -pm2560"
|
||||
"-cdryrun -px64a1"
|
||||
"-cpkobn_updi -B1 -patmega3208"
|
||||
"-cpkobn_updi -B1 -patmega3209"
|
||||
"-cpkobn_updi -B1 -patmega4808"
|
||||
@@ -101,7 +149,9 @@ $avrdude_bin -v 2>&1 | grep Version | cut -f2- -d: | sed s/Version/version/
|
||||
status=$(mktemp "$tmp/$progname.status.XXXXXX")
|
||||
logfile=$(mktemp "$tmp/$progname.log.XXXXXX")
|
||||
outfile=$(mktemp "$tmp/$progname.out.XXXXXX")
|
||||
trap "rm -f $status $logfile $outfile" EXIT
|
||||
tmpfile=$(mktemp "$tmp/$progname.tmp.XXXXXX")
|
||||
resfile=$(mktemp "$tmp/$progname.res.XXXXXX")
|
||||
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
|
||||
@@ -131,13 +181,14 @@ result () {
|
||||
echo ❌ "$(printf '%7.3f s' $elapsed): $specify (failed command below)"
|
||||
echo "\$ ${command[@]}" | tr -s " "
|
||||
FAIL=true
|
||||
exitstate=1
|
||||
[[ $programmer != -cdry* ]] && sleep 4 # Let the hw settle down before next test
|
||||
fi
|
||||
[[ $verbose -eq 1 ]] && { touch $logfile $outfile; cat $logfile $outfile; }
|
||||
[[ $verbose -eq 1 ]] && { cat $logfile $outfile; }
|
||||
else
|
||||
touch $outfile; cat $outfile
|
||||
cat $outfile
|
||||
fi
|
||||
rm -f $logfile $outfile; elapsed=-999; specify="unknown"; command=(sleep 0.1)
|
||||
cp /dev/null $outfile; cp /dev/null $logfile; elapsed=-999; specify="unknown"; command=(sleep 0.1)
|
||||
return $ret
|
||||
}
|
||||
|
||||
@@ -150,6 +201,7 @@ nofusetest=(-pattiny11/ -pt11/ -pattiny12/ -pt12/ -pattiny15/ -pt15/ -pat89s51/
|
||||
-pavr8ea28/ -pavr8ea32/ -pavr8ea32/ -plgt8f88p/ -plgt8f88p/ -plgt8f168p/ -plgt8f168p/
|
||||
-plgt8f328p/ -plgt8f328p/)
|
||||
|
||||
exitstate=0
|
||||
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)
|
||||
@@ -217,8 +269,6 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
# Test binary, octal, decimal, hexadecimal and R number lists for I/O
|
||||
declare -A numsys=([b]=binary [o]=octal [d]=decimal [h]=hexadecimal [R]=R)
|
||||
for fmt in b o d h R; do
|
||||
tmpfile="$tmp/app+data-m2560-$$.$fmt-txt"
|
||||
resfile="$tmp/app+data-m2560-$$.raw"
|
||||
specify="flash writing ${numsys[$fmt]} numbers"
|
||||
command=(${avrdude[@]}
|
||||
-U $tfiles/urboot_m2560_1s_x16m0_115k2_uart0_rxe0_txe1_led+b7_pr_ee_ce.hex
|
||||
@@ -233,13 +283,11 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
-U flash:w:$tmpfile:$fmt
|
||||
-U flash:r:$resfile:r)
|
||||
execute "${command[@]}"
|
||||
touch $tmpfile $resfile
|
||||
result cmp -s $resfile $tfiles/expected-flash-m2560.raw
|
||||
rm -f $tmpfile $resfile
|
||||
cp /dev/null $tmpfile; cp /dev/null $resfile
|
||||
done
|
||||
|
||||
specify="flash writing srec format"
|
||||
tmpfile="$tmp/app+data-m2560-$$.srec"
|
||||
command=(${avrdude[@]}
|
||||
-U $tfiles/urboot_m2560_1s_x16m0_115k2_uart0_rxe0_txe1_led+b7_pr_ee_ce.hex
|
||||
-T '"write flash 0x3fd00 0xc0cac01a 0xcafe \"secret Coca Cola recipe\""'
|
||||
@@ -254,7 +302,7 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
-U flash:v:$tfiles/expected-flash-m2560.raw:r)
|
||||
execute "${command[@]}"
|
||||
result [ $? == 0 ]
|
||||
rm -f $tmpfile
|
||||
cp /dev/null $tmpfile
|
||||
fi
|
||||
|
||||
#####
|
||||
@@ -375,7 +423,6 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
# Write and verify random data to usersig if present
|
||||
#
|
||||
if [[ -n "$USERSIG_SIZE" && $is_bootloader -ne 1 ]]; then
|
||||
tmpfile="$tmp/usersig_dump$$_${USERSIG_SIZE}B.bin"
|
||||
specify="usersig -T/-U write/read random_data_${USERSIG_SIZE}B.bin"
|
||||
command=(${avrdude[@]}
|
||||
-T '"erase usersig; write usersig '$tfiles/random_data_${USERSIG_SIZE}B.bin'"'
|
||||
@@ -386,9 +433,8 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
-T flush
|
||||
-U usersig:v:$tfiles/0xff_${USERSIG_SIZE}B.hex:i)
|
||||
execute "${command[@]}" >$outfile
|
||||
touch "$tmpfile"
|
||||
result [[ ! -s $outfile '&&' ! -s $logfile ]] '&&' cmp -s "$tfiles/random_data_${USERSIG_SIZE}B.bin" "$tmpfile"
|
||||
rm -f "$tmpfile"
|
||||
cp /dev/null $tmpfile
|
||||
fi
|
||||
|
||||
if [ $FAIL == true ]; then
|
||||
@@ -406,3 +452,5 @@ for (( p=0; p<$arraylength; p++ )); do
|
||||
|
||||
fi #key
|
||||
done #for
|
||||
|
||||
exit $exitstate
|
||||
|
||||
Reference in New Issue
Block a user