ao-bringup: Allow dfu_util to "fail" while flashing chaoskey
[fw/altos] / ao-bringup / test-easymini
1 #!/bin/bash
2
3 VERSION=2.0
4 PRODUCT=EasyMini
5 BASE=`echo $PRODUCT | tr 'A-Z' 'a-z'`
6
7 echo "$PRODUCT-v$VERSION Test Program"
8 echo "Copyright 2014 by Keith Packard.  Released under GPL v2"
9 echo
10 echo "Expectations:"
11 echo -e "\t$PRODUCT v$VERSION powered from USB"
12 echo
13
14 found=0
15 while [ $found -eq 0 ]; do
16     (ao-list; echo END END END END) | while read product serial dev; do
17         case "$product" in
18             "$PRODUCT-v$VERSION")
19
20                 found=1
21                 echo -e '\e[34m'Testing $product $serial $dev'\e[39m'
22                 echo ""
23                 
24                 ./test-igniters "$dev" drogue main
25                 echo ""
26
27                 echo "Testing baro sensor"
28                 ../ao-tools/ao-test-baro/ao-test-baro --tty="$dev"
29
30                 if [ $? -ne 0 ]; then
31                     echo -e '\e[31m'"$PRODUCT-$VERSION serial $serial failed"'\e[39m'
32                     exit 1
33                 fi
34                 echo""
35
36                 FLASHSIZE=1048576
37
38                 echo "Testing flash"
39                 ../ao-tools/ao-test-flash/ao-test-flash --tty="$dev" "$FLASHSIZE"
40
41                 if [ $? -ne 0 ]; then
42                     echo -e '\e[31m'"$PRODUCT-$VERSION serial $serial failed"'\e[39m'
43                     exit 1
44                 fi
45
46                 echo ""
47
48                 echo -e '\e[32m'"$PRODUCT-v$VERSION" serial "$serial" is ready to ship'\e[39m'
49                 exit 0
50                 ;;
51             END)
52                 exit 2
53                 ;;
54         esac
55     done
56     result=$?
57     if [ $result -ne 2 ]; then
58         exit $result
59     fi
60     echo 'No device, sleeping...'
61     sleep 1
62 done