check-tests-in-builddir.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # Check that the testsuite driver can find test in the srcdir as
  17. # well as in builddir, and that is prefers those in the builddir.
  18. # For gen-testsuite-part: ==> try-with-serial-tests <==
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. TESTS = foo.test bar.test
  25. EXTRA_DIST = $(TESTS)
  26. END
  27. cat > foo.test << 'END'
  28. #! /bin/sh
  29. exit ${FOO_EXIT_STATUS-0}
  30. END
  31. chmod a+x foo.test
  32. unset FOO_EXIT_STATUS
  33. $ACLOCAL
  34. $AUTOCONF
  35. $AUTOMAKE -a
  36. mkdir build
  37. cd build
  38. ../configure
  39. cat > bar.test << 'END'
  40. #! /bin/sh
  41. exit 0
  42. END
  43. chmod a+x bar.test
  44. run_make -M check
  45. # The serial test driver does not strip VPATH components from
  46. # the name of the test, but the parallel driver should.
  47. if test x"$am_serial_tests" = x"yes"; then
  48. grep '^PASS: .*foo\.test *$' output
  49. else
  50. grep '\.\./foo' output && exit 1
  51. grep '^PASS: foo\.test *$' output
  52. fi
  53. grep '^PASS: bar\.test *$' output
  54. rm -f test-suite.log foo.log bar.log
  55. run_make -M -e FAIL FOO_EXIT_STATUS=1 check
  56. # The serial test driver does not strip VPATH components from
  57. # the name of the test, but the parallel driver should.
  58. if test x"$am_serial_tests" = x"yes"; then
  59. grep '^FAIL: .*foo\.test *$' output
  60. else
  61. grep '\.\./foo' output && exit 1
  62. grep '^FAIL: foo\.test *$' output
  63. fi
  64. grep '^PASS: bar\.test *$' output
  65. rm -f test-suite.log foo.log bar.log
  66. # Check that if the same test is present in srcdir and builddir,
  67. # the one in builddir is preferred.
  68. cp bar.test foo.test
  69. run_make -M FOO_EXIT_STATUS=1 check
  70. grep '^PASS: foo\.test *$' output
  71. grep '^PASS: bar\.test *$' output
  72. # The tests in the builddir must be preferred also by "make dist".
  73. FOO_EXIT_STATUS=1 $MAKE distcheck
  74. :