db5aed6e82346543895260f18098c440fdc40320
[fw/altos] / ao-bringup / test-chaoskey
1 #!/bin/bash
2 snum="unknown"
3 case "$#" in
4     1)
5         case "$1" in
6             "-?"|"--help")
7                 echo "Usage: $0 [serial]"
8                 exit 0
9                 ;;
10         esac
11         snum="$1"
12         serial="--serial $1"
13         ;;
14     0)
15         serial=""
16         ;;
17     *)
18         echo "Usage: $0 [serial]"
19         exit 1
20         ;;
21 esac
22
23 tests="0:100 1:100 2:100 3:100 12:10 13:100 15:10000 16:250 202:1000 203:100 204:500 206:20 207:1000:32 209:1000"
24
25 PASS=0
26 FAIL=0
27 WEAK=0
28 ../ao-tools/ao-chaosread/ao-chaosread $serial --infinite --bytes | for test in $tests done; do
29     case $test in
30         *:*:*)
31             dnum=`echo $test | sed 's/:.*$//'`
32             tnum=`echo $test | sed 's/^[^:]*://'`
33             tnum=`echo $test | sed 's/^[^:]*://' | sed 's/:.*$//'`
34             nnum=`echo $test | sed 's/^.*://'`
35             opts="-d $dnum -t $tnum -n $nnum"
36             ;;
37         *:*)
38             dnum=`echo $test | sed 's/:.*$//'`
39             tnum=`echo $test | sed 's/^.*://'`
40             opts="-d $dnum -t $tnum"
41             ;;
42         *)
43             dnum=$test
44             opts="-d $dnum"
45             ;;
46     esac
47     case $dnum in
48     done)
49         echo DONE
50         ;;
51     *)
52         echo TEST $dnum
53         dieharder -g 200 $opts
54         ;;
55     esac
56 done | while read result; do
57     case "$result" in
58         TEST*)
59             testnum=`echo $result | sed 's/TEST //'`
60             ;;
61         *PASSED*)
62             PASS=`expr $PASS + 1`
63             ;;
64         *WEAK*)
65             WEAK=`expr $WEAK + 1`
66             ;;
67         *FAILED*)
68             echo test $testnum failed
69             FAIL=`expr $FAIL + 1`
70             ;;
71         DONE)
72             echo pass $PASS weak $WEAK fail $FAIL
73             case $PASS:$FAIL in
74                 [1-9]*:0)
75                     echo ChaosKey $snum is ready to ship
76                     exit 0
77                     ;;
78                 *)
79                     echo ChaosKey $snum failed
80                     exit 1
81                     ;;
82             esac
83             ;;
84     esac
85 done