]> git.cworth.org Git - apitrace-tests/commitdiff
cli: Use python differ. Fix failures.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 6 Dec 2012 07:09:48 +0000 (07:09 +0000)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Thu, 6 Dec 2012 07:10:13 +0000 (07:10 +0000)
Tests were failure due to off by one difference in line nos.

cli/.gitignore
cli/cli-trim-unused-shaders.script
cli/cli-trim-unused-textures.script
cli_driver.py

index 214d7f2c2cf6159fe718bdf13fd4152b11c5b6d4..cc6da65af387e504aa33df663c6c589323e32cc5 100644 (file)
@@ -4,4 +4,4 @@ tri-out
 glxsimple-ref
 glxsimple-out
 glxsimple-trim.trace
 glxsimple-ref
 glxsimple-out
 glxsimple-trim.trace
-
+glxsimple-trim-unused-textures.trace
index 2fb53df62111e33fbb8b4690102e4b4123ca3068..8d461b071876e3a6897ae7c52dbcabed0deea6e6 100644 (file)
@@ -12,8 +12,97 @@ apitrace trim --auto --calls=10,47,50,71,87,88 glxsimple.trace
 
 # Verify that we actually trimmed what we wanted to
 
 
 # Verify that we actually trimmed what we wanted to
 
-apitrace diff --diff=diff glxsimple.trace glxsimple-trim.trace
-expect "12,40d11\n< glCreateShader(GL_VERTEX_SHADER) = 7\n< glShaderSource(7, 1, &\"void main()\n< {\n<         gl_Position = ftransform();\n< }\n< \", NULL)\n< glCompileShader(7)\n< glCreateShader(GL_FRAGMENT_SHADER) = 8\n< glShaderSource(8, 1, &\"#version 120\n< uniform vec4 color;\n< void main()\n< {\n<         gl_FragColor = color;\n< }\n< \", NULL)\n< glCompileShader(8)\n< glCreateProgram() = 9\n< glAttachShader(9, 7)\n< glAttachShader(9, 8)\n< glLinkProgram(9)\n< glUseProgram(9)\n< glGetUniformLocation(9, \"color\") = 0\n< glUniform4f(0, 0, 1, 0, 1)\n< glBegin(GL_QUADS)\n< glVertex2f(0, 0)\n< glVertex2f(64, 0)\n< glVertex2f(64, 64)\n< glVertex2f(0, 64)\n< glEnd()\n42,43d12\n< glXSwapBuffers(0x236a280, 41943041)\n< \n"
+apitrace diff --diff=python glxsimple.trace glxsimple-trim.trace
+expect r"""  glXChooseVisual(37134976, 0, (GLX_RGBA, GLX_RED_SIZE, GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_RED_SIZE, GLX_BLUE_SIZE, GLX_RED_SIZE, GLX_ALPHA_SIZE, GLX_RED_SIZE, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, GLX_RED_SIZE, GLX_X_VISUAL_TYPE, GLX_DIRECT_COLOR, 0)) = ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8])
+  glXCreateContext(37134976, ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8]), 0, True) = 37241648
+  glXMakeCurrent(37134976, 41943041, 37241648) = True
+  glViewport(0, 0, 64, 64)
+  glMatrixMode(GL_PROJECTION)
+  glLoadIdentity()
+  glOrtho(0.0, 64.0, 64.0, 0.0, 0.0, 1.0)
+  glMatrixMode(GL_MODELVIEW)
+  glClearColor(0.0, 0.0, 1.0, 1.0)
+  glClear((GL_COLOR_BUFFER_BIT))
+  glXSwapBuffers(37134976, 41943041)
+- glCreateShader(GL_VERTEX_SHADER) = 7
+- glShaderSource(7, 1, ('void main()\n{\n        gl_Position = ftransform();\n}\n'), 0)
+- glCompileShader(7)
+- glCreateShader(GL_FRAGMENT_SHADER) = 8
+- glShaderSource(8, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n        gl_FragColor = color;\n}\n'), 0)
+- glCompileShader(8)
+- glCreateProgram() = 9
+- glAttachShader(9, 7)
+- glAttachShader(9, 8)
+- glLinkProgram(9)
+- glUseProgram(9)
+- glGetUniformLocation(9, color) = 0
+- glUniform4f(0, 0.0, 1.0, 0.0, 1.0)
+- glBegin(GL_QUADS)
+- glVertex2f(0.0, 0.0)
+- glVertex2f(64.0, 0.0)
+- glVertex2f(64.0, 64.0)
+- glVertex2f(0.0, 64.0)
+- glEnd()
+  glUseProgram(0)
+- glXSwapBuffers(37134976, 41943041)
+  glGenTextures(1, (1))
+  glBindTexture(GL_TEXTURE_2D, 1)
+  glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+  glEnable(GL_TEXTURE_2D)
+  glBegin(GL_QUADS)
+  glTexCoord2f(0.0, 0.0)
+  glVertex2f(0.0, 0.0)
+  glTexCoord2f(1.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glTexCoord2f(1.0, 1.0)
+  glVertex2f(64.0, 64.0)
+  glTexCoord2f(0.0, 1.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glDisable(GL_TEXTURE_2D)
+  glXSwapBuffers(37134976, 41943041)
+  glClearColor(1.0, 0.0, 0.0, 1.0)
+  glClear((GL_COLOR_BUFFER_BIT))
+  glXSwapBuffers(37134976, 41943041)
+  glCreateShader(GL_VERTEX_SHADER) = 10
+  glShaderSource(10, 1, ('void main()\n{\n        gl_Position = ftransform();\n}\n'), 0)
+  glCompileShader(10)
+  glCreateShader(GL_FRAGMENT_SHADER) = 11
+  glShaderSource(11, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n        gl_FragColor = color;\n}\n'), 0)
+  glCompileShader(11)
+  glCreateProgram() = 12
+  glAttachShader(12, 10)
+  glAttachShader(12, 11)
+  glLinkProgram(12)
+  glUseProgram(12)
+  glGetUniformLocation(12, color) = 0
+  glUniform4f(0, 1.0, 0.0, 1.0, 1.0)
+  glBegin(GL_QUADS)
+  glVertex2f(0.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glVertex2f(64.0, 64.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glUseProgram(0)
+  glXSwapBuffers(37134976, 41943041)
+  glGenTextures(1, (2))
+  glBindTexture(GL_TEXTURE_2D, 2)
+  glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+  glEnable(GL_TEXTURE_2D)
+  glBegin(GL_QUADS)
+  glTexCoord2f(0.0, 0.0)
+  glVertex2f(0.0, 0.0)
+  glTexCoord2f(1.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glTexCoord2f(1.0, 1.0)
+  glVertex2f(64.0, 64.0)
+  glTexCoord2f(0.0, 1.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glDisable(GL_TEXTURE_2D)
+  glXSwapBuffers(37134976, 41943041)
+  glXDestroyContext(37134976, 37241648)
+"""
 
 # Generate output images for all frames in the trimmed trace
 
 
 # Generate output images for all frames in the trimmed trace
 
@@ -23,4 +112,9 @@ apitrace dump-images --call-nos=no -o ./glxsimple-out/ glxsimple-trim.trace
 # Compare output to reference images
 
 apitrace diff-images -v ./glxsimple-ref ./glxsimple-out
 # Compare output to reference images
 
 apitrace diff-images -v ./glxsimple-ref ./glxsimple-out
-expect "Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH\nComparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH\nComparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH\nComparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH\nComparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH\n"
+expect r"""Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH
+Comparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH
+Comparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH
+Comparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH
+Comparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH
+"""
index e90204215dea1a750664e055fc61531aea279dd3..96ab85345d57a87c88e4d15fb445422e36ac6e91 100644 (file)
@@ -8,19 +8,113 @@ apitrace dump-images --calls=10,31,50,71,87,88 --call-nos=no -o ./glxsimple-ref/
 
 # Trim to the same callset used to generate reference images
 
 
 # Trim to the same callset used to generate reference images
 
-apitrace trim --auto --calls=10,31,50,71,87,88 glxsimple.trace
+apitrace trim --auto -o glxsimple-trim-unused-textures.trace --calls=10,31,50,71,87,88 glxsimple.trace
 
 # Verify that we actually trimmed what we wanted to
 
 
 # Verify that we actually trimmed what we wanted to
 
-apitrace diff --diff=diff glxsimple.trace glxsimple-trim.trace
-expect "44d43\n< glGenTextures(1, &1)\n46d44\n< glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))\n48,57d45\n< glBegin(GL_QUADS)\n< glTexCoord2f(0, 0)\n< glVertex2f(0, 0)\n< glTexCoord2f(1, 0)\n< glVertex2f(64, 0)\n< glTexCoord2f(1, 1)\n< glVertex2f(64, 64)\n< glTexCoord2f(0, 1)\n< glVertex2f(0, 64)\n< glEnd()\n59,60d46\n< glXSwapBuffers(0x236a280, 41943041)\n< \n"
+apitrace diff --diff=python glxsimple.trace glxsimple-trim-unused-textures.trace
+expect r"""  glXChooseVisual(37134976, 0, (GLX_RGBA, GLX_RED_SIZE, GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_RED_SIZE, GLX_BLUE_SIZE, GLX_RED_SIZE, GLX_ALPHA_SIZE, GLX_RED_SIZE, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, GLX_RED_SIZE, GLX_X_VISUAL_TYPE, GLX_DIRECT_COLOR, 0)) = ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8])
+  glXCreateContext(37134976, ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8]), 0, True) = 37241648
+  glXMakeCurrent(37134976, 41943041, 37241648) = True
+  glViewport(0, 0, 64, 64)
+  glMatrixMode(GL_PROJECTION)
+  glLoadIdentity()
+  glOrtho(0.0, 64.0, 64.0, 0.0, 0.0, 1.0)
+  glMatrixMode(GL_MODELVIEW)
+  glClearColor(0.0, 0.0, 1.0, 1.0)
+  glClear((GL_COLOR_BUFFER_BIT))
+  glXSwapBuffers(37134976, 41943041)
+  glCreateShader(GL_VERTEX_SHADER) = 7
+  glShaderSource(7, 1, ('void main()\n{\n        gl_Position = ftransform();\n}\n'), 0)
+  glCompileShader(7)
+  glCreateShader(GL_FRAGMENT_SHADER) = 8
+  glShaderSource(8, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n        gl_FragColor = color;\n}\n'), 0)
+  glCompileShader(8)
+  glCreateProgram() = 9
+  glAttachShader(9, 7)
+  glAttachShader(9, 8)
+  glLinkProgram(9)
+  glUseProgram(9)
+  glGetUniformLocation(9, color) = 0
+  glUniform4f(0, 0.0, 1.0, 0.0, 1.0)
+  glBegin(GL_QUADS)
+  glVertex2f(0.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glVertex2f(64.0, 64.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glUseProgram(0)
+  glXSwapBuffers(37134976, 41943041)
+- glGenTextures(1, (1))
+  glBindTexture(GL_TEXTURE_2D, 1)
+- glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+  glEnable(GL_TEXTURE_2D)
+- glBegin(GL_QUADS)
+- glTexCoord2f(0.0, 0.0)
+- glVertex2f(0.0, 0.0)
+- glTexCoord2f(1.0, 0.0)
+- glVertex2f(64.0, 0.0)
+- glTexCoord2f(1.0, 1.0)
+- glVertex2f(64.0, 64.0)
+- glTexCoord2f(0.0, 1.0)
+- glVertex2f(0.0, 64.0)
+- glEnd()
+  glDisable(GL_TEXTURE_2D)
+- glXSwapBuffers(37134976, 41943041)
+  glClearColor(1.0, 0.0, 0.0, 1.0)
+  glClear((GL_COLOR_BUFFER_BIT))
+  glXSwapBuffers(37134976, 41943041)
+  glCreateShader(GL_VERTEX_SHADER) = 10
+  glShaderSource(10, 1, ('void main()\n{\n        gl_Position = ftransform();\n}\n'), 0)
+  glCompileShader(10)
+  glCreateShader(GL_FRAGMENT_SHADER) = 11
+  glShaderSource(11, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n        gl_FragColor = color;\n}\n'), 0)
+  glCompileShader(11)
+  glCreateProgram() = 12
+  glAttachShader(12, 10)
+  glAttachShader(12, 11)
+  glLinkProgram(12)
+  glUseProgram(12)
+  glGetUniformLocation(12, color) = 0
+  glUniform4f(0, 1.0, 0.0, 1.0, 1.0)
+  glBegin(GL_QUADS)
+  glVertex2f(0.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glVertex2f(64.0, 64.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glUseProgram(0)
+  glXSwapBuffers(37134976, 41943041)
+  glGenTextures(1, (2))
+  glBindTexture(GL_TEXTURE_2D, 2)
+  glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+  glEnable(GL_TEXTURE_2D)
+  glBegin(GL_QUADS)
+  glTexCoord2f(0.0, 0.0)
+  glVertex2f(0.0, 0.0)
+  glTexCoord2f(1.0, 0.0)
+  glVertex2f(64.0, 0.0)
+  glTexCoord2f(1.0, 1.0)
+  glVertex2f(64.0, 64.0)
+  glTexCoord2f(0.0, 1.0)
+  glVertex2f(0.0, 64.0)
+  glEnd()
+  glDisable(GL_TEXTURE_2D)
+  glXSwapBuffers(37134976, 41943041)
+  glXDestroyContext(37134976, 37241648)
+"""
 
 # Generate output images for all frames in the trimmed trace
 
 rm_and_mkdir glxsimple-out
 
 # Generate output images for all frames in the trimmed trace
 
 rm_and_mkdir glxsimple-out
-apitrace dump-images --call-nos=no -o ./glxsimple-out/ glxsimple-trim.trace
+apitrace dump-images --call-nos=no -o ./glxsimple-out/ glxsimple-trim-unused-textures.trace
 
 # Compare output to reference images
 
 apitrace diff-images -v ./glxsimple-ref ./glxsimple-out
 
 # Compare output to reference images
 
 apitrace diff-images -v ./glxsimple-ref ./glxsimple-out
-expect "Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH\nComparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH\nComparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH\nComparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH\nComparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH\n"
+expect r"""Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH
+Comparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH
+Comparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH
+Comparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH
+Comparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH
+"""
index 8016d1853abe76ac77f0ad2a6f46c9c3b4c1a418..6c1bfd05ae28424e4a2ed8269e8b395b292ce894 100644 (file)
@@ -51,7 +51,7 @@ class CliDriver(Driver):
                 fail("Command failed (returned non-zero):\n    " + " ".join(cmd))
 
     def do_expect(self, args):
                 fail("Command failed (returned non-zero):\n    " + " ".join(cmd))
 
     def do_expect(self, args):
-        expected = json.loads(args)
+        expected = eval(args)
         if (self.output != expected):
             differ = difflib.Differ()
             diff = differ.compare(expected.splitlines(1), self.output.splitlines(1))
         if (self.output != expected):
             differ = difflib.Differ()
             diff = differ.compare(expected.splitlines(1), self.output.splitlines(1))
@@ -101,6 +101,11 @@ class CliDriver(Driver):
 
             if " " in line:
                 (cmd, args) = line.split(None,1)
 
             if " " in line:
                 (cmd, args) = line.split(None,1)
+                if args.startswith('r"""'):
+                    while not line.endswith('"""'):
+                        line = script.readline()
+                        line = line.rstrip()
+                        args += '\n' + line
             else:
                 cmd = line
                 args = ''
             else:
                 cmd = line
                 args = ''