From 4764b4045c5fb51d2c3ee5cabedc721b019b4f19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 4 Dec 2011 00:43:24 +0000 Subject: [PATCH] Test trace files too. --- CMakeLists.txt | 1 + apps/CMakeLists.txt | 2 +- driver.py | 54 ++++++++++++++++++---------------- traces/CMakeLists.txt | 15 ++++++++++ traces/incomplete-call.ref.txt | 6 ++++ 5 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 traces/CMakeLists.txt create mode 100644 traces/incomplete-call.ref.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index d45e557..0c7c3da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,4 +75,5 @@ endif () enable_testing() add_subdirectory (apps) +add_subdirectory (traces) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index c4c0518..c1a1762 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -11,7 +11,7 @@ function (ADD_APP_TEST) ) add_test( - NAME ${TEST_NAME} + NAME app_${TEST_NAME} COMMAND python ${CMAKE_SOURCE_DIR}/driver.py --build ${APITRACE_BINARY_DIR} diff --git a/driver.py b/driver.py index 94641c4..6069909 100755 --- a/driver.py +++ b/driver.py @@ -65,24 +65,20 @@ def _get_build_program(program): class TestCase: + cmd = None + cwd = None + api = 'gl' max_frames = None trace_file = None - def __init__(self, name, args, cwd=None, build=None, results = '.'): - self.name = name - self.args = args - self.cwd = cwd - self.build = build - self.results = results - - if not os.path.exists(results): - os.makedirs(results) - expected_dump = None def standalone(self): - p = popen(self.args, cwd=self.cwd) + if not self.cmd: + return + + p = popen(self.cmd, cwd=self.cwd) p.wait() if p.returncode: self.skip('application returned code %i' % p.returncode) @@ -95,8 +91,12 @@ class TestCase: } def trace(self): + if not self.cmd: + return + if self.trace_file is None: - self.trace_file = os.path.abspath(os.path.join(self.results, self.name + '.trace')) + name = os.path.basename(self.cmd[0]) + self.trace_file = os.path.abspath(os.path.join(self.results, name + '.trace')) if os.path.exists(self.trace_file): os.remove(self.trace_file) else: @@ -104,14 +104,14 @@ class TestCase: if not os.path.exists(trace_dir): os.makedirs(trace_dir) - cmd = self.args + cmd = self.cmd env = os.environ.copy() system = platform.system() local_wrapper = None if system == 'Windows': wrapper = _get_build_path('wrappers/opengl32.dll') - local_wrapper = os.path.join(os.path.dirname(self.args[0]), os.path.basename(wrapper)) + local_wrapper = os.path.join(os.path.dirname(self.cmd[0]), os.path.basename(wrapper)) shutil.copy(wrapper, local_wrapper) env['TRACE_FILE'] = self.trace_file else: @@ -152,7 +152,7 @@ class TestCase: ref_line = ref.readline().rstrip() for line in p.stdout: line = line.rstrip() - print line + sys.stdout.write(line + '\n') mo = self.call_re.match(line) if mo: call_no = int(mo.group(1)) @@ -276,7 +276,7 @@ def main(): # Parse command line options optparser = optparse.OptionParser( - usage='\n\t%prog [options] -- program [args] ...', + usage='\n\t%prog [options] -- [TRACE|PROGRAM] ...', version='%%prog') optparser.add_option( '-a', '--api', metavar='API', @@ -301,17 +301,21 @@ def main(): (options, args) = optparser.parse_args(sys.argv[1:]) if not args: - optparser.error('program must be specified') - - test = TestCase( - name = os.path.basename(args[0]), - args = args, - cwd = options.cwd, - build = options.build, - results = options.results, - ) + optparser.error('an argument must be specified') + + if not os.path.exists(options.results): + os.makedirs(options.results) + + test = TestCase() + + if args[0].endswith('.trace'): + test.trace_file = args[0] + else: + test.cmd = args + test.cwd = options.cwd test.api = options.api test.ref_dump = options.ref_dump + test.results = options.results test.run() diff --git a/traces/CMakeLists.txt b/traces/CMakeLists.txt new file mode 100644 index 0000000..e6db3ea --- /dev/null +++ b/traces/CMakeLists.txt @@ -0,0 +1,15 @@ +set (traces + incomplete-call + zlib-no-eof +) + +foreach (trace ${traces}) + add_test( + NAME trace_${trace} + COMMAND + python ${CMAKE_SOURCE_DIR}/driver.py + --build ${APITRACE_BINARY_DIR} + --ref-dump ${CMAKE_CURRENT_SOURCE_DIR}/${trace}.ref.txt + ${trace}.trace + ) +endforeach (trace) diff --git a/traces/incomplete-call.ref.txt b/traces/incomplete-call.ref.txt new file mode 100644 index 0000000..e277c19 --- /dev/null +++ b/traces/incomplete-call.ref.txt @@ -0,0 +1,6 @@ +glXChooseFBConfig(dpy = 0xa7d2a0, screen = 0, attribList = {GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_ALPHA_SIZE, 1, GLX_DOUBLEBUFFER, 1, 0}, nitems = &12) = {0xa9c480, 0xa9c570, 0xa9e260, 0xa9e350, 0xa9c750, 0xa9c840, 0xa9ccf0, 0xa9e530, 0xa9e620, 0xa9ead0, 0xa9cde0, 0xa9ebc0} +glXGetVisualFromFBConfig(dpy = 0xa7d2a0, config = 0xa9c480) = &{visual = 0xa88178, visualid = 154, screen = 0, depth = 24, c_class = 4, red_mask = 16711680, green_mask = 65280, blue_mask = 255, colormap_size = 256, bits_per_rgb = 8} +glXCreateNewContext(dpy = 0xa7d2a0, config = 0xa9c480, renderType = GLX_RGBA_TYPE, shareList = NULL, direct = True) = 0xa95660 +glXMakeContextCurrent(dpy = 0xa7d2a0, draw = 67108866, read = 67108866, ctx = 0xa95660) = True +glXMakeContextCurrent(dpy = 0xa7d2a0, draw = 67108866, read = 67108866, ctx = 0xa95660) = True +glGetIntegerv(pname = GL_RED_BITS, params = ?) // incomplete -- 2.43.0