summaryrefslogtreecommitdiff
path: root/automated/linux/openssl/openssl-speed.sh
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2016-10-20 16:11:55 +0800
committerChase Qi <chase.qi@linaro.org>2016-10-20 16:11:55 +0800
commitbc262f5c23355b814d89494c940292ca87f3f943 (patch)
treec8da88a5eab8a19f7c44388712789df5aff54df6 /automated/linux/openssl/openssl-speed.sh
parent325c4ecfc4ad9f959643267b7322066a0363eaaf (diff)
v2: linux: add openssl speed test
* Migrated ubuntu/openssl.yaml to v2 * Added more symmetric algorithms * Added two asymmetric algorithms, RSA and DSA Change-Id: I03a5ba90ae8b3ee77c8bde83067c6732812e159e Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/linux/openssl/openssl-speed.sh')
-rwxr-xr-xautomated/linux/openssl/openssl-speed.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/automated/linux/openssl/openssl-speed.sh b/automated/linux/openssl/openssl-speed.sh
new file mode 100755
index 0000000..574273b
--- /dev/null
+++ b/automated/linux/openssl/openssl-speed.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+
+usage() {
+ echo "Usage: $0 [-s <true|false>]" 1>&2
+ exit 1
+}
+
+while getopts "s:" o; do
+ case "$o" in
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+! check_root && error_msg "You need to be root to run this script."
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+
+pkgs="openssl"
+install_deps "${pkgs}" "${SKIP_INSTALL}"
+
+# Record openssl vesion as it has a big impact on test reuslt.
+openssl_version="$(openssl version | awk '{print $2}')"
+add_metric "openssl-version" "pass" "${openssl_version}" "version"
+
+# Test run.
+cipher_commands="md5 sha1 sha256 sha512 des des-ede3 aes-128-cbc aes-192-cbc \
+ aes-256-cbc rsa2048 dsa2048"
+for test in ${cipher_commands}; do
+ echo
+ info_msg "Running openssl speed ${test} test"
+ openssl speed "${test}" 2>&1 | tee "${OUTPUT}/${test}-output.txt"
+
+ case "${test}" in
+ # Parse asymmetric encryption output.
+ rsa2048|dsa2048)
+ awk -v test_case_id="${test}" 'match($1$2, test_case_id) \
+ {printf("%s-sign pass %s sign/s\n", test_case_id, $(NF-1)); \
+ printf("%s-verify pass %s verify/s\n", test_case_id, $NF)}' \
+ "${OUTPUT}/${test}-output.txt" | tee -a "${RESULT_FILE}"
+ ;;
+ # Parse symmetric encryption output.
+ des|des-ede3|aes-128-cbc|aes-192-cbc|aes-256-cbc)
+ awk -v test_case_id="${test}" \
+ '/^Doing/ {printf("%s-%s pass %d bytes/s\n", test_case_id, $7, $7*$10/3)}' \
+ "${OUTPUT}/${test}-output.txt" | tee -a "${RESULT_FILE}"
+ ;;
+ *)
+ awk -v test_case_id="${test}" \
+ '/^Doing/ {printf("%s-%s pass %d bytes/s\n", test_case_id, $6, $6*$9/3)}' \
+ "${OUTPUT}/${test}-output.txt" | tee -a "${RESULT_FILE}"
+ ;;
+ esac
+done