Fixes a number of issue related to test portability on Windows.
authorZachary Turner <zturner@google.com>
Fri, 18 Jul 2014 01:02:02 +0000 (01:02 +0000)
committerZachary Turner <zturner@google.com>
Fri, 18 Jul 2014 01:02:02 +0000 (01:02 +0000)
99% of this CL is simply moving calls to "import pexpect" to a more
narrow scope - i.e. the function that actually runs a particular
test.  This way the test suite can run on Windows, which doesn't have
pexpect, and the individual tests that use pexpect can be disabled on
a platform-specific basis.

Additionally, this CL fixes a few other cases of non-portability.
Notably, using "ps" to get the command line, and os.uname() to
determine the architecture don't work on Windows.  Finally, this
also adds a stubbed out builder_win32 module.

The full test suite runs correctly on Windows after this CL, although
there is still some work remaining on the C++ side to fix one-shot
script commands from LLDB (e.g. script print "foo"), which currently
deadlock.

Reviewed by: Todd Fiala

Differential Revision: http://reviews.llvm.org/D4573

llvm-svn: 213343

27 files changed:
lldb/test/benchmarks/disassembly/TestDisassembly.py
lldb/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py
lldb/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py
lldb/test/benchmarks/expression/TestExpressionCmd.py
lldb/test/benchmarks/expression/TestRepeatedExprs.py
lldb/test/benchmarks/frame_variable/TestFrameVariableResponse.py
lldb/test/benchmarks/startup/TestStartupDelays.py
lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py
lldb/test/benchmarks/stepping/TestSteppingSpeed.py
lldb/test/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py
lldb/test/dotest.py
lldb/test/functionalities/command_history/TestCommandHistory.py
lldb/test/functionalities/command_regex/TestCommandRegex.py
lldb/test/functionalities/completion/TestCompletion.py
lldb/test/functionalities/connect_remote/TestConnectRemote.py
lldb/test/functionalities/embedded_interpreter/TestConvenienceVariables.py
lldb/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py
lldb/test/functionalities/stop-hook/TestStopHookMechanism.py
lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py
lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py
lldb/test/plugins/builder_win32.py [new file with mode: 0644]
lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py
lldb/test/python_api/sbdata/TestSBData.py
lldb/test/settings/TestSettings.py
lldb/test/terminal/TestSTTYBeforeAndAfter.py
lldb/test/tools/lldb-gdbserver/gdbremote_testcase.py
lldb/test/warnings/uuid/TestAddDsymCommand.py

index a2a54bd..fb5b49f 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 def is_exe(fpath):
@@ -66,6 +65,7 @@ class DisassembleDriverMainLoop(BenchBase):
         print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg)
 
     def run_lldb_disassembly(self, exe, function, count):
+        import pexpect
         # Set self.child_prompt, which is "(lldb) ".
         self.child_prompt = '(lldb) '
         prompt = self.child_prompt
@@ -106,6 +106,7 @@ class DisassembleDriverMainLoop(BenchBase):
         self.child = None
 
     def run_gdb_disassembly(self, exe, function, count):
+        import pexpect
         # Set self.child_prompt, which is "(gdb) ".
         self.child_prompt = '(gdb) '
         prompt = self.child_prompt
index b31c244..39eb3d4 100644 (file)
@@ -5,7 +5,6 @@ inferior and traverses the stack for thread0 to arrive at frame with function
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class AttachThenDisassemblyBench(BenchBase):
index 6c6dd98..977993a 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class XCode41Vs42GDBDisassembly(BenchBase):
@@ -47,6 +46,7 @@ class XCode41Vs42GDBDisassembly(BenchBase):
         print "gdb_42_avg/gdb_41_avg: %f" % (self.gdb_42_avg/self.gdb_41_avg)
 
     def run_gdb_disassembly(self, gdb_exe_path, exe, function, count):
+        import pexpect
         # Set self.child_prompt, which is "(gdb) ".
         self.child_prompt = '(gdb) '
         prompt = self.child_prompt
index 5f71004..3bce16c 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class ExpressionEvaluationCase(BenchBase):
@@ -29,6 +28,7 @@ class ExpressionEvaluationCase(BenchBase):
         print "lldb expr cmd benchmark:", self.stopwatch
 
     def run_lldb_repeated_exprs(self, exe_name, count):
+        import pexpect
         exe = os.path.join(os.getcwd(), exe_name)
 
         # Set self.child_prompt, which is "(lldb) ".
index 1e7338f..68383c7 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class RepeatedExprsCase(BenchBase):
@@ -34,6 +33,7 @@ class RepeatedExprsCase(BenchBase):
         print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg)
 
     def run_lldb_repeated_exprs(self, exe_name, count):
+        import pexpect
         exe = os.path.join(os.getcwd(), exe_name)
 
         # Set self.child_prompt, which is "(lldb) ".
@@ -79,6 +79,7 @@ class RepeatedExprsCase(BenchBase):
         self.child = None
 
     def run_gdb_repeated_exprs(self, exe_name, count):
+        import pexpect
         exe = os.path.join(os.getcwd(), exe_name)
 
         # Set self.child_prompt, which is "(gdb) ".
index e3acedd..e352108 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class FrameVariableResponseBench(BenchBase):
@@ -33,6 +32,7 @@ class FrameVariableResponseBench(BenchBase):
         print "lldb frame variable benchmark:", self.stopwatch
 
     def run_frame_variable_bench(self, exe, break_spec, count):
+        import pexpect
         # Set self.child_prompt, which is "(lldb) ".
         self.child_prompt = '(lldb) '
         prompt = self.child_prompt
index b9bf90b..f0b9aef 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class StartupDelaysBench(BenchBase):
@@ -40,6 +39,7 @@ class StartupDelaysBench(BenchBase):
         print "lldb startup delay (run to breakpoint) benchmark:", self.stopwatch3
 
     def run_startup_delays_bench(self, exe, break_spec, count):
+        import pexpect
         # Set self.child_prompt, which is "(lldb) ".
         self.child_prompt = '(lldb) '
         prompt = self.child_prompt
index da3ff22..d51da2e 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class RunHooksThenSteppingsBench(BenchBase):
@@ -24,6 +23,7 @@ class RunHooksThenSteppingsBench(BenchBase):
         print "lldb stepping benchmark:", self.stopwatch
 
     def run_lldb_runhooks_then_steppings(self, count):
+        import pexpect
         # Set self.child_prompt, which is "(lldb) ".
         self.child_prompt = '(lldb) '
         prompt = self.child_prompt
index a62491c..974ec20 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class SteppingSpeedBench(BenchBase):
@@ -36,6 +35,7 @@ class SteppingSpeedBench(BenchBase):
         print "lldb stepping benchmark:", self.stopwatch
 
     def run_lldb_steppings(self, exe, break_spec, count):
+        import pexpect
         # Set self.child_prompt, which is "(lldb) ".
         self.child_prompt = '(lldb) '
         prompt = self.child_prompt
index d9d3f42..6644d99 100644 (file)
@@ -3,7 +3,6 @@
 import os, sys
 import unittest2
 import lldb
-import pexpect
 from lldbbench import *
 
 class CompileRunToBreakpointBench(BenchBase):
@@ -33,6 +32,7 @@ class CompileRunToBreakpointBench(BenchBase):
         print "lldb_avg/gdb_avg: %f" % (self.lldb_avg/self.gdb_avg)
 
     def run_lldb_turnaround(self, exe, function, count):
+        import pexpect
         def run_one_round():
             prompt = self.child_prompt
 
@@ -73,6 +73,7 @@ class CompileRunToBreakpointBench(BenchBase):
         self.child = None
 
     def run_gdb_turnaround(self, exe, function, count):
+        import pexpect
         def run_one_round():
             prompt = self.child_prompt
 
index e92dd2d..fa4cde6 100755 (executable)
@@ -1185,10 +1185,7 @@ def lldbLoggings():
             raise Exception('log enable failed (check GDB_REMOTE_LOG env variable)')
 
 def getMyCommandLine():
-    ps = subprocess.Popen([which('ps'), '-o', "command=CMD", str(os.getpid())], stdout=subprocess.PIPE).communicate()[0]
-    lines = ps.split('\n')
-    cmd_line = lines[1]
-    return cmd_line
+    return ' '.join(sys.argv)
 
 # ======================================== #
 #                                          #
index ac88e33..0644f4b 100644 (file)
@@ -5,7 +5,6 @@ Test the command history mechanism
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class CommandHistoryTestCase(TestBase):
index 5e9950f..c0bfb38 100644 (file)
@@ -5,7 +5,6 @@ Test lldb 'commands regex' command which allows the user to create a regular exp
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class CommandRegexTestCase(TestBase):
@@ -14,6 +13,7 @@ class CommandRegexTestCase(TestBase):
 
     def test_command_regex(self):
         """Test a simple scenario of 'command regex' invocation and subsequent use."""
+        import pexpect
         prompt = "(lldb) "
         regex_prompt = "Enter one of more sed substitution commands in the form: 's/<regex>/<subst>/'.\r\nTerminate the substitution list with an empty line.\r\n"
         regex_prompt1 = "\r\n"
index 7d99448..32357b9 100644 (file)
@@ -5,7 +5,6 @@ Test the lldb command line completion mechanism.
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class CommandLineCompletionTestCase(TestBase):
@@ -153,6 +152,7 @@ class CommandLineCompletionTestCase(TestBase):
     def complete_from_to(self, str_input, patterns, turn_off_re_match=False):
         """Test that the completion mechanism completes str_input to patterns,
         where patterns could be a pattern-string or a list of pattern-strings"""
+        import pexpect
         # Patterns should not be None in order to proceed.
         self.assertFalse(patterns is None)
         # And should be either a string or list of strings.  Check for list type
index a86e129..7b838b6 100644 (file)
@@ -5,7 +5,6 @@ Test lldb 'process connect' command.
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class ConnectRemoteTestCase(TestBase):
@@ -15,6 +14,7 @@ class ConnectRemoteTestCase(TestBase):
     def test_connect_remote(self):
         """Test "process connect connect:://localhost:12345"."""
 
+        import pexpect
         # First, we'll start a fake debugserver (a simple echo server).
         fakeserver = pexpect.spawn('./EchoServer.py')
 
index 6892610..2637a9b 100644 (file)
@@ -3,7 +3,6 @@
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class ConvenienceVariablesCase(TestBase):
@@ -33,6 +32,7 @@ class ConvenienceVariablesCase(TestBase):
 
     def convenience_variables(self):
         """Test convenience variables lldb.debugger, lldb.target, lldb.process, lldb.thread, and lldb.frame."""
+        import pexpect
         exe = os.path.join(os.getcwd(), "a.out")
         prompt = "(lldb) "
         python_prompt = ">>> "
index ba696ad..ccd6cbc 100644 (file)
@@ -5,7 +5,6 @@ Test the lldb command line takes a filename with single quote chars.
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class SingleQuoteInCommandLineTestCase(TestBase):
@@ -25,6 +24,7 @@ class SingleQuoteInCommandLineTestCase(TestBase):
 
     def test_lldb_invocation_with_single_quote_in_filename(self):
         """Test that 'lldb my_file_name' works where my_file_name is a string with a single quote char in it."""
+        import pexpect
         self.buildDefault()
         system(["/bin/sh", "-c", "cp a.out \"%s\"" % self.myexe])
 
index 75833ac..5e71e90 100644 (file)
@@ -5,7 +5,6 @@ Test lldb target stop-hook mechanism to see whether it fires off correctly .
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class StopHookMechanismTestCase(TestBase):
@@ -38,6 +37,7 @@ class StopHookMechanismTestCase(TestBase):
 
     def stop_hook_firing(self):
         """Test the stop-hook mechanism."""
+        import pexpect
         exe = os.path.join(os.getcwd(), "a.out")
         prompt = "(lldb) "
         add_prompt = "Enter your stop hook command(s).  Type 'DONE' to end.\r\n> "
index 7fd553a..0627b02 100644 (file)
@@ -5,7 +5,6 @@ Test that lldb stop-hook works for multiple threads.
 import os, time
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class StopHookForMultipleThreadsTestCase(TestBase):
@@ -42,6 +41,7 @@ class StopHookForMultipleThreadsTestCase(TestBase):
 
     def stop_hook_multiple_threads(self):
         """Test that lldb stop-hook works for multiple threads."""
+        import pexpect
         exe = os.path.join(os.getcwd(), self.exe_name)
         prompt = "(lldb) "
 
index 1fc8e59..22108f5 100644 (file)
@@ -3,7 +3,6 @@
 import os, time
 import unittest2
 import lldb
-import pexpect
 import sys
 from lldbtest import *
 
diff --git a/lldb/test/plugins/builder_win32.py b/lldb/test/plugins/builder_win32.py
new file mode 100644 (file)
index 0000000..e56be42
--- /dev/null
@@ -0,0 +1,4 @@
+from builder_base import *
+
+def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None, clean=True):
+    return False
index b23c497..2eeb34f 100644 (file)
@@ -3,7 +3,6 @@
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class CommandInterpreterAPICase(TestBase):
index 046339b..ca2c7ec 100644 (file)
@@ -3,7 +3,6 @@
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 from math import fabs
 import lldbutil
index f89dda4..14054c1 100644 (file)
@@ -165,7 +165,7 @@ class SettingsCommandTestCase(TestBase):
         self.expect("settings show auto-confirm", SETTING_MSG("auto-confirm"),
             startstr = "auto-confirm (boolean) = false")
 
-    @unittest2.skipUnless(os.uname()[4] in ['amd64', 'i386', 'x86_64'], "requires x86 or x86_64")
+    @unittest2.skipUnless(os.name != "nt" and os.uname()[4] in ['amd64', 'i386', 'x86_64'], "requires x86 or x86_64")
     def test_disassembler_settings(self):
         """Test that user options for the disassembler take effect."""
         self.buildDefault()
index 26e3def..927b790 100644 (file)
@@ -5,7 +5,6 @@ Test that 'stty -a' displays the same output before and after running the lldb c
 import os
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 class CommandLineCompletionTestCase(TestBase):
@@ -22,7 +21,7 @@ class CommandLineCompletionTestCase(TestBase):
 
     def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
         """Test that 'stty -a' displays the same output before and after running the lldb command."""
-
+        import pexpect
         if not which('expect'):
             self.skipTest("The 'expect' program cannot be located, skip the test")
 
index b0e9512..a079358 100644 (file)
@@ -5,7 +5,6 @@ Base class for gdb-remote test cases.
 import errno
 import os
 import os.path
-import pexpect
 import platform
 import random
 import re
@@ -180,6 +179,7 @@ class GdbRemoteTestCaseBase(TestBase):
 
     def launch_debug_monitor(self, attach_pid=None):
         # Create the command line.
+        import pexpect
         commandline = "{}{} localhost:{}".format(self.debug_monitor_exe, self.debug_monitor_extra_args, self.port)
         if attach_pid:
             commandline += " --attach=%d" % attach_pid
index aa9048d..f6c1565 100644 (file)
@@ -3,7 +3,6 @@
 import os, time
 import unittest2
 import lldb
-import pexpect
 from lldbtest import *
 
 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")