runy2ktests.ksh 3.5 KB

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