mbed TLS Build

Dependents:   Encrypt_Decrypt1 mbed_blink_tls encrypt encrypt

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 #!/bin/sh
markrad 0:cdf462088d13 2
markrad 0:cdf462088d13 3 # This script splits the data test files containing the test cases into
markrad 0:cdf462088d13 4 # individual files (one test case per file) suitable for use with afl
markrad 0:cdf462088d13 5 # (American Fuzzy Lop). http://lcamtuf.coredump.cx/afl/
markrad 0:cdf462088d13 6 #
markrad 0:cdf462088d13 7 # Usage: generate-afl-tests.sh <test data file path>
markrad 0:cdf462088d13 8 # <test data file path> - should be the path to one of the test suite files
markrad 0:cdf462088d13 9 # such as 'test_suite_mpi.data'
markrad 0:cdf462088d13 10
markrad 0:cdf462088d13 11 # Abort on errors
markrad 0:cdf462088d13 12 set -e
markrad 0:cdf462088d13 13
markrad 0:cdf462088d13 14 if [ -z $1 ]
markrad 0:cdf462088d13 15 then
markrad 0:cdf462088d13 16 echo " [!] No test file specified" >&2
markrad 0:cdf462088d13 17 echo "Usage: $0 <test data file>" >&2
markrad 0:cdf462088d13 18 exit 1
markrad 0:cdf462088d13 19 fi
markrad 0:cdf462088d13 20
markrad 0:cdf462088d13 21 SRC_FILEPATH=$(dirname $1)/$(basename $1)
markrad 0:cdf462088d13 22 TESTSUITE=$(basename $1 .data)
markrad 0:cdf462088d13 23
markrad 0:cdf462088d13 24 THIS_DIR=$(basename $PWD)
markrad 0:cdf462088d13 25
markrad 0:cdf462088d13 26 if [ -d ../library -a -d ../include -a -d ../tests -a $THIS_DIR == "tests" ];
markrad 0:cdf462088d13 27 then :;
markrad 0:cdf462088d13 28 else
markrad 0:cdf462088d13 29 echo " [!] Must be run from mbed TLS tests directory" >&2
markrad 0:cdf462088d13 30 exit 1
markrad 0:cdf462088d13 31 fi
markrad 0:cdf462088d13 32
markrad 0:cdf462088d13 33 DEST_TESTCASE_DIR=$TESTSUITE-afl-tests
markrad 0:cdf462088d13 34 DEST_OUTPUT_DIR=$TESTSUITE-afl-out
markrad 0:cdf462088d13 35
markrad 0:cdf462088d13 36 echo " [+] Creating output directories" >&2
markrad 0:cdf462088d13 37
markrad 0:cdf462088d13 38 if [ -e $DEST_OUTPUT_DIR/* ];
markrad 0:cdf462088d13 39 then :
markrad 0:cdf462088d13 40 echo " [!] Test output files already exist." >&2
markrad 0:cdf462088d13 41 exit 1
markrad 0:cdf462088d13 42 else
markrad 0:cdf462088d13 43 mkdir -p $DEST_OUTPUT_DIR
markrad 0:cdf462088d13 44 fi
markrad 0:cdf462088d13 45
markrad 0:cdf462088d13 46 if [ -e $DEST_TESTCASE_DIR/* ];
markrad 0:cdf462088d13 47 then :
markrad 0:cdf462088d13 48 echo " [!] Test output files already exist." >&2
markrad 0:cdf462088d13 49 else
markrad 0:cdf462088d13 50 mkdir -p $DEST_TESTCASE_DIR
markrad 0:cdf462088d13 51 fi
markrad 0:cdf462088d13 52
markrad 0:cdf462088d13 53 echo " [+] Creating test cases" >&2
markrad 0:cdf462088d13 54 cd $DEST_TESTCASE_DIR
markrad 0:cdf462088d13 55
markrad 0:cdf462088d13 56 split -p '^\s*$' ../$SRC_FILEPATH
markrad 0:cdf462088d13 57
markrad 0:cdf462088d13 58 for f in *;
markrad 0:cdf462088d13 59 do
markrad 0:cdf462088d13 60 # Strip out any blank lines (no trim on OS X)
markrad 0:cdf462088d13 61 sed '/^\s*$/d' $f >testcase_$f
markrad 0:cdf462088d13 62 rm $f
markrad 0:cdf462088d13 63 done
markrad 0:cdf462088d13 64
markrad 0:cdf462088d13 65 cd ..
markrad 0:cdf462088d13 66
markrad 0:cdf462088d13 67 echo " [+] Test cases in $DEST_TESTCASE_DIR" >&2
markrad 0:cdf462088d13 68