master - test: Run in /tmp if LVM_TEST_DIR is unset.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=48275c78361578...
Commit: 48275c78361578672f5f3f5c29737404cf159f6d
Parent: 246fecee277cbabe6d377b80c43dee22485e3872
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:16:49 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Run in /tmp if LVM_TEST_DIR is unset.
---
test/lib/inittest.sh | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 7f49b02..5b3ad87 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -29,7 +29,8 @@ TESTOLDPWD=$(pwd)
COMMON_PREFIX="LVMTEST"
PREFIX="${COMMON_PREFIX}$$"
-TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-$TESTOLDPWD}" "$PREFIX.XXXXXXXXXX") || \
+if test -n "$LVM_TEST_DIR"; then LVM_TEST_DIR=$TMPDIR; fi
+TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-/tmp}" "$PREFIX.XXXXXXXXXX") || \
die "failed to create temporary directory in ${LVM_TEST_DIR:-$TESTOLDPWD}"
RUNNING_DMEVENTD=$(pgrep dmeventd) || true
9 years, 2 months
master - test: Rename the --quiet option to --batch.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=246fecee277cba...
Commit: 246fecee277cbabe6d377b80c43dee22485e3872
Parent: feb2c7bc4773e88f2fa96ef838e88d5b427835b0
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 21:46:07 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Rename the --quiet option to --batch.
---
test/lib/runner.cpp | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index bfcea91..fde441b 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -58,10 +58,10 @@ bool fatal_signal = false;
bool interrupt = false;
struct Options {
- bool verbose, quiet, interactive, cont;
+ bool verbose, batch, interactive, cont;
std::string testdir, outdir;
std::vector< std::string > flavours;
- Options() : verbose( false ), quiet( false ), interactive( false ), cont( false ) {}
+ Options() : verbose( false ), batch( false ), interactive( false ), cont( false ) {}
};
struct TestProcess
@@ -175,7 +175,7 @@ struct TestCase {
wait.tv_sec = 0;
wait.tv_usec = 500000; /* timeout 0.5s */
- if ( !options.verbose && !options.interactive )
+ if ( !options.verbose && !options.interactive && !options.batch )
progress( Update ) << tag( "running" ) << pretty() << " " << end - start << std::flush;
if ( select( io.fd + 1, &set, NULL, NULL, &wait ) > 0 )
@@ -445,19 +445,19 @@ int main(int argc, char **argv)
if ( args.has( "--continue" ) )
opt.cont = true;
- if ( args.has( "--quiet" ) || hasenv( "QUIET" ) ) {
+ if ( args.has( "--batch" ) || hasenv( "BATCH" ) ) {
opt.verbose = false;
- opt.quiet = true;
+ opt.batch = true;
}
if ( args.has( "--verbose" ) || hasenv( "VERBOSE" ) ) {
- opt.quiet = false;
+ opt.batch = false;
opt.verbose = true;
}
if ( args.has( "--interactive" ) || hasenv( "INTERACTIVE" ) ) {
opt.verbose = false;
- opt.quiet = false;
+ opt.batch = false;
opt.interactive = true;
}
9 years, 2 months
master - test: Targets and sources can't have the same name if builddir == srcdir.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=feb2c7bc4773e8...
Commit: feb2c7bc4773e88f2fa96ef838e88d5b427835b0
Parent: 2bc76bcdabe76876c59f9fec61292240993974bc
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 09:10:56 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Targets and sources can't have the same name if builddir == srcdir.
---
test/Makefile.in | 2 +-
test/lib/flavour-ndev-cluster | 1 -
test/lib/flavour-ndev-cluster.sh | 1 +
test/lib/flavour-ndev-lvmetad | 2 --
test/lib/flavour-ndev-lvmetad.sh | 2 ++
test/lib/flavour-ndev-vanilla | 1 -
test/lib/flavour-ndev-vanilla.sh | 1 +
test/lib/flavour-udev-cluster | 2 --
test/lib/flavour-udev-cluster.sh | 2 ++
test/lib/flavour-udev-lvmetad | 3 ---
test/lib/flavour-udev-lvmetad.sh | 3 +++
test/lib/flavour-udev-vanilla | 2 --
test/lib/flavour-udev-vanilla.sh | 2 ++
13 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index d930888..82adf20 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -171,7 +171,7 @@ lib/%: $(srcdir)/lib/%.sh .lib-dir-stamp
cp $< $@
chmod +x $@
-lib/flavour-%: $(srcdir)/lib/flavour-% .lib-dir-stamp
+lib/flavour-%: $(srcdir)/lib/flavour-%.sh .lib-dir-stamp
cp $< $@
lib/paths-common: $(srcdir)/Makefile.in .lib-dir-stamp Makefile
diff --git a/test/lib/flavour-ndev-cluster b/test/lib/flavour-ndev-cluster
deleted file mode 100644
index 013b02d..0000000
--- a/test/lib/flavour-ndev-cluster
+++ /dev/null
@@ -1 +0,0 @@
-LVM_TEST_LOCKING=3
diff --git a/test/lib/flavour-ndev-cluster.sh b/test/lib/flavour-ndev-cluster.sh
new file mode 100644
index 0000000..013b02d
--- /dev/null
+++ b/test/lib/flavour-ndev-cluster.sh
@@ -0,0 +1 @@
+LVM_TEST_LOCKING=3
diff --git a/test/lib/flavour-ndev-lvmetad b/test/lib/flavour-ndev-lvmetad
deleted file mode 100644
index 6f8c2d4..0000000
--- a/test/lib/flavour-ndev-lvmetad
+++ /dev/null
@@ -1,2 +0,0 @@
-LVM_TEST_LOCKING=1
-LVM_TEST_LVMETAD=1
diff --git a/test/lib/flavour-ndev-lvmetad.sh b/test/lib/flavour-ndev-lvmetad.sh
new file mode 100644
index 0000000..6f8c2d4
--- /dev/null
+++ b/test/lib/flavour-ndev-lvmetad.sh
@@ -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
deleted file mode 100644
index b3f4cee..0000000
--- a/test/lib/flavour-ndev-vanilla
+++ /dev/null
@@ -1 +0,0 @@
-LVM_TEST_LOCKING=1
diff --git a/test/lib/flavour-ndev-vanilla.sh b/test/lib/flavour-ndev-vanilla.sh
new file mode 100644
index 0000000..b3f4cee
--- /dev/null
+++ b/test/lib/flavour-ndev-vanilla.sh
@@ -0,0 +1 @@
+LVM_TEST_LOCKING=1
diff --git a/test/lib/flavour-udev-cluster b/test/lib/flavour-udev-cluster
deleted file mode 100644
index 7c37616..0000000
--- a/test/lib/flavour-udev-cluster
+++ /dev/null
@@ -1,2 +0,0 @@
-LVM_TEST_LOCKING=3
-LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-cluster.sh b/test/lib/flavour-udev-cluster.sh
new file mode 100644
index 0000000..7c37616
--- /dev/null
+++ b/test/lib/flavour-udev-cluster.sh
@@ -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
deleted file mode 100644
index e1dac52..0000000
--- a/test/lib/flavour-udev-lvmetad
+++ /dev/null
@@ -1,3 +0,0 @@
-LVM_TEST_LOCKING=1
-LVM_TEST_LVMETAD=1
-LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-lvmetad.sh b/test/lib/flavour-udev-lvmetad.sh
new file mode 100644
index 0000000..e1dac52
--- /dev/null
+++ b/test/lib/flavour-udev-lvmetad.sh
@@ -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
deleted file mode 100644
index 09d023a..0000000
--- a/test/lib/flavour-udev-vanilla
+++ /dev/null
@@ -1,2 +0,0 @@
-LVM_TEST_LOCKING=1
-LVM_TEST_DEVDIR=/dev
diff --git a/test/lib/flavour-udev-vanilla.sh b/test/lib/flavour-udev-vanilla.sh
new file mode 100644
index 0000000..09d023a
--- /dev/null
+++ b/test/lib/flavour-udev-vanilla.sh
@@ -0,0 +1,2 @@
+LVM_TEST_LOCKING=1
+LVM_TEST_DEVDIR=/dev
9 years, 2 months
master - test: Run the testcases chdir'd into --testdir.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2bc76bcdabe768...
Commit: 2bc76bcdabe76876c59f9fec61292240993974bc
Parent: efb3e7ca007f57c7627ef47e084d2f03cdc906f3
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:23:14 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Run the testcases chdir'd into --testdir.
---
test/lib/runner.cpp | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 7f1f495..bfcea91 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -270,6 +270,7 @@ struct TestCase {
exit(201);
} else if (pid == 0) {
io.close();
+ chdir( options.testdir.c_str() );
setenv("LVM_TEST_FLAVOUR", flavour.c_str(), 1);
child.exec();
} else {
9 years, 2 months
master - test: Improve IO handling in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=efb3e7ca007f57...
Commit: efb3e7ca007f57c7627ef47e084d2f03cdc906f3
Parent: 8c8fb67fc21f7f5c651ea0b30961039c868a0bc6
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:23:02 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Improve IO handling in the runner.
---
test/lib/runner.cpp | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 0c99dbd..7f1f495 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -108,6 +108,7 @@ struct TestCase {
TestProcess child;
std::string name, flavour;
IO io;
+ BufSink *iobuf;
struct rusage usage;
int status;
@@ -162,6 +163,7 @@ struct TestCase {
waitpid( pid, &status, 0 );
}
timeout = true;
+ io.sync();
return false;
}
@@ -179,6 +181,7 @@ struct TestCase {
if ( select( io.fd + 1, &set, NULL, NULL, &wait ) > 0 )
silent_start = end; /* something happened */
+ usleep(500000);
io.sync();
return true;
@@ -215,8 +218,16 @@ struct TestCase {
void parent()
{
+ ::close( child.fd );
+ setupIO();
+
+ journal->started( id() );
silent_start = start = time( 0 );
+ progress( First ) << tag( "running" ) << pretty() << std::flush;
+ if ( options.verbose || options.interactive )
+ progress() << std::endl;
+
while ( monitor() );
Journal::R r = Journal::UNKNOWN;
@@ -243,8 +254,12 @@ struct TestCase {
close(fd_debuglog);
} */
+ if ( iobuf && r == Journal::FAILED || r == Journal::TIMEOUT )
+ iobuf->dump( std::cout );
+
journal->done( id(), r );
progress( Last ) << tag( r ) << pretty() << std::endl;
+ io.clear();
}
void run() {
@@ -258,21 +273,26 @@ struct TestCase {
setenv("LVM_TEST_FLAVOUR", flavour.c_str(), 1);
child.exec();
} else {
- ::close( child.fd );
- journal->started( id() );
- progress( First ) << tag( "running" ) << pretty() << std::flush;
- if ( options.verbose || options.interactive )
- progress() << std::endl;
- start = time( 0 );
parent();
}
}
+ void setupIO() {
+ iobuf = 0;
+ if ( options.verbose )
+ io.sinks.push_back( new FdSink( 1 ) );
+ else
+ io.sinks.push_back( iobuf = new BufSink() );
+
+ std::string n = id();
+ std::replace( n.begin(), n.end(), '/', '_' );
+ std::string fn = options.outdir + "/" + n + ".txt";
+ io.sinks.push_back( new FileSink( fn ) );
+ }
+
TestCase( Journal &j, Options opt, std::string path, std::string name, std::string flavour )
: timeout( false ), child( path ), name( name ), flavour( flavour ), options( opt ), journal( &j )
{
- if ( opt.verbose )
- io.sinks.push_back( new FdSink( 1 ) );
}
};
9 years, 2 months
master - test: Improve tracking of silence (stuck testcases) in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8c8fb67fc21f7f...
Commit: 8c8fb67fc21f7f5c651ea0b30961039c868a0bc6
Parent: dc1d15787830e37480925fbd5bb3ab04982ad1dd
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:21:20 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Improve tracking of silence (stuck testcases) in the runner.
---
test/lib/runner.cpp | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 1a91738..0c99dbd 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -112,10 +112,9 @@ struct TestCase {
struct rusage usage;
int status;
bool timeout;
- int silent_ctr;
pid_t pid;
- time_t start, end;
+ time_t start, end, silent_start;
Options options;
Journal *journal;
@@ -148,11 +147,13 @@ struct TestCase {
bool monitor() {
end = time( 0 );
- if ( wait4(pid, &status, WNOHANG, &usage) != 0 )
+ if ( wait4(pid, &status, WNOHANG, &usage) != 0 ) {
+ io.sync();
return false;
+ }
/* kill off tests after a minute of silence */
- if ( silent_ctr > 2 * 60 ) {
+ if ( end - silent_start > 60 ) {
kill( pid, SIGINT );
sleep( 5 ); /* wait a bit for a reaction */
if ( waitpid( pid, &status, WNOHANG ) == 0 ) {
@@ -175,14 +176,10 @@ struct TestCase {
if ( !options.verbose && !options.interactive )
progress( Update ) << tag( "running" ) << pretty() << " " << end - start << std::flush;
- if ( select( io.fd + 1, &set, NULL, NULL, &wait ) <= 0 )
- {
- silent_ctr++;
- return true;
- }
+ if ( select( io.fd + 1, &set, NULL, NULL, &wait ) > 0 )
+ silent_start = end; /* something happened */
io.sync();
- silent_ctr = 0;
return true;
}
@@ -216,7 +213,10 @@ struct TestCase {
return null;
}
- void parent() {
+ void parent()
+ {
+ silent_start = start = time( 0 );
+
while ( monitor() );
Journal::R r = Journal::UNKNOWN;
9 years, 2 months
master - test: Make the runner's journal more reliable.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dc1d15787830e3...
Commit: dc1d15787830e37480925fbd5bb3ab04982ad1dd
Parent: d27833ba7ca2e6e80a01923e311b263681d4279d
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:19:15 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Make the runner's journal more reliable.
---
test/lib/filesystem.h | 9 +++++++++
test/lib/journal.h | 19 +++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/test/lib/filesystem.h b/test/lib/filesystem.h
index 718c433..2ae0c09 100644
--- a/test/lib/filesystem.h
+++ b/test/lib/filesystem.h
@@ -48,6 +48,15 @@ struct dir {
typedef std::vector< std::string > Listing;
+inline void fsync_name( std::string n )
+{
+ int fd = open( n.c_str(), O_WRONLY );
+ if ( fd >= 0 ) {
+ fsync( fd );
+ close( fd );
+ }
+}
+
inline Listing listdir( std::string p, bool recurse = false, std::string prefix = "" )
{
Listing r;
diff --git a/test/lib/journal.h b/test/lib/journal.h
index d2f028c..020afe3 100644
--- a/test/lib/journal.h
+++ b/test/lib/journal.h
@@ -1,5 +1,7 @@
// -*- C++ -*-
+#include "filesystem.h"
+
#include <map>
#include <string>
#include <iostream>
@@ -26,6 +28,7 @@ struct Journal {
friend std::ostream &operator<<( std::ostream &o, R r ) {
switch ( r ) {
case STARTED: return o << "started";
+ case RETRIED: return o << "retried";
case FAILED: return o << "failed";
case INTERRUPTED: return o << "interrupted";
case PASSED: return o << "passed";
@@ -71,6 +74,7 @@ struct Journal {
void sync() {
write( location_tmp );
+ fsync_name( location_tmp );
rename( location_tmp.c_str(), location.c_str() );
}
@@ -112,12 +116,23 @@ struct Journal {
std::cout << i->second << ": " << i->first << std::endl;
}
- void read() {
- std::ifstream ifs( location.c_str() );
+ void read( std::string n ) {
+ std::ifstream ifs( n.c_str() );
typedef std::istream_iterator< std::pair< std::string, R > > It;
std::copy( It( ifs ), It(), std::inserter( status, status.begin() ) );
}
+ void read() {
+ struct stat64 stat;
+ if ( ::stat64( location.c_str(), &stat ) == 0 )
+ read( location );
+ /* on CIFS, rename might fail halfway through, with journal
+ * already gone but journal.tmp not yet replacing it... in that
+ * case, pick up journal.tmp */
+ else if ( ::stat64( location_tmp.c_str(), &stat ) == 0 )
+ read( location_tmp );
+ }
+
Journal( std::string dir )
: location( dir + "/journal" ),
location_tmp( dir + "/journal.tmp" )
9 years, 2 months
master - test: Implement flavours in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d27833ba7ca2e6...
Commit: d27833ba7ca2e6e80a01923e311b263681d4279d
Parent: f3bf89ebcc98a1e03c1687d6b292be3274a9bc8a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:13:14 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Implement flavours in the runner.
---
test/lib/runner.cpp | 56 ++++++++++++++++++++++++++++++++++++--------------
1 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 14c7d9f..1a91738 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -60,6 +60,7 @@ bool interrupt = false;
struct Options {
bool verbose, quiet, interactive, cont;
std::string testdir, outdir;
+ std::vector< std::string > flavours;
Options() : verbose( false ), quiet( false ), interactive( false ), cont( false ) {}
};
@@ -105,7 +106,7 @@ struct TestProcess
struct TestCase {
TestProcess child;
- std::string name;
+ std::string name, flavour;
IO io;
struct rusage usage;
@@ -119,6 +120,14 @@ struct TestCase {
Journal *journal;
+ std::string pretty() {
+ return "[" + flavour + "] " + name;
+ }
+
+ std::string id() {
+ return flavour + ":" + name;
+ }
+
void pipe() {
int fds[2];
@@ -164,7 +173,7 @@ struct TestCase {
wait.tv_usec = 500000; /* timeout 0.5s */
if ( !options.verbose && !options.interactive )
- progress( Update ) << tag( "running" ) << name << " " << end - start << std::flush;
+ progress( Update ) << tag( "running" ) << pretty() << " " << end - start << std::flush;
if ( select( io.fd + 1, &set, NULL, NULL, &wait ) <= 0 )
{
@@ -234,8 +243,8 @@ struct TestCase {
close(fd_debuglog);
} */
- journal->done( name, r );
- progress( Last ) << tag( r ) << name << std::endl;
+ journal->done( id(), r );
+ progress( Last ) << tag( r ) << pretty() << std::endl;
}
void run() {
@@ -246,11 +255,12 @@ struct TestCase {
exit(201);
} else if (pid == 0) {
io.close();
+ setenv("LVM_TEST_FLAVOUR", flavour.c_str(), 1);
child.exec();
} else {
::close( child.fd );
- journal->started( name );
- progress( First ) << tag( "running" ) << name << std::flush;
+ journal->started( id() );
+ progress( First ) << tag( "running" ) << pretty() << std::flush;
if ( options.verbose || options.interactive )
progress() << std::endl;
start = time( 0 );
@@ -258,8 +268,8 @@ struct TestCase {
}
}
- TestCase( Journal &j, Options opt, std::string path, std::string name )
- : timeout( false ), silent_ctr( 0 ), child( path ), name( name ), options( opt ), journal( &j )
+ TestCase( Journal &j, Options opt, std::string path, std::string name, std::string flavour )
+ : timeout( false ), child( path ), name( name ), flavour( flavour ), options( opt ), journal( &j )
{
if ( opt.verbose )
io.sinks.push_back( new FdSink( 1 ) );
@@ -271,6 +281,7 @@ struct Main {
time_t start;
typedef std::vector< TestCase > Cases;
+ typedef std::vector< std::string > Flavours;
Journal journal;
Options options;
@@ -280,13 +291,17 @@ struct Main {
Listing l = listdir( options.testdir, true );
std::sort( l.begin(), l.end() );
- for ( Listing::iterator i = l.begin(); i != l.end(); ++i ) {
- if ( i->substr( i->length() - 3, i->length() ) != ".sh" )
- continue;
- if ( i->substr( 0, 4 ) == "lib/" )
- continue;
- cases.push_back( TestCase( journal, options, options.testdir + *i, *i ) );
- cases.back().options = options;
+ for ( Flavours::iterator flav = options.flavours.begin();
+ flav != options.flavours.end(); ++flav ) {
+
+ for ( Listing::iterator i = l.begin(); i != l.end(); ++i ) {
+ if ( i->substr( i->length() - 3, i->length() ) != ".sh" )
+ continue;
+ if ( i->substr( 0, 4 ) == "lib/" )
+ continue;
+ cases.push_back( TestCase( journal, options, options.testdir + *i, *i, *flav ) );
+ cases.back().options = options;
+ }
}
if ( options.cont )
@@ -300,7 +315,7 @@ struct Main {
for ( Cases::iterator i = cases.begin(); i != cases.end(); ++i ) {
- if ( options.cont && journal.done( i->name ) )
+ if ( options.cont && journal.done( i->id() ) )
continue;
i->run();
@@ -316,6 +331,7 @@ struct Main {
journal.banner();
journal.write( options.outdir + "/list" );
+ fsync_name( options.outdir + "/list" );
if ( die || fatal_signal )
exit( 1 );
}
@@ -424,6 +440,14 @@ int main(int argc, char **argv)
opt.interactive = true;
}
+ if ( args.has( "--flavours" ) ) {
+ std::stringstream ss( args.opt( "--flavours" ) );
+ std::string item;
+ while ( std::getline( ss, item, ',' ) )
+ opt.flavours.push_back( item );
+ } else
+ opt.flavours.push_back( "vanilla" );
+
opt.outdir = args.opt( "--outdir" );
opt.testdir = args.opt( "--testdir" );
9 years, 2 months
master - test: Fix handling of envvars in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f3bf89ebcc98a1...
Commit: f3bf89ebcc98a1e03c1687d6b292be3274a9bc8a
Parent: 0bd2a9b7b10640d9d16cceb9e753acff6356d5df
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:03:08 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Fix handling of envvars in the runner.
---
test/lib/runner.cpp | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 287b8f9..14c7d9f 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -391,6 +391,15 @@ struct Args {
}
};
+bool hasenv( const char *name ) {
+ const char *v = getenv( name );
+ if ( !v )
+ return false;
+ if ( strlen( v ) == 0 || !strcmp( v, "0" ) )
+ return false;
+ return true;
+}
+
int main(int argc, char **argv)
{
Args args( argc, argv );
@@ -399,17 +408,17 @@ int main(int argc, char **argv)
if ( args.has( "--continue" ) )
opt.cont = true;
- if ( args.has( "--quiet" ) || getenv( "QUIET" ) ) {
+ if ( args.has( "--quiet" ) || hasenv( "QUIET" ) ) {
opt.verbose = false;
opt.quiet = true;
}
- if ( args.has( "--verbose" ) || getenv( "VERBOSE" ) ) {
+ if ( args.has( "--verbose" ) || hasenv( "VERBOSE" ) ) {
opt.quiet = false;
opt.verbose = true;
}
- if ( args.has( "--interactive" ) || getenv( "INTERACTIVE" ) ) {
+ if ( args.has( "--interactive" ) || hasenv( "INTERACTIVE" ) ) {
opt.verbose = false;
opt.quiet = false;
opt.interactive = true;
9 years, 2 months
master - test: Makefile updates.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0bd2a9b7b10640...
Commit: 0bd2a9b7b10640d9d16cceb9e753acff6356d5df
Parent: b4215f956f4576ce38b19a9a9ca216e9d096fe5a
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:00:37 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:17 2015 +0100
test: Makefile updates.
- make check now uses the new test runner
- the testsuite can be installed (make -C test install)
---
test/Makefile.in | 88 +++++++++++++++++++++++++++++++++++++----------------
1 files changed, 61 insertions(+), 27 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 88644f3..d930888 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -61,7 +61,7 @@ ifeq ("@UDEV_SYNC@", "yes")
dm_udev_synchronisation = 1
endif
-all: check
+all: .tests-stamp
help:
@echo -e "\nAvailable targets:"
@@ -100,33 +100,56 @@ help:
@echo " VERBOSE Verbose output (1), timing (2)."
check: .tests-stamp
- VERBOSE=$(VERBOSE) ./lib/runner --testdir shell --outdir results
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --only $(T) --skip $(S)
check_system: .tests-stamp
- VERBOSE=$(VERBOSE) \
- 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 \
- ./lib/harness $(patsubst %,snormal:%,$(RUN_BASE)) \
- $(patsubst %,scluster:%,$(RUN_BASE)) \
- $(patsubst %,slvmetad:%,$(LVMETAD_RUN_BASE))
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --only udev- --only $(T) --skip $(S)
check_cluster: .tests-stamp
- @echo Testing with locking_type 3
- VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./lib/harness $(RUN_BASE)
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --only ndev-cluster --only $(T) --skip $(S)
check_local: .tests-stamp
- @echo Testing with locking_type 1
- VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./lib/harness $(RUN_BASE)
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --only ndev- --only $(T) --skip $(S)
ifeq ("@BUILD_LVMETAD@", "yes")
check_lvmetad: .tests-stamp
- @echo Testing with lvmetad on
- VERBOSE=$(VERBOSE) LVM_TEST_LVMETAD=1 ./lib/harness $(RUN_BASE)
+ VERBOSE=$(VERBOSE) ./lib/runner \
+ --testdir . --outdir results \
+ --only ndev-lvmetad --only $(T) --skip $(S)
endif
+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/
+ $(INSTALL_DATA) lib/paths-installed $(DATADIR)/lib/paths
+ $(INSTALL_DATA) $(LIB_FLAVOURS) $(DATADIR)/lib/
+ $(INSTALL_SCRIPT) $(LIB_SHARED) $(DATADIR)/lib/
+
+ $(INSTALL_DIR) $(EXECDIR)
+ $(INSTALL_PROGRAM) $(LIB_EXEC) $(EXECDIR)
+ $(INSTALL_PROGRAM) -D lib/runner $(bindir)/lvm2-testsuite
+
lib/should: lib/not
ln -sf not lib/should
@@ -148,13 +171,10 @@ lib/%: $(srcdir)/lib/%.sh .lib-dir-stamp
cp $< $@
chmod +x $@
-lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp Makefile
- $(RM) $@-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
+lib/flavour-%: $(srcdir)/lib/flavour-% .lib-dir-stamp
+ cp $< $@
+
+lib/paths-common: $(srcdir)/Makefile.in .lib-dir-stamp Makefile
echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t
echo 'export THIN=@THIN@' >> $@-t
echo 'export RAID=@RAID@' >> $@-t
@@ -172,11 +192,25 @@ lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp Makefile
echo 'export LVM_TEST_CACHE_RESTORE_CMD=$${LVM_TEST_CACHE_RESTORE_CMD:-@CACHE_RESTORE_CMD@}' >> $@-t
mv $@-t $@
-LIB = lib/not lib/invalid lib/fail lib/should lib/harness \
- lib/check lib/aux lib/inittest lib/utils lib/get lib/lvm-wrapper \
- lib/paths lib/runner
+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 $@
CMDS = lvm $(shell cat $(top_builddir)/tools/.commands)
+LIB = $(LIB_SHARED) $(LIB_LOCAL) $(LIB_EXEC) $(LIB_FLAVOURS)
.tests-stamp: $(ALL) $(LIB) $(SUBDIRS)
@if test "$(srcdir)" != . ; then \
9 years, 2 months