|
Packit |
33f14e |
# Most of this is probably too coreutils-centric to be useful to other packages.
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
bin=bin-$$$$
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
tmpdir = $(abs_top_builddir)/tests/torture
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
t=$(tmpdir)/$(PACKAGE)/test
|
|
Packit |
33f14e |
pfx=$(t)/i
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
built_programs = \
|
|
Packit |
33f14e |
$$(echo 'spy:;@echo $$(bin_PROGRAMS)' \
|
|
Packit |
33f14e |
| MAKEFLAGS= $(MAKE) -s -C src -f Makefile -f - spy \
|
|
Packit |
33f14e |
| fmt -1 | sed 's,$(EXEEXT)$$,,' | sort -u)
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# More than once, tainted build and source directory names would
|
|
Packit |
33f14e |
# have caused at least one "make check" test to apply "chmod 700"
|
|
Packit |
33f14e |
# to all directories under $HOME. Make sure it doesn't happen again.
|
|
Packit |
33f14e |
tp = $(tmpdir)/taint
|
|
Packit |
33f14e |
t_prefix = $(tp)/a
|
|
Packit |
33f14e |
t_taint = '$(t_prefix) b'
|
|
Packit |
33f14e |
fake_home = $(tp)/home
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# When extracting from a distribution tarball, extract using the fastest
|
|
Packit |
33f14e |
# method possible. With dist-xz, that means using the *.xz file.
|
|
Packit |
33f14e |
ifneq ('', $(filter *.xz, $(DIST_ARCHIVES)))
|
|
Packit |
33f14e |
tar_decompress_opt_ = J
|
|
Packit |
33f14e |
suffix_ = xz
|
|
Packit |
33f14e |
else
|
|
Packit |
33f14e |
ifneq ('', $(filter *.gz, $(DIST_ARCHIVES)))
|
|
Packit |
33f14e |
tar_decompress_opt_ = z
|
|
Packit |
33f14e |
suffix_ = gz
|
|
Packit |
33f14e |
else
|
|
Packit |
33f14e |
tar_decompress_opt_ = j
|
|
Packit |
33f14e |
suffix_ = bz2
|
|
Packit |
33f14e |
endif
|
|
Packit |
33f14e |
endif
|
|
Packit |
33f14e |
amtar_extract_ = $(AMTAR) -$(tar_decompress_opt_)xf
|
|
Packit |
33f14e |
preferred_tarball_ = $(distdir).tar.$(suffix_)
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Ensure that tests run from tainted build and src dir names work,
|
|
Packit |
33f14e |
# and don't affect anything in $HOME. Create witness files in $HOME,
|
|
Packit |
33f14e |
# record their attributes, and build/test. Then ensure that the
|
|
Packit |
33f14e |
# witnesses were not affected.
|
|
Packit |
33f14e |
# Skip this test when using libtool, since libtool-generated scripts
|
|
Packit |
33f14e |
# cannot deal with a space-tainted srcdir.
|
|
Packit |
33f14e |
ALL_RECURSIVE_TARGETS += taint-distcheck
|
|
Packit |
33f14e |
taint-distcheck: $(DIST_ARCHIVES)
|
|
Packit |
33f14e |
grep '^[ ]*LT_INIT' configure.ac >/dev/null && exit 0 || :
|
|
Packit |
33f14e |
test -d $(t_taint) && chmod -R 700 $(t_taint) || :
|
|
Packit |
33f14e |
-rm -rf $(t_taint) $(fake_home)
|
|
Packit |
33f14e |
mkdir -p $(t_prefix) $(t_taint) $(fake_home)
|
|
Packit |
33f14e |
$(amtar_extract_) $(preferred_tarball_) -C $(t_taint)
|
|
Packit |
33f14e |
mkfifo $(fake_home)/fifo
|
|
Packit |
33f14e |
touch $(fake_home)/f
|
|
Packit |
33f14e |
mkdir -p $(fake_home)/d/e
|
|
Packit |
33f14e |
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
|
|
Packit |
33f14e |
HOME=$(fake_home); export HOME; \
|
|
Packit |
33f14e |
cd $(t_taint)/$(distdir) \
|
|
Packit |
33f14e |
&& ./configure \
|
|
Packit |
33f14e |
&& $(MAKE) \
|
|
Packit |
33f14e |
&& $(MAKE) check \
|
|
Packit |
33f14e |
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
|
|
Packit |
33f14e |
&& diff $(tp)/.ls-before $(tp)/.ls-after \
|
|
Packit |
33f14e |
&& test -d $(t_prefix)
|
|
Packit |
33f14e |
rm -rf $(tp)
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Verify that a twisted use of --program-transform-name=PROGRAM works.
|
|
Packit |
33f14e |
define install-transform-check
|
|
Packit |
33f14e |
echo running install-transform-check \
|
|
Packit |
33f14e |
&& rm -rf $(pfx) \
|
|
Packit |
33f14e |
&& $(MAKE) program_transform_name='s/.*/zyx/' \
|
|
Packit |
33f14e |
prefix=$(pfx) install \
|
|
Packit |
33f14e |
&& test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
|
|
Packit |
33f14e |
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
|
|
Packit |
33f14e |
endef
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Install, then verify that all binaries and man pages are in place.
|
|
Packit |
33f14e |
# Note that neither the binary, ginstall, nor the [.1 man page is installed.
|
|
Packit |
33f14e |
define my-instcheck
|
|
Packit |
33f14e |
echo running my-instcheck; \
|
|
Packit |
33f14e |
$(MAKE) prefix=$(pfx) install \
|
|
Packit |
33f14e |
&& test ! -f $(pfx)/bin/ginstall \
|
|
Packit |
33f14e |
&& { fail=0; \
|
|
Packit |
33f14e |
for i in $(built_programs); do \
|
|
Packit |
33f14e |
test "$$i" = ginstall && i=install; \
|
|
Packit |
33f14e |
for j in "$(pfx)/bin/$$i" \
|
|
Packit |
33f14e |
"$(pfx)/share/man/man1/$$i.1"; do \
|
|
Packit |
33f14e |
case $$j in *'[.1') continue;; esac; \
|
|
Packit |
33f14e |
test -f "$$j" && : \
|
|
Packit |
33f14e |
|| { echo "$$j not installed"; fail=1; }; \
|
|
Packit |
33f14e |
done; \
|
|
Packit |
33f14e |
done; \
|
|
Packit |
33f14e |
test $$fail = 1 && exit 1 || :; \
|
|
Packit |
33f14e |
}
|
|
Packit |
33f14e |
endef
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# The hard-linking for-loop below ensures that there is a bin/ directory
|
|
Packit |
33f14e |
# full of all of the programs under test (except the ones that are required
|
|
Packit |
33f14e |
# for basic Makefile rules), all symlinked to the just-built "false" program.
|
|
Packit |
33f14e |
# This is to ensure that if ever a test neglects to make PATH include
|
|
Packit |
33f14e |
# the build srcdir, these always-failing programs will run.
|
|
Packit |
33f14e |
# Otherwise, it is too easy to test the wrong programs.
|
|
Packit |
33f14e |
# Note that "false" itself is a symlink to true, so it too will malfunction.
|
|
Packit |
33f14e |
define coreutils-path-check
|
|
Packit |
33f14e |
{ \
|
|
Packit |
33f14e |
echo running coreutils-path-check; \
|
|
Packit |
33f14e |
if test -f $(srcdir)/src/true.c; then \
|
|
Packit |
33f14e |
fail=1; \
|
|
Packit |
33f14e |
mkdir $(bin) \
|
|
Packit |
33f14e |
&& ($(write_loser)) > $(bin)/loser \
|
|
Packit |
33f14e |
&& chmod a+x $(bin)/loser \
|
|
Packit |
33f14e |
&& for i in $(built_programs); do \
|
|
Packit |
33f14e |
case $$i in \
|
|
Packit |
33f14e |
rm|expr|basename|echo|sort|ls|tr);; \
|
|
Packit |
33f14e |
cat|dirname|mv|wc);; \
|
|
Packit |
33f14e |
*) ln $(bin)/loser $(bin)/$$i;; \
|
|
Packit |
33f14e |
esac; \
|
|
Packit |
33f14e |
done \
|
|
Packit |
33f14e |
&& ln -sf ../src/true $(bin)/false \
|
|
Packit |
33f14e |
&& PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
|
|
Packit |
33f14e |
$(MAKE) -C tests check \
|
|
Packit |
33f14e |
&& { test -d gnulib-tests \
|
|
Packit |
33f14e |
&& $(MAKE) -C gnulib-tests check \
|
|
Packit |
33f14e |
|| :; } \
|
|
Packit |
33f14e |
&& rm -rf $(bin) \
|
|
Packit |
33f14e |
&& fail=0; \
|
|
Packit |
33f14e |
else \
|
|
Packit |
33f14e |
fail=0; \
|
|
Packit |
33f14e |
fi; \
|
|
Packit |
33f14e |
test $$fail = 1 && exit 1 || :; \
|
|
Packit |
33f14e |
}
|
|
Packit |
33f14e |
endef
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
# Use this to make sure we don't run these programs when building
|
|
Packit |
33f14e |
# from a virgin compressed tarball file, below.
|
|
Packit |
33f14e |
null_AM_MAKEFLAGS ?= \
|
|
Packit |
33f14e |
ACLOCAL=false \
|
|
Packit |
33f14e |
AUTOCONF=false \
|
|
Packit |
33f14e |
AUTOMAKE=false \
|
|
Packit |
33f14e |
AUTOHEADER=false \
|
|
Packit |
33f14e |
GPERF=false \
|
|
Packit |
33f14e |
MAKEINFO=false
|
|
Packit |
33f14e |
|
|
Packit |
33f14e |
ALL_RECURSIVE_TARGETS += my-distcheck
|
|
Packit |
33f14e |
my-distcheck: $(DIST_ARCHIVES) $(local-check)
|
|
Packit |
33f14e |
$(MAKE) syntax-check
|
|
Packit |
33f14e |
$(MAKE) check
|
|
Packit |
33f14e |
-rm -rf $(t)
|
|
Packit |
33f14e |
mkdir -p $(t)
|
|
Packit |
33f14e |
$(amtar_extract_) $(preferred_tarball_) -C $(t)
|
|
Packit |
33f14e |
(set -e; cd $(t)/$(distdir); \
|
|
Packit |
33f14e |
./configure --quiet --enable-gcc-warnings --disable-nls; \
|
|
Packit |
33f14e |
$(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'; \
|
|
Packit |
33f14e |
$(MAKE) dvi; \
|
|
Packit |
33f14e |
$(install-transform-check); \
|
|
Packit |
33f14e |
$(my-instcheck); \
|
|
Packit |
33f14e |
$(coreutils-path-check); \
|
|
Packit |
33f14e |
$(MAKE) distclean \
|
|
Packit |
33f14e |
)
|
|
Packit |
33f14e |
(cd $(t) && mv $(distdir) $(distdir).old \
|
|
Packit |
33f14e |
&& $(amtar_extract_) - ) < $(preferred_tarball_)
|
|
Packit |
33f14e |
find $(t)/$(distdir).old $(t)/$(distdir) -name .deps | xargs rm -rf
|
|
Packit |
33f14e |
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
|
Packit |
33f14e |
-rm -rf $(t)
|
|
Packit |
33f14e |
rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)
|
|
Packit |
33f14e |
@echo "========================"; \
|
|
Packit |
33f14e |
echo "ready for distribution:"; \
|
|
Packit |
33f14e |
for i in $(DIST_ARCHIVES); do echo " $$i"; done; \
|
|
Packit |
33f14e |
echo "========================"
|