2013-06-03 14:07:31 +04:00
# Copyright (C) 2007-2013 Red Hat, Inc. All rights reserved.
2007-09-18 18:02:22 +04:00
#
# 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
2007-09-18 18:00:42 +04:00
#TEST_OPTS=--verbose --debug
SHELL_PATH ?= $( SHELL)
RM ?= rm -f
2011-11-23 16:21:41 +04:00
subdir = $( shell pwd| sed 's,.*/,,' )
2007-09-18 18:00:42 +04:00
2007-09-18 18:02:22 +04:00
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
2014-03-14 17:10:29 +04:00
abs_srcdir = @abs_srcdir@
abs_builddir = @abs_builddir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
2011-11-23 16:21:41 +04:00
2013-06-03 14:07:31 +04:00
LVM_TEST_RESULTS ?= results
2013-10-17 12:41:08 +04:00
export LVM_TEST_THIN_CHECK_CMD ?= @THIN_CHECK_CMD@
export LVM_TEST_THIN_DUMP_CMD ?= @THIN_DUMP_CMD@
export LVM_TEST_THIN_REPAIR_CMD ?= @THIN_REPAIR_CMD@
2011-11-23 16:21:41 +04:00
SUBDIRS = api unit
2011-11-23 18:56:47 +04:00
SOURCES = lib/not.c lib/harness.c
2011-11-23 16:21:41 +04:00
2011-01-13 17:58:59 +03:00
i n c l u d e $( top_builddir ) / m a k e . t m p l
2007-09-18 18:00:42 +04:00
2010-04-13 10:45:53 +04:00
T ?= .
2010-10-12 20:17:25 +04:00
S ?= @ # never match anything by default
2010-10-14 18:36:26 +04:00
VERBOSE ?= 0
2011-11-21 04:15:42 +04:00
ALL = $( shell find $( srcdir) \( -path \* /shell/\* .sh -or -path \* /api/\* .sh \) | sort)
2013-10-09 16:02:34 +04:00
comma = ,
RUN = $( shell find $( srcdir) -regextype posix-egrep \( -path \* /shell/\* .sh -or -path \* /api/\* .sh \) -and -regex " $( srcdir) /.*( $( subst $( comma) ,| ,$( T) ) ).* " -and -not -regex " $( srcdir) /.*( $( subst $( comma) ,| ,$( S) ) ).* " | sort)
2011-09-25 01:10:19 +04:00
RUN_BASE = $( subst $( srcdir) /,,$( RUN) )
2010-04-13 10:45:53 +04:00
2013-12-05 15:31:49 +04:00
i f e q ( "@BUILD_LVMETAD@" , "yes" )
LVMETAD_RUN_BASE = $( RUN_BASE)
e n d i f
2009-11-30 17:59:26 +03:00
# Shell quote;
SHELL_PATH_SQ = $( subst ',' \' ' ,$( SHELL_PATH) )
2010-01-11 18:48:49 +03:00
i f e q ( "@UDEV_SYNC@" , "yes" )
2010-02-15 19:30:13 +03:00
dm_udev_synchronisation = 1
2010-01-11 18:48:49 +03:00
e n d i f
2011-09-25 01:10:19 +04:00
all : check
2012-03-28 15:10:08 +04:00
help :
@echo -e "\nAvailable targets:"
@echo " all Default target, run check."
@echo " check Run all tests."
@echo " check_local Run tests without clvmd and lvmetad."
@echo " check_cluster Run tests with cluster daemon."
@echo " check_lvmetad Run tests with lvmetad daemon."
@echo " clean Clean dir."
@echo " help Display callable targets."
@echo -e "\nSupported variables:"
2014-03-14 17:10:29 +04:00
@echo " LVM_TEST_CAN_CLOBBER_DMESG Allow to clobber dmesg buffer without /dev/kmsg. (1)"
2012-03-28 15:10:08 +04:00
@echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
2013-10-16 12:17:17 +04:00
@echo " LVM_TEST_DIR Where to create test files [ $( LVM_TEST_DIR) ]. "
2012-03-28 15:10:08 +04:00
@echo " LVM_TEST_LOCKING Normal (1), Cluster (3)."
@echo " LVM_TEST_LVMETAD Start lvmetad (1)."
@echo " LVM_TEST_NODEBUG Do not debug lvm commands."
@echo " LVM_TEST_PARALLEL May skip agresive wipe of LVMTEST resources."
2013-06-03 14:07:31 +04:00
@echo " LVM_TEST_RESULTS Where to create result files [results]."
2013-10-16 12:17:17 +04:00
@echo " LVM_TEST_THIN_CHECK_CMD Command for thin_check [ $( LVM_TEST_THIN_CHECK_CMD) ]. "
@echo " LVM_TEST_THIN_DUMP_CMD Command for thin_dump [ $( LVM_TEST_THIN_DUMP_CMD) ]. "
@echo " LVM_TEST_THIN_REPAIR_CMD Command for thin_repair [ $( LVM_TEST_THIN_REPAIR_CMD) ]. "
2013-06-09 00:23:39 +04:00
@echo " LVM_TEST_UNLIMITED Set to get unlimited test log (>32MB)"
2014-03-14 17:10:29 +04:00
@echo " LVM_VALGRIND Enable valgrind testing (1,2,3) execs $$ " VALGRIND
@echo " LVM_VALGRIND_CLVMD Enable valgrind testing of clvmd (1)."
@echo " LVM_VALGRIND_DMEVENTD Enable valgrind testing of dmeventd (1)."
@echo " LVM_VALGRIND_LVMETAD Enable valgrind testing of lvmetad (1)."
2012-03-28 15:10:08 +04:00
@echo " LVM_VERIFY_UDEV Default verify state for lvm.conf."
@echo " S Skip given test (regex)."
@echo " T Run given test (regex)."
@echo " VERBOSE Verbose output (1), timing (2)."
2013-05-27 05:12:03 +04:00
check : .tests -stamp
2013-09-19 16:03:03 +04:00
VERBOSE = $( VERBOSE) \
2013-05-27 05:12:03 +04:00
cluster_LVM_TEST_LOCKING = 3 \
lvmetad_LVM_TEST_LVMETAD = 1 \
./lib/harness $( patsubst %,normal:%,$( RUN_BASE) ) \
$( patsubst %,cluster:%,$( RUN_BASE) ) \
2013-12-05 15:31:49 +04:00
$( patsubst %,lvmetad:%,$( LVMETAD_RUN_BASE) )
2008-09-29 20:07:02 +04:00
2013-12-15 20:26:28 +04:00
check_system : .tests -stamp
2013-09-19 16:03:03 +04:00
VERBOSE = $( VERBOSE) \
2013-08-23 12:09:23 +04:00
scluster_LVM_TEST_LOCKING = 3 \
slvmetad_LVM_TEST_LVMETAD = 1 \
snormal_LVM_TEST_DEVDIR = /dev \
scluster_LVM_TEST_DEVDIR = /dev \
slvmetad_LVM_TEST_DEVDIR = /dev \
2013-12-15 20:26:28 +04:00
./lib/harness $( patsubst %,snormal:%,$( RUN_BASE) ) \
2013-08-23 12:09:23 +04:00
$( patsubst %,scluster:%,$( RUN_BASE) ) \
2013-12-05 15:31:49 +04:00
$( patsubst %,slvmetad:%,$( LVMETAD_RUN_BASE) )
2013-08-23 12:09:23 +04:00
2011-01-05 03:16:18 +03:00
check_cluster : .tests -stamp
2010-04-13 17:28:52 +04:00
@echo Testing with locking_type 3
2011-01-05 03:16:18 +03:00
VERBOSE = $( VERBOSE) LVM_TEST_LOCKING = 3 ./lib/harness $( RUN_BASE)
2010-04-13 17:28:52 +04:00
2011-01-05 03:16:18 +03:00
check_local : .tests -stamp
2010-04-13 17:28:52 +04:00
@echo Testing with locking_type 1
2011-01-05 03:16:18 +03:00
VERBOSE = $( VERBOSE) LVM_TEST_LOCKING = 1 ./lib/harness $( RUN_BASE)
2010-04-13 17:28:52 +04:00
2013-12-05 15:31:49 +04:00
i f e q ( "@BUILD_LVMETAD@" , "yes" )
2012-02-15 18:24:31 +04:00
check_lvmetad : .tests -stamp
@echo Testing with lvmetad on
VERBOSE = $( VERBOSE) LVM_TEST_LVMETAD = 1 ./lib/harness $( RUN_BASE)
2013-12-05 15:31:49 +04:00
e n d i f
2012-02-15 18:24:31 +04:00
2011-01-05 03:16:18 +03:00
lib/should : lib /not
ln -sf not lib/should
2009-01-12 21:45:44 +03:00
2014-03-28 03:34:04 +04:00
lib/invalid : lib /not
ln -sf not lib/invalid
lib/fail : lib /not
ln -sf not lib/fail
2011-11-23 18:56:47 +04:00
lib/% : lib /%.o .lib -dir -stamp
$( CC) $( LDFLAGS) -o $@ $<
2009-02-12 22:54:45 +03:00
2011-01-05 03:16:18 +03:00
lib/% : $( srcdir ) /lib /%.sh .lib -dir -stamp
cp $< $@
chmod +x $@
2010-04-12 23:02:59 +04:00
2011-01-05 03:16:18 +03:00
lib/paths : $( srcdir ) /Makefile .in .lib -dir -stamp
2011-11-23 16:21:41 +04:00
$( RM) $@ -t
2014-03-14 17:10:29 +04:00
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
2010-02-15 19:30:13 +03:00
echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@ -t
2012-10-10 02:20:22 +04:00
echo 'export THIN=@THIN@' >> $@ -t
2014-03-14 17:10:29 +04:00
echo 'export LVMETAD_PIDFILE="@LVMETAD_PIDFILE@"' >> $@ -t
echo 'export DMEVENTD_PIDFILE="@DMEVENTD_PIDFILE@"' >> $@ -t
2014-03-21 14:38:20 +04:00
echo 'export CLVMD_PIDFILE="@CLVMD_PIDFILE@"' >> $@ -t
2007-09-18 18:00:42 +04:00
mv $@ -t $@
2011-01-05 03:16:18 +03:00
2014-03-28 03:34:04 +04:00
LIB = lib/not lib/invalid lib/fail lib/should lib/harness \
2011-01-05 03:16:18 +03:00
lib/check lib/aux lib/test lib/utils lib/get lib/lvm-wrapper \
lib/paths
2011-09-25 01:10:19 +04:00
CMDS = lvm $( shell cat $( top_builddir) /tools/.commands)
2011-11-23 16:21:41 +04:00
.tests-stamp : $( ALL ) $( LIB ) $( SUBDIRS )
2010-12-12 23:36:38 +03:00
@if test " $( srcdir) " != . ; then \
2011-11-23 16:21:41 +04:00
echo "Linking tests to builddir." ; \
$( MKDIR_P) shell; \
for f in $( subst $( srcdir) /,,$( ALL) ) ; do \
ln -sf $( abs_top_srcdir) /test/$$ f $$ f; \
done ; \
2010-12-12 23:36:38 +03:00
fi
2013-06-09 00:23:39 +04:00
@$( MKDIR_P) -m a = rwx $( LVM_TEST_RESULTS)
2011-09-25 01:10:19 +04:00
touch $@
2009-09-04 16:54:23 +04:00
2011-11-23 16:21:41 +04:00
.lib-dir-stamp :
$( MKDIR_P) lib
2011-09-25 01:10:19 +04:00
for i in $( CMDS) ; do ln -fs lvm-wrapper lib/$$ i; done
2012-03-14 21:14:33 +04:00
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
2014-04-01 17:51:46 +04:00
ln -fs $( abs_top_srcdir) /conf/default.profile lib/default.profile
ln -fs $( abs_top_srcdir) /conf/thin-performance.profile lib/thin-performance.profile
2007-09-18 18:00:42 +04:00
touch $@
clean :
2011-11-23 17:03:57 +04:00
test " $( srcdir) " = . || $( RM) $( RUN_BASE)
2013-06-03 14:07:31 +04:00
$( RM) -r $( LVM_TEST_RESULTS)
2011-11-21 01:43:20 +04:00
2011-09-25 01:10:19 +04:00
CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $( LIB) $( addprefix lib/,$( CMDS) ) \
lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone
2008-06-27 23:24:17 +04:00
2011-11-23 16:21:41 +04:00
Makefile : $( srcdir ) /Makefile .in $( top_builddir ) /config .status
cd $( top_builddir) && $( SHELL) ./config.status $( subdir) /$@
2007-09-18 18:00:42 +04:00
.NOTPARALLEL :