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