Skip to content

Commit

Permalink
test-avrdude: Abort if running "avrdude -v" fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ndim committed Aug 16, 2024
1 parent c8581dc commit b1d561c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/test-avrdude
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ 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 '[vV]ersion' | sed 's/^.* [Vv]ersion/version/' | head -n1

[[ -d $tmp && -w $tmp ]] || tmp=/tmp # Fall back to /tmp if tmp directory unusable
status=$(mktemp "$tmp/$progname.status.XXXXXX")
Expand All @@ -160,6 +158,17 @@ tmpfile=$(mktemp "$tmp/$progname.tmp.XXXXXX")
resfile=$(mktemp "$tmp/$progname.res.XXXXXX")
trap "rm -f $status $logfile $outfile $tmpfile $resfile" EXIT

echo -n "Testing $avrdude_bin version..."
$avrdude_bin -v 2>&1 | grep '[vV]ersion' | sed 's/^.* [Vv]ersion //' | head -n1 > "$outfile"
if test -s "$outfile"; then
echo -n " "
cat "$outfile"
else
echo " error"
$avrdude_bin -v
exit 1
fi

devnull=$tmpfile # Cannot use /dev/null as file in Windows avrdude

TIMEFORMAT=%R # time built-in only returns elapsed wall-clock time
Expand Down

0 comments on commit b1d561c

Please sign in to comment.