From: Justin Seyster Date: Tue, 30 Mar 2010 22:09:21 +0000 (-0400) Subject: Added verbose mode to test case framework. X-Git-Tag: release-v1.0~114 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=62ba5dec90321fb9155402e706a443a3acd84c84;p=interaspect.git Added verbose mode to test case framework. Verbose mode prints each GCC command that the framework executes. --- diff --git a/test/run-testcase.py b/test/run-testcase.py index e0966f9..5138295 100755 --- a/test/run-testcase.py +++ b/test/run-testcase.py @@ -16,6 +16,16 @@ from xml.sax.handler import feature_namespaces gcc_path = 'gcc' gcc_interaspect_lib = None gcc_interaspect_src = None +verbose = False + +# Note that \ _must_ be first in this list, or else \s added for the +# purpose of escaping will themselves get escaped. +BASH_ESCAPED_CHARS = """\ *~"&`$';!|#<>""" + +def escapeBashArg(arg): + for char in BASH_ESCAPED_CHARS: + arg = arg.replace(char, "\\" + char) + return arg # A whole host of specialized exceptions for things that can go # horribly wrong with the input XML test case. @@ -395,6 +405,13 @@ def printHook(stream, hook): # If the compile fails because of an error in the C file, runGCC also # prints compile_fail_msg. def runGCC(args, compile_fail_msg): + # Print the GCC command before running it when verbose mode is on. + if verbose: + print escapeBashArg(gcc_path), + for arg in args: + print escapeBashArg(arg), + print + args = [gcc_path] + args try: gcc_proc = subprocess.Popen(args, stderr = subprocess.PIPE) @@ -559,8 +576,9 @@ def checkFileReadable(filename): if __name__ == '__main__': # Deal with command line arguments try: - long_switches = ["with-gcc=", "with-ia-lib-dir=", "with-ia-src-dir="] - opts, args = getopt.gnu_getopt(sys.argv[1:], "", long_switches) + long_switches = ["verbose", "with-gcc=", "with-ia-lib-dir=", + "with-ia-src-dir="] + opts, args = getopt.gnu_getopt(sys.argv[1:], "v", long_switches) except getopt.GetoptError: usage() sys.exit(1) @@ -572,6 +590,8 @@ if __name__ == '__main__': gcc_interaspect_lib = arg + '/libinteraspect.a' elif (opt == "--with-ia-src-dir"): gcc_interaspect_src = arg + elif (opt == "--verbose" or opt == "-v"): + verbose = True else: assert(1)