po: Update German man pages translation
[dpkg.git] / tests / Test.mk
blob3c020af2c1b4cc91e07eb218e53dede78cd1b0e6
2 # Dpkg functional testsuite (kind of)
4 # Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
7 -include ../.pkg-tests.conf
9 ## Feature checks setup ##
11 include ../Feature.mk
13 ## Test case support ##
15 ifneq (,$(filter debug,$(DPKG_TESTSUITE_OPTIONS)))
16 DPKG_MAINTSCRIPT_DEBUG = DPKG_DEBUG=1
17 endif
19 DPKG_PATH := $(PATH):/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
20 ifdef DPKG_BUILDTREE
21 DPKG_PATH := $(DPKG_BUILDTREE)/src:$(DPKG_BUILDTREE)/utils:$(DPKG_BUILDTREE)/scripts:$(DPKG_PATH)
22 endif
24 DPKG_ENV = \
25 PATH=$(DPKG_PATH) \
26 $(DPKG_MAINTSCRIPT_DEBUG)
28 # eatmydata confuses ASAN link order check.
29 export ASAN_OPTIONS = verify_asan_link_order=0
31 ifdef DPKG_BUILDTREE
32 export DPKG_DATADIR := $(DPKG_BUILDTREE)/src
33 DPKG_ENV += \
34 DPKG_DATADIR="$(DPKG_DATADIR)"
35 endif
37 export PATH
38 PATH = $(DPKG_PATH)
40 DPKG_OPTIONS =
41 DPKG_DIVERT_OPTIONS =
43 ifdef DPKG_AS_ROOT
44 DPKG_INSTDIR = /
45 ifeq ($(shell id -u),0)
46 BEROOT := env $(DPKG_ENV)
47 else
48 DPKG_ENV += \
49 LD_PRELOAD="$(LD_PRELOAD)" \
50 LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)"
51 BEROOT := sudo -E env $(DPKG_ENV)
52 endif
53 else
54 DPKG_INSTDIR = $(CURDIR)/../dpkginst
55 DPKG_OPTIONS += \
56 --force-script-chrootless \
57 --force-not-root \
58 # EOL
59 BEROOT := env $(DPKG_ENV)
61 DPKG_DIVERT_OPTIONS += \
62 --instdir="$(DPKG_INSTDIR)" \
63 # EOL
64 endif
66 DPKG_OPTIONS += \
67 --force-unsafe-io \
68 --instdir="$(DPKG_INSTDIR)" \
69 --no-debsig --log=/dev/null \
70 # EOL
72 ifneq (,$(filter debug,$(DPKG_TESTSUITE_OPTIONS)))
73 DPKG_OPTIONS += -D77777
74 endif
76 # Always use a local db.
77 DPKG_ADMINDIR = $(CURDIR)/../dpkgdb
78 DPKG_COMMON_OPTIONS = --admindir="$(DPKG_ADMINDIR)"
80 DPKG = dpkg $(DPKG_COMMON_OPTIONS) $(DPKG_OPTIONS)
81 DPKG_INSTALL = $(BEROOT) $(DPKG) -i
82 DPKG_UNPACK = $(BEROOT) $(DPKG) --unpack
83 DPKG_CONFIGURE = $(BEROOT) $(DPKG) --configure
84 DPKG_REMOVE = $(BEROOT) $(DPKG) -r
85 DPKG_PURGE = $(BEROOT) $(DPKG) -P
86 DPKG_VERIFY = $(DPKG) -V
87 DPKG_DEB = dpkg-deb $(DPKG_DEB_OPTIONS)
88 DPKG_DIVERT = dpkg-divert $(DPKG_COMMON_OPTIONS) $(DPKG_DIVERT_OPTIONS)
89 DPKG_DIVERT_ADD = $(BEROOT) $(DPKG_DIVERT) --add
90 DPKG_DIVERT_DEL = $(BEROOT) $(DPKG_DIVERT) --remove
91 DPKG_SPLIT = dpkg-split $(DPKG_SPLIT_OPTIONS)
92 DPKG_BUILD_DEB = $(DPKG_DEB) -b
93 DPKG_QUERY = dpkg-query $(DPKG_COMMON_OPTIONS) $(DPKG_QUERY_OPTIONS)
94 DPKG_TRIGGER = dpkg-trigger $(DPKG_COMMON_OPTIONS) $(DPKG_TRIGGER_OPTIONS)
96 PKG_STATUS = $(DPKG_QUERY) -f '$${Status}' -W
98 DEB = $(addsuffix .deb,$(TESTS_DEB))
100 # Common test patterns to use with $(call foo,args...)
101 stdout_is = test "`$(1)`" = "$(2)"
102 stdout_has = $(1) | grep -qE "$(2)"
103 stderr_is = test "`$(1) 2>&1 1>/dev/null`" = "$(2)"
104 stderr_has = $(1) 2>&1 1>/dev/null | grep -qE "$(2)"
105 pkg_is_installed = $(call stdout_is,$(PKG_STATUS) $(1),install ok installed)
106 pkg_is_not_installed = $(call stdout_has,$(PKG_STATUS) $(1) 2>/dev/null, ok not-installed) || ! $(PKG_STATUS) $(1) >/dev/null 2>&1
107 pkg_status_is = $(call stdout_is,$(PKG_STATUS) $(1),$(2))
108 pkg_field_is = $(call stdout_is,$(DPKG_QUERY) -f '$${$(2)}' -W $(1),$(3))
110 %.deb: %
111 $(DPKG_BUILD_DEB) $< $@
113 TEST_CASES :=
115 build: build-hook $(DEB)
117 test: build test-case test-clean
119 clean: clean-hook
120 $(RM) $(DEB)
122 .PHONY: build-hook build test test-case test-clean clean-hook clean
124 # Most of the tests are serial in nature, as they perform package database
125 # changes, and the Makefile are written with that in mind. Avoid any
126 # surprises by explicitly disallowing parallel executions.
127 .NOTPARALLEL: