Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(848)

Unified Diff: src/platform/vboot_reference/tests/gen_test_cases.sh

Issue 1101004: Vboot Reference: Spring cleaning of test scripts. (Closed)
Patch Set: review fixes. Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/platform/vboot_reference/tests/gen_test_cases.sh
diff --git a/src/platform/vboot_reference/tests/gen_test_cases.sh b/src/platform/vboot_reference/tests/gen_test_cases.sh
index b15921d61e00ce0045ea747a4b4c6081dba518a5..bad7e334d46a77ba76a832db467f1637a8f72dbb 100755
--- a/src/platform/vboot_reference/tests/gen_test_cases.sh
+++ b/src/platform/vboot_reference/tests/gen_test_cases.sh
@@ -6,49 +6,39 @@
# Generate test cases for use for the RSA verify benchmark.
-KEY_DIR=testkeys
-TESTCASE_DIR=testcases
-UTIL_DIR=../utils/
-TEST_FILE=test_file
-TEST_FILE_SIZE=1000000
+# Load common constants and variables.
+. "$(dirname "$0")/common.sh"
-hash_algos=( sha1 sha256 sha512 )
-key_lengths=( 1024 2048 4096 8192 )
+TEST_FILE=${TESTCASE_DIR}/test_file
+TEST_FILE_SIZE=1000000
-# Generate public key signatures and digest on an input file for
-# various combinations of message digest algorithms and RSA key sizes.
+# Generate public key signatures on an input file for various combinations
+# of message digest algorithms and RSA key sizes.
function generate_test_signatures {
+ echo "Generating test signatures..."
algorithmcounter=0
for keylen in ${key_lengths[@]}
do
for hashalgo in ${hash_algos[@]}
do
- openssl dgst -${hashalgo} -binary -out $1.${hashalgo}.digest $1
- ${UTIL_DIR}/signature_digest $algorithmcounter $1 | openssl rsautl -sign \
- -pkcs -inkey ${KEY_DIR}/key_rsa${keylen}.pem \
- > $1.rsa${keylen}_${hashalgo}.sig
+ openssl dgst -${hashalgo} -binary ${TEST_FILE} > \
+ ${TEST_FILE}.${hashalgo}.digest
+ ${UTIL_DIR}/signature_digest_utility $algorithmcounter \
+ ${TEST_FILE} | openssl rsautl \
+ -sign -pkcs -inkey ${TESTKEY_DIR}/key_rsa${keylen}.pem \
+ > ${TEST_FILE}.rsa${keylen}_${hashalgo}.sig
let algorithmcounter=algorithmcounter+1
done
done
}
-function pre_work {
- # Generate a file with random bytes for signature tests.
+# Generate a file with random bytes for signature tests.
+function generate_test_file {
echo "Generating test file..."
- dd if=/dev/urandom of=${TESTCASE_DIR}/${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
+ dd if=/dev/urandom of=${TEST_FILE} bs=${TEST_FILE_SIZE} count=1
}
-if [ ! -d "$KEY_DIR" ]
-then
- echo "You must run gen_test_cases.sh to generate test keys first."
- exit 1
-fi
-
-if [ ! -d "$TESTCASE_DIR" ]
-then
- mkdir "$TESTCASE_DIR"
-fi
-
-pre_work
-echo "Generating test signatures..."
-generate_test_signatures ${TESTCASE_DIR}/$TEST_FILE
+mkdir -p ${TESTCASE_DIR}
+check_test_keys
+generate_test_file
+generate_test_signatures
« no previous file with comments | « src/platform/vboot_reference/tests/gen_fuzz_test_cases.sh ('k') | src/platform/vboot_reference/tests/gen_test_keys.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698