aboutsummaryrefslogtreecommitdiff
path: root/framework/test
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2019-10-31 11:05:41 -0700
committerMarge Bot <eric+marge@anholt.net>2020-02-13 19:09:15 +0000
commit19eb8323c8c96b786520d2e57741ae9e96be740c (patch)
tree233ec9c13a3d9383cc58063496ec3ebb62e4250f /framework/test
parent740649eaff3af7738548d899c5404c487d529f75 (diff)
downloadpiglit-19eb8323c8c96b786520d2e57741ae9e96be740c.tar.gz
drop python2 support
This removes all of the python code for handling python 2.x vs 3.x, now only 3.6+ is supported. This also drops all uses of the six module, as its no longer needed. Python 2.x and <= 3.5 are all EOL, it doesn't make sense to continue to support version of python that are at the end of their lives and are being removed from operating systems. Acked-by: Eric Engestrom <eric@engestrom.ch> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/merge_requests/223>
Diffstat (limited to 'framework/test')
-rw-r--r--framework/test/__init__.py3
-rw-r--r--framework/test/base.py131
-rw-r--r--framework/test/deqp.py13
-rw-r--r--framework/test/glsl_parser_test.py7
-rw-r--r--framework/test/gtest.py5
-rw-r--r--framework/test/oclconform.py5
-rw-r--r--framework/test/opencv.py5
-rw-r--r--framework/test/opengl.py7
-rw-r--r--framework/test/piglit_test.py7
-rw-r--r--framework/test/shader_test.py5
10 files changed, 53 insertions, 135 deletions
diff --git a/framework/test/__init__.py b/framework/test/__init__.py
index daf3b6d41..1d14cb01e 100644
--- a/framework/test/__init__.py
+++ b/framework/test/__init__.py
@@ -25,9 +25,6 @@
# create a general use API, but allow it to be controlled by setting the
# __all__ in each module
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
from .base import *
from .piglit_test import *
from .glsl_parser_test import *
diff --git a/framework/test/base.py b/framework/test/base.py
index 6e719cc78..77f07c211 100644
--- a/framework/test/base.py
+++ b/framework/test/base.py
@@ -23,85 +23,45 @@
""" Module provides a base class for Tests """
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
+import abc
+import copy
import errno
+import itertools
import os
-import time
+import signal
+import subprocess
import sys
+import time
import traceback
-import itertools
-import abc
-import copy
-import signal
import warnings
-import six
-from six.moves import range
-
from framework import exceptions
from framework import status
from framework.options import OPTIONS
from framework.results import TestResult
-# We're doing some special crazy here to make timeouts work on python 2. pylint
-# is going to complain a lot
-# pylint: disable=wrong-import-position,wrong-import-order
-if six.PY2:
- try:
- # subprocess32 only supports *nix systems, this is important because
- # "start_new_session" is not a valid argument on windows
-
- import subprocess32 as subprocess
- _EXTRA_POPEN_ARGS = {'start_new_session': True}
- except ImportError:
- # If there is no timeout support, fake it. Add a TimeoutExpired
- # exception and a Popen that accepts a timeout parameter (and ignores
- # it), then shadow the actual Popen with this wrapper.
-
- import subprocess
-
- class TimeoutExpired(Exception):
- pass
-
- class Popen(subprocess.Popen):
- """Sublcass of Popen that accepts and ignores a timeout argument."""
- def communicate(self, *args, **kwargs):
- if 'timeout' in kwargs:
- del kwargs['timeout']
- return super(Popen, self).communicate(*args, **kwargs)
-
- subprocess.TimeoutExpired = TimeoutExpired
- subprocess.Popen = Popen
- _EXTRA_POPEN_ARGS = {}
-
- warnings.warn('Timeouts are not available')
-elif six.PY3:
- # In python3.2+ this all just works, no need for the madness above.
- import subprocess
- _EXTRA_POPEN_ARGS = {}
-
- if sys.platform == 'win32':
- # There is no implementation in piglit to make timeouts work in
- # windows, this uses the same Popen snippet as python 2 without
- # subprocess32 to mask it. Patches are welcome.
- # XXX: Should this also include cygwin?
- warnings.warn('Timeouts are not implemented on Windows.')
-
- class Popen(subprocess.Popen):
- """Sublcass of Popen that accepts and ignores a timeout argument."""
- def communicate(self, *args, **kwargs):
- if 'timeout' in kwargs:
- del kwargs['timeout']
- return super(Popen, self).communicate(*args, **kwargs)
-
- subprocess.Popen = Popen
- elif os.name == 'posix':
- # This should work for all *nix systems, Linux, the BSDs, and OSX.
- # This speicifically creates a session group for each test, so that
- # it's children can be killed if it times out.
- _EXTRA_POPEN_ARGS = {'start_new_session': True}
+_EXTRA_POPEN_ARGS = {}
+
+if sys.platform == 'win32':
+ # There is no implementation in piglit to make timeouts work in
+ # windows, this uses the same Popen snippet as python 2 without
+ # subprocess32 to mask it. Patches are welcome.
+ # XXX: Should this also include cygwin?
+ warnings.warn('Timeouts are not implemented on Windows.')
+
+ class Popen(subprocess.Popen):
+ """Sublcass of Popen that accepts and ignores a timeout argument."""
+ def communicate(self, *args, **kwargs):
+ if 'timeout' in kwargs:
+ del kwargs['timeout']
+ return super(Popen, self).communicate(*args, **kwargs)
+
+ subprocess.Popen = Popen
+elif os.name == 'posix':
+ # This should work for all *nix systems, Linux, the BSDs, and OSX.
+ # This speicifically creates a session group for each test, so that
+ # it's children can be killed if it times out.
+ _EXTRA_POPEN_ARGS = {'start_new_session': True}
# pylint: enable=wrong-import-position,wrong-import-order
@@ -153,8 +113,7 @@ def is_crash_returncode(returncode):
return returncode < 0
-@six.add_metaclass(abc.ABCMeta)
-class Test(object):
+class Test(metaclass=abc.ABCMeta):
""" Abstract base class for Test classes
This class provides the framework for running tests, with several methods
@@ -241,7 +200,7 @@ class Test(object):
# We know because subtests are ordered that the first test with
# a status of NOTRUN is the subtest that crashed, mark that
# test and move on.
- for k, v in six.iteritems(self.result.subtests):
+ for k, v in self.result.subtests.items():
if v == status.NOTRUN:
self.result.subtests[k] = status.CRASH
break
@@ -264,13 +223,13 @@ class Test(object):
self.result.command = ' '.join(self.command)
self.result.environment = " ".join(
'{0}="{1}"'.format(k, v) for k, v in itertools.chain(
- six.iteritems(OPTIONS.env), six.iteritems(self.env)))
+ OPTIONS.env.items(), self.env.items()))
try:
self.is_skip()
except TestIsSkip as e:
self.result.result = status.SKIP
- for each in six.iterkeys(self.result.subtests):
+ for each in self.result.subtests.keys():
self.result.subtests[each] = status.SKIP
self.result.out = e.reason
self.result.returncode = None
@@ -279,10 +238,10 @@ class Test(object):
try:
self._run_command()
except TestRunError as e:
- self.result.result = six.text_type(e.status)
- for each in six.iterkeys(self.result.subtests):
- self.result.subtests[each] = six.text_type(e.status)
- self.result.out = six.text_type(e)
+ self.result.result = str(e.status)
+ for each in self.result.subtests.keys():
+ self.result.subtests[each] = str(e.status)
+ self.result.out = str(e)
self.result.returncode = None
return
@@ -321,17 +280,10 @@ class Test(object):
# command line options (2) override environment variables (1); and
# Piglit considers environment variables set in all.py (3) to be test
# requirements.
- #
- # passing this as unicode is basically broken in python2 on windows, it
- # must be passed a bytes.
- if six.PY2 and sys.platform.startswith('win32'):
- f = six.binary_type
- else:
- f = six.text_type
- _base = itertools.chain(six.iteritems(os.environ),
- six.iteritems(OPTIONS.env),
- six.iteritems(self.env))
- fullenv = {f(k): f(v) for k, v in _base}
+ _base = itertools.chain(os.environ.items(),
+ OPTIONS.env.items(),
+ self.env.items())
+ fullenv = {str(k): str(v) for k, v in _base}
try:
proc = subprocess.Popen(command,
@@ -476,8 +428,7 @@ class ValgrindMixin(object):
self.result.result = 'fail'
-@six.add_metaclass(abc.ABCMeta)
-class ReducedProcessMixin(object):
+class ReducedProcessMixin(metaclass=abc.ABCMeta):
"""This Mixin simplifies writing Test classes that run more than one test
in a single process.
diff --git a/framework/test/deqp.py b/framework/test/deqp.py
index 5db2a922f..abf7b355d 100644
--- a/framework/test/deqp.py
+++ b/framework/test/deqp.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright 2014-2016,2018 Intel Corporation
+# Copyright 2014-2016, 2018-2019 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -19,16 +19,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import abc
import os
import subprocess
-import six
-from six.moves import range
-
from framework import core, grouptools, exceptions
from framework import options
from framework.profile import TestProfile
@@ -142,8 +136,7 @@ def iter_deqp_test_cases(case_file):
'deqp: {}:{}: ill-formed line'.format(case_file, i))
-@six.add_metaclass(abc.ABCMeta)
-class DEQPBaseTest(Test):
+class DEQPBaseTest(Test, metaclass=abc.ABCMeta):
__RESULT_MAP = {
"Pass": "pass",
"Fail": "fail",
@@ -190,7 +183,7 @@ class DEQPBaseTest(Test):
# otherwise this requires some break/else/continue madness
for line in self.result.out.split('\n'):
line = line.lstrip()
- for k, v in six.iteritems(self.__RESULT_MAP):
+ for k, v in self.__RESULT_MAP.items():
if line.startswith(k):
self.result.result = v
return
diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index 980abec4a..5026a43e4 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -29,7 +29,6 @@ import os
import sys
import re
import io
-import six
from framework import exceptions
from .base import TestIsSkip
@@ -56,10 +55,10 @@ _FORCE_DESKTOP_VERSION = os.environ.get('PIGLIT_FORCE_GLSLPARSER_DESKTOP', False
def _is_gles_version(version):
"""Return True if version is es, otherwsie false."""
- assert not isinstance(version, six.binary_type), \
+ assert not isinstance(version, bytes), \
'{}({})'.format(version, type(version))
- if isinstance(version, six.text_type):
+ if isinstance(version, str):
# GLES 3+ versions should have "es" appended, even though
# glslparsertest doesn't require them. If the version ends in "es" then
# it is a GLES test for sure.
@@ -109,7 +108,7 @@ class Parser(object):
self.command = self.get_command(filepath, installpath)
except GLSLParserInternalError as e:
raise exceptions.PiglitFatalError(
- 'In file "{}":\n{}'.format(filepath, six.text_type(e)))
+ 'In file "{}":\n{}'.format(filepath, str(e)))
self.set_skip_conditions()
diff --git a/framework/test/gtest.py b/framework/test/gtest.py
index dbb461368..546a161ff 100644
--- a/framework/test/gtest.py
+++ b/framework/test/gtest.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright 2016 Intel Corporation
+# Copyright 2016, 2019 Intel Corporation
# Copyright 2013, 2014 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,9 +24,6 @@
# Authors: Tom Stellard <thomas.stellard@amd.com>
#
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import re
from .base import Test
diff --git a/framework/test/oclconform.py b/framework/test/oclconform.py
index 65b10b2b8..2012047c9 100644
--- a/framework/test/oclconform.py
+++ b/framework/test/oclconform.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright 2016 Intel Corporation
+# Copyright 2016, 2019 Intel Corporation
# Copyright 2014 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,9 +24,6 @@
# Authors: Tom Stellard <thomas.stellard@amd.com>
#
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import re
import subprocess
from os.path import join
diff --git a/framework/test/opencv.py b/framework/test/opencv.py
index 3cbdb02f8..c107d2495 100644
--- a/framework/test/opencv.py
+++ b/framework/test/opencv.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright 2016 Intel Corporation
+# Copyright 2016, 2019 Intel Corporation
# Copyright 2014 Advanced Micro Devices, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,9 +24,6 @@
# Authors: Tom Stellard <thomas.stellard@amd.com>
#
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import re
import subprocess
from os import path
diff --git a/framework/test/opengl.py b/framework/test/opengl.py
index 0566fb0a8..2f1c5e157 100644
--- a/framework/test/opengl.py
+++ b/framework/test/opengl.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright (c) 2015-2016 Intel Corporation
+# Copyright (c) 2015-2016, 2019 Intel Corporation
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -21,14 +21,9 @@
"""Mixins for OpenGL derived tests."""
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import os
import warnings
-import six
-
from framework import wflinfo
from .base import TestIsSkip
diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py
index 566563059..a14bd03b1 100644
--- a/framework/test/piglit_test.py
+++ b/framework/test/piglit_test.py
@@ -23,9 +23,6 @@
""" Module provides a base class for Tests """
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import glob
import os
import sys
@@ -34,8 +31,6 @@ try:
except ImportError:
import json
-import six
-
from framework import core, options
from framework import status
from .base import Test, WindowResizeMixin, ValgrindMixin, TestIsSkip
@@ -106,7 +101,7 @@ class PiglitBaseTest(ValgrindMixin, Test):
# missing feature. We should fix these tests to do the right thing, but
# for the moment this work around will suffice to keep things running.
if self.result.raw_result is status.SKIP and self.result.subtests:
- for k, v in six.iteritems(self.result.subtests):
+ for k, v in self.result.subtests.items():
if v is status.NOTRUN:
self.result.subtests[k] = status.SKIP
diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py
index 3f6f7bb0f..44b40f938 100644
--- a/framework/test/shader_test.py
+++ b/framework/test/shader_test.py
@@ -1,5 +1,5 @@
# coding=utf-8
-# Copyright (C) 2012, 2014-2016 Intel Corporation
+# Copyright (C) 2012, 2014-2016, 2019 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
@@ -24,9 +24,6 @@
""" This module enables running shader tests. """
-from __future__ import (
- absolute_import, division, print_function, unicode_literals
-)
import io
import os
import re