python/tests: Run trhough tests randomly.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 31 Mar 2010 13:05:55 +0000 (14:05 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 31 Mar 2010 13:05:55 +0000 (14:05 +0100)
progs/gallium/python/tests/base.py
progs/gallium/python/tests/texture_blit.py

index 6296eb5850494ecb53e77513323132d8e4f3cfe6..8c55e3ae5d5e7d712ec15a52567001b9c990600e 100755 (executable)
@@ -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):
index 63686463fa5ad1361575265d3a0ae8232baa6713..a2e62c89ee3bfe5a89e4289b2c35ebf410eebd1c 100755 (executable)
@@ -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()