check.tpl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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 [ -n "$MSYSTEM" -o -n "$DJGPP" ]
  102. then
  103. # On MinGW and DJGPP convert line endings to avoid false positives
  104. mv $f $f.dos; tr -d '\r' < $f.dos > $f; rm $f.dos
  105. fi
  106. if [ ! -f ${TESTBASE}/$f ]
  107. then
  108. echo "Newly fixed header: $f" >&2
  109. exitok=false
  110. elif cmp $f ${TESTBASE}/$f >&2
  111. then
  112. :
  113. else
  114. ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
  115. exitok=false
  116. fi
  117. done
  118. echo $exitok`
  119. cd $TESTBASE
  120. find * -type f ! -name .DS_Store ! -name CVS ! -name .svn -print \
  121. > ${TESTDIR}/LIST
  122. exitok=`
  123. exec < ${TESTDIR}/LIST
  124. while read f
  125. do
  126. if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
  127. then
  128. echo "Missing header fix: $f" >&2
  129. exitok=false
  130. fi
  131. done
  132. echo $exitok`
  133. echo
  134. if $exitok
  135. then
  136. cd ${TESTDIR}
  137. rm -rf inc res LIST
  138. cd ..
  139. rmdir ${TESTDIR} > /dev/null 2>&1 || :
  140. echo All fixinclude tests pass >&2
  141. else
  142. echo There were fixinclude test FAILURES >&2
  143. fi
  144. $exitok[=
  145. (if (defined? 'set-writable) (set-writable))
  146. =]