2009-04-25 03:36:22 +08:00
|
|
|
# Most of this is probably too coreutils-centric to be useful to other packages.
|
|
|
|
|
|
|
|
bin=bin-$$$$
|
|
|
|
|
|
|
|
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
|
|
|
|
|
2009-12-06 05:16:32 +08:00
|
|
|
tmpdir = $(abs_top_builddir)/tests/torture
|
|
|
|
|
|
|
|
t=$(tmpdir)/$(PACKAGE)/test
|
2009-04-25 03:36:22 +08:00
|
|
|
pfx=$(t)/i
|
|
|
|
|
2009-12-13 17:35:49 +08:00
|
|
|
built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
|
|
|
|
|
2009-04-25 03:36:22 +08:00
|
|
|
# More than once, tainted build and source directory names would
|
|
|
|
# have caused at least one "make check" test to apply "chmod 700"
|
|
|
|
# to all directories under $HOME. Make sure it doesn't happen again.
|
2009-12-06 05:16:32 +08:00
|
|
|
tp = $(tmpdir)/taint
|
2009-04-25 03:36:22 +08:00
|
|
|
t_prefix = $(tp)/a
|
|
|
|
t_taint = '$(t_prefix) b'
|
|
|
|
fake_home = $(tp)/home
|
|
|
|
|
|
|
|
# Ensure that tests run from tainted build and src dir names work,
|
|
|
|
# and don't affect anything in $HOME. Create witness files in $HOME,
|
|
|
|
# record their attributes, and build/test. Then ensure that the
|
|
|
|
# witnesses were not affected.
|
|
|
|
ALL_RECURSIVE_TARGETS += taint-distcheck
|
|
|
|
taint-distcheck: $(DIST_ARCHIVES)
|
|
|
|
test -d $(t_taint) && chmod -R 700 $(t_taint) || :
|
|
|
|
-rm -rf $(t_taint) $(fake_home)
|
|
|
|
mkdir -p $(t_prefix) $(t_taint) $(fake_home)
|
|
|
|
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
|
|
|
|
mkfifo $(fake_home)/fifo
|
|
|
|
touch $(fake_home)/f
|
|
|
|
mkdir -p $(fake_home)/d/e
|
|
|
|
ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
|
2009-12-06 05:16:32 +08:00
|
|
|
HOME=$(fake_home); export HOME; \
|
2009-04-25 03:36:22 +08:00
|
|
|
cd $(t_taint)/$(distdir) \
|
|
|
|
&& ./configure \
|
|
|
|
&& $(MAKE) \
|
2009-12-06 05:16:32 +08:00
|
|
|
&& $(MAKE) check \
|
2009-04-25 03:36:22 +08:00
|
|
|
&& ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
|
|
|
|
&& diff $(tp)/.ls-before $(tp)/.ls-after \
|
|
|
|
&& test -d $(t_prefix)
|
|
|
|
rm -rf $(tp)
|
|
|
|
|
|
|
|
# Verify that a twisted use of --program-transform-name=PROGRAM works.
|
|
|
|
define install-transform-check
|
|
|
|
echo running install-transform-check \
|
|
|
|
&& rm -rf $(pfx) \
|
|
|
|
&& $(MAKE) program_transform_name='s/.*/zyx/' \
|
|
|
|
prefix=$(pfx) install \
|
|
|
|
&& test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
|
|
|
|
&& test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Install, then verify that all binaries and man pages are in place.
|
|
|
|
# Note that neither the binary, ginstall, nor the ].1 man page is installed.
|
|
|
|
define my-instcheck
|
2009-12-06 05:16:32 +08:00
|
|
|
echo running my-instcheck; \
|
2009-04-25 03:36:22 +08:00
|
|
|
$(MAKE) prefix=$(pfx) install \
|
|
|
|
&& test ! -f $(pfx)/bin/ginstall \
|
|
|
|
&& { fail=0; \
|
|
|
|
for i in $(built_programs); do \
|
|
|
|
test "$$i" = ginstall && i=install; \
|
|
|
|
for j in "$(pfx)/bin/$$i" \
|
|
|
|
"$(pfx)/share/man/man1/$$i.1"; do \
|
|
|
|
case $$j in *'[.1') continue;; esac; \
|
|
|
|
test -f "$$j" && : \
|
|
|
|
|| { echo "$$j not installed"; fail=1; }; \
|
|
|
|
done; \
|
|
|
|
done; \
|
|
|
|
test $$fail = 1 && exit 1 || :; \
|
|
|
|
}
|
|
|
|
endef
|
|
|
|
|
2009-12-13 17:35:49 +08:00
|
|
|
# The hard-linking for-loop below ensures that there is a bin/ directory
|
|
|
|
# full of all of the programs under test (except the ones that are required
|
|
|
|
# for basic Makefile rules), all symlinked to the just-built "false" program.
|
|
|
|
# This is to ensure that if ever a test neglects to make PATH include
|
|
|
|
# the build srcdir, these always-failing programs will run.
|
|
|
|
# Otherwise, it is too easy to test the wrong programs.
|
|
|
|
# Note that "false" itself is a symlink to true, so it too will malfunction.
|
2009-04-25 03:36:22 +08:00
|
|
|
define coreutils-path-check
|
|
|
|
{ \
|
2009-12-06 05:16:32 +08:00
|
|
|
echo running coreutils-path-check; \
|
2009-04-25 03:36:22 +08:00
|
|
|
if test -f $(srcdir)/src/true.c; then \
|
|
|
|
fail=1; \
|
|
|
|
mkdir $(bin) \
|
|
|
|
&& ($(write_loser)) > $(bin)/loser \
|
|
|
|
&& chmod a+x $(bin)/loser \
|
|
|
|
&& for i in $(built_programs); do \
|
|
|
|
case $$i in \
|
|
|
|
rm|expr|basename|echo|sort|ls|tr);; \
|
|
|
|
cat|dirname|mv|wc);; \
|
|
|
|
*) ln $(bin)/loser $(bin)/$$i;; \
|
|
|
|
esac; \
|
|
|
|
done \
|
|
|
|
&& ln -sf ../src/true $(bin)/false \
|
|
|
|
&& PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
|
|
|
|
$(MAKE) -C tests check \
|
|
|
|
&& { test -d gnulib-tests \
|
|
|
|
&& $(MAKE) -C gnulib-tests check \
|
|
|
|
|| :; } \
|
|
|
|
&& rm -rf $(bin) \
|
|
|
|
&& fail=0; \
|
|
|
|
else \
|
|
|
|
fail=0; \
|
|
|
|
fi; \
|
|
|
|
test $$fail = 1 && exit 1 || :; \
|
|
|
|
}
|
|
|
|
endef
|
|
|
|
|
2009-12-13 17:35:49 +08:00
|
|
|
# Use this to make sure we don't run these programs when building
|
|
|
|
# from a virgin tgz file, below.
|
|
|
|
null_AM_MAKEFLAGS ?= \
|
|
|
|
ACLOCAL=false \
|
|
|
|
AUTOCONF=false \
|
|
|
|
AUTOMAKE=false \
|
|
|
|
AUTOHEADER=false \
|
|
|
|
GPERF=false \
|
|
|
|
LIBTOOL=false \
|
|
|
|
MAKEINFO=false
|
|
|
|
|
2009-04-25 03:36:22 +08:00
|
|
|
ALL_RECURSIVE_TARGETS += my-distcheck
|
|
|
|
my-distcheck: $(DIST_ARCHIVES) $(local-check)
|
|
|
|
$(MAKE) syntax-check
|
|
|
|
$(MAKE) check
|
|
|
|
-rm -rf $(t)
|
|
|
|
mkdir -p $(t)
|
|
|
|
GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
|
|
|
|
cd $(t)/$(distdir) \
|
2009-12-06 05:16:32 +08:00
|
|
|
&& ./configure --quiet --enable-gcc-warnings --disable-nls \
|
2009-06-02 22:33:49 +08:00
|
|
|
&& $(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
|
2009-04-25 03:36:22 +08:00
|
|
|
&& $(MAKE) dvi \
|
|
|
|
&& $(install-transform-check) \
|
|
|
|
&& $(my-instcheck) \
|
|
|
|
&& $(coreutils-path-check) \
|
|
|
|
&& $(MAKE) distclean
|
|
|
|
(cd $(t) && mv $(distdir) $(distdir).old \
|
|
|
|
&& $(AMTAR) -zxf - ) < $(distdir).tar.gz
|
|
|
|
diff -ur $(t)/$(distdir).old $(t)/$(distdir)
|
|
|
|
-rm -rf $(t)
|
2009-12-06 05:16:32 +08:00
|
|
|
rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)
|
2009-04-25 03:36:22 +08:00
|
|
|
@echo "========================"; \
|
|
|
|
echo "$(distdir).tar.gz is ready for distribution"; \
|
|
|
|
echo "========================"
|