added upstream testsuite wrapper
This commit is contained in:
parent
30eace5964
commit
d6f766d1cb
2 changed files with 241 additions and 0 deletions
39
Sanity/testsuite/main.fmf
Normal file
39
Sanity/testsuite/main.fmf
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
summary: Executes testsuite shipped with opencryptoki
|
||||
description: |
|
||||
it seems it should work with softoken on all architectures
|
||||
contact: Karel Srot <ksrot@redhat.com>
|
||||
component:
|
||||
- openCryptoki
|
||||
test: ./runtest.sh
|
||||
framework: beakerlib
|
||||
require:
|
||||
- url: https://src.fedoraproject.org/tests/opencryptoki.git
|
||||
name: /Library/token-manipulation
|
||||
recommend:
|
||||
- openCryptoki
|
||||
- opencryptoki
|
||||
- gcc
|
||||
- yum-utils
|
||||
- rpm-build
|
||||
- opencryptoki-swtok
|
||||
- opencryptoki-ccatok
|
||||
- opencryptoki-icatok
|
||||
duration: 100m
|
||||
enabled: true
|
||||
tag:
|
||||
- TIPfail_Security
|
||||
- noExpectedness
|
||||
# test duration is big for tiers
|
||||
- notier
|
||||
- rhel8-buildroot
|
||||
- rhel9-buildroot
|
||||
- rhel9_broken
|
||||
link:
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=644284
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1099175
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=904937
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=650482
|
||||
- relates: https://bugzilla.redhat.com/show_bug.cgi?id=1099193
|
||||
extra-nitrate: TC#0063178
|
||||
extra-summary: /CoreOS/openCryptoki/Sanity/testsuite
|
||||
extra-task: /CoreOS/openCryptoki/Sanity/testsuite
|
||||
202
Sanity/testsuite/runtest.sh
Executable file
202
Sanity/testsuite/runtest.sh
Executable file
|
|
@ -0,0 +1,202 @@
|
|||
#!/bin/bash
|
||||
# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# runtest.sh of /CoreOS/openCryptoki/Sanity/testsuite
|
||||
# Description: Executes testsuite shipped with openCryptoki
|
||||
# Author: Karel Srot <ksrot@redhat.com>
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#
|
||||
# Copyright (c) 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing
|
||||
# to use, modify, copy, or redistribute it subject to the terms
|
||||
# and conditions of the GNU General Public License version 2.
|
||||
#
|
||||
# This program is distributed in the hope that it will be
|
||||
# useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
# PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public
|
||||
# License along with this program; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
# Include rhts environment
|
||||
. /usr/share/beakerlib/beakerlib.sh || exit 1
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
# At the moment of creation of this test a lot of upstream tests
|
||||
# were not fully functional. Please check README documents and
|
||||
# try enable additional tests if possible
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
# find out package name
|
||||
PACKAGE="opencryptoki"
|
||||
|
||||
LOGDIR=`mktemp -d`
|
||||
|
||||
|
||||
function reset_tokens() {
|
||||
rlLogInfo "Reseting tokens..."
|
||||
rlServiceStop pkcsslotd
|
||||
rlRun "pkcsResetTokens"
|
||||
rlServiceStart pkcsslotd
|
||||
rlLogInfo "Initializing tokens..."
|
||||
rlRun "pkcsInitToken $SLOT"
|
||||
}
|
||||
|
||||
function get_test_id() {
|
||||
ID=`cat $TmpDir/testid`
|
||||
ID=$(( $ID+1 ))
|
||||
echo $ID > $TmpDir/testid
|
||||
echo $ID
|
||||
}
|
||||
|
||||
rlJournalStart
|
||||
rlPhaseStartSetup
|
||||
rlRun "rlImport opencryptoki/token-manipulation" || rlDie "Could not import opencryptoki/token-manipulation library"
|
||||
export PKCS11_USER_PIN=$pkcsUSER_PIN
|
||||
export PKCS11_SO_PIN=$pkcsSO_PIN
|
||||
rlAssertRpm $PACKAGE
|
||||
rlAssertRpm "openssl-devel"
|
||||
TmpDir=`mktemp -d`
|
||||
pushd $TmpDir
|
||||
rlFetchSrcForInstalled $PACKAGE
|
||||
rlRun "rpm -ivh $PACKAGE*.src.rpm" 0 "Installing $PACKAGE src rpm"
|
||||
rlRun "yum-builddep -y ~/rpmbuild/SPECS/opencryptoki.spec"
|
||||
# opencryptoki needs to enable building test cases during the pkg build
|
||||
rlRun "sed -i 's/^%configure /%configure --enable-testcases /' ~/rpmbuild/SPECS/opencryptoki.spec"
|
||||
rlRun "rpmbuild -bc ~/rpmbuild/SPECS/opencryptoki.spec &> build.log" 0 "Building opencryptoki files"
|
||||
tail build.log
|
||||
TESTDIR=`ls -d ~/rpmbuild/BUILD/opencryptoki*/testcases`
|
||||
|
||||
rlServiceStart pkcsslotd
|
||||
rlLogInfo "Available tokens"
|
||||
pkcsconf -t
|
||||
# allow to pass SLOT number as a parameter
|
||||
# or take the first available slot (Token)
|
||||
[ -z "$SLOT" ] && SLOT=`pkcsconf -t | sed -n 's/^Token #\([0-9]\).*/\1/gp' | head -n 1`
|
||||
rlLogInfo "Token under a test"
|
||||
pkcsconf -t -c $SLOT
|
||||
|
||||
NOSKIP=""
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!
|
||||
# tests doings writes are not skipped only for a softoken because they could descrease flash memory
|
||||
# lifetime on real tokens
|
||||
pkcsconf -t -c $SLOT | grep -qi 'soft' && NOSKIP="-noskip"
|
||||
rlPhaseEnd
|
||||
|
||||
echo 0 > $TmpDir/testid
|
||||
|
||||
rlPhaseStartTest "crypto"
|
||||
reset_tokens
|
||||
if [ -d $TESTDIR/crypto ]; then
|
||||
export PKCS11_USER_PIN=01234567
|
||||
export PKCS11_SO_PIN=76543210
|
||||
pushd $TESTDIR/crypto
|
||||
for TEST in *_tests; do
|
||||
# skip test if it is on TODO list in README
|
||||
if grep -A 1 $TEST README | grep -q TODO; then
|
||||
rlLogWarning "Skipping $TEST since it is on TODO list in README"
|
||||
else
|
||||
ID=`get_test_id`
|
||||
rlRun "./$TEST $NOSKIP -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
RESULT=$?
|
||||
grep Total $TmpDir/testlog.$ID
|
||||
rlAssertGrep 'Errors=0' $TmpDir/testlog.$ID
|
||||
rlAssertGrep 'Failed=0' $TmpDir/testlog.$ID
|
||||
# print log in case of error
|
||||
[ $RESULT -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID
|
||||
fi
|
||||
done
|
||||
popd
|
||||
else
|
||||
rlFail "No crypto tests available!"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "misc_tests"
|
||||
if [ -d $TESTDIR/misc_tests ]; then
|
||||
reset_tokens
|
||||
pushd $TESTDIR/misc_tests
|
||||
|
||||
# obj_mgmt_tests
|
||||
ID=`get_test_id`
|
||||
rlRun "./obj_mgmt_tests $NOSKIP -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
|
||||
#spinlock_tests.sh
|
||||
ID=`get_test_id`
|
||||
rlRun "./spinlock_tests.sh -s 1 -p 10 -l 20 &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
|
||||
#fork
|
||||
ID=`get_test_id`
|
||||
rlRun "./fork -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
|
||||
popd
|
||||
else
|
||||
rlFail "No misc_tests test available!"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "pkcs11"
|
||||
if [ -d $TESTDIR/pkcs11 ]; then
|
||||
reset_tokens
|
||||
pushd $TESTDIR/pkcs11
|
||||
for TEST in get_interface attribute copyobjects findobjects generate_keypair; do
|
||||
ID=`get_test_id`
|
||||
rlRun "./$TEST $NOSKIP -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
RESULT=$?
|
||||
grep Total $TmpDir/testlog.$ID
|
||||
rlAssertGrep 'Errors=0' $TmpDir/testlog.$ID
|
||||
rlAssertGrep 'Failed=0' $TmpDir/testlog.$ID
|
||||
# print log in case of error
|
||||
[ $RESULT -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID
|
||||
done
|
||||
|
||||
# now run additiona tests with specific
|
||||
#sess_opstate
|
||||
ID=`get_test_id`
|
||||
rlRun "./sess_opstate -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
rlAssertGrep "TESTCASE sess_opstate_funcs PASS" $TmpDir/testlog.$ID
|
||||
|
||||
#getobjectsize
|
||||
ID=`get_test_id`
|
||||
rlRun "./getobjectsize -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
rlAssertGrep "C_GetObjectSize test passed" $TmpDir/testlog.$ID
|
||||
|
||||
#hw_fn
|
||||
ID=`get_test_id`
|
||||
rlRun "./hw_fn -slot $SLOT &> $TmpDir/testlog.$ID"
|
||||
[ $? -gt 0 ] && echo -e "Test log:\n" && cat $TmpDir/testlog.$ID # print log in case of error
|
||||
rlAssertGrep "Hardware Feature tests succeeded." $TmpDir/testlog.$ID
|
||||
|
||||
popd
|
||||
|
||||
else
|
||||
rlFail "No pkcs11_tests test available!"
|
||||
fi
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun "popd"
|
||||
rlBundleLogs testlogs $TmpDir/testlog* build.log
|
||||
#rlRun "rpmbuild --clean -bp ~/rpmbuild/SPECS/opencryptoki.spec" 0 "Clean the BUILD root"
|
||||
rlRun "rm -rf $TmpDir"
|
||||
[ -d $TESTDIR ] && rlRun "rm -rf $TESTDIR"
|
||||
rlFileRestore
|
||||
rlRun "pkcsRestoreTokens"
|
||||
rlServiceRestore pkcsslotd
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalPrintText
|
||||
rlJournalEnd
|
||||
Loading…
Add table
Add a link
Reference in a new issue