ao-bringup: Test chaoskey using dieharder
authorKeith Packard <keithp@keithp.com>
Tue, 2 Aug 2016 23:30:15 +0000 (16:30 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 3 Aug 2016 00:05:42 +0000 (17:05 -0700)
This uses a subset of the dieharder tests which run in reasonable time
and don't appear to emit false negatives on a regular basis.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-bringup/test-chaoskey [new file with mode: 0755]
ao-bringup/turnon_chaoskey

diff --git a/ao-bringup/test-chaoskey b/ao-bringup/test-chaoskey
new file mode 100755 (executable)
index 0000000..db5aed6
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/bash
+snum="unknown"
+case "$#" in
+    1)
+       case "$1" in
+           "-?"|"--help")
+               echo "Usage: $0 [serial]"
+               exit 0
+               ;;
+       esac
+       snum="$1"
+       serial="--serial $1"
+       ;;
+    0)
+       serial=""
+       ;;
+    *)
+       echo "Usage: $0 [serial]"
+       exit 1
+       ;;
+esac
+
+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"
+
+PASS=0
+FAIL=0
+WEAK=0
+../ao-tools/ao-chaosread/ao-chaosread $serial --infinite --bytes | for test in $tests done; do
+    case $test in
+       *:*:*)
+           dnum=`echo $test | sed 's/:.*$//'`
+           tnum=`echo $test | sed 's/^[^:]*://'`
+           tnum=`echo $test | sed 's/^[^:]*://' | sed 's/:.*$//'`
+           nnum=`echo $test | sed 's/^.*://'`
+           opts="-d $dnum -t $tnum -n $nnum"
+           ;;
+       *:*)
+           dnum=`echo $test | sed 's/:.*$//'`
+           tnum=`echo $test | sed 's/^.*://'`
+           opts="-d $dnum -t $tnum"
+           ;;
+       *)
+           dnum=$test
+           opts="-d $dnum"
+           ;;
+    esac
+    case $dnum in
+    done)
+       echo DONE
+       ;;
+    *)
+       echo TEST $dnum
+       dieharder -g 200 $opts
+       ;;
+    esac
+done | while read result; do
+    case "$result" in
+       TEST*)
+           testnum=`echo $result | sed 's/TEST //'`
+           ;;
+       *PASSED*)
+           PASS=`expr $PASS + 1`
+           ;;
+       *WEAK*)
+           WEAK=`expr $WEAK + 1`
+           ;;
+       *FAILED*)
+           echo test $testnum failed
+           FAIL=`expr $FAIL + 1`
+           ;;
+       DONE)
+           echo pass $PASS weak $WEAK fail $FAIL
+           case $PASS:$FAIL in
+               [1-9]*:0)
+                   echo ChaosKey $snum is ready to ship
+                   exit 0
+                   ;;
+               *)
+                   echo ChaosKey $snum failed
+                   exit 1
+                   ;;
+           esac
+           ;;
+    esac
+done
index 8c20ebaa83854a450f50a6910e07c7e9f3410823..50460008f2479717c2d226a341f3858e7bc4bb45 100755 (executable)
@@ -30,4 +30,12 @@ sleep 2
 
 $USBLOAD --serial=1 ../src/chaoskey-v$VERSION/chaoskey-v$VERSION*.ihx || exit 1
 
+sleep 1
+
+serial=`dmesg | grep 'on chaoskey' | tail -1 | sed 's/.*chaoskey \([0-9a-f][0-9a-f]*\) on chaoskey.*/\1/'`
+
+echo 'Testing ChaosKey' $serial
+
+./test-chaoskey $serial
+
 exit $?