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
> "
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
