diff options
author | Marian Csontos <mcsontos@redhat.com> | 2015-06-22 16:43:17 +0200 |
---|---|---|
committer | Marian Csontos <mcsontos@redhat.com> | 2015-06-22 16:43:17 +0200 |
commit | 1c8a11858806ede33cd332d39606217edbefd346 (patch) | |
tree | 1a5f3128e77f82d328d75e95339d513e40ad3352 | |
parent | 50d70eff352fd651a68b8edbd9a7fcbe30300726 (diff) | |
download | lvm2-dev-mcsontos-test-dmesg.tar.gz |
Revert "tests: avoid clobering dmesg"dev-mcsontos-test-dmesg
This reverts commit abcab54cca4b4f9ff157a5f51718c69ffdf34c7a.
Dmesg is not uploaded on machines except on F19.
-rw-r--r-- | test/lib/brick-shelltest.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h index e64a166e1..af8051efc 100644 --- a/test/lib/brick-shelltest.h +++ b/test/lib/brick-shelltest.h @@ -541,22 +541,26 @@ struct FileSource : Source { struct KMsg : Source { bool can_clear; - KMsg() : can_clear( strcmp(getenv("LVM_TEST_CAN_CLOBBER_DMESG") ? : "0", "0") ) { + KMsg() : can_clear( true ) {} + + bool dev_kmsg() { + return fd >= 0; + } + + void reset() { #ifdef __unix - if ( (fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK)) < 0 ) { - if (errno != ENOENT) /* Older kernels (<3.5) do not support /dev/kmsg */ - perror("opening /dev/kmsg"); + if ( dev_kmsg() ) { + if ( (fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK)) < 0 ) { + if (errno != ENOENT) /* Older kernels (<3.5) do not support /dev/kmsg */ + perror("opening /dev/kmsg"); + } else if (lseek(fd, 0L, SEEK_END) == (off_t) -1) + perror("lseek /dev/kmsg"); + } else if ( klogctl( BRICK_SYSLOG_ACTION_CLEAR, 0, 0 ) < 0 ) can_clear = false; - } else if (lseek(fd, 0L, SEEK_END) == (off_t) -1) - perror("lseek /dev/kmsg"); #endif } - bool dev_kmsg() { - return fd >= 0; - } - void sync( Sink *s ) { #ifdef __unix ssize_t sz; @@ -565,6 +569,10 @@ struct KMsg : Source { if ( dev_kmsg() ) { while ( (sz = ::read(fd, buf, sizeof(buf) - 1)) > 0 ) s->push( std::string( buf, sz ) ); + if ( sz < 0 ) { + fd = -1; + sync( s ); + } } else if ( can_clear ) { while ( (sz = klogctl( BRICK_SYSLOG_ACTION_READ_CLEAR, buf, sizeof(buf) - 1 )) > 0 ) |