1 # Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved.
3 # This file is part of LVM2.
5 # This copyrighted material is made available to anyone wishing to use,
6 # modify, copy, or redistribute it subject to the terms and conditions
7 # of the GNU General Public License v.2.
9 # You should have received a copy of the GNU General Public License
10 # along with this program; if not, write to the Free Software Foundation,
11 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13 #TEST_OPTS=--verbose --debug
14 SHELL_PATH ?= $(SHELL)
18 subdir := $(shell pwd|sed 's,.*/,,')
21 top_srcdir = @top_srcdir@
22 top_builddir = @top_builddir@
23 abs_srcdir = @abs_srcdir@
24 abs_builddir = @abs_builddir@
25 abs_top_builddir = @abs_top_builddir@
26 abs_top_srcdir = @abs_top_srcdir@
29 S ?= @ # never match anything by default
31 RUN = $(shell find $(srcdir) -regextype posix-egrep \( -name t-\*.sh -or -path */api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort)
32 RUN_BASE = $(shell echo $(RUN) | xargs -n 1 echo | sed -e s,^$(srcdir)/,,)
35 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
37 SUPPORT := $(srcdir)/test-utils.sh \
38 $(srcdir)/lvm-utils.sh
40 ifeq ("@UDEV_SYNC@", "yes")
41 dm_udev_synchronisation = 1
46 @echo Testing with locking_type 1
47 VERBOSE=$(VERBOSE) ./bin/harness $(RUN_BASE)
48 @echo Testing with locking_type 3
49 VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./bin/harness $(RUN_BASE)
51 check_cluster: init.sh
53 @echo Testing with locking_type 3
54 VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./bin/harness $(RUN_BASE)
58 @echo Testing with locking_type 1
59 VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./bin/harness $(RUN_BASE)
61 bin/not: $(srcdir)/not.c .bin-dir-stamp
65 bin/harness: $(srcdir)/harness.c .bin-dir-stamp
66 $(CC) -o bin/harness $<
68 bin/check: $(srcdir)/check.sh .bin-dir-stamp
72 init.sh: $(srcdir)/Makefile.in .bin-dir-stamp bin/not bin/check bin/harness $(RUN) $(SUPPORT) $(UNIT)
74 echo 'top_srcdir=$(top_srcdir)' >> $@-t
75 echo 'abs_top_builddir=$(abs_top_builddir)' >> $@-t
76 echo 'abs_top_srcdir=$(abs_top_builddir)' >> $@-t
77 echo 'PATH=$$abs_top_builddir/test/bin:$$PATH' >> $@-t
78 LDLPATH="\$$abs_top_builddir/libdm"; \
79 LDLPATH="$$LDLPATH:\$$abs_top_builddir/tools"; \
80 LDLPATH="$$LDLPATH:\$$abs_top_builddir/liblvm"; \
81 LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd"; \
82 LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/lvm2"; \
83 LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/mirror"; \
84 LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/snapshot"; \
85 echo "export LD_LIBRARY_PATH=\"$$LDLPATH\"" >> $@-t
86 echo 'top_srcdir=$(top_srcdir)' >> $@-t
87 echo 'abs_srcdir=$(abs_srcdir)' >> $@-t
88 echo 'abs_builddir=$(abs_builddir)' >> $@-t
89 echo 'export PATH' >> $@-t
90 echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t
93 @if test "$(srcdir)" != . ; then \
94 echo "Copying tests to builddir."; \
96 for f in $(RUN); do cp $$f `echo $$f | sed -e s,^$(srcdir)/,,`; done; \
99 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
100 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
102 .bin-dir-stamp: lvm-wrapper
105 for i in lvm $$(cat ../tools/.commands); do \
106 ln -s ../lvm-wrapper bin/$$i; \
108 ln -s "$(abs_top_builddir)/tools/dmsetup" bin/dmsetup
109 ln -s "$(abs_top_builddir)/daemons/clvmd/clvmd" bin/clvmd
110 ln -s "$(abs_top_builddir)/daemons/dmeventd/dmeventd" bin/dmeventd
113 lvm-wrapper: Makefile
115 echo '#!/bin/sh' > $@-t
116 echo 'cmd=$$(echo ./$$0|sed "s,.*/,,")' >> $@-t
117 echo 'test "$$cmd" = lvm &&' >> $@-t
118 echo 'exec "$(abs_top_builddir)/tools/lvm" "$$@"' >> $@-t
119 echo 'exec "$(abs_top_builddir)/tools/lvm" "$$cmd" "$$@"' >> $@-t
124 rm -rf init.sh lvm-wrapper bin .bin-dir-stamp
125 if test "$(srcdir)" != . ; then rm -f $(subst $(srcdir)/, ,$(RUN)) lvm2app.sh ; fi