mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
python/test: Move the test description logic to the base class.
This commit is contained in:
parent
a8251d041a
commit
5e815cf26f
2 changed files with 54 additions and 27 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue