[Lldb-commits] [lldb] r126979 - in /lldb/trunk/test: dotest.py logging/TestLogging.py source-manager/TestSourceManager.py

Johnny Chen johnny.chen at apple.com
Thu Mar 3 17:35:22 PST 2011


Author: johnny
Date: Thu Mar  3 19:35:22 2011
New Revision: 126979

URL: http://llvm.org/viewvc/llvm-project?rev=126979&view=rev
Log:
Add the ability for the test suite to specify a list of compilers and a list of architectures
on the command line.  For example, use '-A x86_64^i386' to launch the inferior use both x86_64
and i386.

This is an example of building the debuggee using both clang and gcc compiers:

[17:30:46] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -C clang^gcc -v -f SourceManagerTestCase.test_modify_source_file_while_debugging

Session logs for test failures/errors will go into directory '2011-03-03-17_31_39'
Command invoked: python ./dotest.py -C clang^gcc -v -f SourceManagerTestCase.test_modify_source_file_while_debugging

Configuration:  compiler=clang
----------------------------------------------------------------------
Collected 1 test

1: test_modify_source_file_while_debugging (TestSourceManager.SourceManagerTestCase)
   Modify a source file while debugging the executable. ... Command 'run' failed!

original content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

new content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello lldb.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after writing new content: 1299202305.0
content restored to: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after restore: 1299202307.0
ok

----------------------------------------------------------------------
Ran 1 test in 8.259s

OK

Configuration:  compiler=gcc
----------------------------------------------------------------------
Collected 1 test

1: test_modify_source_file_while_debugging (TestSourceManager.SourceManagerTestCase)
   Modify a source file while debugging the executable. ... original content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

new content: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello lldb.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after writing new content: 1299202307.0
content restored to: #include <stdio.h>

int main(int argc, char const *argv[]) {
    printf("Hello world.\n"); // Set break point at this line.
    return 0;
}

os.path.getmtime() after restore: 1299202309.0
ok

----------------------------------------------------------------------
Ran 1 test in 2.301s

OK
[17:31:49] johnny:/Volumes/data/lldb/svn/trunk/test $ 

Modified:
    lldb/trunk/test/dotest.py
    lldb/trunk/test/logging/TestLogging.py
    lldb/trunk/test/source-manager/TestSourceManager.py

Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=126979&r1=126978&r2=126979&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Mar  3 19:35:22 2011
@@ -69,6 +69,13 @@
 # The dictionary as a result of sourcing configFile.
 config = {}
 
+# The 'archs' and 'compilers' can be specified via either command line or configFile,
+# with the command line overriding the configFile.  When specified, they should be
+# of the list type.  For example, "-A x86_64^i386" => archs=['x86_64', 'i386'] and
+# "-C gcc^clang" => compilers=['gcc', 'clang'].
+archs = None
+compilers = None
+
 # Delay startup in order for the debugger to attach.
 delay = False
 
@@ -124,8 +131,12 @@
 Usage: dotest.py [option] [args]
 where options:
 -h   : print this help message and exit (also --help)
--A   : specify the architecture to launch for the inferior process
--C   : specify the compiler used to build the inferior executable
+-A   : specify the architecture(s) to launch for the inferior process
+       -A i386 => launch inferior with i386 architecture
+       -A x86_64^i386 => launch inferior with x86_64 and i386 architectures
+-C   : specify the compiler(s) used to build the inferior executable
+       -C clang => build debuggee using clang compiler
+       -C clang^gcc => build debuggee using clang and gcc compilers
 -D   : dump the Python sys.path variable
 -a   : don't do lldb Python API tests
        use @python_api_test to decorate a test case as lldb Python API test
@@ -133,6 +144,8 @@
        do not specify both '-a' and '+a' at the same time
 -b   : read a blacklist file specified after this option
 -c   : read a config file specified after this option
+       the architectures and compilers (note the plurals) specified via '-A' and '-C'
+       will override those specified via a config file
        (see also lldb-trunk/example/test/usage-config)
 -d   : delay startup for 10 seconds (in order for the debugger to attach)
 -F   : failfast, stop the test suite on the first error/failure
@@ -254,6 +267,8 @@
     global blacklist
     global blacklistConfig
     global configFile
+    global archs
+    global compilers
     global count
     global delay
     global dumpSysPath
@@ -288,14 +303,22 @@
             index += 1
             if index >= len(sys.argv) or sys.argv[index].startswith('-'):
                 usage()
-            os.environ["ARCH"] = sys.argv[index]
+            archSpec = sys.argv[index]
+            if archSpec.find('^') != -1:
+                archs = archSpec.split('^')
+            else:
+                os.environ["ARCH"] = archSpec
             index += 1
         elif sys.argv[index].startswith('-C'):
             # Increment by 1 to fetch the CC spec.
             index += 1
             if index >= len(sys.argv) or sys.argv[index].startswith('-'):
                 usage()
-            os.environ["CC"] = sys.argv[index]
+            ccSpec = sys.argv[index]
+            if ccSpec.find('^') != -1:
+                compilers = ccSpec.split('^')
+            else:
+                os.environ["CC"] = ccSpec
             index += 1
         elif sys.argv[index].startswith('-D'):
             dumpSysPath = True
@@ -737,20 +760,24 @@
 iterArchs = False
 iterCompilers = False
 
-from types import *
-if "archs" in config:
+if not archs and "archs" in config:
     archs = config["archs"]
-    if type(archs) is ListType and len(archs) >= 1:
-        iterArchs = True
-if "compilers" in config:
+
+if isinstance(archs, list) and len(archs) >= 1:
+    iterArchs = True
+
+if not compilers and "compilers" in config:
     compilers = config["compilers"]
-    if type(compilers) is ListType and len(compilers) >= 1:
-        iterCompilers = True
+
+if isinstance(compilers, list) and len(compilers) >= 1:
+    iterCompilers = True
 
 # Make a shallow copy of sys.path, we need to manipulate the search paths later.
 # This is only necessary if we are relocated and with different configurations.
-if rdir and (iterArchs or iterCompilers):
+if rdir:
     old_sys_path = sys.path[:]
+# If we iterate on archs or compilers, there is a chance we want to split stderr/stdout.
+if iterArchs or iterCompilers:
     old_stderr = sys.stderr
     old_stdout = sys.stdout
     new_stderr = None
@@ -770,37 +797,38 @@
             configString = archConfig
 
         if iterArchs or iterCompilers:
+            # Translate ' ' to '-' for pathname component.
+            from string import maketrans
+            tbl = maketrans(' ', '-')
+            configPostfix = configString.translate(tbl)
+
+            # Check whether we need to split stderr/stdout into configuration
+            # specific files.
+            if old_stderr.name != '<stderr>' and config.get('split_stderr'):
+                if new_stderr:
+                    new_stderr.close()
+                new_stderr = open("%s.%s" % (old_stderr.name, configPostfix), "w")
+                sys.stderr = new_stderr
+            if old_stdout.name != '<stdout>' and config.get('split_stdout'):
+                if new_stdout:
+                    new_stdout.close()
+                new_stdout = open("%s.%s" % (old_stdout.name, configPostfix), "w")
+                sys.stdout = new_stdout
+ 
             # If we specified a relocated directory to run the test suite, do
             # the extra housekeeping to copy the testdirs to a configStringified
             # directory and to update sys.path before invoking the test runner.
             # The purpose is to separate the configuration-specific directories
             # from each other.
             if rdir:
-                from string import maketrans
                 from shutil import copytree, ignore_patterns
 
-                # Translate ' ' to '-' for dir name.
-                tbl = maketrans(' ', '-')
-                configPostfix = configString.translate(tbl)
                 newrdir = "%s.%s" % (rdir, configPostfix)
 
                 # Copy the tree to a new directory with postfix name configPostfix.
                 copytree(rdir, newrdir, ignore=ignore_patterns('*.pyc', '*.o', '*.d'))
 
-                # Check whether we need to split stderr/stdout into configuration
-                # specific files.
-                if old_stderr.name != '<stderr>' and config.get('split_stderr'):
-                    if new_stderr:
-                        new_stderr.close()
-                    new_stderr = open("%s.%s" % (old_stderr.name, configPostfix), "w")
-                    sys.stderr = new_stderr
-                if old_stdout.name != '<stdout>' and config.get('split_stdout'):
-                    if new_stdout:
-                        new_stdout.close()
-                    new_stdout = open("%s.%s" % (old_stdout.name, configPostfix), "w")
-                    sys.stdout = new_stdout
-
-                # Update the LLDB_TEST environment variable to reflect new top
+               # Update the LLDB_TEST environment variable to reflect new top
                 # level test directory.
                 #
                 # See also lldbtest.TestBase.setUpClass(cls).

Modified: lldb/trunk/test/logging/TestLogging.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/logging/TestLogging.py?rev=126979&r1=126978&r2=126979&view=diff
==============================================================================
--- lldb/trunk/test/logging/TestLogging.py (original)
+++ lldb/trunk/test/logging/TestLogging.py Thu Mar  3 19:35:22 2011
@@ -25,7 +25,9 @@
         self.expect("file " + exe,
                     patterns = [ "Current executable set to .*a.out" ])
 
-        log_file = os.path.join (os.getcwd(), "lldb-commands-log-%s.txt" % type)
+        log_file = os.path.join (os.getcwd(), "lldb-commands-log-%s-%s-%s.txt" % (type,
+                                                                                  self.getCompiler(),
+                                                                                  self.getArchitecture()))
 
         if (os.path.exists (log_file)):
             os.remove (log_file)

Modified: lldb/trunk/test/source-manager/TestSourceManager.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/source-manager/TestSourceManager.py?rev=126979&r1=126978&r2=126979&view=diff
==============================================================================
--- lldb/trunk/test/source-manager/TestSourceManager.py (original)
+++ lldb/trunk/test/source-manager/TestSourceManager.py Thu Mar  3 19:35:22 2011
@@ -103,15 +103,24 @@
 
         # This is the function to restore the original content.
         def restore_file():
+            #print "os.path.getmtime() before restore:", os.path.getmtime('main.c')
+            time.sleep(1)
             with open('main.c', 'w') as f:
                 f.write(original_content)
             with open('main.c', 'r') as f:
                 print "content restored to:", f.read()
+            # Touch the file just to be sure.
+            os.utime('main.c', None)
+            print "os.path.getmtime() after restore:", os.path.getmtime('main.c')
+
+
 
         # Modify the source code file.
         with open('main.c', 'w') as f:
+            time.sleep(1)
             f.write(new_content)
             print "new content:", new_content
+            print "os.path.getmtime() after writing new content:", os.path.getmtime('main.c')
             # Add teardown hook to restore the file to the original content.
             self.addTearDownHook(restore_file)
 





More information about the lldb-commits mailing list