summaryrefslogtreecommitdiffstats
path: root/test/Makefile.in
blob: 1372e5aedad5a0f9e51243911ac00c56e20cbf4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#TEST_OPTS=--verbose --debug
SHELL_PATH ?= $(SHELL)
RM ?= rm -f

subdir = $(shell pwd|sed 's,.*/,,')

srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
abs_srcdir = "@abs_srcdir@"
abs_builddir = "@abs_builddir@"
abs_top_builddir = "@abs_top_builddir@"
abs_top_srcdir = "@abs_top_srcdir@"

SUBDIRS = api unit
SOURCES = lib/not.c lib/harness.c

include $(top_builddir)/make.tmpl

T ?= .
S ?= @ # never match anything by default
VERBOSE ?= 0
ALL = $(shell find $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | sort)
RUN = $(shell find $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort)
RUN_BASE = $(subst $(srcdir)/,,$(RUN))

# Shell quote;
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))

ifeq ("@UDEV_SYNC@", "yes")
dm_udev_synchronisation = 1
endif

all: check

check: check_local check_cluster check_lvmetad

check_cluster: .tests-stamp
	@echo Testing with locking_type 3
	VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./lib/harness $(RUN_BASE)

check_local: .tests-stamp
	@echo Testing with locking_type 1
	VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./lib/harness $(RUN_BASE)

check_lvmetad: .tests-stamp
	@echo Testing with lvmetad on
	VERBOSE=$(VERBOSE) LVM_TEST_LVMETAD=1 ./lib/harness $(RUN_BASE)

lib/should: lib/not
	ln -sf not lib/should

lib/%: lib/%.o .lib-dir-stamp
	$(CC) $(LDFLAGS) -o $@ $<

lib/%: $(srcdir)/lib/%.sh .lib-dir-stamp
	cp $< $@
	chmod +x $@

lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp
	$(RM) $@-t
	echo 'top_srcdir=$(top_srcdir)' >> $@-t
	echo 'abs_top_builddir=$(abs_top_builddir)' >> $@-t
	echo 'abs_top_srcdir=$(abs_top_srcdir)' >> $@-t
	echo 'abs_srcdir=$(abs_srcdir)' >> $@-t
	echo 'abs_builddir=$(abs_builddir)' >> $@-t
	echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t
	mv $@-t $@

LIB = lib/not lib/should lib/harness \
      lib/check lib/aux lib/test lib/utils lib/get lib/lvm-wrapper \
      lib/paths

CMDS = lvm $(shell cat $(top_builddir)/tools/.commands)

.tests-stamp: $(ALL) $(LIB) $(SUBDIRS)
	@if test "$(srcdir)" != . ; then \
		echo "Linking tests to builddir."; \
		$(MKDIR_P) shell; \
		for f in $(subst $(srcdir)/,,$(ALL)); do \
			ln -sf $(abs_top_srcdir)/test/$$f $$f; \
		done; \
	fi
	touch $@

.lib-dir-stamp:
	$(MKDIR_P) lib
	for i in $(CMDS); do ln -fs lvm-wrapper lib/$$i; done
	ln -fs $(abs_top_builddir)/tools/dmsetup lib/dmsetup
	ln -fs $(abs_top_builddir)/daemons/clvmd/clvmd lib/clvmd
	ln -fs $(abs_top_builddir)/daemons/dmeventd/dmeventd lib/dmeventd
	ln -fs $(abs_top_builddir)/daemons/lvmetad/lvmetad lib/lvmetad
	ln -fs $(abs_top_srcdir)/scripts/vgimportclone.sh lib/vgimportclone
	ln -fs $(abs_top_srcdir)/scripts/fsadm.sh lib/fsadm
	touch $@

clean:
	test "$(srcdir)" = . || $(RM) $(RUN_BASE)

CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,$(CMDS)) \
	lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

.NOTPARALLEL: