1 # Most of this is probably too coreutils-centric to be useful to other packages.
5 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
7 tmpdir = $(abs_top_builddir)/tests/torture
9 t=$(tmpdir)/$(PACKAGE)/test
12 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
14 # More than once, tainted build and source directory names would
15 # have caused at least one "make check" test to apply "chmod 700"
16 # to all directories under $HOME. Make sure it doesn't happen again.
19 t_taint = '$(t_prefix) b'
20 fake_home = $(tp)/home
22 # Ensure that tests run from tainted build and src dir names work,
23 # and don't affect anything in $HOME. Create witness files in $HOME,
24 # record their attributes, and build/test. Then ensure that the
25 # witnesses were not affected.
26 # Skip this test when using libtool, since libtool-generated scripts
27 # cannot deal with a space-tainted srcdir.
28 ALL_RECURSIVE_TARGETS += taint-distcheck
29 taint-distcheck: $(DIST_ARCHIVES)
30 grep '^[ ]*LT_INIT' configure.ac >/dev/null && exit 0
31 test -d $(t_taint) && chmod -R 700 $(t_taint) || :
32 -rm -rf $(t_taint) $(fake_home)
33 mkdir -p $(t_prefix) $(t_taint) $(fake_home)
34 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
35 mkfifo $(fake_home)/fifo
37 mkdir -p $(fake_home)/d/e
38 ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
39 HOME=$(fake_home); export HOME; \
40 cd $(t_taint)/$(distdir) \
44 && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
45 && diff $(tp)/.ls-before $(tp)/.ls-after \
46 && test -d $(t_prefix)
49 # Verify that a twisted use of --program-transform-name=PROGRAM works.
50 define install-transform-check
51 echo running install-transform-check \
53 && $(MAKE) program_transform_name='s/.*/zyx/' \
54 prefix=$(pfx) install \
55 && test "$$(echo $(pfx)/sbin/*)" = "$(pfx)/sbin/zyx" \
56 && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
59 # Install, then verify that all binaries and man pages are in place.
60 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
62 echo running my-instcheck; \
63 $(MAKE) prefix=$(pfx) install \
64 && test ! -f $(pfx)/bin/ginstall \
66 for i in $(built_programs); do \
67 test "$$i" = ginstall && i=install; \
68 for j in "$(pfx)/bin/$$i" \
69 "$(pfx)/share/man/man1/$$i.1"; do \
70 case $$j in *'[.1') continue;; esac; \
72 || { echo "$$j not installed"; fail=1; }; \
75 test $$fail = 1 && exit 1 || :; \
79 # The hard-linking for-loop below ensures that there is a bin/ directory
80 # full of all of the programs under test (except the ones that are required
81 # for basic Makefile rules), all symlinked to the just-built "false" program.
82 # This is to ensure that if ever a test neglects to make PATH include
83 # the build srcdir, these always-failing programs will run.
84 # Otherwise, it is too easy to test the wrong programs.
85 # Note that "false" itself is a symlink to true, so it too will malfunction.
86 define coreutils-path-check
88 echo running coreutils-path-check; \
89 if test -f $(srcdir)/src/true.c; then \
92 && ($(write_loser)) > $(bin)/loser \
93 && chmod a+x $(bin)/loser \
94 && for i in $(built_programs); do \
96 rm|expr|basename|echo|sort|ls|tr);; \
97 cat|dirname|mv|wc);; \
98 *) ln $(bin)/loser $(bin)/$$i;; \
101 && ln -sf ../src/true $(bin)/false \
102 && PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
103 $(MAKE) -C tests check \
104 && { test -d gnulib-tests \
105 && $(MAKE) -C gnulib-tests check \
112 test $$fail = 1 && exit 1 || :; \
116 # Use this to make sure we don't run these programs when building
117 # from a virgin tgz file, below.
118 null_AM_MAKEFLAGS ?= \
127 ALL_RECURSIVE_TARGETS += my-distcheck
128 my-distcheck: $(DIST_ARCHIVES) $(local-check)
133 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
135 && ./configure --quiet --enable-gcc-warnings --disable-nls \
136 && $(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
138 && $(install-transform-check) \
140 && $(coreutils-path-check) \
142 (cd $(t) && mv $(distdir) $(distdir).old \
143 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
144 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
146 rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)
147 @echo "========================"; \
148 echo "$(distdir).tar.gz is ready for distribution"; \
149 echo "========================"