mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-04 09:18:36 +03:00
Revert "tests: avoid clobering dmesg"
This reverts commit abcab54cca
.
Dmesg is not uploaded on machines except on F19.
This commit is contained in:
parent
50d70eff35
commit
1c8a118588
@ -541,22 +541,26 @@ struct FileSource : Source {
|
|||||||
struct KMsg : Source {
|
struct KMsg : Source {
|
||||||
bool can_clear;
|
bool can_clear;
|
||||||
|
|
||||||
KMsg() : can_clear( strcmp(getenv("LVM_TEST_CAN_CLOBBER_DMESG") ? : "0", "0") ) {
|
KMsg() : can_clear( true ) {}
|
||||||
#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 ( 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() {
|
bool dev_kmsg() {
|
||||||
return fd >= 0;
|
return fd >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
#ifdef __unix
|
||||||
|
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;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void sync( Sink *s ) {
|
void sync( Sink *s ) {
|
||||||
#ifdef __unix
|
#ifdef __unix
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
@ -565,6 +569,10 @@ struct KMsg : Source {
|
|||||||
if ( dev_kmsg() ) {
|
if ( dev_kmsg() ) {
|
||||||
while ( (sz = ::read(fd, buf, sizeof(buf) - 1)) > 0 )
|
while ( (sz = ::read(fd, buf, sizeof(buf) - 1)) > 0 )
|
||||||
s->push( std::string( buf, sz ) );
|
s->push( std::string( buf, sz ) );
|
||||||
|
if ( sz < 0 ) {
|
||||||
|
fd = -1;
|
||||||
|
sync( s );
|
||||||
|
}
|
||||||
} else if ( can_clear ) {
|
} else if ( can_clear ) {
|
||||||
while ( (sz = klogctl( BRICK_SYSLOG_ACTION_READ_CLEAR, buf,
|
while ( (sz = klogctl( BRICK_SYSLOG_ACTION_READ_CLEAR, buf,
|
||||||
sizeof(buf) - 1 )) > 0 )
|
sizeof(buf) - 1 )) > 0 )
|
||||||
|
Loading…
Reference in New Issue
Block a user