2 # Dpkg functional testsuite (kind of)
4 # Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
7 -include ..
/.pkg-tests.conf
9 ## Feature checks setup ##
13 ## Test case support ##
15 ifneq (,$(filter debug
,$(DPKG_TESTSUITE_OPTIONS
)))
16 DPKG_MAINTSCRIPT_DEBUG
= DPKG_DEBUG
=1
19 DPKG_PATH
:= $(PATH
):/usr
/local
/sbin
:/usr
/local
/bin
:/usr
/sbin
:/usr
/bin
:/sbin
:/bin
21 DPKG_PATH
:= $(DPKG_BUILDTREE
)/src
:$(DPKG_BUILDTREE
)/utils
:$(DPKG_BUILDTREE
)/scripts
:$(DPKG_PATH
)
26 $(DPKG_MAINTSCRIPT_DEBUG
)
28 # eatmydata confuses ASAN link order check.
29 export ASAN_OPTIONS
= verify_asan_link_order
=0
30 # Do not fail due to leaks, as the code is still using lots of
31 # static variables and error variables.
32 export LSAN_OPTIONS
= exitcode
=0
35 export DPKG_DATADIR
:= $(DPKG_BUILDTREE
)/src
37 DPKG_DATADIR
="$(DPKG_DATADIR)"
48 ifeq ($(shell id
-u
),0)
49 BEROOT
:= env
$(DPKG_ENV
)
52 LD_PRELOAD
="$(LD_PRELOAD)" \
53 LD_LIBRARY_PATH
="$(LD_LIBRARY_PATH)"
54 BEROOT
:= sudo
-E env
$(DPKG_ENV
)
57 DPKG_INSTDIR
= $(CURDIR
)/..
/dpkginst
59 --force-script-chrootless \
62 BEROOT
:= env
$(DPKG_ENV
)
64 DPKG_DIVERT_OPTIONS
+= \
65 --instdir
="$(DPKG_INSTDIR)" \
71 --instdir
="$(DPKG_INSTDIR)" \
72 --no-debsig
--log
=/dev
/null \
75 ifneq (,$(filter debug
,$(DPKG_TESTSUITE_OPTIONS
)))
76 DPKG_OPTIONS
+= -D77777
79 # Always use a local db.
80 DPKG_ADMINDIR
= $(CURDIR
)/..
/dpkgdb
81 DPKG_COMMON_OPTIONS
= --admindir
="$(DPKG_ADMINDIR)"
83 DPKG
= dpkg
$(DPKG_COMMON_OPTIONS
) $(DPKG_OPTIONS
)
84 DPKG_INSTALL
= $(BEROOT
) $(DPKG
) -i
85 DPKG_UNPACK
= $(BEROOT
) $(DPKG
) --unpack
86 DPKG_CONFIGURE
= $(BEROOT
) $(DPKG
) --configure
87 DPKG_REMOVE
= $(BEROOT
) $(DPKG
) -r
88 DPKG_PURGE
= $(BEROOT
) $(DPKG
) -P
89 DPKG_VERIFY
= $(DPKG
) -V
90 DPKG_DEB
= dpkg-deb
$(DPKG_DEB_OPTIONS
)
91 DPKG_DIVERT
= dpkg-divert
$(DPKG_COMMON_OPTIONS
) $(DPKG_DIVERT_OPTIONS
)
92 DPKG_DIVERT_ADD
= $(BEROOT
) $(DPKG_DIVERT
) --add
93 DPKG_DIVERT_DEL
= $(BEROOT
) $(DPKG_DIVERT
) --remove
94 DPKG_SPLIT
= dpkg-split
$(DPKG_SPLIT_OPTIONS
)
95 DPKG_BUILD_DEB
= $(DPKG_DEB
) -b
96 DPKG_QUERY
= dpkg-query
$(DPKG_COMMON_OPTIONS
) $(DPKG_QUERY_OPTIONS
)
97 DPKG_TRIGGER
= dpkg-trigger
$(DPKG_COMMON_OPTIONS
) $(DPKG_TRIGGER_OPTIONS
)
99 PKG_STATUS
= $(DPKG_QUERY
) -f
'$${Status}' -W
101 DEB
= $(addsuffix .deb
,$(TESTS_DEB
))
103 # Common test patterns to use with $(call foo,args...)
104 stdout_is
= test "`$(1)`" = "$(2)"
105 stdout_has
= $(1) | grep
-qE
"$(2)"
106 stderr_is
= test "`$(1) 2>&1 1>/dev/null`" = "$(2)"
107 stderr_has
= $(1) 2>&1 1>/dev
/null | grep
-qE
"$(2)"
108 pkg_is_installed
= $(call stdout_is
,$(PKG_STATUS
) $(1),install ok installed
)
109 pkg_is_not_installed
= $(call stdout_has
,$(PKG_STATUS
) $(1) 2>/dev
/null
, ok not-installed
) ||
! $(PKG_STATUS
) $(1) >/dev
/null
2>&1
110 pkg_status_is
= $(call stdout_is
,$(PKG_STATUS
) $(1),$(2))
111 pkg_field_is
= $(call stdout_is
,$(DPKG_QUERY
) -f
'$${$(2)}' -W
$(1),$(3))
114 $(DPKG_BUILD_DEB
) $< $@
118 build
: build-hook
$(DEB
)
120 test: build test-case test-clean
125 .PHONY
: build-hook build
test test-case test-clean clean-hook
clean
127 # Most of the tests are serial in nature, as they perform package database
128 # changes, and the Makefile are written with that in mind. Avoid any
129 # surprises by explicitly disallowing parallel executions.