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 15, 2024
1 parent 29133dc commit 6995b3f
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' | cut -f2- -d: | sed s/Version/version/

[[ -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 -v'..."
$avrdude_bin -v 2>&1 | grep '[vV]ersion' | cut -f2- -d: | sed s/Version/version/ > "$outfile"
if grep version "$outfile" > /dev/null 2>&1; 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 6995b3f

Please sign in to comment.