PageRenderTime 64ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/libs/js/nsprpub/pr/tests/runy2ktests.ksh

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