diff options
Diffstat (limited to 'progs/gallium/python/tests')
-rwxr-xr-x | progs/gallium/python/tests/base.py | 74 | ||||
-rwxr-xr-x | progs/gallium/python/tests/surface_copy.py | 116 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_blit.py | 9 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_render.py | 4 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_transfer.py | 109 |
5 files changed, 188 insertions, 124 deletions
diff --git a/progs/gallium/python/tests/base.py b/progs/gallium/python/tests/base.py index 8c55e3ae5d..d8cf84db36 100755 --- a/progs/gallium/python/tests/base.py +++ b/progs/gallium/python/tests/base.py @@ -116,7 +116,7 @@ class Test: def run(self): result = TestResult() self._run(result) - result.summary() + result.report() def assert_rgba(self, ctx, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85): total = h*w @@ -250,7 +250,7 @@ class TestResult: sys.stdout.write("SKIP\n") sys.stdout.flush() self.skipped += 1 - #self.log_result(test, 'skip') + self.log_result(test, 'skip') def test_failed(self, test): sys.stdout.write("FAIL\n") @@ -296,11 +296,16 @@ class TestResult: self.rows.append(row) - def summary(self): + def report(self): sys.stdout.write("%u tests, %u passed, %u skipped, %u failed\n\n" % (self.tests, self.passed, self.skipped, self.failed)) sys.stdout.flush() name, ext = os.path.splitext(os.path.basename(sys.argv[0])) + + tree = self.report_tree(name) + self.report_junit(name, stdout=tree) + + def report_tree(self, name): filename = name + '.tsv' stream = file(filename, 'wt') @@ -311,6 +316,8 @@ class TestResult: # rows for row in self.rows: + if row[0] == 'skip': + continue row += ['']*(len(self.names) - len(row)) stream.write('\t'.join(row) + '\n') @@ -322,7 +329,7 @@ class TestResult: import orngTree except ImportError: sys.stderr.write('Install Orange from http://www.ailab.si/orange/ for a classification tree.\n') - return + return None data = orange.ExampleTable(filename) @@ -330,6 +337,63 @@ class TestResult: orngTree.printTxt(tree, maxDepth=4) - file(name+'.txt', 'wt').write(orngTree.dumpTree(tree)) + text_tree = orngTree.dumpTree(tree) + + file(name + '.txt', 'wt').write(text_tree) orngTree.printDot(tree, fileName=name+'.dot', nodeShape='ellipse', leafShape='box') + + return text_tree + + def report_junit(self, name, stdout=None, stderr=None): + """Write test results in ANT's junit XML format, to use with Hudson CI. + + See also: + - http://fisheye.hudson-ci.org/browse/Hudson/trunk/hudson/main/core/src/test/resources/hudson/tasks/junit + - http://www.junit.org/node/399 + - http://wiki.apache.org/ant/Proposals/EnhancedTestReports + """ + + stream = file(name + '.xml', 'wt') + + stream.write('<?xml version="1.0" encoding="UTF-8" ?>\n') + stream.write('<testsuite name="%s">\n' % self.escape_xml(name)) + stream.write(' <properties>\n') + stream.write(' </properties>\n') + + names = self.names[1:] + + for row in self.rows: + + test_name = ' '.join(['%s=%s' % pair for pair in zip(self.names[1:], row[1:])]) + + stream.write(' <testcase name="%s">\n' % (self.escape_xml(test_name))) + + result = row[0] + if result == 'pass': + pass + elif result == 'skip': + stream.write(' <skipped/>\n') + else: + stream.write(' <failure/>\n') + + stream.write(' </testcase>\n') + + if stdout: + stream.write(' <system-out>%s</system-out>\n' % self.escape_xml(stdout)) + if stderr: + stream.write(' <system-err>%s</system-err>\n' % self.escape_xml(stderr)) + + stream.write('</testsuite>\n') + + stream.close() + + def escape_xml(self, s): + '''Escape a XML string.''' + s = s.replace('&', '&') + s = s.replace('<', '<') + s = s.replace('>', '>') + s = s.replace('"', '"') + s = s.replace("'", ''') + return s + diff --git a/progs/gallium/python/tests/surface_copy.py b/progs/gallium/python/tests/surface_copy.py index 9364fd1110..3eefa690bd 100755 --- a/progs/gallium/python/tests/surface_copy.py +++ b/progs/gallium/python/tests/surface_copy.py @@ -27,6 +27,9 @@ ########################################################################## +import os +import random + from gallium import * from base import * @@ -68,6 +71,14 @@ class TextureTest(TestCase): level = self.level zslice = self.zslice + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER + geom_flags = 0 + if not dev.is_format_supported(format, target, tex_usage, geom_flags): + raise TestSkip + + if not dev.is_format_supported(format, target, tex_usage, geom_flags): + raise TestSkip + # textures dst_texture = dev.texture_create( target = target, @@ -76,10 +87,8 @@ class TextureTest(TestCase): height = height, depth = depth, last_level = last_level, - tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, + tex_usage = tex_usage, ) - if dst_texture is None: - raise TestSkip dst_surface = dst_texture.get_surface(face = face, level = level, zslice = zslice) @@ -95,8 +104,6 @@ class TextureTest(TestCase): src_surface = src_texture.get_surface() - x = 0 - y = 0 w = dst_surface.width h = dst_surface.height @@ -113,7 +120,6 @@ class TextureTest(TestCase): if dst_raw != src_raw: raise TestFailure - def main(): @@ -124,27 +130,7 @@ def main(): targets = [ PIPE_TEXTURE_2D, PIPE_TEXTURE_CUBE, - #PIPE_TEXTURE_3D, - ] - - formats = [ - PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_B5G5R5A1_UNORM, - PIPE_FORMAT_B4G4R4A4_UNORM, - PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_X8Z24_UNORM, - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_S8_UNORM, - PIPE_FORMAT_A8_UNORM, - PIPE_FORMAT_L8_UNORM, - PIPE_FORMAT_DXT1_RGB, - PIPE_FORMAT_DXT1_RGBA, - PIPE_FORMAT_DXT3_RGBA, - PIPE_FORMAT_DXT5_RGBA, + PIPE_TEXTURE_3D, ] sizes = [64, 32, 16, 8, 4, 2, 1] @@ -161,36 +147,52 @@ def main(): PIPE_TEX_FACE_NEG_Z, ] - for target in targets: - for format in formats: - 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 = TextureTest( - 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 + try: + n = int(sys.argv[1]) + except: + n = 10000 + + for i in range(n): + format = random.choice(formats.keys()) + if not util_format_is_depth_or_stencil(format): + 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) + + test = TextureTest( + 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() diff --git a/progs/gallium/python/tests/texture_blit.py b/progs/gallium/python/tests/texture_blit.py index 5ae0a7398d..a68c081931 100755 --- a/progs/gallium/python/tests/texture_blit.py +++ b/progs/gallium/python/tests/texture_blit.py @@ -191,7 +191,7 @@ class TextureColorSampleTest(TestCase): zslice = zslice, ) - ctx.surface_sample_rgba(surface, expected_rgba) + ctx.surface_sample_rgba(surface, expected_rgba, True) ctx.set_fragment_sampler_texture(0, texture) @@ -428,7 +428,7 @@ class TextureDepthSampleTest(TestCase): zslice = zslice, ) - ctx.surface_sample_rgba(surface, expected_rgba) + ctx.surface_sample_rgba(surface, expected_rgba, True) ctx.set_fragment_sampler_texture(0, texture) @@ -555,6 +555,7 @@ def main(): random.seed(0xdead3eef) dev = Device() + ctx = dev.context_create() suite = TestSuite() targets = [ @@ -577,8 +578,6 @@ def main(): PIPE_TEX_FACE_NEG_Z, ] - ctx = dev.context_create() - try: n = int(sys.argv[1]) except: @@ -602,7 +601,7 @@ def main(): depth = 1 if target == PIPE_TEXTURE_CUBE: - face =random.choice(faces) + face = random.choice(faces) else: face = PIPE_TEX_FACE_POS_X diff --git a/progs/gallium/python/tests/texture_render.py b/progs/gallium/python/tests/texture_render.py index 1e26639db6..12def7ec72 100755 --- a/progs/gallium/python/tests/texture_render.py +++ b/progs/gallium/python/tests/texture_render.py @@ -258,10 +258,10 @@ def main(): PIPE_FORMAT_B5G5R5A1_UNORM, PIPE_FORMAT_B4G4R4A4_UNORM, #PIPE_FORMAT_Z32_UNORM, - #PIPE_FORMAT_S8Z24_UNORM, + #PIPE_FORMAT_S8_USCALED_Z24_UNORM, #PIPE_FORMAT_X8Z24_UNORM, #PIPE_FORMAT_Z16_UNORM, - #PIPE_FORMAT_S8_UNORM, + #PIPE_FORMAT_S8_USCALED, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_L8_UNORM, #PIPE_FORMAT_DXT1_RGB, diff --git a/progs/gallium/python/tests/texture_transfer.py b/progs/gallium/python/tests/texture_transfer.py index 97a28e01a4..639d3d362c 100755 --- a/progs/gallium/python/tests/texture_transfer.py +++ b/progs/gallium/python/tests/texture_transfer.py @@ -29,6 +29,7 @@ import os +import random from gallium import * from base import * @@ -71,8 +72,12 @@ class TextureTest(TestCase): level = self.level zslice = self.zslice - tex_usage = 0 + tex_usage = PIPE_TEXTURE_USAGE_SAMPLER + geom_flags = 0 + if not dev.is_format_supported(format, target, tex_usage, geom_flags): + raise TestSkip + # textures texture = dev.texture_create( target = target, format = format, @@ -82,13 +87,11 @@ class TextureTest(TestCase): last_level = last_level, tex_usage = tex_usage, ) - if texture is None: - raise TestSkip surface = texture.get_surface(face, level, zslice) - stride = util_format_get_stride(format, width) - size = util_format_get_nblocksy(format, height) * stride + stride = util_format_get_stride(format, surface.width) + size = util_format_get_nblocksy(format, surface.height) * stride in_raw = os.urandom(size) @@ -111,26 +114,6 @@ def main(): PIPE_TEXTURE_3D, ] - formats = [ - PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_B5G6R5_UNORM, - PIPE_FORMAT_B5G5R5A1_UNORM, - PIPE_FORMAT_B4G4R4A4_UNORM, - PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_X8Z24_UNORM, - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_S8_UNORM, - PIPE_FORMAT_A8_UNORM, - PIPE_FORMAT_L8_UNORM, - PIPE_FORMAT_DXT1_RGB, - PIPE_FORMAT_DXT1_RGBA, - PIPE_FORMAT_DXT3_RGBA, - PIPE_FORMAT_DXT5_RGBA, - ] - sizes = [64, 32, 16, 8, 4, 2, 1] #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] #sizes = [64] @@ -145,36 +128,52 @@ def main(): PIPE_TEX_FACE_NEG_Z, ] - for target in targets: - for format in formats: - 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 = TextureTest( - 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 + try: + n = int(sys.argv[1]) + except: + n = 10000 + + for i in range(n): + format = random.choice(formats.keys()) + if not util_format_is_depth_or_stencil(format): + 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) + + test = TextureTest( + 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() |