Tizen 2.1 base
[external/device-mapper.git] / test / Makefile.in
1 # Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved.
2 #
3 # This file is part of LVM2.
4 #
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.
8 #
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
12
13 #TEST_OPTS=--verbose --debug
14 SHELL_PATH ?= $(SHELL)
15 TAR ?= $(TAR)
16 RM ?= rm -f
17
18 subdir := $(shell pwd|sed 's,.*/,,')
19
20 srcdir = @srcdir@
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@
27
28 T ?= .
29 S ?= @ # never match anything by default
30 VERBOSE ?= 0
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)/,,)
33
34 # Shell quote;
35 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
36
37 SUPPORT := $(srcdir)/test-utils.sh \
38            $(srcdir)/lvm-utils.sh
39
40 ifeq ("@UDEV_SYNC@", "yes")
41 dm_udev_synchronisation = 1
42 endif
43
44 all check: init.sh
45         make -C api tests
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)
50
51 check_cluster: init.sh
52         make -C api tests
53         @echo Testing with locking_type 3
54         VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./bin/harness $(RUN_BASE)
55
56 check_local: init.sh
57         make -C api tests
58         @echo Testing with locking_type 1
59         VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./bin/harness $(RUN_BASE)
60
61 bin/not: $(srcdir)/not.c .bin-dir-stamp
62         $(CC) -o bin/not $<
63         ln -sf not bin/should
64
65 bin/harness: $(srcdir)/harness.c .bin-dir-stamp
66         $(CC) -o bin/harness $<
67
68 bin/check: $(srcdir)/check.sh .bin-dir-stamp
69         cp $< bin/check
70         chmod +x bin/check
71
72 init.sh: $(srcdir)/Makefile.in .bin-dir-stamp bin/not bin/check bin/harness $(RUN) $(SUPPORT) $(UNIT)
73         rm -f $@-t $@
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
91         chmod a-w $@-t
92         mv $@-t $@
93         @if test "$(srcdir)" != . ; then \
94             echo "Copying tests to builddir."; \
95             cp $(SUPPORT) .; \
96             for f in $(RUN); do cp $$f `echo $$f | sed -e s,^$(srcdir)/,,`; done; \
97         fi
98
99 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
100         cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
101
102 .bin-dir-stamp: lvm-wrapper
103         rm -rf bin
104         mkdir bin
105         for i in lvm $$(cat ../tools/.commands); do \
106           ln -s ../lvm-wrapper bin/$$i; \
107         done
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
111         touch $@
112
113 lvm-wrapper: Makefile
114         rm -f $@-t $@
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
120         chmod a-w,a+x $@-t
121         mv $@-t $@
122
123 clean:
124         rm -rf init.sh lvm-wrapper bin .bin-dir-stamp
125         if test "$(srcdir)" != . ; then rm -f $(subst $(srcdir)/, ,$(RUN)) lvm2app.sh ; fi
126
127 distclean: clean
128         rm -f Makefile
129
130 .NOTPARALLEL: