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
13 $$(echo
'spy:;@echo $$(PROGRAMS)' \
14 | MAKEFLAGS
= $(MAKE
) -s
-C src
-f Makefile
-f
- spy \
15 | fmt
-1 | sed
's,$(EXEEXT)$$,,' |
sort -u
)
17 # More than once, tainted build and source directory names would
18 # have caused at least one "make check" test to apply "chmod 700"
19 # to all directories under $HOME. Make sure it doesn't happen again.
22 t_taint
= '$(t_prefix) b'
23 fake_home
= $(tp
)/home
25 # When extracting from a distribution tarball, extract using the fastest
26 # method possible. With dist-xz, that means using the *.xz file.
27 ifneq ('', $(filter *.xz
, $(DIST_ARCHIVES
)))
28 tar_decompress_opt_
= J
31 ifneq ('', $(filter *.gz
, $(DIST_ARCHIVES
)))
32 tar_decompress_opt_
= z
35 tar_decompress_opt_
= j
39 amtar_extract_
= $(AMTAR
) -$(tar_decompress_opt_
)xf
40 preferred_tarball_
= $(distdir
).
tar.
$(suffix_
)
42 # Ensure that tests run from tainted build and src dir names work,
43 # and don't affect anything in $HOME. Create witness files in $HOME,
44 # record their attributes, and build/test. Then ensure that the
45 # witnesses were not affected.
46 # Skip this test when using libtool, since libtool-generated scripts
47 # cannot deal with a space-tainted srcdir.
48 ALL_RECURSIVE_TARGETS
+= taint-distcheck
49 taint-distcheck
: $(DIST_ARCHIVES
)
50 grep
'^[ ]*LT_INIT' configure.ac
>/dev
/null
&& exit
0 ||
:
51 test -d
$(t_taint
) && chmod
-R
700 $(t_taint
) ||
:
52 -rm -rf
$(t_taint
) $(fake_home
)
53 mkdir
-p
$(t_prefix
) $(t_taint
) $(fake_home
)
54 $(amtar_extract_
) $(preferred_tarball_
) -C
$(t_taint
)
55 mkfifo
$(fake_home
)/fifo
57 mkdir
-p
$(fake_home
)/d
/e
58 ls
-lR
$(fake_home
) $(t_prefix
) > $(tp
)/.ls-before
59 HOME
=$(fake_home
); export HOME
; \
60 cd
$(t_taint
)/$(distdir
) \
64 && ls
-lR
$(fake_home
) $(t_prefix
) > $(tp
)/.ls-after \
65 && diff
$(tp
)/.ls-before
$(tp
)/.ls-after \
66 && test -d
$(t_prefix
)
69 # Verify that a twisted use of --program-transform-name=PROGRAM works.
70 define install-transform-check
71 echo running install-transform-check \
73 && $(MAKE
) program_transform_name
='s/.*/zyx/' \
74 prefix=$(pfx
) install \
75 && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
76 && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
79 # Install, then verify that all binaries and man pages are in place.
80 # Note that neither the binary, ginstall, nor the [.1 man page is installed.
82 echo running my-instcheck
; \
83 $(MAKE
) prefix=$(pfx
) install \
84 && test ! -f
$(pfx
)/bin
/ginstall \
86 for i in
$(built_programs
); do \
87 test "$$i" = ginstall
&& i
=install; \
88 for j in
"$(pfx)/bin/$$i" \
89 "$(pfx)/share/man/man1/$$i.1"; do \
90 case
$$j in
*'[.1') continue
;; esac
; \
92 ||
{ echo
"$$j not installed"; fail
=1; }; \
95 test $$fail = 1 && exit
1 ||
:; \
99 # The hard-linking for-loop below ensures that there is a bin/ directory
100 # full of all of the programs under test (except the ones that are required
101 # for basic Makefile rules), all symlinked to the just-built "false" program.
102 # This is to ensure that if ever a test neglects to make PATH include
103 # the build srcdir, these always-failing programs will run.
104 # Otherwise, it is too easy to test the wrong programs.
105 # Note that "false" itself is a symlink to true, so it too will malfunction.
106 define coreutils-path-check
108 echo running coreutils-path-check
; \
109 if
test -f
$(srcdir)/src
/true.c
; then \
112 && ($(write_loser
)) > $(bin
)/loser \
113 && chmod a
+x
$(bin
)/loser \
114 && for i in
$(built_programs
); do \
116 rm|expr|
basename|echo|
sort|ls|tr
);; \
117 cat|dirname|mv|wc
);; \
118 *) ln
$(bin
)/loser
$(bin
)/$$i;; \
121 && ln
-sf ..
/src
/true
$(bin
)/false \
122 && PATH
=`pwd`/$(bin
)$(PATH_SEPARATOR
)$$PATH \
123 $(MAKE
) -C tests
check \
124 && { test -d gnulib-tests \
125 && $(MAKE
) -C gnulib-tests
check \
132 test $$fail = 1 && exit
1 ||
:; \
136 # Use this to make sure we don't run these programs when building
137 # from a virgin compressed tarball file, below.
138 null_AM_MAKEFLAGS ?
= \
146 ALL_RECURSIVE_TARGETS
+= my-distcheck
147 my-distcheck
: $(DIST_ARCHIVES
) $(local-check
)
152 $(amtar_extract_
) $(preferred_tarball_
) -C
$(t
)
153 (set
-e
; cd
$(t
)/$(distdir
); \
154 .
/configure
--quiet
--enable-gcc-warnings
--disable-nls
; \
155 $(MAKE
) AM_MAKEFLAGS
='$(null_AM_MAKEFLAGS)'; \
157 $(install-transform-check
); \
159 $(coreutils-path-check
); \
162 (cd
$(t
) && mv
$(distdir
) $(distdir
).old \
163 && $(amtar_extract_
) - ) < $(preferred_tarball_
)
164 diff
-ur
$(t
)/$(distdir
).old
$(t
)/$(distdir
)
166 rmdir
$(tmpdir
)/$(PACKAGE
) $(tmpdir
)
167 @echo
"========================"; \
168 echo
"ready for distribution:"; \
169 for i in
$(DIST_ARCHIVES
); do echo
" $$i"; done
; \
170 echo
"========================"