1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: update runner

Reenable TESTDIR  & PREFIX replacement.
Since we need to replace string in proper order (1st. @TESTDIR@,
2nd. @PREFIX@), drop map and use plain string.

Drop timestamp logging when 'stacktracing'
This commit is contained in:
Zdenek Kabelac 2015-04-13 16:31:02 +02:00
parent 0aef2b719f
commit e4261ba037

View File

@ -345,18 +345,23 @@ struct Sink {
struct Substitute {
typedef std::map< std::string, std::string > Map;
Map _map;
std::string testdir; // replace testdir first
std::string prefix;
std::string map( std::string line ) {
if ( std::string( line, 0, 9 ) == "@TESTDIR=" )
_map[ "@TESTDIR@" ] = std::string( line, 9, std::string::npos );
testdir = std::string( line, 9, line.length() - 10 ); // skip \n
else if ( std::string( line, 0, 8 ) == "@PREFIX=" )
_map[ "@PREFIX@" ] = std::string( line, 8, std::string::npos );
prefix = std::string( line, 8, line.length() - 9 ); // skip \n
else {
size_t off;
for ( Map::iterator s = _map.begin(); s != _map.end(); ++s )
while ( (off = line.find( s->first )) != std::string::npos )
line.replace( off, s->first.length(), s->second );
if (!testdir.empty())
while ( (off = line.find( testdir )) != std::string::npos )
line.replace( off, testdir.length(), "@TESTDIR@" );
if (!prefix.empty())
while ( (off = line.find( prefix )) != std::string::npos )
line.replace( off, prefix.length(), "@PREFIX@" );
}
return line;
}
@ -406,6 +411,13 @@ struct FdSink : Sink {
virtual void outline( bool force )
{
TimedBuffer::Line line = stream.shift( force );
if (line.second.c_str()[0] == '#') {
/* Disable timing between STACKTRACE & teardown keywords */
if (strstr(line.second.c_str() + 1, "# 0 STACKTRACE"))
fmt.stamp = false;
else if (strstr(line.second.c_str() + 1, "# teardown"))
fmt.stamp = true;
}
std::string out = fmt.format( line );
write( fd, out.c_str(), out.length() );
}