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
32 export DPKG_DATADIR
:= $(DPKG_BUILDTREE
)/src
34 DPKG_DATADIR
="$(DPKG_DATADIR)"
45 ifeq ($(shell id
-u
),0)
46 BEROOT
:= env
$(DPKG_ENV
)
49 LD_PRELOAD
="$(LD_PRELOAD)" \
50 LD_LIBRARY_PATH
="$(LD_LIBRARY_PATH)"
51 BEROOT
:= sudo
-E env
$(DPKG_ENV
)
54 DPKG_INSTDIR
= $(CURDIR
)/..
/dpkginst
56 --force-script-chrootless \
59 BEROOT
:= env
$(DPKG_ENV
)
61 DPKG_DIVERT_OPTIONS
+= \
62 --instdir
="$(DPKG_INSTDIR)" \
68 --instdir
="$(DPKG_INSTDIR)" \
69 --no-debsig
--log
=/dev
/null \
72 ifneq (,$(filter debug
,$(DPKG_TESTSUITE_OPTIONS
)))
73 DPKG_OPTIONS
+= -D77777
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))
111 $(DPKG_BUILD_DEB
) $< $@
115 build
: build-hook
$(DEB
)
117 test: build test-case test-clean
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.