check.tpl 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. [= autogen5 template sh=check.sh =]
  2. [=
  3. #
  4. # This file contains the shell template to run tests on the fixes
  5. #
  6. =]#!/bin/sh
  7. set -e
  8. TESTDIR=tests
  9. TESTBASE=`cd $1;${PWDCMD-pwd}`
  10. [ -d ${TESTDIR} ] || mkdir ${TESTDIR}
  11. cd ${TESTDIR}
  12. TESTDIR=`${PWDCMD-pwd}`
  13. TARGET_MACHINE='*'
  14. DESTDIR=`${PWDCMD-pwd}`/res
  15. SRCDIR=`${PWDCMD-pwd}`/inc
  16. FIND_BASE='.'
  17. VERBOSE=[=` echo ${VERBOSE-1} `=]
  18. INPUT=`${PWDCMD-pwd}`
  19. ORIGDIR=${INPUT}
  20. export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR
  21. rm -rf ${DESTDIR} ${SRCDIR}
  22. mkdir ${DESTDIR} ${SRCDIR}
  23. (
  24. [=
  25. (shellf
  26. "for f in %s
  27. do case $f in
  28. */* ) echo $f | sed 's;/[^/]*$;;' ;;
  29. esac
  30. done | sort -u | \
  31. while read g
  32. do echo \" mkdir \\${SRCDIR}/$g || mkdir -p \\${SRCDIR}/$g || exit 1\"
  33. done" (join " " (stack "fix.files")) ) =]
  34. ) 2> /dev/null[= # suppress 'No such file or directory' messages =]
  35. cd inc
  36. [=
  37. (define sfile "")
  38. (define HACK "")
  39. (define dfile "") =][=
  40. FOR fix =][=
  41. IF (> (count "test_text") 1) =][=
  42. (set! HACK (string-upcase! (get "hackname")))
  43. (set! sfile (if (exist? "files") (get "files[]") "testing.h"))
  44. (set! dfile (string-append
  45. (if (*==* sfile "/")
  46. (shellf "echo \"%s\"|sed 's,/[^/]*,/,'" sfile )
  47. "" )
  48. (string-tr! (get "hackname") "_A-Z" "-a-z")
  49. ) ) =][=
  50. FOR test_text (for-from 1) =]
  51. cat >> [=(. sfile)=] <<_HACK_EOF_
  52. #if defined( [=(. HACK)=]_CHECK_[=(for-index)=] )
  53. [=test_text=]
  54. #endif /* [=(. HACK)=]_CHECK_[=(for-index)=] */
  55. _HACK_EOF_
  56. echo [=(. sfile)=] | ../../fixincl
  57. mv -f [=(. sfile)=] [=(. dfile)=]-[=(for-index)=].h
  58. [ -f ${DESTDIR}/[=(. sfile)=] ] && [=#
  59. =]mv ${DESTDIR}/[=(. sfile)=] ${DESTDIR}/[=(. dfile)=]-[=(for-index)=].h[=
  60. ENDFOR test_text =][=
  61. ENDIF multi-test =][=
  62. ENDFOR fix
  63. =][=
  64. FOR fix =][=
  65. (set! HACK (string-upcase! (get "hackname"))) =][=
  66. IF (not (exist? "test_text")) =][=
  67. (if (not (exist? "replace"))
  68. (error (sprintf "include fix '%s' has no test text"
  69. (get "hackname") )) )
  70. =][=
  71. ELSE =]
  72. cat >> [= (raw-shell-str (if (exist? "files") (get "files[0]") "testing.h"))
  73. =] <<_HACK_EOF_
  74. #if defined( [=(. HACK)=]_CHECK )
  75. [=test_text=]
  76. #endif /* [=(. HACK)=]_CHECK */
  77. _HACK_EOF_
  78. [=ENDIF =][=
  79. ENDFOR fix
  80. =]
  81. export TEST_MODE=true
  82. find . -type f | sed 's;^\./;;' | sort | ../../fixincl
  83. cd ${DESTDIR}
  84. exitok=true
  85. find * -type f -print > ${TESTDIR}/LIST
  86. # Special hack for sys/types.h: the #define-d types for size_t,
  87. # ptrdiff_t and wchar_t are different for each port. Therefore,
  88. # strip off the defined-to type so that the test results are the
  89. # same for all platforms.
  90. #
  91. sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
  92. mv -f XX sys/types.h
  93. # The following subshell weirdness is for saving an exit
  94. # status from within a while loop that reads input. If you can
  95. # think of a cleaner way, suggest away, please...
  96. #
  97. exitok=`
  98. exec < ${TESTDIR}/LIST
  99. while read f
  100. do
  101. if [ ! -f ${TESTBASE}/$f ]
  102. then
  103. echo "Newly fixed header: $f" >&2
  104. exitok=false
  105. elif cmp $f ${TESTBASE}/$f >&2
  106. then
  107. :
  108. else
  109. ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
  110. exitok=false
  111. fi
  112. done
  113. echo $exitok`
  114. cd $TESTBASE
  115. find * -type f -print | \
  116. fgrep -v 'CVS/' | \
  117. fgrep -v '.svn/' > ${TESTDIR}/LIST
  118. exitok=`
  119. exec < ${TESTDIR}/LIST
  120. while read f
  121. do
  122. if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
  123. then
  124. echo "Missing header fix: $f" >&2
  125. exitok=false
  126. fi
  127. done
  128. echo $exitok`
  129. echo
  130. if $exitok
  131. then
  132. cd ${TESTDIR}
  133. rm -rf inc res LIST
  134. cd ..
  135. rmdir ${TESTDIR} > /dev/null 2>&1 || :
  136. echo All fixinclude tests pass >&2
  137. else
  138. echo There were fixinclude test FAILURES >&2
  139. fi
  140. $exitok[=
  141. (if (defined? 'set-writable) (set-writable))
  142. =]