Bug 193386: Patch to fips.sh to use temporary library for mangle test. r=alexei, sr=nelson
authorslavomir.katuscak%sun.com
Thu, 25 Jan 2007 12:40:33 +0000
changeset 7650 c413cd09e4e0e23838a8dc183e3c00d73b50d303
parent 7649 d7b15c1eaf973ae8fd10556121b96c81af73a80c
child 7652 d70110235221ae039c9222682b7e8bb5dcb9582f
push idunknown
push userunknown
push dateunknown
reviewersalexei, nelson
bugs193386
Bug 193386: Patch to fips.sh to use temporary library for mangle test. r=alexei, sr=nelson
security/nss/tests/fips/fips.sh
--- a/security/nss/tests/fips/fips.sh
+++ b/security/nss/tests/fips/fips.sh
@@ -169,51 +169,62 @@ fips_140()
   certutil -d ${P_R_FIPSDIR} -L 2>&1
   html_msg $? 0 "List the FIPS module certificates (certutil -L)"
 
   echo "$SCRIPTNAME: List the FIPS module keys --------------------------"
   echo "certutil -d ${P_R_FIPSDIR} -K -f ${R_FIPSPWFILE}"
   certutil -d ${P_R_FIPSDIR} -K -f ${R_FIPSPWFILE} 2>&1
   html_msg $? 0 "List the FIPS module keys (certutil -K)"
 
-#
-# This test was interfering with QA running on more than one machine pointing
-# to the same binary file. Turn it off for now.
-#
-#  echo "$SCRIPTNAME: Detect mangled database --------------------------"
-#  SOFTOKEN=${DIST}/${OBJDIR}/lib/${DLL_PREFIX}softokn3.${DLL_SUFFIX}
-#  echo "cp ${SOFTOKEN} ${TMP}/softokn3.sav"
-#  cp ${SOFTOKEN} ${TMP}/softokn3.sav
-#  echo "mangling ${SOFTOKEN}"
-#  echo "mangle -i ${SOFTOKEN} -o 60000 -b 5"
-#  mangle -i ${SOFTOKEN} -o 60000 -b 5 2>&1
-#  if [ $? -eq 0 ]; then
-#    echo "dbtest -r  -d ${P_R_FIPSDIR} "
-# suppress the expected failure message
-#    dbtest -r  -d ${P_R_FIPSDIR}  > ${TMP}/dbtestoutput.txt 2>&1
-#    html_msg $? 46 "Init NSS with a corrupted library (dbtest -r)"
-#    echo "cp ${TMP}/softokn3.sav ${SOFTOKEN}"
-#    cp ${TMP}/softokn3.sav ${SOFTOKEN}
-#  else
-#    html_msg 0 0 "Skipping corruption test, can't open ${DLL_PREFIX}softokn3.${DLL_SUFFIX}"
-#  fi
-#  echo "rm ${TMP}/softokn3.sav"
-#  rm ${TMP}/softokn3.sav
+  LIBDIR="${DIST}/${OBJDIR}/lib"
+  MANGLEDIR="${FIPSDIR}/mangle"
+   
+  # There are different versions of cp command on different systems, some of them 
+  # copies only symlinks, others doesn't have option to disable links, so there
+  # is needed to copy files one by one. 
+  echo "mkdir ${MANGLEDIR}"
+  mkdir ${MANGLEDIR}
+  for lib in `ls ${LIBDIR}`; do
+    echo "cp ${LIBDIR}/${lib} ${MANGLEDIR}"
+    cp ${LIBDIR}/${lib} ${MANGLEDIR}
+  done
+    
+  echo "$SCRIPTNAME: Detect mangled database --------------------------"
+  SOFTOKEN=${MANGLEDIR}/${DLL_PREFIX}softokn3.${DLL_SUFFIX}
+
+  echo "mangling ${SOFTOKEN}"
+  echo "mangle -i ${SOFTOKEN} -o 60000 -b 5"
+  mangle -i ${SOFTOKEN} -o 60000 -b 5 2>&1
+  if [ $? -eq 0 ]; then
+    if [ "${OS_ARCH}" = "WINNT" ]; then
+      DBTEST=`which dbtest`
+      echo "PATH=${MANGLEDIR} ${DBTEST} -r -d ${P_R_FIPSDIR}"
+      PATH="${MANGLEDIR}" ${DBTEST} -r -d ${P_R_FIPSDIR} > ${TMP}/dbtestoutput.txt 2>&1
+      RESULT=$?
+    else
+      echo "LD_LIBRARY_PATH=${MANGLEDIR} dbtest -r -d ${P_R_FIPSDIR}"
+      LD_LIBRARY_PATH="${MANGLEDIR}" dbtest -r -d ${P_R_FIPSDIR} > ${TMP}/dbtestoutput.txt 2>&1
+      RESULT=$?
+    fi  
+
+    html_msg ${RESULT} 46 "Init NSS with a corrupted library (dbtest -r)"
+  else
+    html_msg 0 0 "Skipping corruption test, can't open ${DLL_PREFIX}softokn3.${DLL_SUFFIX}"
+  fi
 }
 
 ############################## fips_cleanup ############################
 # local shell function to finish this script (no exit since it might be 
 # sourced)
 ########################################################################
 fips_cleanup()
 {
   html "</TABLE><BR>"
   cd ${QADIR}
   . common/cleanup.sh
 }
 
 ################## main #################################################
 
 fips_init
-
 fips_140
 fips_cleanup