From: inoguchi Date: Sat, 8 Sep 2018 09:34:12 +0000 (+0000) Subject: Split test blocks into a function. Test contents are not changed. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=25e43152f157d80b33a22136cc0daa8f89ae3bfd;p=openbsd Split test blocks into a function. Test contents are not changed. --- diff --git a/regress/usr.bin/openssl/appstest.sh b/regress/usr.bin/openssl/appstest.sh index 744153412bf..f2666011c39 100755 --- a/regress/usr.bin/openssl/appstest.sh +++ b/regress/usr.bin/openssl/appstest.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $OpenBSD: appstest.sh,v 1.11 2018/09/08 03:39:51 inoguchi Exp $ +# $OpenBSD: appstest.sh,v 1.12 2018/09/08 09:34:12 inoguchi Exp $ # # Copyright (c) 2016 Kinichiro Inoguchi # @@ -23,15 +23,6 @@ # output : all files generated by this script go under $ssldir # -openssl_bin=${OPENSSL:-/usr/bin/openssl} - -uname_s=`uname -s | grep 'MINGW'` -if [ "$uname_s" = "" ] ; then - mingw=0 -else - mingw=1 -fi - function section_message { echo "" echo "#---------#---------#---------#---------#---------#---------#---------#--------" @@ -70,43 +61,8 @@ function usage { echo "usage: appstest.sh [-q]" } -no_long_tests=0 - -while [ "$1" != "" ]; do - case $1 in - -q | --quick ) shift - no_long_tests=1 - ;; - * ) usage - exit 1 - esac -done - #---------#---------#---------#---------#---------#---------#---------#--------- - -# -# create ssldir, and all files generated by this script goes under this dir. -# -ssldir="appstest_dir" - -if [ -d $ssldir ] ; then - echo "directory [ $ssldir ] exists, this script deletes this directory ..." - /bin/rm -rf $ssldir -fi - -mkdir -p $ssldir - -export OPENSSL_CONF=$ssldir/openssl.cnf -touch $OPENSSL_CONF - -user1_dir=$ssldir/user1 -mkdir -p $user1_dir - -key_dir=$ssldir/key -mkdir -p $key_dir - -#---------#---------#---------#---------#---------#---------#---------#--------- - +function test_usage_lists_others { # === COMMAND USAGE === section_message "COMMAND USAGE" @@ -192,9 +148,10 @@ check_exit_status $? $openssl_bin rand -hex 100 check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_md { # === MESSAGE DIGEST COMMANDS === section_message "MESSAGE DIGEST COMMANDS" @@ -223,9 +180,10 @@ for d in $digests ; do -out $dgstdat.$d.cmac $dgstdat check_exit_status $? done +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_encoding_cipher { # === ENCODING AND CIPHER COMMANDS === section_message "ENCODING AND CIPHER COMMANDS" @@ -251,9 +209,10 @@ for c in $ciphers ; do cmp $encfile $encfile-$c.dec check_exit_status $? done +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_key { # === various KEY operations === section_message "various KEY operations" @@ -427,20 +386,16 @@ check_exit_status $? $openssl_bin pkeyutl -verifyrecover -in $pkeyutlsig -inkey $genpkey_rsa check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_pki { section_message "setup local CA" # # prepare test openssl.cnf # -ca_dir=$ssldir/testCA -tsa_dir=$ssldir/testTSA -ocsp_dir=$ssldir/testOCSP -server_dir=$ssldir/server - cat << __EOF__ > $ssldir/openssl.cnf oid_section = new_oids [ new_oids ] @@ -793,9 +748,10 @@ user1_cert=$user1_dir/user1_cert.pem $openssl_bin ca -batch -cert $ca_cert -keyfile $ca_key -key $ca_pass \ -in $user1_csr -out $user1_cert check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_tsa { # --- TSA operations --- section_message "TSA operations" @@ -833,9 +789,10 @@ start_message "ts ... verify time stamp response" $openssl_bin ts -verify -queryfile $tsa_tsq -in $tsa_tsr -CAfile $ca_cert -untrusted $tsa_cert check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_smime { # --- S/MIME operations --- section_message "S/MIME operations" @@ -861,9 +818,10 @@ start_message "smime ... verify message" $openssl_bin smime -verify -in $smime_msg -signer $user1_cert -CAfile $ca_cert -out $smime_ver check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_ocsp { # --- OCSP operations --- section_message "OCSP operations" @@ -902,9 +860,10 @@ ocsp_qry=$user1_dir/ocsp_qry.der $openssl_bin ocsp -issuer $ca_cert -cert $server_cert -cert $revoke_cert \ -CAfile $ca_cert -url http://localhost:$ocsp_port -resp_text -respout $ocsp_qry > $ocsp_qry.out 2>&1 check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_pkcs { # --- PKCS operations --- section_message "PKCS operations" @@ -937,9 +896,10 @@ start_message "pkcs12 ... to PEM" $openssl_bin pkcs12 -in $server_cert.p12 -passin pass:$pkcs_pass \ -passout pass:$pkcs_pass -out $server_cert.p12.pem check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_server_client { # --- client/server operations (TLS) --- section_message "client/server operations (TLS)" @@ -1083,9 +1043,10 @@ $openssl_bin sess_id -in $sess_dat -text -out $sess_dat.out check_exit_status $? stop_s_server +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_speed { # === PERFORMANCE === section_message "PERFORMANCE" @@ -1096,18 +1057,81 @@ if [ $no_long_tests = 0 ] ; then else start_message "SKIPPNG speed (quick mode)" fi +} #---------#---------#---------#---------#---------#---------#---------#--------- - +function test_version { # --- VERSION INFORMATION --- section_message "VERSION INFORMATION" start_message "version" $openssl_bin version -a check_exit_status $? +} #---------#---------#---------#---------#---------#---------#---------#--------- +openssl_bin=${OPENSSL:-/usr/bin/openssl} + +no_long_tests=0 + +while [ "$1" != "" ]; do + case $1 in + -q | --quick ) shift + no_long_tests=1 + ;; + * ) usage + exit 1 + esac +done + +# +# create ssldir, and all files generated by this script goes under this dir. +# +ssldir="appstest_dir" + +if [ -d $ssldir ] ; then + echo "directory [ $ssldir ] exists, this script deletes this directory ..." + /bin/rm -rf $ssldir +fi + +mkdir -p $ssldir + +ca_dir=$ssldir/testCA +tsa_dir=$ssldir/testTSA +ocsp_dir=$ssldir/testOCSP +server_dir=$ssldir/server +user1_dir=$ssldir/user1 +mkdir -p $user1_dir +key_dir=$ssldir/key +mkdir -p $key_dir + +export OPENSSL_CONF=$ssldir/openssl.cnf +touch $OPENSSL_CONF + +uname_s=`uname -s | grep 'MINGW'` +if [ "$uname_s" = "" ] ; then + mingw=0 +else + mingw=1 +fi + +# +# process tests +# +test_usage_lists_others +test_md +test_encoding_cipher +test_key +test_pki +test_tsa +test_smime +test_ocsp +test_pkcs +test_server_client +test_speed +test_version + section_message "END" exit 0