[Piglit] [PATCH] dmesg.py: Make timestamp check slightly smarter
Dylan Baker
baker.dylan.c at gmail.com
Mon Aug 11 11:57:43 PDT 2014
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.
> + 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
> "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140811/a31a41f2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140811/a31a41f2/attachment.sig>
More information about the Piglit
mailing list