master - spec: Add an (optional) lvm2-testsuite subpackage.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d5537e7d6b28d2...
Commit: d5537e7d6b28d2a7f2214529797aade0ed29efab
Parent: d488f032298ee6e8bf3f0abc50e2756f11a73196
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 01:24:47 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
spec: Add an (optional) lvm2-testsuite subpackage.
---
spec/build.inc | 3 +++
spec/packages.inc | 15 +++++++++++++++
spec/source.inc | 1 +
3 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/spec/build.inc b/spec/build.inc
index 95c9b83..176fdb1 100644
--- a/spec/build.inc
+++ b/spec/build.inc
@@ -37,6 +37,9 @@ make install_initscripts DESTDIR=$RPM_BUILD_ROOT
make install_systemd_units DESTDIR=$RPM_BUILD_ROOT
make install_tmpfiles_configuration DESTDIR=$RPM_BUILD_ROOT
%endif
+%if %{enable_testsuite}
+make -C test install DESTDIR=$RPM_BUILD_ROOT
+%endif
# when building an src.rpm from freestanding specfiles
test -e %{_sourcedir}/source.inc || cp source.inc build.inc packages.inc macros.inc %{_sourcedir}
diff --git a/spec/packages.inc b/spec/packages.inc
index f0b7cfd..d368838 100644
--- a/spec/packages.inc
+++ b/spec/packages.inc
@@ -494,3 +494,18 @@ the device-mapper event library.
%{_includedir}/libdevmapper-event.h
%{_libdir}/pkgconfig/devmapper-event.pc
+%if %{enable_testsuite}
+%package testsuite
+Summary: LVM2 Testsuite
+License: LGPLv2
+Group: Development
+
+%description testsuite
+An extensive functional testsuite for LVM2.
+
+%files testsuite
+%defattr(-,root,root,-)
+%{_datadir}/lvm2-testsuite/
+%{_libexecdir}/lvm2-testsuite/
+%{_bindir}/lvm2-testsuite
+%endif
diff --git a/spec/source.inc b/spec/source.inc
index 6ef4791..21fbf7d 100644
--- a/spec/source.inc
+++ b/spec/source.inc
@@ -4,6 +4,7 @@
# Defaults (rawhide)...
%global enable_profiling 0
+%global enable_testsuite 0
%global enable_udev 1
%global enable_systemd 1
%global enable_cmirror 1
9 years, 2 months
master - test: Implement --only option to runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d488f032298ee6...
Commit: d488f032298ee6e8bf3f0abc50e2756f11a73196
Parent: a8eb70209322f4344b9b11d190f64a9184fe23eb
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jul 1 14:07:27 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Implement --only option to runner.
---
test/lib/runner.cpp | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 303b66d..1522fd5 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -62,7 +62,7 @@ bool interrupt = false;
struct Options {
bool verbose, batch, interactive, cont;
std::string testdir, outdir;
- std::vector< std::string > flavours;
+ std::vector< std::string > flavours, filter;
Options() : verbose( false ), batch( false ), interactive( false ), cont( false ) {}
};
@@ -375,6 +375,15 @@ struct Main {
continue;
if ( i->substr( 0, 4 ) == "lib/" )
continue;
+ bool filter = !options.filter.empty();
+
+ for ( std::vector< std::string >::iterator filt = options.filter.begin();
+ filt != options.filter.end(); ++filt ) {
+ if ( i->find( *filt ) != std::string::npos )
+ filter = false;
+ }
+ if ( filter )
+ continue;
cases.push_back( TestCase( journal, options, options.testdir + *i, *i, *flav ) );
cases.back().options = options;
}
@@ -473,6 +482,14 @@ bool hasenv( const char *name ) {
return true;
}
+template< typename C >
+void split( std::string s, C &c ) {
+ std::stringstream ss( s );
+ std::string item;
+ while ( std::getline( ss, item, ',' ) )
+ c.push_back( item );
+}
+
int main(int argc, char **argv)
{
Args args( argc, argv );
@@ -481,6 +498,9 @@ int main(int argc, char **argv)
if ( args.has( "--continue" ) )
opt.cont = true;
+ if ( args.has( "--only" ) )
+ split( args.opt( "--only" ), opt.filter );
+
if ( args.has( "--batch" ) || hasenv( "BATCH" ) ) {
opt.verbose = false;
opt.batch = true;
@@ -497,12 +517,9 @@ 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
+ if ( args.has( "--flavours" ) )
+ split( args.opt( "--flavours" ), opt.flavours );
+ else
opt.flavours.push_back( "vanilla" );
opt.outdir = args.opt( "--outdir" );
9 years, 2 months
master - test: Fix loading of an append-mode journal.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a8eb70209322f4...
Commit: a8eb70209322f4344b9b11d190f64a9184fe23eb
Parent: d74c1472233e29b9168966334315dc012ee915ce
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Mon Jun 30 00:38:07 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Fix loading of an append-mode journal.
---
test/lib/journal.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/test/lib/journal.h b/test/lib/journal.h
index 458d1ee..8913d7c 100644
--- a/test/lib/journal.h
+++ b/test/lib/journal.h
@@ -157,7 +157,8 @@ struct Journal {
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() ) );
+ for ( It i( ifs ); i != It(); ++i )
+ status[ i->first ] = i->second;
}
void read() { read( location ); }
9 years, 2 months
master - test: Add a missing copyright/licence notice to journal.h.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d74c1472233e29...
Commit: d74c1472233e29b9168966334315dc012ee915ce
Parent: 10c992e861175498b9007067db493d5ba0a97727
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Jun 29 14:30:49 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Add a missing copyright/licence notice to journal.h.
---
test/lib/journal.h | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/test/lib/journal.h b/test/lib/journal.h
index 4335f71..458d1ee 100644
--- a/test/lib/journal.h
+++ b/test/lib/journal.h
@@ -1,4 +1,29 @@
-// -*- C++ -*-
+/* -*- C++ -*- copyright (c) 2014 Red Hat, Inc.
+ *
+ * This file is part of LVM2.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
#include "filesystem.h"
9 years, 2 months
master - test: Fix a precedence bug in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=10c992e8611754...
Commit: 10c992e861175498b9007067db493d5ba0a97727
Parent: b3caba849d28b7dd82a89f9cedbc0e9d0de273b7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sat Jun 28 11:15:28 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Fix a precedence bug in the runner.
---
test/lib/runner.cpp | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 027f216..303b66d 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -302,7 +302,7 @@ struct TestCase {
close(fd_debuglog);
} */
- if ( iobuf && r == Journal::FAILED || r == Journal::TIMEOUT )
+ if ( iobuf && ( r == Journal::FAILED || r == Journal::TIMEOUT ) )
iobuf->dump( std::cout );
journal->done( id(), r );
9 years, 2 months
master - test: Use append for journal maintenance instead of rename.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b3caba849d28b7...
Commit: b3caba849d28b7dd82a89f9cedbc0e9d0de273b7
Parent: 23b5a006d405cfeb2ea270377e774297e368eed4
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sat Jun 28 11:15:13 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Use append for journal maintenance instead of rename.
---
test/lib/journal.h | 36 ++++++++++++++++++++----------------
test/lib/runner.cpp | 4 ++--
2 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/test/lib/journal.h b/test/lib/journal.h
index 020afe3..4335f71 100644
--- a/test/lib/journal.h
+++ b/test/lib/journal.h
@@ -61,9 +61,21 @@ struct Journal {
}
typedef std::map< std::string, R > Status;
- Status status;
+ Status status, written;
- std::string location_tmp, location;
+ std::string location, list;
+
+ void append( std::string path ) {
+ std::ofstream of( path.c_str(), std::fstream::app );
+ Status::iterator writ;
+ for ( Status::iterator i = status.begin(); i != status.end(); ++i ) {
+ writ = written.find( i->first );
+ if ( writ == written.end() || writ->second != i->second )
+ of << i->first << " " << i->second << std::endl;
+ }
+ written = status;
+ of.close();
+ }
void write( std::string path ) {
std::ofstream of( path.c_str() );
@@ -73,9 +85,10 @@ struct Journal {
}
void sync() {
- write( location_tmp );
- fsync_name( location_tmp );
- rename( location_tmp.c_str(), location.c_str() );
+ append( location );
+ fsync_name( location );
+ write ( list );
+ fsync_name( list );
}
void started( std::string n ) {
@@ -122,20 +135,11 @@ struct Journal {
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 );
- }
+ void read() { read( location ); }
Journal( std::string dir )
: location( dir + "/journal" ),
- location_tmp( dir + "/journal.tmp" )
+ list( dir + "/list" )
{}
};
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index f4da315..027f216 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -382,6 +382,8 @@ struct Main {
if ( options.cont )
journal.read();
+ else
+ ::unlink( journal.location.c_str() );
}
void run() {
@@ -406,8 +408,6 @@ struct Main {
}
journal.banner();
- journal.write( options.outdir + "/list" );
- fsync_name( options.outdir + "/list" );
if ( die || fatal_signal )
exit( 1 );
}
9 years, 2 months
master - test: Implement specialised --batch output style w/ rusage stats.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=23b5a006d405cf...
Commit: 23b5a006d405cfeb2ea270377e774297e368eed4
Parent: a665b9062395e69327aa3ecfb85a047f759e8db7
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:19:43 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Implement specialised --batch output style w/ rusage stats.
---
test/lib/runner.cpp | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 7fcf9e2..f4da315 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -123,6 +123,8 @@ struct TestCase {
Journal *journal;
std::string pretty() {
+ if ( options.batch )
+ return flavour + ": " + name;
return "[" + flavour + "] " + name;
}
@@ -228,6 +230,8 @@ struct TestCase {
}
std::string tag( std::string n ) {
+ if ( options.batch )
+ return "## ";
int pad = (12 - n.length());
return "### " + std::string( pad, ' ' ) + n + ": ";
}
@@ -245,7 +249,10 @@ struct TestCase {
static struct : std::streambuf {} buf;
static std::ostream null(&buf);
- if ( isatty( STDOUT_FILENO ) ) {
+ if ( options.batch && p == First )
+ return std::cout;
+
+ if ( isatty( STDOUT_FILENO ) && !options.batch ) {
if ( p != First )
return std::cout << "\r";
return std::cout;
@@ -253,6 +260,7 @@ struct TestCase {
if ( p == Last )
return std::cout;
+
return null;
}
@@ -298,7 +306,14 @@ struct TestCase {
iobuf->dump( std::cout );
journal->done( id(), r );
- progress( Last ) << tag( r ) << pretty() << std::endl;
+
+ if ( options.batch ) {
+ int spaces = std::max( 64 - int(pretty().length()), 0 );
+ progress( Last ) << " " << std::string( spaces, '.' ) << " " << r << std::endl;
+ if ( r == Journal::PASSED )
+ progress( First ) << " " << rusage() << std::endl;
+ } else
+ progress( Last ) << tag( r ) << pretty() << std::endl;
io.clear();
}
@@ -322,7 +337,7 @@ struct TestCase {
iobuf = 0;
if ( options.verbose )
io.sinks.push_back( new FdSink( 1 ) );
- else
+ else if ( !options.batch )
io.sinks.push_back( iobuf = new BufSink() );
std::string n = id();
9 years, 2 months
master - test: Add time/rusage formatting to the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a665b9062395e6...
Commit: a665b9062395e69327aa3ecfb85a047f759e8db7
Parent: 3fbea6029d77ce49434d0680b34d9dd367bce755
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:19:21 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Add time/rusage formatting to the runner.
---
test/lib/runner.cpp | 46 +++++++++++++++++++++++++++-------------------
1 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index b617110..7fcf9e2 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -30,6 +30,8 @@
#include "filesystem.h"
#include <iostream>
+#include <iomanip>
+
#include <vector>
#include <deque>
#include <map>
@@ -200,6 +202,31 @@ struct TestCase {
return true;
}
+ std::string timefmt( time_t t ) {
+ std::stringstream ss;
+ ss << t / 60 << ":" << std::setw( 2 ) << std::setfill( '0' ) << t % 60;
+ return ss.str();
+ }
+
+ std::string rusage()
+ {
+ std::stringstream ss;
+ time_t wall = end - start, user = usage.ru_utime.tv_sec,
+ system = usage.ru_stime.tv_sec;
+ size_t rss = usage.ru_maxrss / 1024,
+ inb = usage.ru_inblock / 100,
+ outb = usage.ru_oublock / 100;
+
+ size_t inb_10 = inb % 10, outb_10 = outb % 10;
+ inb /= 10; outb /= 10;
+
+ ss << timefmt( wall ) << " wall " << timefmt( user ) << " user "
+ << timefmt( system ) << " sys " << std::setw( 3 ) << rss << "M RSS | "
+ << "IOPS: " << std::setw( 5 ) << inb << "." << inb_10 << "K in "
+ << std::setw( 5 ) << outb << "." << outb_10 << "K out";
+ return ss.str();
+ }
+
std::string tag( std::string n ) {
int pad = (12 - n.length());
return "### " + std::string( pad, ' ' ) + n + ": ";
@@ -401,25 +428,6 @@ static int64_t get_time_us(void)
}
-static const char *duration(time_t start, const struct rusage *usage)
-{
- static char buf[100];
- int t = (int)(time(NULL) - start);
-
- int p = sprintf(buf, "%2d:%02d walltime", t / 60, t % 60);
-
- if (usage)
- sprintf(buf + p, " %2ld:%02ld.%03ld u, %ld:%02ld.%03ld s, %5ldk rss, %8ld/%ld IO",
- usage->ru_utime.tv_sec / 60, usage->ru_utime.tv_sec % 60,
- usage->ru_utime.tv_usec / 1000,
- usage->ru_stime.tv_sec / 60, usage->ru_stime.tv_sec % 60,
- usage->ru_stime.tv_usec / 1000,
- usage->ru_maxrss / 1024,
- usage->ru_inblock, usage->ru_oublock);
-
- return buf;
-}
-
struct Args {
typedef std::vector< std::string > V;
V args;
9 years, 2 months
master - test: Print a heartbeat file (every 20s) in the runner.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3fbea6029d77ce...
Commit: 3fbea6029d77ce49434d0680b34d9dd367bce755
Parent: e8cc9254e038b59bb6cc5ec9ba7793f9a82ab150
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:18:14 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Print a heartbeat file (every 20s) in the runner.
---
test/lib/runner.cpp | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index 1e61a68..b617110 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -188,6 +188,15 @@ struct TestCase {
io.sync();
+ /* heartbeat */
+ if ( time( 0 ) % 20 == 0 ) {
+ std::string stampfile( options.outdir + "/timestamp" );
+ std::ofstream stamp( stampfile.c_str() );
+ stamp << time( 0 );
+ stamp.close();
+ fsync_name( stampfile );
+ }
+
return true;
}
9 years, 2 months
master - test: Avoid sleeps in the runner monitoring loop.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e8cc9254e038b5...
Commit: e8cc9254e038b59bb6cc5ec9ba7793f9a82ab150
Parent: 48275c78361578672f5f3f5c29737404cf159f6d
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:17:47 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:18 2015 +0100
test: Avoid sleeps in the runner monitoring loop.
---
test/lib/runner.cpp | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/test/lib/runner.cpp b/test/lib/runner.cpp
index fde441b..1e61a68 100644
--- a/test/lib/runner.cpp
+++ b/test/lib/runner.cpp
@@ -115,7 +115,7 @@ struct TestCase {
bool timeout;
pid_t pid;
- time_t start, end, silent_start;
+ time_t start, end, silent_start, last_update;
Options options;
Journal *journal;
@@ -175,13 +175,17 @@ struct TestCase {
wait.tv_sec = 0;
wait.tv_usec = 500000; /* timeout 0.5s */
- if ( !options.verbose && !options.interactive && !options.batch )
- progress( Update ) << tag( "running" ) << pretty() << " " << end - start << std::flush;
+ if ( !options.verbose && !options.interactive && !options.batch ) {
+ if ( end - last_update >= 1 ) {
+ progress( Update ) << tag( "running" ) << pretty() << " "
+ << end - start << std::flush;
+ last_update = end;
+ }
+ }
if ( select( io.fd + 1, &set, NULL, NULL, &wait ) > 0 )
silent_start = end; /* something happened */
- usleep(500000);
io.sync();
return true;
9 years, 2 months