diff options
author | Ryan Harkin <ryan.harkin@linaro.org> | 2020-02-28 18:19:55 +0000 |
---|---|---|
committer | Ryan Harkin <ryan.harkin@linaro.org> | 2021-02-02 09:03:18 +0000 |
commit | 5ed145373f5b8f055185205dd009810bf202dbaa (patch) | |
tree | 75cdc2dbc20ff9e82cb6cf3bd41150864f5d0504 | |
parent | 9ef52614e17a35f346c82fdaef34d7c6fd493add (diff) |
cryptotest added
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
-rwxr-xr-x | automated/linux/cryptotest/cryptotest.sh | 129 | ||||
-rw-r--r-- | automated/linux/cryptotest/cryptotest.yaml | 21 |
2 files changed, 150 insertions, 0 deletions
diff --git a/automated/linux/cryptotest/cryptotest.sh b/automated/linux/cryptotest/cryptotest.sh new file mode 100755 index 0000000..eb27786 --- /dev/null +++ b/automated/linux/cryptotest/cryptotest.sh @@ -0,0 +1,129 @@ +#!/bin/sh +# shellcheck disable=SC1091 + +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" +CUNIT_FILE="CUnitAutomated-Results.xml" +CRYPTO_DEVICE="/dev/cryptotest" + +. ../../lib/sh-test-lib + +create_out_dir "${OUTPUT}" + +usage() { + echo "Usage: $0 [-c <crypto_device>] [-s <skip install: true|false]" 1>&2 + exit 1 +} + +while getopts "c:h:s" o; do + case "$o" in + c) CRYPTO_DEVICE="${OPTARG}" ;; + s) SKIP_INSTALL="${OPTARG}" ;; + h|*) usage ;; + esac +done + +# Copied from automated/linux/spectre-meltdown-checker-test/bin/spectre-meltdown-checker.sh +# example usage: +# dmesg_grep 'Xen HVM callback vector for event delivery is enabled$'; ret=$? +# +dmesg_grep() +{ + # grep for something in dmesg, ensuring that the dmesg buffer + # has not been truncated + dmesg_grepped='' + if ! dmesg | grep -qE -e '(^|\] )Linux version [0-9]' ; then + # dmesg truncated + return 2 + fi + dmesg_grepped=$(dmesg | grep -E "$1" | head -1) + # not found: + [ -z "$dmesg_grepped" ] && return 1 + # found, output is in $dmesg_grepped + return 0 +} + +# Check device does NOT exist +# It won't exist until the module is probed +if [ -c "${CRYPTO_DEVICE}" ]; then + result="fail" +else + result="pass" +fi +echo "device-not-exists-yet ${result}" | tee -a ${RESULT_FILE} + +if [ "${result}" = pass ]; then + + modprobe cryptotest + + # Expected output in dmesg: + dmesg_grep 'Cryptotest init' + ret=$? + + if [ "${ret}" -eq 0 ]; then + result="pass" + else + result="fail" + fi + echo "modprobe-cryptotest ${result}" | tee -a ${RESULT_FILE} +fi + +if [ "${result}" = pass ]; then + + # Check device exists + if [ -c ${CRYPTO_DEVICE} ]; then + result="pass" + else + result="fail" + fi + echo "device-exists ${result}" | tee -a ${RESULT_FILE} +fi + +if [ "${result}" = pass ]; then + modprobe crypto-safexcel-eip28 + # Expected output in dmesg: + dmesg_grep 'crypto-safexcel-eip28 40044000.crypto_eip28: IRQ initialization is done' + irq_done=$? + dmesg_grep 'crypto-safexcel-eip28 40044000.crypto_eip28: HW initialization is done' + hw_init_done=$? + if [[ "${irq_done}" -eq 0 && "${hw_init_done}" -eq 0 ]]; then + result="pass" + else + result="fail" + fi + echo "modprobe-cryptotest ${result}" | tee -a ${RESULT_FILE} +fi + +if [ "${result}" = pass ]; then + ctests=/usr/bin/crypto_test/ctests + if [ -e "${ctests}" ]; then + result="pass" + else + result="fail" + fi + echo ctests-exist ${result} | tee -a ${RESULT_FILE} +fi + +if [ "${result}" = pass ]; then + logfile="${OUTPUT}/cunit-output" + /usr/bin/crypto_test/ctests | tee ${logfile} + + ## Parse output from test + info_msg "Parsing results from ${logfile}" + + # Expected output + # Number of failures : 0 + failures=$(grep 'Number of failures' ${logfile} | awk -F ':' '{gsub(/ /, "", $2); print $2}') + + if [ ${failures} -eq 0 ]; then + result="pass" + else + result="fail" + fi + echo "ctests ${result}" | tee -a ${RESULT_FILE} + +fi + +# cleanup +rmmod crypto-safexcel-eip28 +rmmod cryptotest diff --git a/automated/linux/cryptotest/cryptotest.yaml b/automated/linux/cryptotest/cryptotest.yaml new file mode 100644 index 0000000..765b870 --- /dev/null +++ b/automated/linux/cryptotest/cryptotest.yaml @@ -0,0 +1,21 @@ +metadata: + name: meminfo + format: "Lava-Test-Shell Test Definition 1.0" + description: "Schneider Electric cryptotest" + maintainer: + - ryan.harkin@linaro.org + os: + - oe + scope: + - functional + devices: + - rzn1d + +params: + CRYPTO_DEVICE: '/dev/cryptotest' + +run: + steps: + - cd ./automated/linux/cryptotest + - ./cryptotest.sh -c "${CRYPTO_DEVICE}" + - ../../utils/send-to-lava.sh ./output/result.txt |