3 # Copyright 2008 Free Software Foundation, Inc.
5 # This file is free software; as a special exception the author gives
6 # unlimited permission to copy and/or distribute it, with or without
7 # modifications, as long as this notice is preserved.
9 # This file is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 # 1. Cd to the libgcrypt/tests directory
17 # 2. Unpack the test vector tarball into subdirectory named "cavs".
18 # An example directory layout after unpacking might be:
19 # libgcrypt/tests/cavs/AES/req/CBCGFSbox128.req
20 # libgcrypt/tests/cavs/AES/req/CFB128MCT128.req
22 # Note that below the "cavs" directory there should only be one
23 # directory part named "req". Further avoid directory part
26 # 3. Run this script from the libgcrypt/tests directory:
29 # 4. Send the result file cavs/CAVS_results-*.zip to the testing lab.
32 # Stop script if something unexpected happens.
35 # A global flag to keep track of errors.
36 errors_seen_file="$(pwd)/.#cavs_test.errors_seen.tmp"
37 [ -f "$errors_seen_file" ] && rm "$errors_seen_file"
39 [ "$1" = "--continue" ] && continue_mode=yes
42 # Function to run one test.
43 # The argument is the request file name.
44 function run_one_test () {
51 tmprspfile=$(echo "$reqfile" | sed 's,.req$,.rsp,')
52 rspfile=$(echo "$tmprspfile" | sed 's,/req/,/resp/,' )
53 respdir=$(dirname "$rspfile")
54 [ -f "$tmprspfile" ] && rm "$tmprspfile"
55 [ -d "$respdir" ] || mkdir "$respdir"
56 [ -f "$rspfile" ] && rm "$rspfile"
58 if echo "$reqfile" | grep '/DSA/req/' >/dev/null 2>/dev/null; then
62 if ./cavs_driver.pl -I libgcrypt $dflag "$reqfile"; then
63 if [ -f "$tmprspfile" ]; then
64 mv "$tmprspfile" "$rspfile"
66 echo "failed test: $reqfile" >&2
67 : >"$errors_seen_file"
70 echo "failed test: $reqfile rc=$?" >&2
71 : >"$errors_seen_file"
77 # Save date and system architecure to construct the output archive name
79 ARCH=$(arch || echo unknown)
80 result_file="CAVS_results-$ARCH-$DATE.zip"
82 for f in fipsdrv cavs_driver.pl; do
83 if [ ! -f "./$f" ]; then
84 echo "required program \"$f\" missing in current directory" >&2
88 if [ ! -d cavs ]; then
89 echo "required directory \"cavs\" missing below current directory" >&2
92 if [ ! zip -h >/dev/null 2>&1 ]; then
93 echo "required program \"zip\" is not installed on this system" >&2
97 # Set the PATH to this directory so that the perl script is able to
98 # find the test drivers.
101 # Check whether there are any stale response files
102 find cavs -type f -name "*.rsp" | ( while read f ; do
103 echo "Stale response file: $f" >&2
106 if [ "$any" = "yes" ]; then
107 echo "Stale response files found" >&2
108 if [ "$continue_mode" != "yes" ]; then
109 echo "use option --continue if that is not a problem" >&2
116 # Find all test files and run the tests.
117 find cavs -type f -name "*.req" | while read f ; do
118 echo "Running test file $f" >&2
120 if [ -f "$errors_seen_file" ]; then
125 if [ -f "$errors_seen_file" ]; then
126 rm "$errors_seen_file"
127 echo "Error encountered - not packing up response file" >&2
131 echo "Packing up all response files" >&2
133 find . -type f -name "*rsp" -print | zip -@ "$result_file"
135 echo "Result file is: cavs/$result_file" >&2