[Piglit] [PATCH 10/20] unittests: fix dmesg test that could not work on non-posix platforms
Dylan Baker
dylan at pnwbakers.com
Thu Jun 2 00:47:29 UTC 2016
Quoting Dylan Baker (2016-06-01 16:50:17)
> The test would try to initialize a linuxDmesg even on windows, which
> obviously wouldn't work, since there is not /dev/kmesg on windows. The
> test is a little hacky anyways, and better tested using appveyor for
> windows testing. The updated test just tests that the currently platform
> returns the right thing.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
> unittests/dmesg_tests.py | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/unittests/dmesg_tests.py b/unittests/dmesg_tests.py
> index 0b0490d..18fa361 100644
> --- a/unittests/dmesg_tests.py
> +++ b/unittests/dmesg_tests.py
> @@ -29,6 +29,7 @@ from __future__ import (
> absolute_import, division, print_function, unicode_literals
> )
> import re
> +import sys
> import warnings
>
> try:
> @@ -37,7 +38,6 @@ except ImportError:
> import mock
>
> import nose.tools as nt
> -import six
>
> from . import utils
> from framework import dmesg, status, results, exceptions
> @@ -280,24 +280,15 @@ def test_dummydmesg_update_result():
> nt.eq_(result.result, mock.sentinel.result)
>
>
> - at utils.nose.generator
> + at utils.nose.Skip(sys.platform.startswith('win32') or sys.platform.startswith('linux'),
> + 'Dmesg support unimplemented for platfor {}'.format(sys.platform))
> def test_get_dmesg():
> - """Generate tests for get_dmesg."""
> - tests = [
> - ('linux', dmesg.LinuxDmesg),
> - # There is no dmesg on windows, thus it will always get the dummy
> - ('win32', dmesg.DummyDmesg),
> - ]
> - description = 'dmesg.get_dmesg: returns correct class when platform is {}'
> -
> - def test(platform, class_):
> - with mock.patch('framework.dmesg.sys.platform', platform):
> - ret = dmesg.get_dmesg()
> - nt.assert_is_instance(ret, class_)
> -
> - for platform, class_ in tests:
> - test.description = description.format(platform)
> - yield test, platform, class_
> + """dmesg.get_dmesg: Returns correct class for platform"""
> + ret = dmesg.get_dmesg()
> + if sys.platform.startswith('win32'):
> + nt.ok_(ret is dmesg.DummyDmesg)
> + elif sys.platform.startswith('linux'):
> + nt.ok_(ret is dmesg.LinuxDmesg)
>
>
> def test_get_dmesg_dummy():
> --
> 2.8.3
>
and this patch is completely wrong. well, mostly wrong. It hides it by
always skipping. The assert should be 'istinstance(ret, dmesg.<type>)'.
I've fixed that locally.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160601/4a42c3e7/attachment.sig>
More information about the Piglit
mailing list