nsprpub/pr/tests/runy2ktests.ksh

Wed, 31 Dec 2014 07:53:36 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:53:36 +0100
branch
TOR_BUG_3246
changeset 5
4ab42b5ab56c
permissions
-rw-r--r--

Correct small whitespace inconsistency, lost while renaming variables.

michael@0 1 #!/bin/ksh
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 #
michael@0 8 # runy2ktests.ksh
michael@0 9 # Set system clock to Y2K dates of interest and run the Y2K tests.
michael@0 10 # Needs root/administrator privilege
michael@0 11 #
michael@0 12 # WARNING: Because this script needs to be run with root/administrator
michael@0 13 # privilege, thorough understanding of the script and extreme
michael@0 14 # caution are urged.
michael@0 15 #
michael@0 16
michael@0 17 #
michael@0 18 # SECTION I
michael@0 19 # Define variables
michael@0 20 #
michael@0 21
michael@0 22 SYSTEM_INFO=`uname -a`
michael@0 23 OS_ARCH=`uname -s`
michael@0 24 if [ $OS_ARCH = "Windows_NT" ] || [ $OS_ARCH = "Windows_95" ]
michael@0 25 then
michael@0 26 NULL_DEVICE=nul
michael@0 27 else
michael@0 28 NULL_DEVICE=/dev/null
michael@0 29 fi
michael@0 30
michael@0 31 #
michael@0 32 # Test dates for NSPR Y2K tests
michael@0 33 #
michael@0 34 Y2KDATES=" 123123591998.55
michael@0 35 090923591999.55
michael@0 36 123123591999.55
michael@0 37 022823592000.55
michael@0 38 022923592000.55
michael@0 39 123123592000.55"
michael@0 40
michael@0 41 Y2KDATES_AIX=" 12312359.5598
michael@0 42 09092359.5599
michael@0 43 12312359.5599
michael@0 44 02282359.5500
michael@0 45 02292359.5500
michael@0 46 12312359.5500"
michael@0 47
michael@0 48 Y2KDATES_HPUX=" 123123591998
michael@0 49 090923591999
michael@0 50 123123591999
michael@0 51 022823592000
michael@0 52 022923592000
michael@0 53 123123592000"
michael@0 54
michael@0 55 Y2KDATES_MKS=" 1231235998.55
michael@0 56 0909235999.55
michael@0 57 1231235999.55
michael@0 58 0228235900.55
michael@0 59 0229235900.55
michael@0 60 1231235900.55"
michael@0 61
michael@0 62 #
michael@0 63 # NSPR Y2K tests
michael@0 64 #
michael@0 65 Y2KTESTS="
michael@0 66 y2k \n
michael@0 67 y2ktmo \n
michael@0 68 y2k \n
michael@0 69 ../runtests.ksh"
michael@0 70
michael@0 71 Y2KTESTS_HPUX="
michael@0 72 y2k \n
michael@0 73 y2ktmo -l 60\n
michael@0 74 y2k \n
michael@0 75 ../runtests.ksh"
michael@0 76
michael@0 77 #
michael@0 78 # SECTION II
michael@0 79 # Define functions
michael@0 80 #
michael@0 81
michael@0 82 save_date()
michael@0 83 {
michael@0 84 case $OS_ARCH in
michael@0 85 AIX)
michael@0 86 SAVED_DATE=`date "+%m%d%H%M.%S%y"`
michael@0 87 ;;
michael@0 88 HP-UX)
michael@0 89 SAVED_DATE=`date "+%m%d%H%M%Y"`
michael@0 90 ;;
michael@0 91 Windows_NT)
michael@0 92 SAVED_DATE=`date "+%m%d%H%M%y.%S"`
michael@0 93 ;;
michael@0 94 Windows_95)
michael@0 95 SAVED_DATE=`date "+%m%d%H%M%y.%S"`
michael@0 96 ;;
michael@0 97 *)
michael@0 98 SAVED_DATE=`date "+%m%d%H%M%Y.%S"`
michael@0 99 ;;
michael@0 100 esac
michael@0 101 }
michael@0 102
michael@0 103 set_date()
michael@0 104 {
michael@0 105 case $OS_ARCH in
michael@0 106 Windows_NT)
michael@0 107 #
michael@0 108 # The date command in MKS Toolkit releases 5.1 and 5.2
michael@0 109 # uses the current DST status for the date we want to
michael@0 110 # set the system clock to. However, the DST status for
michael@0 111 # that date may be different from the current DST status.
michael@0 112 # We can work around this problem by invoking the date
michael@0 113 # command with the same date twice.
michael@0 114 #
michael@0 115 date "$1" > $NULL_DEVICE
michael@0 116 date "$1" > $NULL_DEVICE
michael@0 117 ;;
michael@0 118 *)
michael@0 119 date "$1" > $NULL_DEVICE
michael@0 120 ;;
michael@0 121 esac
michael@0 122 }
michael@0 123
michael@0 124 restore_date()
michael@0 125 {
michael@0 126 set_date "$SAVED_DATE"
michael@0 127 }
michael@0 128
michael@0 129 savedate()
michael@0 130 {
michael@0 131 case $OS_ARCH in
michael@0 132 AIX)
michael@0 133 SAVED_DATE=`date "+%m%d%H%M.%S%y"`
michael@0 134 ;;
michael@0 135 HP-UX)
michael@0 136 SAVED_DATE=`date "+%m%d%H%M%Y"`
michael@0 137 ;;
michael@0 138 Windows_NT)
michael@0 139 SAVED_DATE=`date "+%m%d%H%M%y.%S"`
michael@0 140 ;;
michael@0 141 Windows_95)
michael@0 142 SAVED_DATE=`date "+%m%d%H%M%y.%S"`
michael@0 143 ;;
michael@0 144 *)
michael@0 145 SAVED_DATE=`date "+%m%d%H%M%Y.%S"`
michael@0 146 ;;
michael@0 147 esac
michael@0 148 }
michael@0 149
michael@0 150 set_y2k_test_parameters()
michael@0 151 {
michael@0 152 #
michael@0 153 # set dates
michael@0 154 #
michael@0 155 case $OS_ARCH in
michael@0 156 AIX)
michael@0 157 DATES=$Y2KDATES_AIX
michael@0 158 ;;
michael@0 159 HP-UX)
michael@0 160 DATES=$Y2KDATES_HPUX
michael@0 161 ;;
michael@0 162 Windows_NT)
michael@0 163 DATES=$Y2KDATES_MKS
michael@0 164 ;;
michael@0 165 Windows_95)
michael@0 166 DATES=$Y2KDATES_MKS
michael@0 167 ;;
michael@0 168 *)
michael@0 169 DATES=$Y2KDATES
michael@0 170 ;;
michael@0 171 esac
michael@0 172
michael@0 173 #
michael@0 174 # set tests
michael@0 175 #
michael@0 176 case $OS_ARCH in
michael@0 177 HP-UX)
michael@0 178 TESTS=$Y2KTESTS_HPUX
michael@0 179 ;;
michael@0 180 *)
michael@0 181 TESTS=$Y2KTESTS
michael@0 182 ;;
michael@0 183 esac
michael@0 184 }
michael@0 185
michael@0 186 #
michael@0 187 # runtests:
michael@0 188 # - runs each test in $TESTS after setting the
michael@0 189 # system clock to each date in $DATES
michael@0 190 #
michael@0 191
michael@0 192 runtests()
michael@0 193 {
michael@0 194 for newdate in ${DATES}
michael@0 195 do
michael@0 196 set_date $newdate
michael@0 197 echo $newdate
michael@0 198 echo "BEGIN\t\t\t`date`"
michael@0 199 echo "Date\t\t\t\t\tTest\t\t\tResult"
michael@0 200 echo $TESTS | while read prog
michael@0 201 do
michael@0 202 echo "`date`\t\t\c"
michael@0 203 echo "$prog\c"
michael@0 204 ./$prog >> ${LOGFILE} 2>&1
michael@0 205 if [ 0 = $? ] ; then
michael@0 206 echo "\t\t\tPassed";
michael@0 207 else
michael@0 208 echo "\t\t\tFAILED";
michael@0 209 fi;
michael@0 210 done
michael@0 211 echo "END\t\t\t`date`\n"
michael@0 212 done
michael@0 213
michael@0 214 }
michael@0 215
michael@0 216 #
michael@0 217 # SECTION III
michael@0 218 # Run tests
michael@0 219 #
michael@0 220
michael@0 221 LOGFILE=${NSPR_TEST_LOGFILE:-$NULL_DEVICE}
michael@0 222 OBJDIR=`basename $PWD`
michael@0 223 echo "\nNSPR Year 2000 Test Results - $OBJDIR\n"
michael@0 224 echo "SYSTEM:\t\t\t${SYSTEM_INFO}"
michael@0 225 echo "NSPR_TEST_LOGFILE:\t${LOGFILE}\n"
michael@0 226
michael@0 227
michael@0 228 save_date
michael@0 229
michael@0 230 #
michael@0 231 # Run NSPR Y2k and standard tests
michael@0 232 #
michael@0 233
michael@0 234 set_y2k_test_parameters
michael@0 235 runtests
michael@0 236
michael@0 237 restore_date

mercurial