[Piglit] [PATCH] dmesg.py: Make timestamp check slightly smarter
Ben Widawsky
ben at bwidawsk.net
Mon Aug 11 12:55:51 PDT 2014
On Mon, Aug 11, 2014 at 11:57:43AM -0700, Dylan Baker wrote:
> On Thursday, August 07, 2014 04:16:39 PM Ben Widawsky wrote:
> > If users wish to clear their dmesg before a piglit run, the current code
> > will emit a warning. It is possible to query the information about the
> > running kernel, and most distros do package that, so default to that.
> > The live kernel config is more future proof than regex parsing of the
> > timestamp (although I'd be shocked if either ever stopped working), and
> > it works for the empty dmesg case.
> > ---
> > framework/dmesg.py | 19 +++++++++++++++++--
> > 1 file changed, 17 insertions(+), 2 deletions(-)
> >
> > diff --git a/framework/dmesg.py b/framework/dmesg.py
> > index 1a8faa2..54f7119 100644
> > --- a/framework/dmesg.py
> > +++ b/framework/dmesg.py
> > @@ -40,6 +40,7 @@ import sys
> > import subprocess
> > import warnings
> > import abc
> > +import gzip
> >
> > __all__ = [
> > 'BaseDmesg',
> > @@ -163,8 +164,22 @@ class LinuxDmesg(BaseDmesg):
> > # on Linux because each entry is guaranteed unique by timestamps.
> > self._last_message = None
> > super(LinuxDmesg, self).__init__()
> > -
> > - if not self._last_message:
> > + printk_has_timestamps = False
> > +
> > + # First check to see if we can find the live kernel config.
> > + try:
> > + f = gzip.open("/proc/config.gz", 'r')
> > + for line in f:
> > + if line.startswith("CONFIG_PRINTK_TIME=y"):
> > + printk_has_timestamps = True
> > + break
>
> could you just return here instead of using the flag? It seems like you could.
>
Yeah. Looks that way to me as well. I did a quick hack from the original
'finally' (which we talked about why that won't work). I'll get around
to a respin eventually.
> > + f.close()
> > + except Exception:
> > + pass
> > +
> > + if printk_has_timestamps:
> > + return
> > + elif not self._last_message:
> > # We need to ensure that there is something in dmesg to check
> > # timestamps.
> > warnings.warn("Cannot check dmesg for timestamp support. If you
> > "
>
--
Ben Widawsky, Intel Open Source Technology Center
More information about the Piglit
mailing list