2013-06-03 12:07:31 +02:00
# Copyright (C) 2007-2013 Red Hat, Inc. All rights reserved.
2007-09-18 14:02:22 +00: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 14:00:42 +00:00
#TEST_OPTS=--verbose --debug
SHELL_PATH ?= $( SHELL)
RM ?= rm -f
2011-11-23 12:21:41 +00:00
subdir = $( shell pwd| sed 's,.*/,,' )
2007-09-18 14:00:42 +00:00
2007-09-18 14:02:22 +00:00
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
2014-03-14 14:10:29 +01:00
abs_srcdir = @abs_srcdir@
abs_builddir = @abs_builddir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
2015-02-05 16:30:50 +01:00
datarootdir = @datarootdir@
2011-11-23 12:21:41 +00:00
2013-06-03 12:07:31 +02:00
LVM_TEST_RESULTS ?= results
2013-10-17 10:41:08 +02: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@
2014-05-26 23:28:03 +02:00
export LVM_TEST_THIN_RESTORE_CMD ?= @THIN_RESTORE_CMD@
2013-10-17 10:41:08 +02:00
2014-11-17 00:41:33 +01:00
export LVM_TEST_CACHE_CHECK_CMD ?= @CACHE_CHECK_CMD@
export LVM_TEST_CACHE_DUMP_CMD ?= @CACHE_DUMP_CMD@
export LVM_TEST_CACHE_REPAIR_CMD ?= @CACHE_REPAIR_CMD@
export LVM_TEST_CACHE_RESTORE_CMD ?= @CACHE_RESTORE_CMD@
2011-11-23 12:21:41 +00:00
SUBDIRS = api unit
2011-11-23 14:56:47 +00:00
SOURCES = lib/not.c lib/harness.c
2014-06-08 18:24:33 +02:00
CXXSOURCES = lib/runner.cpp
2011-11-23 12:21:41 +00:00
2011-01-13 14:58:59 +00:00
i n c l u d e $( top_builddir ) / m a k e . t m p l
2007-09-18 14:00:42 +00:00
2010-04-13 06:45:53 +00:00
T ?= .
2010-10-12 16:17:25 +00:00
S ?= @ # never match anything by default
2010-10-14 14:36:26 +00:00
VERBOSE ?= 0
2011-11-21 00:15:42 +00:00
ALL = $( shell find $( srcdir) \( -path \* /shell/\* .sh -or -path \* /api/\* .sh \) | sort)
2013-10-09 14:02:34 +02: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-24 21:10:19 +00:00
RUN_BASE = $( subst $( srcdir) /,,$( RUN) )
2010-04-13 06:45:53 +00:00
2013-12-05 12:31:49 +01:00
i f e q ( "@BUILD_LVMETAD@" , "yes" )
LVMETAD_RUN_BASE = $( RUN_BASE)
2015-04-14 09:45:36 +02:00
LVMETAD_NDEV_FLAVOUR = ,ndev-lvmetad
LVMETAD_UDEV_FLAVOUR = ,udev-lvmetad
2013-12-05 12:31:49 +01:00
e n d i f
2009-11-30 14:59:26 +00:00
# Shell quote;
SHELL_PATH_SQ = $( subst ',' \' ' ,$( SHELL_PATH) )
2010-01-11 15:48:49 +00:00
i f e q ( "@UDEV_SYNC@" , "yes" )
2010-02-15 16:30:13 +00:00
dm_udev_synchronisation = 1
2010-01-11 15:48:49 +00:00
e n d i f
2014-06-27 01:00:37 +02:00
all : .tests -stamp
2011-09-24 21:10:19 +00:00
2012-03-28 11:10:08 +00: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 14:10:29 +01:00
@echo " LVM_TEST_CAN_CLOBBER_DMESG Allow to clobber dmesg buffer without /dev/kmsg. (1)"
2012-03-28 11:10:08 +00:00
@echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev."
2014-05-26 23:28:03 +02:00
@echo " LVM_TEST_DIR Where to create test files [ $( LVM_TEST_DIR) ]. "
2012-03-28 11:10:08 +00: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 12:07:31 +02:00
@echo " LVM_TEST_RESULTS Where to create result files [results]."
2014-05-26 23:28:03 +02: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) ]. "
@echo " LVM_TEST_THIN_RESTORE_CMD Command for thin_restore [ $( LVM_TEST_THIN_RESTORE_CMD) ]. "
2014-11-17 00:41:33 +01:00
@echo " LVM_TEST_CACHE_CHECK_CMD Command for cache_check [ $( LVM_TEST_CACHE_CHECK_CMD) ]. "
@echo " LVM_TEST_CACHE_DUMP_CMD Command for cache_dump [ $( LVM_TEST_CACHE_DUMP_CMD) ]. "
@echo " LVM_TEST_CACHE_REPAIR_CMD Command for cache_repair [ $( LVM_TEST_CACHE_REPAIR_CMD) ]. "
@echo " LVM_TEST_CACHE_RESTORE_CMD Command for cache_restore [ $( LVM_TEST_CACHE_RESTORE_CMD) ]. "
2013-06-08 22:23:39 +02:00
@echo " LVM_TEST_UNLIMITED Set to get unlimited test log (>32MB)"
2015-04-14 09:45:36 +02:00
@echo " LVM_VALGRIND Enable valgrind testing, execs $$ " VALGRIND.
2014-03-14 14:10:29 +01:00
@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)."
2015-04-14 09:45:36 +02:00
@echo " LVM_STRACE Enable strace logging."
@echo " LVM_DEBUG_LEVEL Sets debuging level for valgrind/strace (use > 0)."
2012-03-28 11:10:08 +00: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 03:12:03 +02:00
check : .tests -stamp
2014-06-27 01:00:37 +02:00
VERBOSE = $( VERBOSE) ./lib/runner \
2015-03-11 21:11:09 +01:00
--testdir . --outdir $( LVM_TEST_RESULTS) \
2015-04-14 09:45:36 +02:00
--flavours ndev-vanilla,ndev-cluster$( LVMETAD_NDEV_FLAVOUR) --only $( T) --skip $( S)
2008-09-29 16:07:02 +00:00
2013-12-15 17:26:28 +01:00
check_system : .tests -stamp
2014-06-27 01:00:37 +02:00
VERBOSE = $( VERBOSE) ./lib/runner \
2015-03-11 21:11:09 +01:00
--testdir . --outdir $( LVM_TEST_RESULTS) \
2015-04-14 09:45:36 +02:00
--flavours udev-vanilla,udev-cluster$( LVMETAD_UDEV_FLAVOUR) --only $( T) --skip $( S)
2013-08-23 10:09:23 +02:00
2011-01-05 00:16:18 +00:00
check_cluster : .tests -stamp
2014-06-27 01:00:37 +02:00
VERBOSE = $( VERBOSE) ./lib/runner \
2015-03-11 21:11:09 +01:00
--testdir . --outdir $( LVM_TEST_RESULTS) \
2014-09-14 11:11:12 +02:00
--flavours ndev-cluster --only $( T) --skip $( S)
2010-04-13 13:28:52 +00:00
2011-01-05 00:16:18 +00:00
check_local : .tests -stamp
2014-06-27 01:00:37 +02:00
VERBOSE = $( VERBOSE) ./lib/runner \
2015-03-11 21:11:09 +01:00
--testdir . --outdir $( LVM_TEST_RESULTS) \
2014-09-14 11:11:12 +02:00
--flavours ndev-vanilla --only $( T) --skip $( S)
2010-04-13 13:28:52 +00:00
2013-12-05 12:31:49 +01:00
i f e q ( "@BUILD_LVMETAD@" , "yes" )
2012-02-15 14:24:31 +00:00
check_lvmetad : .tests -stamp
2014-06-27 01:00:37 +02:00
VERBOSE = $( VERBOSE) ./lib/runner \
2015-03-11 21:11:09 +01:00
--testdir . --outdir $( LVM_TEST_RESULTS) \
2014-09-14 11:11:12 +02:00
--flavours ndev-lvmetad --only $( T) --skip $( S)
2013-12-05 12:31:49 +01:00
e n d i f
2012-02-15 14:24:31 +00:00
2014-06-27 01:00:37 +02:00
DATADIR = $( datadir) /lvm2-testsuite
EXECDIR = $( libexecdir) /lvm2-testsuite
LIB_FLAVOURS = lib/flavour-ndev-vanilla lib/flavour-ndev-cluster lib/flavour-ndev-lvmetad \
lib/flavour-udev-vanilla lib/flavour-udev-cluster lib/flavour-udev-lvmetad
LIB_LOCAL = lib/paths lib/runner
LIB_EXEC = lib/not lib/invalid lib/fail lib/should
LIB_SHARED = lib/check lib/aux lib/inittest lib/utils lib/get lib/lvm-wrapper
install : .tests -stamp lib /paths -installed
@echo $( srcdir)
@echo $( LIB_FLAVOURS)
$( INSTALL_DIR) $( DATADIR) /{ shell,api,lib}
$( INSTALL_DATA) shell/*.sh $( DATADIR) /shell/
$( INSTALL_DATA) api/*.sh $( DATADIR) /api/
2015-04-22 10:57:42 +02:00
$( INSTALL_PROGRAM) api/*.{ t,py} $( DATADIR) /api/
2014-06-27 01:00:37 +02:00
$( INSTALL_DATA) lib/paths-installed $( DATADIR) /lib/paths
$( INSTALL_DATA) $( LIB_FLAVOURS) $( DATADIR) /lib/
2015-04-22 10:57:42 +02:00
$( INSTALL_DATA) $( abs_top_srcdir) /conf/thin-performance.profile $( DATADIR) /lib/thin-performance.profile
2014-06-27 01:00:37 +02:00
$( INSTALL_SCRIPT) $( LIB_SHARED) $( DATADIR) /lib/
2014-09-30 17:08:34 +02:00
for i in $( CMDS) ; do ( cd $( DATADIR) /lib && ln -fs lvm-wrapper $$ i) ; done
2014-06-27 01:00:37 +02:00
$( INSTALL_DIR) $( EXECDIR)
$( INSTALL_PROGRAM) $( LIB_EXEC) $( EXECDIR)
$( INSTALL_PROGRAM) -D lib/runner $( bindir) /lvm2-testsuite
2011-01-05 00:16:18 +00:00
lib/should : lib /not
ln -sf not lib/should
2009-01-12 18:45:44 +00:00
2014-03-28 00:34:04 +01:00
lib/invalid : lib /not
ln -sf not lib/invalid
lib/fail : lib /not
ln -sf not lib/fail
2014-06-08 18:24:33 +02:00
lib/runner : lib /runner .o .lib -dir -stamp
$( CXX) $( LDFLAGS) -o $@ $<
2014-06-25 21:34:34 +02:00
lib/runner.o : $( wildcard $ ( srcdir ) /lib /*.h )
2011-11-23 14:56:47 +00:00
lib/% : lib /%.o .lib -dir -stamp
$( CC) $( LDFLAGS) -o $@ $<
2009-02-12 19:54:45 +00:00
2011-01-05 00:16:18 +00:00
lib/% : $( srcdir ) /lib /%.sh .lib -dir -stamp
cp $< $@
chmod +x $@
2010-04-12 19:02:59 +00:00
2014-06-27 09:10:56 +02:00
lib/flavour-% : $( srcdir ) /lib /flavour -%.sh .lib -dir -stamp
2014-06-27 01:00:37 +02:00
cp $< $@
lib/paths-common : $( srcdir ) /Makefile .in .lib -dir -stamp Makefile
2010-02-15 16:30:13 +00:00
echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@ -t
2012-10-10 00:20:22 +02:00
echo 'export THIN=@THIN@' >> $@ -t
2014-05-20 19:54:48 +02:00
echo 'export RAID=@RAID@' >> $@ -t
echo 'export CACHE=@CACHE@' >> $@ -t
2014-03-14 14:10:29 +01:00
echo 'export LVMETAD_PIDFILE="@LVMETAD_PIDFILE@"' >> $@ -t
echo 'export DMEVENTD_PIDFILE="@DMEVENTD_PIDFILE@"' >> $@ -t
2014-03-21 11:38:20 +01:00
echo 'export CLVMD_PIDFILE="@CLVMD_PIDFILE@"' >> $@ -t
2015-04-15 13:08:41 +02:00
echo 'export LVM_TEST_THIN_CHECK_CMD=$${LVM_TEST_THIN_CHECK_CMD-@THIN_CHECK_CMD@}' >> $@ -t
echo 'export LVM_TEST_THIN_DUMP_CMD=$${LVM_TEST_THIN_DUMP_CMD-@THIN_DUMP_CMD@}' >> $@ -t
echo 'export LVM_TEST_THIN_REPAIR_CMD=$${LVM_TEST_THIN_REPAIR_CMD-@THIN_REPAIR_CMD@}' >> $@ -t
echo 'export LVM_TEST_THIN_RESTORE_CMD=$${LVM_TEST_THIN_RESTORE_CMD-@THIN_RESTORE_CMD@}' >> $@ -t
echo 'export LVM_TEST_CACHE_CHECK_CMD=$${LVM_TEST_CACHE_CHECK_CMD-@CACHE_CHECK_CMD@}' >> $@ -t
echo 'export LVM_TEST_CACHE_DUMP_CMD=$${LVM_TEST_CACHE_DUMP_CMD-@CACHE_DUMP_CMD@}' >> $@ -t
echo 'export LVM_TEST_CACHE_REPAIR_CMD=$${LVM_TEST_CACHE_REPAIR_CMD-@CACHE_REPAIR_CMD@}' >> $@ -t
echo 'export LVM_TEST_CACHE_RESTORE_CMD=$${LVM_TEST_CACHE_RESTORE_CMD-@CACHE_RESTORE_CMD@}' >> $@ -t
2007-09-18 14:00:42 +00:00
mv $@ -t $@
2011-01-05 00:16:18 +00:00
2014-06-27 01:00:37 +02:00
lib/paths-installed : lib /paths -common
$( RM) $@ -t
cat lib/paths-common > $@ -t
echo 'installed_testsuite=1' >> $@ -t
echo 'export PATH=@libexecdir@/lvm2-testsuite:@datadir@/lvm2-testsuite/lib:$$PATH' >> $@ -t
mv $@ -t $@
lib/paths : lib /paths -common
$( RM) $@ -t
cat lib/paths-common > $@ -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
mv $@ -t $@
2011-01-05 00:16:18 +00:00
2011-09-24 21:10:19 +00:00
CMDS = lvm $( shell cat $( top_builddir) /tools/.commands)
2014-06-27 01:00:37 +02:00
LIB = $( LIB_SHARED) $( LIB_LOCAL) $( LIB_EXEC) $( LIB_FLAVOURS)
2011-09-24 21:10:19 +00:00
2011-11-23 12:21:41 +00:00
.tests-stamp : $( ALL ) $( LIB ) $( SUBDIRS )
2010-12-12 20:36:38 +00:00
@if test " $( srcdir) " != . ; then \
2011-11-23 12:21:41 +00: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 20:36:38 +00:00
fi
2013-06-08 22:23:39 +02:00
@$( MKDIR_P) -m a = rwx $( LVM_TEST_RESULTS)
2011-09-24 21:10:19 +00:00
touch $@
2009-09-04 12:54:23 +00:00
2011-11-23 12:21:41 +00:00
.lib-dir-stamp :
$( MKDIR_P) lib
2011-09-24 21:10:19 +00:00
for i in $( CMDS) ; do ln -fs lvm-wrapper lib/$$ i; done
2012-03-14 17:14:33 +00: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 15:51:46 +02:00
ln -fs $( abs_top_srcdir) /conf/thin-performance.profile lib/thin-performance.profile
2007-09-18 14:00:42 +00:00
touch $@
2015-03-11 21:11:09 +01:00
cleantest :
2011-11-23 13:03:57 +00:00
test " $( srcdir) " = . || $( RM) $( RUN_BASE)
2013-06-03 12:07:31 +02:00
$( RM) -r $( LVM_TEST_RESULTS)
2011-11-20 21:43:20 +00:00
2015-03-11 21:11:09 +01:00
clean : cleantest
distclean : cleantest
2011-09-24 21:10:19 +00:00
CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $( LIB) $( addprefix lib/,$( CMDS) ) \
2014-10-02 09:30:38 +02:00
lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone \
2015-04-22 10:57:42 +02:00
lib/thin-performance.profile lib/harness \
lib/paths-installed lib/paths-installed-t \
lib/paths-common lib/paths-common-t
2008-06-27 19:24:17 +00:00
2011-11-23 12:21:41 +00:00
Makefile : $( srcdir ) /Makefile .in $( top_builddir ) /config .status
cd $( top_builddir) && $( SHELL) ./config.status $( subdir) /$@
2007-09-18 14:00:42 +00:00
.NOTPARALLEL :