From: Justin Seyster Date: Thu, 2 Sep 2010 20:56:44 +0000 (-0400) Subject: Test cases now work when the builddir is not the srcdir. X-Git-Tag: release-v1.0~49^2~3 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=92648704a317df79b04c113c022523d5e4ad6244;p=interaspect.git Test cases now work when the builddir is not the srcdir. --- diff --git a/test/Makefile.am b/test/Makefile.am index 0dc11d0..ba7b3db 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ if HAVE_PYTHON TESTS_ENVIRONMENT = $(PYTHON) $(srcdir)/run-testcase.py --with-gcc=$(CC) \ --with-ia-lib-dir=$(top_builddir)/src/.libs \ - --with-ia-src-dir=$(top_srcdir) + --with-ia-src-dir=$(top_srcdir) --with-tests-dir=$(srcdir) TESTS = int-types.xml endif diff --git a/test/run-testcase.py b/test/run-testcase.py index da54918..85d939f 100755 --- a/test/run-testcase.py +++ b/test/run-testcase.py @@ -16,6 +16,7 @@ from xml.sax.handler import feature_namespaces gcc_path = 'gcc' gcc_interaspect_lib = None gcc_interaspect_src = None +tests_dir = None verbose = False # Note that \ _must_ be first in this list, or else \s added for the @@ -230,6 +231,14 @@ class TestcaseHandler(handler.ContentHandler): self.current_cdata += chars +# If the tests_dir is set, prepend the tests_dir directory to the name +# of the source file. +def formatSourceFile(source_file): + if (tests_dir is not None): + return '{0:s}/{1:s}'.format(tests_dir, source_file) + else: + return source_file + # Run GCC with the given arguments. On failure, print an appropriate # error and return False. # If the compile fails because of an error in the C file, runGCC also @@ -280,7 +289,7 @@ def compilePlugin(working_dir, plugin_id, plugin_base_name, plugin_source): plugin_lib_name = '{0:s}/{1:s}.so.1.0.0'.format(working_dir, plugin_base_name) - + plugin_source = formatSourceFile(plugin_source) include_flag = '-I{0:s}/src'.format(gcc_interaspect_src) cmd_args = ['-Wall', '-Werror', include_flag, '-fPIC', '-shared', '-Wl,-soname,{0:s}.so.1'.format(plugin_base_name), '-o', @@ -314,6 +323,7 @@ def compilePlugin(working_dir, plugin_id, plugin_base_name, plugin_source): # executable (which will be in working_dir). On failure, the return # value is None. def compileTestcase(working_dir, target_source, hooks_source, plugin_libs): + hooks_source = formatSourceFile(hooks_source) test_include = '-I{0:s}/test'.format(gcc_interaspect_src) hook_o_file = working_dir + '/hooks.o' cmd_args = ['-Wall', '-Werror', test_include, '-c', '-o', hook_o_file, @@ -331,6 +341,7 @@ def compileTestcase(working_dir, target_source, hooks_source, plugin_libs): return None # Compile the target itself. + target_source = formatSourceFile(target_source) target_o_file = working_dir + '/target.o' cmd_args = ['-fplugin={0:s}'.format(lib) for lib in plugin_libs] cmd_args += ['-Wall', '-Werror', '-c', '-o', target_o_file, target_source] @@ -433,6 +444,7 @@ Options --with-gcc: Path to gcc to compile the tests with --with-ia-lib-dir: Directory with InterAspect library file --with-ia-src-dir: Directory with InterAspect source + --with-tests-dir: Directory with test C files (. by default) """) # End function usage() @@ -452,7 +464,7 @@ if __name__ == '__main__': # Deal with command line arguments try: long_switches = ["verbose", "with-gcc=", "with-ia-lib-dir=", - "with-ia-src-dir="] + "with-ia-src-dir=", "with-tests-dir="] opts, args = getopt.gnu_getopt(sys.argv[1:], "v", long_switches) except getopt.GetoptError: usage() @@ -465,6 +477,8 @@ if __name__ == '__main__': gcc_interaspect_lib = arg + '/libinteraspect.a' elif (opt == "--with-ia-src-dir"): gcc_interaspect_src = arg + elif (opt == "--with-tests-dir"): + tests_dir = arg elif (opt == "--verbose" or opt == "-v"): verbose = True else: