po: Update German man pages translation
[dpkg.git] / tests / Test.mk
blob9aaa52b6b175d4b6c1fab7a82e024ba538a00e93
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 ifdef DPKG_BUILDTREE
29 export DPKG_DATADIR := $(DPKG_BUILDTREE)/src
30 DPKG_ENV += \
31 DPKG_DATADIR="$(DPKG_DATADIR)"
32 endif
34 export PATH
35 PATH = $(DPKG_PATH)
37 DPKG_OPTIONS =
38 DPKG_DIVERT_OPTIONS =
40 ifdef DPKG_AS_ROOT
41 DPKG_INSTDIR = /
42 ifeq ($(shell id -u),0)
43 BEROOT := env $(DPKG_ENV)
44 else
45 DPKG_ENV += \
46 LD_PRELOAD="$(LD_PRELOAD)" \
47 LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)"
48 BEROOT := sudo -E env $(DPKG_ENV)
49 endif
50 else
51 DPKG_INSTDIR = $(CURDIR)/../dpkginst
52 DPKG_OPTIONS += \
53 --force-script-chrootless \
54 --force-not-root \
55 # EOL
56 BEROOT := env $(DPKG_ENV)
58 DPKG_DIVERT_OPTIONS += \
59 --instdir="$(DPKG_INSTDIR)" \
60 # EOL
61 endif
63 DPKG_OPTIONS += \
64 --force-unsafe-io \
65 --instdir="$(DPKG_INSTDIR)" \
66 --no-debsig --log=/dev/null \
67 # EOL
69 ifneq (,$(filter debug,$(DPKG_TESTSUITE_OPTIONS)))
70 DPKG_OPTIONS += -D77777
71 endif
73 # Always use a local db.
74 DPKG_ADMINDIR = $(CURDIR)/../dpkgdb
75 DPKG_COMMON_OPTIONS = --admindir="$(DPKG_ADMINDIR)"
77 DPKG = dpkg $(DPKG_COMMON_OPTIONS) $(DPKG_OPTIONS)
78 DPKG_INSTALL = $(BEROOT) $(DPKG) -i
79 DPKG_UNPACK = $(BEROOT) $(DPKG) --unpack
80 DPKG_CONFIGURE = $(BEROOT) $(DPKG) --configure
81 DPKG_REMOVE = $(BEROOT) $(DPKG) -r
82 DPKG_PURGE = $(BEROOT) $(DPKG) -P
83 DPKG_VERIFY = $(DPKG) -V
84 DPKG_DEB = dpkg-deb $(DPKG_DEB_OPTIONS)
85 DPKG_DIVERT = dpkg-divert $(DPKG_COMMON_OPTIONS) $(DPKG_DIVERT_OPTIONS)
86 DPKG_DIVERT_ADD = $(BEROOT) $(DPKG_DIVERT) --add
87 DPKG_DIVERT_DEL = $(BEROOT) $(DPKG_DIVERT) --remove
88 DPKG_SPLIT = dpkg-split $(DPKG_SPLIT_OPTIONS)
89 DPKG_BUILD_DEB = $(DPKG_DEB) -b
90 DPKG_QUERY = dpkg-query $(DPKG_COMMON_OPTIONS) $(DPKG_QUERY_OPTIONS)
91 DPKG_TRIGGER = dpkg-trigger $(DPKG_COMMON_OPTIONS) $(DPKG_TRIGGER_OPTIONS)
93 PKG_STATUS = $(DPKG_QUERY) -f '$${Status}' -W
95 DEB = $(addsuffix .deb,$(TESTS_DEB))
97 # Common test patterns to use with $(call foo,args...)
98 stdout_is = test "`$(1)`" = "$(2)"
99 stdout_has = $(1) | grep -qE "$(2)"
100 stderr_is = test "`$(1) 2>&1 1>/dev/null`" = "$(2)"
101 stderr_has = $(1) 2>&1 1>/dev/null | grep -qE "$(2)"
102 pkg_is_installed = $(call stdout_is,$(PKG_STATUS) $(1),install ok installed)
103 pkg_is_not_installed = $(call stdout_has,$(PKG_STATUS) $(1) 2>/dev/null, ok not-installed) || ! $(PKG_STATUS) $(1) >/dev/null 2>&1
104 pkg_status_is = $(call stdout_is,$(PKG_STATUS) $(1),$(2))
105 pkg_field_is = $(call stdout_is,$(DPKG_QUERY) -f '$${$(2)}' -W $(1),$(3))
107 %.deb: %
108 $(DPKG_BUILD_DEB) $< $@
110 TEST_CASES :=
112 build: build-hook $(DEB)
114 test: build test-case test-clean
116 clean: clean-hook
117 $(RM) $(DEB)
119 .PHONY: build-hook build test test-case test-clean clean-hook clean
121 # Most of the tests are serial in nature, as they perform package database
122 # changes, and the Makefile are written with that in mind. Avoid any
123 # surprises by explicitly disallowing parallel executions.
124 .NOTPARALLEL: