2
0

test-driver-custom.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Custom test drivers: per-extension test drivers.
  17. . test-init.sh
  18. cat >> configure.ac << 'END'
  19. AC_OUTPUT
  20. END
  21. cat > Makefile.am << 'END'
  22. # Automake shouldn't match the '/test' in 'sub/test' as '.test' suffix.
  23. TESTS = 1.chk 2.test 3 4.c.chk 5.suf sub/test
  24. TEST_EXTENSIONS = .chk .test
  25. CHK_LOG_DRIVER = ./chk-wrapper
  26. TEST_LOG_DRIVER = $(SHELL) $(srcdir)/test-wrapper
  27. LOG_DRIVER = noext-wrapper
  28. AM_CHK_LOG_DRIVER_FLAGS = --am-chk
  29. CHK_LOG_DRIVER_FLAGS = --chk
  30. AM_TEST_LOG_DRIVER_FLAGS = -am-test
  31. TEST_LOG_DRIVER_FLAGS = -test
  32. AM_LOG_DRIVER_FLAGS = am
  33. LOG_DRIVER_FLAGS = _
  34. END
  35. mkdir sub bin
  36. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
  37. cat > wrapper.skel <<'END'
  38. #! /bin/sh
  39. set -e
  40. me=`echo "$0" | sed 's,^.*/,,'`
  41. if test -z "$me"; then
  42. echo "$0: cannot determine program name" >&2
  43. exit 99
  44. fi
  45. am_log_wflags='@am_log_wflags@'
  46. log_wflags='@log_wflags@'
  47. test_name=INVALID
  48. log_file=BAD.log
  49. trs_file=BAD.trs
  50. extra_opts=
  51. while test $# -gt 0; do
  52. case $1 in
  53. --test-name) test_name=$2; shift;;
  54. --log-file) log_file=$2; shift;;
  55. --trs-file) trs_file=$2; shift;;
  56. # Ignored.
  57. --expect-failure) shift;;
  58. --color-tests) shift;;
  59. --enable-hard-errors) shift;;
  60. # Remembered in the same order they're passed in.
  61. $am_log_wflags|$log_wflags) extra_opts="$extra_opts $1";;
  62. # Explicitly terminate option list.
  63. --) shift; break;;
  64. # Shouldn't happen
  65. *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
  66. esac
  67. shift
  68. done
  69. echo "$me" "$test_name" $extra_opts > "$log_file"
  70. : > "$trs_file"
  71. exec "$@"
  72. exit 127
  73. END
  74. sed -e 's|@am_log_wflags@|--am-chk|' \
  75. -e 's|@log_wflags@|--chk|' \
  76. < wrapper.skel > chk-wrapper
  77. sed -e 's|@am_log_wflags@|-am-test|' \
  78. -e 's|@log_wflags@|-test|' \
  79. < wrapper.skel > test-wrapper
  80. sed -e 's|@am_log_wflags@|am|' \
  81. -e 's|@log_wflags@|_|' \
  82. < wrapper.skel > bin/noext-wrapper
  83. # 'test-wrapper' is deliberately not made executable.
  84. chmod a+x chk-wrapper bin/noext-wrapper
  85. # Not needed anymore.
  86. rm -f wrapper.skel
  87. cat > 1.chk << 'END'
  88. #! /bin/sh
  89. exit 0
  90. END
  91. chmod a+x 1.chk
  92. cp 1.chk 2.test
  93. cp 1.chk 3
  94. cp 1.chk 4.c.chk
  95. cp 1.chk 5.suf
  96. cp 1.chk sub/test
  97. $ACLOCAL
  98. $AUTOCONF
  99. $AUTOMAKE
  100. ./configure
  101. $MAKE
  102. VERBOSE=yes $MAKE check
  103. ls -l . sub
  104. test ! -e BAD.log
  105. test ! -e BAD.trs
  106. echo 'chk-wrapper 1.chk --am-chk --chk' > 1.exp
  107. echo 'test-wrapper 2.test -am-test -test' > 2.exp
  108. echo 'noext-wrapper 3 am _' > 3.exp
  109. echo 'chk-wrapper 4.c.chk --am-chk --chk' > 4.c.exp
  110. echo 'noext-wrapper 5.suf am _' > 5.suf.exp
  111. echo 'noext-wrapper sub/test am _' > sub/test.exp
  112. st=0
  113. for x in 1 2 3 4.c 5.suf sub/test; do
  114. cat $x.log
  115. diff $x.exp $x.log || st=1
  116. done
  117. exit $st