diff options
-rw-r--r-- | src/gallium/state_trackers/python/tests/base.py | 44 | ||||
-rw-r--r-- | src/gallium/state_trackers/python/tests/texture.py | 37 |
2 files changed, 54 insertions, 27 deletions
diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 2df2af0..10964d9 100644 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -137,14 +137,54 @@ class Test: class TestCase(Test): + tags = () + def __init__(self, dev, **kargs): Test.__init__(self) self.dev = dev self.__dict__.update(kargs) def description(self): - raise NotImplementedError - + descriptions = [] + for tag in self.tags: + try: + method = getattr(self, '_describe_' + tag) + except AttributeError: + description = str(getattr(self, tag, None)) + else: + description = method() + if description is not None: + descriptions.append(tag + '=' + description) + return ' '.join(descriptions) + + def _describe_target(self): + return { + PIPE_TEXTURE_1D: "1d", + PIPE_TEXTURE_2D: "2d", + PIPE_TEXTURE_3D: "3d", + PIPE_TEXTURE_CUBE: "cube", + }[self.target] + + def _describe_format(self): + name = formats[self.format] + if name.startswith('PIPE_FORMAT_'): + name = name[12:] + name = name.lower() + return name + + def _describe_face(self): + if self.target == PIPE_TEXTURE_CUBE: + return { + PIPE_TEX_FACE_POS_X: "+x", + PIPE_TEX_FACE_NEG_X: "-x", + PIPE_TEX_FACE_POS_Y: "+y", + PIPE_TEX_FACE_NEG_Y: "-y", + PIPE_TEX_FACE_POS_Z: "+z", + PIPE_TEX_FACE_NEG_Z: "-z", + }[self.face] + else: + return None + def test(self): raise NotImplementedError diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py index 58b7e1c..fcb347f 100644 --- a/src/gallium/state_trackers/python/tests/texture.py +++ b/src/gallium/state_trackers/python/tests/texture.py @@ -100,31 +100,18 @@ def is_pot(n): class TextureTest(TestCase): - def description(self): - target = { - PIPE_TEXTURE_1D: "1d", - PIPE_TEXTURE_2D: "2d", - PIPE_TEXTURE_3D: "3d", - PIPE_TEXTURE_CUBE: "cube", - }[self.target] - format = formats[self.format] - if self.target == PIPE_TEXTURE_CUBE: - face = { - PIPE_TEX_FACE_POS_X: "+x", - PIPE_TEX_FACE_NEG_X: "-x", - PIPE_TEX_FACE_POS_Y: "+y", - PIPE_TEX_FACE_NEG_Y: "-y", - PIPE_TEX_FACE_POS_Z: "+z", - PIPE_TEX_FACE_NEG_Z: "-z", - }[self.face] - else: - face = "" - return "%s %s %ux%ux%u last_level=%u face=%s level=%u zslice=%u" % ( - target, format, - self.width, self.height, self.depth, self.last_level, - face, self.level, self.zslice, - ) - + tags = ( + 'target', + 'format', + 'width', + 'height', + 'depth', + 'last_level', + 'face', + 'level', + 'zslice', + ) + def test(self): dev = self.dev |