summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-03-30 18:18:15 +0100
committerJosé Fonseca <[email protected]>2009-03-30 18:18:15 +0100
commit5e815cf26fe4789d92c0fa018e6a20c463e20d32 (patch)
tree4b50c68a96716c0db8527c38b9a1d52c5d92b837
parenta8251d041ac323712a00d5fed3e51fa5ad7bc987 (diff)
python/test: Move the test description logic to the base class.
-rw-r--r--src/gallium/state_trackers/python/tests/base.py44
-rw-r--r--src/gallium/state_trackers/python/tests/texture.py37
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 2df2af0cdf2..10964d99568 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 58b7e1c1246..fcb347f9a17 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