This patch removes moves ock_tests.sh to ock_tests.sh.in in
order to have it processed at build time. Time allow us to
use the pathnames used by the overall build process.

Signed-off-by: Klaus Heinrich Kiwi <[email protected]>
---
 testcases/Makefile.am     |   13 +++
 testcases/ock_tests.sh    |  208 ---------------------------------------------
 testcases/ock_tests.sh.in |  208 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 221 insertions(+), 208 deletions(-)
 delete mode 100755 testcases/ock_tests.sh
 create mode 100755 testcases/ock_tests.sh.in

diff --git a/testcases/Makefile.am b/testcases/Makefile.am
index baea5a4..0a0c878 100644
--- a/testcases/Makefile.am
+++ b/testcases/Makefile.am
@@ -1 +1,14 @@
+noinst_SCRIPTS = ock_tests.sh
+
+EXTRA_DIST = ock_tests.sh.in
+
+CLEANFILES = ock_tests.sh
+
+ock_tests.sh: ock_tests.sh.in
+       @SED@   -e s...@localstatedir\@!"@localstatedir@"!g     \
+               -e s...@sbindir\@!"@sbindir@"!g                 \
+               -e s...@libdir\@!"@libdir@"!g < $< > $...@-t
+       @CHMOD@ a+x $...@-t
+       mv $...@-t $@
+
 SUBDIRS=common driver init_tok mkobj oc-digest rsa_keygen rsa_test speed 
test_crypto threadmkobj tok_obj v2.11 login
diff --git a/testcases/ock_tests.sh b/testcases/ock_tests.sh
deleted file mode 100755
index 16078b4..0000000
--- a/testcases/ock_tests.sh
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/bin/bash
-#
-#
-#   Copyright (C) International Business Machines  Corp., 2008
-#
-#   This program is free software;  you can redistribute it and/or modify
-#   it under the terms of the GNU General Public License as published by
-#   the Free Software Foundation; either version 2 of the License, or
-#   (at your option) any later version.
-#
-#   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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-#
-# NAME
-#      ocktests.sh
-#
-# DESCRIPTION
-#      Simple Bash script that checks the enviroment in which the ock-tests 
will run
-#      and starts them.
-#
-# ALGORITHM
-#      None.
-#
-# USAGE
-#
-# HISTORY
-#      Rajiv Andrade <[email protected]>
-#
-# RESTRICTIONS
-#      None.
-##
-
-LOGGING=0
-LOGFILE="$PWD/ock-tests.log"
-ERR_SUMMARY="$PWD/ock-tests.err"
-TCSD="/usr/sbin/tcsd"
-PKCONF="/var/lib/opencryptoki/pk_config_data"
-PKCSCONFBIN="/usr/sbin/pkcsconf"
-TESTCONF="$PWD/ock-tests.config"
-OCKDIR="/var/lib/opencryptoki"
-STDLLDIR="/usr/lib/pkcs11/stdll"
-CONFSTART="/usr/sbin/pkcs11_startup"
-
-usage()
-{
-       cat <<-END >&2
-
-       usage: ./ock_tests.sh [-s <slot>] [-l <logfile>] [-n] [-h]
-               -l        logfile to redirect output to (default is command 
line)
-               -h        display this help
-               -q        run quietly - display only total number of tests 
passed/failed
-               -s <slot> slot against which the testcases will run
-               -n        don't stop in case one of the testcases fail
-       END
-       exit -1
-}
-
-
-while getopts s:l:hc:n arg
-do
-       case $arg in
-               h)
-                       usage
-                       ;;
-               l)
-                       LOGGING=1
-                       if [ -n $OPTARG ]
-                       then
-                               LOGFILE="$OPTARG"
-                       fi
-                       touch $LOGFILE
-                       ;;
-               c)
-                       TESTCONF="$OPTARG"
-                       touch $TESTCONF
-                       ;;
-               n)      
-                       NO_STOP="-nostop"
-                       ;;
-               s)
-                       SLOT="$OPTARG"
-                       ;;
-       esac
-done
-
-check_slots()
-{
-       [ -d $OCKDIR ] || echo "$OCKDIR not present"
-
-       #pkcsslotd running?
-       if [ -z "`pgrep pkcsslotd`" ]
-       then 
-               echo "Error: pkcsslotd not started"
-               exit -1
-       fi
-
-       #Are all the tokens listed in pk_config_data loaded?
-       for i in $( cat $PKCONF | awk -F \| '{print $3}' )
-       do
-               if [ -z "`$PKCSCONFBIN -s | grep $i`" ]
-               then
-                       echo "Warning: Token not loaded: $i"
-               
-                       if [ -n "`echo $i | grep -i TPM`" ]
-                       then
-                               [ -n "`pgrep tcsd`" ] || echo " TCSD not 
running"
-                               [ -n "`lsmod | grep tpm`" ] || echo " TPM 
kernel module not loaded"
-                       fi
-                       echo
-               fi
-       done
-}
-
-check_files()
-{
-       #Not implemented yet
-       #[ -e $TESTCONF ] || touch $TESTCONF #echo "Config file missing"
-       
-       #Is the TCSD present?
-       if grep -i tpm $PKCONF && [ ! -e $TCSD ] 
-       then
-               echo "Error: TCSD not present"
-               exit -1
-       fi
-       
-
-       #Checks if for each token in $PKCFONF there is a .so file.
-       if [ -e $PKCONF ] 
-       then
-               for i in $( cat $PKCONF | awk -F \| '{print $13}' )
-               do
-                       if [ ! -e $STDLLDIR/$i ]
-                       then
-                               echo "Error: $i not present"
-                               exit -1
-                       fi
-               done
-
-       else
-               echo "Error: pk_config_data is missing"
-               exit -1
-       fi
-}
-
-check_environment_vars()
-{
-
-       if [ `env | grep -c PKCS11` -lt 2 ] 
-       then
-               [ -n "`env | grep PKCS11_SO_PIN`" ] ||  echo "Error: 
PKCS11_SO_PIN not set"
-               [ -n "`env | grep PKCS11_USER_PIN`" ] ||  echo "Error: 
PKCS11_USER_PIN not set"
-               exit -1
-       fi
-       
-       i=`env | grep PKCSLIB | sed "s/PKCSLIB=//"`
-
-       if [ -z "$i" ]
-       then
-               echo "Warning: PKCSLIB not set."
-               echo " It should point to libopencryptoki.so or PKCS11_API.so"
-       elif [ -z "`echo $i | grep libopencryptoki.so`" ] && [ -z "`echo $i | 
grep PKCS11_API.so`" ]
-       then
-               echo "Error: PKCSLIB pointing to an unknown .so file"
-               env | grep PKCSLIB
-               exit -1
-       fi
-
-}
-run_tests()
-{
-       
-       for i in $( $PKCSCONFBIN -t | grep Info: | awk {'print $2'} | sed 
's/#//' ) 
-       do
-               if [ -z "$SLOT" ] || [ "$SLOT" = "$i" ]
-               then
-                       for j in $( ls driver/*tests )
-                               do
-                               echo "=====Now executing '$j'======"
-                               $j -slot $i $NO_STOP 2>&1
-                       done
-               fi
-       done
-}
-
-main_script()
-{
-       check_slots
-       check_files
-       check_environment_vars
-       run_tests 
-}
-
-if [ "$LOGGING" = "1" ]
-then
-       main_script >>$LOGFILE 2>&1
-else
-       main_script
-fi
-
-exit 0
-
diff --git a/testcases/ock_tests.sh.in b/testcases/ock_tests.sh.in
new file mode 100755
index 0000000..ca474b6
--- /dev/null
+++ b/testcases/ock_tests.sh.in
@@ -0,0 +1,208 @@
+#!/bin/bash
+#
+#
+#   Copyright (C) International Business Machines  Corp., 2008
+#
+#   This program is free software;  you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+#
+# NAME
+#      ocktests.sh
+#
+# DESCRIPTION
+#      Simple Bash script that checks the enviroment in which the ock-tests 
will run
+#      and starts them.
+#
+# ALGORITHM
+#      None.
+#
+# USAGE
+#
+# HISTORY
+#      Rajiv Andrade <[email protected]>
+#
+# RESTRICTIONS
+#      None.
+##
+
+LOGGING=0
+LOGFILE="$PWD/ock-tests.log"
+ERR_SUMMARY="$PWD/ock-tests.err"
+TCSD="/usr/sbin/tcsd"
+PKCONF="@localstatedir@/lib/opencryptoki/pk_config_data"
+PKCSCONFBIN="@sbindir@/pkcsconf"
+TESTCONF="$PWD/ock-tests.config"
+OCKDIR="lib/opencryptoki"
+STDLLDIR="@libdir@/pkcs11/stdll"
+CONFSTART="@sbindir@/pkcs11_startup"
+
+usage()
+{
+       cat <<-END >&2
+
+       usage: ./ock_tests.sh [-s <slot>] [-l <logfile>] [-n] [-h]
+               -l        logfile to redirect output to (default is command 
line)
+               -h        display this help
+               -q        run quietly - display only total number of tests 
passed/failed
+               -s <slot> slot against which the testcases will run
+               -n        don't stop in case one of the testcases fail
+       END
+       exit -1
+}
+
+
+while getopts s:l:hc:n arg
+do
+       case $arg in
+               h)
+                       usage
+                       ;;
+               l)
+                       LOGGING=1
+                       if [ -n $OPTARG ]
+                       then
+                               LOGFILE="$OPTARG"
+                       fi
+                       touch $LOGFILE
+                       ;;
+               c)
+                       TESTCONF="$OPTARG"
+                       touch $TESTCONF
+                       ;;
+               n)
+                       NO_STOP="-nostop"
+                       ;;
+               s)
+                       SLOT="$OPTARG"
+                       ;;
+       esac
+done
+
+check_slots()
+{
+       [ -d $OCKDIR ] || echo "$OCKDIR not present"
+
+       #pkcsslotd running?
+       if [ -z "`pgrep pkcsslotd`" ]
+       then
+               echo "Error: pkcsslotd not started"
+               exit -1
+       fi
+
+       #Are all the tokens listed in pk_config_data loaded?
+       for i in $( cat $PKCONF | awk -F \| '{print $3}' )
+       do
+               if [ -z "`$PKCSCONFBIN -s | grep $i`" ]
+               then
+                       echo "Warning: Token not loaded: $i"
+
+                       if [ -n "`echo $i | grep -i TPM`" ]
+                       then
+                               [ -n "`pgrep tcsd`" ] || echo " TCSD not 
running"
+                               [ -n "`lsmod | grep tpm`" ] || echo " TPM 
kernel module not loaded"
+                       fi
+                       echo
+               fi
+       done
+}
+
+check_files()
+{
+       #Not implemented yet
+       #[ -e $TESTCONF ] || touch $TESTCONF #echo "Config file missing"
+
+       #Is the TCSD present?
+       if grep -i tpm $PKCONF && [ ! -e $TCSD ]
+       then
+               echo "Error: TCSD not present"
+               exit -1
+       fi
+
+
+       #Checks if for each token in $PKCFONF there is a .so file.
+       if [ -e $PKCONF ]
+       then
+               for i in $( cat $PKCONF | awk -F \| '{print $13}' )
+               do
+                       if [ ! -e $STDLLDIR/$i ]
+                       then
+                               echo "Error: $i not present"
+                               exit -1
+                       fi
+               done
+
+       else
+               echo "Error: pk_config_data is missing"
+               exit -1
+       fi
+}
+
+check_environment_vars()
+{
+
+       if [ `env | grep -c PKCS11` -lt 2 ]
+       then
+               [ -n "`env | grep PKCS11_SO_PIN`" ] ||  echo "Error: 
PKCS11_SO_PIN not set"
+               [ -n "`env | grep PKCS11_USER_PIN`" ] ||  echo "Error: 
PKCS11_USER_PIN not set"
+               exit -1
+       fi
+
+       i=`env | grep PKCSLIB | sed "s/PKCSLIB=//"`
+
+       if [ -z "$i" ]
+       then
+               echo "Warning: PKCSLIB not set."
+               echo " It should point to libopencryptoki.so or PKCS11_API.so"
+       elif [ -z "`echo $i | grep libopencryptoki.so`" ] && [ -z "`echo $i | 
grep PKCS11_API.so`" ]
+       then
+               echo "Error: PKCSLIB pointing to an unknown .so file"
+               env | grep PKCSLIB
+               exit -1
+       fi
+
+}
+run_tests()
+{
+
+       for i in $( $PKCSCONFBIN -t | grep Info: | awk {'print $2'} | sed 
's/#//' )
+       do
+               if [ -z "$SLOT" ] || [ "$SLOT" = "$i" ]
+               then
+                       for j in $( ls driver/*tests )
+                               do
+                               echo "=====Now executing '$j'======"
+                               $j -slot $i $NO_STOP 2>&1
+                       done
+               fi
+       done
+}
+
+main_script()
+{
+       check_slots
+       check_files
+       check_environment_vars
+       run_tests
+}
+
+if [ "$LOGGING" = "1" ]
+then
+       main_script >>$LOGFILE 2>&1
+else
+       main_script
+fi
+
+exit 0
+
-- 
1.6.2.5


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to