summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-03-31 14:05:55 +0100
committerJosé Fonseca <jfonseca@vmware.com>2010-03-31 14:05:55 +0100
commitd0258ca59dd529799092d768eec52c6cad7321c8 (patch)
treed5e500cdabe7e8ccf802ee790992ca17108e97b6
parent213e6584ed91b4ac6c3ed27f076e1b64e51cbc06 (diff)
python/tests: Run trhough tests randomly.
-rwxr-xr-xprogs/gallium/python/tests/base.py2
-rwxr-xr-xprogs/gallium/python/tests/texture_blit.py105
2 files changed, 52 insertions, 55 deletions
diff --git a/progs/gallium/python/tests/base.py b/progs/gallium/python/tests/base.py
index 6296eb58504..8c55e3ae5d5 100755
--- a/progs/gallium/python/tests/base.py
+++ b/progs/gallium/python/tests/base.py
@@ -43,7 +43,7 @@ from gallium import *
# Enumerate all pixel formats
formats = {}
for name, value in globals().items():
- if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name != "PIPE_FORMAT_COUNT":
+ if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name not in ("PIPE_FORMAT_NONE", "PIPE_FORMAT_COUNT"):
formats[value] = name
def make_image(width, height, rgba):
diff --git a/progs/gallium/python/tests/texture_blit.py b/progs/gallium/python/tests/texture_blit.py
index 63686463fa5..a2e62c89ee3 100755
--- a/progs/gallium/python/tests/texture_blit.py
+++ b/progs/gallium/python/tests/texture_blit.py
@@ -28,6 +28,8 @@
##########################################################################
+import random
+
from gallium import *
from base import *
@@ -550,6 +552,8 @@ class TextureDepthSampleTest(TestCase):
def main():
+ random.seed(0xdead3eef)
+
dev = Device()
suite = TestSuite()
@@ -574,62 +578,55 @@ def main():
]
ctx = dev.context_create()
+
+ n = 10000
- for format in formats.iterkeys():
- if format == PIPE_FORMAT_NONE:
- continue
+ for i in range(n):
+ format = random.choice(formats.keys())
if not util_format_is_depth_or_stencil(format):
- for target in targets:
- for size in sizes:
- if target == PIPE_TEXTURE_3D:
- depth = size
- else:
- depth = 1
- for face in faces:
- if target != PIPE_TEXTURE_CUBE and face:
- continue
- levels = lods(size)
- for last_level in range(levels):
- for level in range(0, last_level + 1):
- zslice = 0
- while zslice < depth >> level:
- test = TextureColorSampleTest(
- dev = dev,
- ctx = ctx,
- target = target,
- format = format,
- width = size,
- height = size,
- depth = depth,
- last_level = last_level,
- face = face,
- level = level,
- zslice = zslice,
- )
- suite.add_test(test)
- zslice = (zslice + 1)*2 - 1
- else:
- target = PIPE_TEXTURE_2D
- depth = 1
- face = 0
- last_level = 0
- level = 0
- zslice = 0
- for size in sizes:
- test = TextureDepthSampleTest(
- dev = dev,
- ctx = ctx,
- target = target,
- format = format,
- width = size,
- height = size,
- depth = depth,
- last_level = last_level,
- face = face,
- level = level,
- zslice = zslice,
- )
- suite.add_test(test)
+ is_depth_or_stencil = util_format_is_depth_or_stencil(format)
+
+ if is_depth_or_stencil:
+ target = PIPE_TEXTURE_2D
+ else:
+ target = random.choice(targets)
+
+ size = random.choice(sizes)
+
+ if target == PIPE_TEXTURE_3D:
+ depth = size
+ else:
+ depth = 1
+
+ if target == PIPE_TEXTURE_CUBE:
+ face =random.choice(faces)
+ else:
+ face = PIPE_TEX_FACE_POS_X
+
+ levels = lods(size)
+ last_level = random.randint(0, levels - 1)
+ level = random.randint(0, last_level)
+ zslice = random.randint(0, max(depth >> level, 1) - 1)
+
+ if is_depth_or_stencil:
+ klass = TextureDepthSampleTest
+ else:
+ klass = TextureColorSampleTest
+
+ test = klass(
+ dev = dev,
+ ctx = ctx,
+ target = target,
+ format = format,
+ width = size,
+ height = size,
+ depth = depth,
+ last_level = last_level,
+ face = face,
+ level = level,
+ zslice = zslice,
+ )
+ suite.add_test(test)
suite.run()