master - test: Make it possible to run tests from an installed location.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b4215f956f4576...
Commit: b4215f956f4576ce38b19a9a9ca216e9d096fe5a
Parent: 569895394895ea4354a3ab8de919f99acf5a5e87
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:59:17 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Make it possible to run tests from an installed location.
---
test/lib/utils.sh | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/test/lib/utils.sh b/test/lib/utils.sh
index b4cfdeb..70f8ca5 100644
--- a/test/lib/utils.sh
+++ b/test/lib/utils.sh
@@ -207,18 +207,21 @@ prepare_test_vars() {
done
}
-# check if $abs_top_builddir was already set via 'lib/paths'
-test -n "${abs_top_builddir+varset}" || . lib/paths || die "you must run make first"
-
-case "$PATH" in
-*"$abs_top_builddir/test/lib"*) ;;
-*)
- PATH="$abs_top_builddir/test/lib":"$abs_top_builddir/test/api":$PATH
- for i in `find $abs_top_builddir -name \*.so`; do
- p=`dirname $i`
- LD_LIBRARY_PATH="$p":$LD_LIBRARY_PATH
- done
- export PATH LD_LIBRARY_PATH ;;
-esac
+if test -z "${abs_top_builddir+varset}" && test -z "${installed_testsuite+varset}"; then
+ . lib/paths || die "something went wrong -- lib/paths is missing?"
+fi
+
+if test -z "${installed_testsuite+varset}"; then
+ case "$PATH" in
+ *"$abs_top_builddir/test/lib"*) ;;
+ *)
+ PATH="$abs_top_builddir/test/lib":"$abs_top_builddir/test/api":$PATH
+ for i in `find $abs_top_builddir -name \*.so`; do
+ p=`dirname $i`
+ LD_LIBRARY_PATH="$p":$LD_LIBRARY_PATH
+ done
+ export PATH LD_LIBRARY_PATH ;;
+ esac
+fi
test -z "$PREFIX" || prepare_test_vars
9 years, 2 months
master - test: Use the new flavour setup files in lib/inittest.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=569895394895ea...
Commit: 569895394895ea4354a3ab8de919f99acf5a5e87
Parent: 9752ee8ed2322b9f35f16e259c87b525796d4b2d
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:58:28 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Use the new flavour setup files in lib/inittest.
---
test/lib/inittest.sh | 22 ++++++++++------------
1 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 731cd7a..7f49b02 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -39,19 +39,23 @@ test -n "$BASH" && trap 'set +vx; STACKTRACE; set -vx' ERR
trap 'aux teardown' EXIT # don't forget to clean up
cd "$TESTDIR"
+mkdir lib
+
+# Setting up symlink from $i to $TESTDIR/lib
+test -n "$abs_top_builddir" && \
+ find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \
+ -exec ln -s -t lib "{}" +
+find "$TESTOLDPWD/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \
+ -o -name '*~' \) -exec ln -s -t lib "{}" +
if test -n "$LVM_TEST_FLAVOUR"; then
- touch flavour_overrides
- env | grep ^${LVM_TEST_FLAVOUR} | while read var; do
- (echo -n "export "; echo $var | sed -e s,^${LVM_TEST_FLAVOUR}_,,) >> flavour_overrides
- done
- . flavour_overrides
+ . lib/flavour-$LVM_TEST_FLAVOUR
fi
DM_DEFAULT_NAME_MANGLING_MODE=none
DM_DEV_DIR="$TESTDIR/dev"
LVM_SYSTEM_DIR="$TESTDIR/etc"
-mkdir "$LVM_SYSTEM_DIR" "$TESTDIR/lib" "$DM_DEV_DIR"
+mkdir "$LVM_SYSTEM_DIR" "$DM_DEV_DIR"
if test -n "$LVM_TEST_DEVDIR" ; then
DM_DEV_DIR=$LVM_TEST_DEVDIR
else
@@ -76,12 +80,6 @@ else
echo "Selinux mode is not installed."
fi
-# Setting up symlink from $i to $TESTDIR/lib
-find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \
- -exec ln -s -t lib "{}" +
-find "$abs_top_builddir/test/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \
- -o -name '*~' \) -exec ln -s -t lib "{}" +
-
# Set vars from utils now that we have TESTDIR/PREFIX/...
prepare_test_vars
9 years, 2 months
master - test: Fix IO sink destructors in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9752ee8ed2322b...
Commit: 9752ee8ed2322b9f35f16e259c87b525796d4b2d
Parent: df27c6404197dd07f1a8a260736111bf5615cf26
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:54:56 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Fix IO sink destructors in the runner.
---
test/lib/io.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/test/lib/io.h b/test/lib/io.h
index 7f71208..c93b401 100644
--- a/test/lib/io.h
+++ b/test/lib/io.h
@@ -53,6 +53,7 @@ struct Sink {
virtual void outline( bool ) {}
virtual void push( std::string x ) = 0;
virtual void sync() {}
+ virtual ~Sink() {}
};
struct BufSink : Sink {
@@ -241,11 +242,14 @@ struct IO : Sink {
return *this;
}
- ~IO() {
+ void clear() {
for ( Sinks::iterator i = sinks.begin(); i != sinks.end(); ++i )
delete *i;
+ sinks.clear();
}
+ ~IO() { clear(); }
+
};
#endif
9 years, 2 months
master - test: Add a buffer-backed IO sink (for interactive runs).
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=df27c6404197dd...
Commit: df27c6404197dd07f1a8a260736111bf5615cf26
Parent: f53fcc0746184d2d221a3c37e71769b4accabf19
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:54:36 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Add a buffer-backed IO sink (for interactive runs).
---
test/lib/io.h | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/test/lib/io.h b/test/lib/io.h
index c96382c..7f71208 100644
--- a/test/lib/io.h
+++ b/test/lib/io.h
@@ -55,6 +55,23 @@ struct Sink {
virtual void sync() {}
};
+struct BufSink : Sink {
+ std::vector< char > data;
+ virtual void push( std::string x ) {
+ std::copy( x.begin(), x.end(), std::back_inserter( data ) );
+ }
+
+ void dump( std::ostream &o ) {
+ std::vector< char >::iterator b = data.begin(), e = data.begin();
+ o << std::endl;
+ while ( e != data.end() ) {
+ e = std::find( b, data.end(), '\n' );
+ o << "| " << std::string( b, e ) << std::endl;
+ b = (e == data.end() ? e : e + 1);
+ }
+ }
+};
+
struct FdSink : Sink {
int fd;
9 years, 2 months
master - test: Implement a file-backed IO sink in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f53fcc0746184d...
Commit: f53fcc0746184d2d221a3c37e71769b4accabf19
Parent: bdd0bc83ebc3b753b45f2e7465a40c2b6b7bac27
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:53:36 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Implement a file-backed IO sink in the runner.
---
test/lib/io.h | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/test/lib/io.h b/test/lib/io.h
index 28e40d8..c96382c 100644
--- a/test/lib/io.h
+++ b/test/lib/io.h
@@ -95,6 +95,8 @@ struct FdSink : Sink {
}
virtual void sync() {
+ if ( killed )
+ return;
while ( !stream.empty() )
outline( true );
}
@@ -107,6 +109,26 @@ struct FdSink : Sink {
FdSink( int _fd ) : fd( _fd ), killed( false ) {}
};
+struct FileSink : FdSink {
+ std::string file;
+ FileSink( std::string n ) : FdSink( -1 ), file( n ) {}
+
+ void sync() {
+ if ( fd < 0 && !killed ) {
+ fd = open( file.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644 );
+ if ( fd < 0 )
+ killed = true;
+ }
+ FdSink::sync();
+ }
+ ~FileSink() {
+ if ( fd >= 0 ) {
+ fsync( fd );
+ close( fd );
+ }
+ }
+};
+
struct Observer : Sink {
Observer() {}
void push( std::string ) {}
9 years, 2 months
master - test: Make runner use bigger IO buffers, put them on stack.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bdd0bc83ebc3b7...
Commit: bdd0bc83ebc3b753b45f2e7465a40c2b6b7bac27
Parent: 7957fc4a4449d301d2c0743e2037eadd4bcc4f9d
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:52:07 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Make runner use bigger IO buffers, put them on stack.
---
test/lib/io.h | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/test/lib/io.h b/test/lib/io.h
index 8ade281..28e40d8 100644
--- a/test/lib/io.h
+++ b/test/lib/io.h
@@ -114,7 +114,6 @@ struct Observer : Sink {
struct KMsg {
int fd;
- char buf[ 4096 ];
bool dev_kmsg() {
return fd >= 0;
@@ -136,6 +135,8 @@ struct KMsg {
void read( Sink *s ) {
int sz;
+ char buf[ 128 * 1024 ];
+
if ( dev_kmsg() ) {
while ( (sz = ::read(fd, buf, sizeof(buf) - 1)) > 0 )
s->push( std::string( buf, sz ) );
@@ -144,8 +145,7 @@ struct KMsg {
read( s );
}
} else {
- sz = klogctl( SYSLOG_ACTION_READ_CLEAR, buf, sizeof(buf) - 1 );
- if ( sz > 0 )
+ while ( (sz = klogctl( SYSLOG_ACTION_READ_CLEAR, buf, sizeof(buf) - 1 )) > 0 )
s->push( std::string( buf, sz ) );
}
}
@@ -160,7 +160,6 @@ struct IO : Sink {
KMsg kmsg;
int fd;
- char buf[ 4096 ];
virtual void push( std::string x ) {
for ( Sinks::iterator i = sinks.begin(); i != sinks.end(); ++i )
@@ -169,6 +168,8 @@ struct IO : Sink {
void sync() {
ssize_t sz;
+ char buf[ 128 * 1024 ];
+
while ( (sz = read(fd, buf, sizeof(buf) - 1)) > 0 )
push( std::string( buf, sz ) );
9 years, 2 months
master - test: Allow test devices backed by a permanent block device.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7957fc4a4449d3...
Commit: 7957fc4a4449d301d2c0743e2037eadd4bcc4f9d
Parent: c5a120c4439875c75549da97d2dcd752642fcc50
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 00:44:53 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Allow test devices backed by a permanent block device.
---
test/lib/aux.sh | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 2fef207..9def304 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -273,7 +273,7 @@ prepare_loop() {
echo -n .
local LOOPFILE="$PWD/test.img"
- dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size-1)) 2> /dev/null
+ dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size)) 2> /dev/null
if LOOP=$(losetup -s -f "$LOOPFILE" 2>/dev/null); then
:
elif LOOP=$(losetup -f) && losetup "$LOOP" "$LOOPFILE"; then
@@ -295,7 +295,9 @@ prepare_loop() {
done
fi
test -n "$LOOP" # confirm or fail
+ BACKING_DEV="$LOOP"
echo "$LOOP" > LOOP
+ echo "$LOOP" > BACKING_DEV
echo "ok ($LOOP)"
}
@@ -339,20 +341,24 @@ cleanup_scsi_debug_dev() {
rm -f SCSI_DEBUG_DEV LOOP
}
+prepare_backing_dev() {
+ if test -b "$LVM_TEST_BACKING_DEVICE"; then
+ BACKING_DEV="$LVM_TEST_BACKING_DEVICE"
+ echo "$BACKING_DEV" > BACKING_DEV
+ else
+ prepare_loop "$@"
+ fi
+}
+
prepare_devs() {
local n=${1:-3}
local devsize=${2:-34}
local pvname=${3:-pv}
- local loopsz
- prepare_loop $(($n*$devsize))
+ prepare_backing_dev $(($n*$devsize))
echo -n "## preparing $n devices..."
- if ! loopsz=$(blockdev --getsz "$LOOP" 2>/dev/null); then
- loopsz=$(blockdev --getsize "$LOOP" 2>/dev/null)
- fi
-
- local size=$(($loopsz/$n))
+ local size=$(($devsize*2048)) # sectors
local count=0
init_udev_transaction
for i in $(seq 1 $n); do
@@ -360,11 +366,16 @@ prepare_devs() {
local dev="$DM_DEV_DIR/mapper/$name"
DEVICES[$count]=$dev
count=$(( $count + 1 ))
- echo 0 $size linear "$LOOP" $((($i-1)*$size)) > "$name.table"
+ echo 0 $size linear "$BACKING_DEV" $((($i-1)*$size)) > "$name.table"
dmsetup create -u "TEST-$name" "$name" "$name.table"
done
finish_udev_transaction
+ # non-ephemeral devices need to be cleared between tests
+ test -f LOOP || for d in ${DEVICES[@]}; do
+ dd if=/dev/zero of=$d bs=1M count=1
+ done
+
#for i in `seq 1 $n`; do
# local name="${PREFIX}$pvname$i"
# dmsetup info -c $name
9 years, 2 months
master - test: Add new flavour definition files.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c5a120c4439875...
Commit: c5a120c4439875c75549da97d2dcd752642fcc50
Parent: fa46385164e971d998ef89f20162fe547efeaea0
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Jun 26 22:34:38 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Add new flavour definition files.
---
test/lib/flavour-ndev-cluster | 1 +
test/lib/flavour-ndev-lvmetad | 2 ++
test/lib/flavour-ndev-vanilla | 1 +
test/lib/flavour-udev-cluster | 2 ++
test/lib/flavour-udev-lvmetad | 3 +++
test/lib/flavour-udev-vanilla | 2 ++
6 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/test/lib/flavour-ndev-cluster b/test/lib/flavour-ndev-cluster
new file mode 100644
index 0000000..013b02d
--- /dev/null
+++ b/test/lib/flavour-ndev-cluster
@@ -0,0 +1 @@
+LVM_TEST_LOCKING=3
diff --git a/test/lib/flavour-ndev-lvmetad b/test/lib/flavour-ndev-lvmetad
new file mode 100644
index 0000000..6f8c2d4
--- /dev/null
+++ b/test/lib/flavour-ndev-lvmetad
@@ -0,0 +1,2 @@
+LVM_TEST_LOCKING=1
+LVM_TEST_LVMETAD=1
diff --git a/test/lib/flavour-ndev-vanilla b/test/lib/flavour-ndev-vanilla
new file mode 100644
index 0000000..b3f4cee
--- /dev/null
+++ b/test/lib/flavour-ndev-vanilla
@@ -0,0 +1 @@
+LVM_TEST_LOCKING=1
diff --git a/test/lib/flavour-udev-cluster b/test/lib/flavour-udev-cluster
new file mode 100644
index 0000000..7c37616
--- /dev/null
+++ b/test/lib/flavour-udev-cluster
@@ -0,0 +1,2 @@
+LVM_TEST_LOCKING=3
+LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-lvmetad b/test/lib/flavour-udev-lvmetad
new file mode 100644
index 0000000..e1dac52
--- /dev/null
+++ b/test/lib/flavour-udev-lvmetad
@@ -0,0 +1,3 @@
+LVM_TEST_LOCKING=1
+LVM_TEST_LVMETAD=1
+LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-vanilla b/test/lib/flavour-udev-vanilla
new file mode 100644
index 0000000..09d023a
--- /dev/null
+++ b/test/lib/flavour-udev-vanilla
@@ -0,0 +1,2 @@
+LVM_TEST_LOCKING=1
+LVM_TEST_DEVDIR=/dev
9 years, 2 months
master - test: Write a results/list at the end of a test run.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa46385164e971...
Commit: fa46385164e971d998ef89f20162fe547efeaea0
Parent: bf1693786905777d0ad0857797fe742889eebcd4
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Jun 26 01:11:19 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Write a results/list at the end of a test run.
---
test/lib/journal.h | 8 ++++++--
test/lib/runner.cpp | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/test/lib/journal.h b/test/lib/journal.h
index 6d0e243..d2f028c 100644
--- a/test/lib/journal.h
+++ b/test/lib/journal.h
@@ -62,11 +62,15 @@ struct Journal {
std::string location_tmp, location;
- void sync() {
- std::ofstream of( location_tmp.c_str() );
+ void write( std::string path ) {
+ std::ofstream of( path.c_str() );
for ( Status::iterator i = status.begin(); i != status.end(); ++i )
of << i->first << " " << i->second << std::endl;
of.close();
+ }
+
+ void sync() {
+ write( location_tmp );
rename( location_tmp.c_str(), location.c_str() );
}
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index a0f9fbd..287b8f9 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -315,6 +315,7 @@ struct Main {
}
journal.banner();
+ journal.write( options.outdir + "/list" );
if ( die || fatal_signal )
exit( 1 );
}
9 years, 2 months
master - test: Clean up fds properly in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bf169378690577...
Commit: bf1693786905777d0ad0857797fe742889eebcd4
Parent: d2dbc65f00abe5ccf44af3545a1ec1ddd5ebdad7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Jun 26 01:08:57 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:16 2015 +0100
test: Clean up fds properly in the runner.
---
test/lib/runner.cpp | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 0875b02..a0f9fbd 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -75,6 +75,7 @@ struct TestProcess
close( STDIN_FILENO );
dup2( fd, STDOUT_FILENO );
dup2( fd, STDERR_FILENO );
+ close( fd );
}
environment();
@@ -225,7 +226,7 @@ struct TestCase {
else
r = Journal::FAILED;
- ::close( io.fd );
+ io.close();
/*
if ((fd_debuglog = open(testdirdebug, O_RDONLY)) != -1) {
@@ -247,6 +248,7 @@ struct TestCase {
io.close();
child.exec();
} else {
+ ::close( child.fd );
journal->started( name );
progress( First ) << tag( "running" ) << name << std::flush;
if ( options.verbose || options.interactive )
9 years, 2 months