Skip to content

Commit

Permalink
Add simple test script to test all modes supported by capture.py
Browse files Browse the repository at this point in the history
Signed-off-by: Pirmin Vogel <[email protected]>
  • Loading branch information
vogelpi committed Aug 10, 2023
1 parent 67c5152 commit b413294
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions cw/test_capture.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#!/bin/bash
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Simple script to test all relevant capture modes supported by capture.py.
# To test capture modes on the CW305 board, type
#
# ./test_capture.sh cw305
#
# For the CW310, simply type
#
# ./test_capture.sh
#

set -e
set -o pipefail

error () {
echo >&2 "$@"
exit 1
}

# Input arguments.
# Only one argument is supported to specify the FPGA board.
if [ $# -lt 1 ]; then
BOARD=cw310
else
BOARD=$1
fi
if `[ "${BOARD}" != "cw305" ] && [ "${BOARD}" != "cw310" ]`; then
error "Board ${BOARD} not supported"
fi

# Create results folder.
mkdir -p tmp

# AES
MODE="aes"
declare -A aes_test_list
aes_test_list["aes-random"]=100
aes_test_list["aes-random-batch"]=1000
aes_test_list["aes-fvsr-key"]=100
aes_test_list["aes-fvsr-key-batch"]=1000

for test in ${!aes_test_list[@]}; do
echo Testing ${test} on ${BOARD}
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log"
if [ "${test}" = "aes-random" ]; then
ARGS="--force-program-bitstream"
else
ARGS=""
fi
NUM_TRACES=${aes_test_list[${test}]}
./capture.py --cfg-file capture_${MODE}_${BOARD}.yaml capture ${test} \
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log"
mv projects/sample_traces_${MODE}.html tmp/${BOARD}_${test}_traces.html
done

if [ ${BOARD} == "cw310" ]; then
# KMAC
MODE="kmac"
declare -A kmac_test_list
kmac_test_list["kmac-random"]=100
kmac_test_list["kmac-fvsr-key"]=100
kmac_test_list["kmac-fvsr-key-batch"]=1000

for test in ${!kmac_test_list[@]}; do
echo Testing ${test} on ${BOARD}
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log"
if [ "${test}" = "kmac-random" ]; then
ARGS="--force-program-bitstream"
else
ARGS=""
fi
NUM_TRACES=${kmac_test_list[${test}]}
./capture.py --cfg-file capture_${MODE}_${BOARD}.yaml capture ${test} \
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log"
mv projects/sample_traces_${MODE}.html tmp/${BOARD}_${test}_traces.html
done

# SHA3
MODE="sha3"
declare -A sha3_test_list
sha3_test_list["sha3-fvsr-data"]=100
sha3_test_list["sha3-fvsr-data-batch"]=1000

for test in ${!sha3_test_list[@]}; do
echo Testing ${test} on ${BOARD}
echo Testing ${test} on ${BOARD} - `date` >> "tmp/${BOARD}_test_capture.log"
if [ "${test}" = "sha3-fvsr-data" ]; then
ARGS="--force-program-bitstream"
else
ARGS=""
fi
NUM_TRACES=${sha3_test_list[${test}]}
./capture.py --cfg-file capture_${MODE}_${BOARD}.yaml capture ${test} \
--num-traces ${NUM_TRACES} ${ARGS} &>> "tmp/${BOARD}_test_capture.log"
mv projects/sample_traces_${MODE}.html tmp/${BOARD}_${test}_traces.html
done

# OTBN
# TODO!
fi

echo "Done! Checkout tmp/${BOARD}_... for results."

0 comments on commit b413294

Please sign in to comment.