test-driver-create-log-dir.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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: if a log file has a directory component (as in
  17. # e.g., 'sub/foo.log'), the Automake test harness must ensure that
  18. # directory exists before calling any custom test driver.
  19. . test-init.sh
  20. cat >> configure.ac << 'END'
  21. AC_OUTPUT
  22. END
  23. cat > Makefile.am << 'END'
  24. # The extra '.' components below are meant.
  25. TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
  26. $(TESTS):
  27. LOG_DRIVER = $(srcdir)/checkdir-driver
  28. TEST_LOG_DRIVER = $(LOG_DRIVER)
  29. EXTRA_DIST = checkdir-driver
  30. check-local: $(TEST_SUITE_LOG)
  31. test -d sub
  32. test -d sub1
  33. test -d sub/subsub
  34. test -f sub/foo.log
  35. test -f sub/subsub/bar.log
  36. test -f sub1/baz.log
  37. test -f sub/foo.trs
  38. test -f sub/subsub/bar.trs
  39. test -f sub1/baz.trs
  40. END
  41. echo "#!$AM_TEST_RUNNER_SHELL" > checkdir-driver
  42. cat >> checkdir-driver <<'END'
  43. set -e; set -u
  44. while test $# -gt 0; do
  45. case $1 in
  46. --log-file) log_file=$2; shift;;
  47. --trs-file) trs_file=$2; shift;;
  48. --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
  49. --) shift; break;;
  50. *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
  51. esac
  52. shift
  53. done
  54. echo "log: $log_file" # For debugging.
  55. echo "trs: $trs_file" # Ditto.
  56. case $log_file in */*);; *) exit 1;; esac
  57. dir_log=${log_file%/*}
  58. dir_trs=${trs_file%/*}
  59. echo "dir_log: $dir_log" # For debugging.
  60. echo "dir_trs: $dir_trs" # Likewise.
  61. test x"$dir_trs" = x"$dir_log" || exit 1
  62. test -d "$dir_log" || exit 1
  63. echo dummy1 > "$log_file"
  64. echo dummy2 > "$trs_file"
  65. END
  66. chmod a+x checkdir-driver
  67. $ACLOCAL
  68. $AUTOCONF
  69. $AUTOMAKE
  70. ./configure
  71. $MAKE check
  72. $MAKE distcheck
  73. :