OSDN Git Service

tests: disable the taint-distcheck rule
[android-x86/external-parted.git] / dist-check.mk
1 # Most of this is probably too coreutils-centric to be useful to other packages.
2
3 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
4 bin=bin-$$$$
5
6 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
7
8 TMPDIR ?= /tmp
9 t=$(TMPDIR)/$(PACKAGE)/test
10 pfx=$(t)/i
11
12 # More than once, tainted build and source directory names would
13 # have caused at least one "make check" test to apply "chmod 700"
14 # to all directories under $HOME.  Make sure it doesn't happen again.
15 tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
16 t_prefix = $(tp)/a
17 t_taint = '$(t_prefix) b'
18 fake_home = $(tp)/home
19
20 # Disable this test, since libtool-generated scripts
21 # can't deal with a space-tainted srcdir.
22 ALL_RECURSIVE_TARGETS += taint-distcheck
23 .PHONY: taint-distcheck
24 taint-distcheck:
25
26 # Verify that a twisted use of --program-transform-name=PROGRAM works.
27 define install-transform-check
28   echo running install-transform-check                  \
29     && rm -rf $(pfx)                                    \
30     && $(MAKE) program_transform_name='s/.*/zyx/'       \
31       prefix=$(pfx) install                             \
32     && test "$$(echo $(pfx)/sbin/*)" = "$(pfx)/sbin/zyx"        \
33     && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
34 endef
35
36 # Install, then verify that all binaries and man pages are in place.
37 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
38 define my-instcheck
39   $(MAKE) prefix=$(pfx) install                         \
40     && test ! -f $(pfx)/bin/ginstall                    \
41     && { fail=0;                                        \
42       for i in $(built_programs); do                    \
43         test "$$i" = ginstall && i=install;             \
44         for j in "$(pfx)/bin/$$i"                       \
45                  "$(pfx)/share/man/man1/$$i.1"; do      \
46           case $$j in *'[.1') continue;; esac;          \
47           test -f "$$j" && :                            \
48             || { echo "$$j not installed"; fail=1; };   \
49         done;                                           \
50       done;                                             \
51       test $$fail = 1 && exit 1 || :;                   \
52     }
53 endef
54
55 define coreutils-path-check
56   {                                                     \
57     if test -f $(srcdir)/src/true.c; then               \
58       fail=1;                                           \
59       mkdir $(bin)                                      \
60         && ($(write_loser)) > $(bin)/loser              \
61         && chmod a+x $(bin)/loser                       \
62         && for i in $(built_programs); do               \
63                case $$i in                              \
64                  rm|expr|basename|echo|sort|ls|tr);;    \
65                  cat|dirname|mv|wc);;                   \
66                  *) ln $(bin)/loser $(bin)/$$i;;        \
67                esac;                                    \
68              done                                       \
69           && ln -sf ../src/true $(bin)/false            \
70           && PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH   \
71                 $(MAKE) -C tests check                  \
72           && { test -d gnulib-tests                     \
73                  && $(MAKE) -C gnulib-tests check       \
74                  || :; }                                \
75           && rm -rf $(bin)                              \
76           && fail=0;                                    \
77     else                                                \
78       fail=0;                                           \
79     fi;                                                 \
80     test $$fail = 1 && exit 1 || :;                     \
81   }
82 endef
83
84 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
85 # Also, check for shadowing problems with -Wshadow, and for pointer
86 # arithmetic problems with -Wpointer-arith.
87 # These CFLAGS are pretty strict.  If you build this target, you probably
88 # have to have a recent version of gcc and glibc headers.
89 # The hard-linking for-loop below ensures that there is a bin/ directory
90 # full of all of the programs under test (except the ones that are required
91 # for basic Makefile rules), all symlinked to the just-built "false" program.
92 # This is to ensure that if ever a test neglects to make PATH include
93 # the build srcdir, these always-failing programs will run.
94 # Otherwise, it is too easy to test the wrong programs.
95 # Note that "false" itself is a symlink to true, so it too will malfunction.
96 ALL_RECURSIVE_TARGETS += my-distcheck
97 my-distcheck: $(DIST_ARCHIVES) $(local-check)
98         $(MAKE) syntax-check
99         $(MAKE) check
100         -rm -rf $(t)
101         mkdir -p $(t)
102         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
103         cd $(t)/$(distdir)                              \
104           && ./configure --disable-nls                  \
105           && $(MAKE) CFLAGS='$(warn_cflags)'            \
106               AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
107           && $(MAKE) dvi                                \
108           && $(install-transform-check)                 \
109           && $(my-instcheck)                            \
110           && $(coreutils-path-check)                    \
111           && $(MAKE) distclean
112         (cd $(t) && mv $(distdir) $(distdir).old        \
113           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
114         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
115         -rm -rf $(t)
116         @echo "========================"; \
117         echo "$(distdir).tar.gz is ready for distribution"; \
118         echo "========================"