diff options
| author | Zachary Turner <zturner@google.com> | 2014-07-18 01:02:02 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2014-07-18 01:02:02 +0000 |
| commit | 045fde58d13132959711d3a0c27a6bfa0bf9564d (patch) | |
| tree | 5df2bf781ad07f66d1e7e07fb6678e2394d29021 | |
| parent | b6535c32f549a2a981578c29a93995213c798b1e (diff) | |
| download | bcm5719-llvm-045fde58d13132959711d3a0c27a6bfa0bf9564d.tar.gz bcm5719-llvm-045fde58d13132959711d3a0c27a6bfa0bf9564d.zip | |
Fixes a number of issue related to test portability on Windows.
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, 27 insertions, 30 deletions
diff --git a/lldb/test/benchmarks/disassembly/TestDisassembly.py b/lldb/test/benchmarks/disassembly/TestDisassembly.py index a2a54bd7a25..fb5b49f7ddb 100644 --- a/lldb/test/benchmarks/disassembly/TestDisassembly.py +++ b/lldb/test/benchmarks/disassembly/TestDisassembly.py @@ -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 diff --git a/lldb/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py b/lldb/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py index b31c244d57b..39eb3d427ec 100644 --- a/lldb/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py +++ b/lldb/test/benchmarks/disassembly/TestDoAttachThenDisassembly.py @@ -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): diff --git a/lldb/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py b/lldb/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py index 6c6dd9886b8..977993a18e4 100644 --- a/lldb/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py +++ b/lldb/test/benchmarks/disassembly/TestXcode41Vs42GDBDisassembly.py @@ -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 diff --git a/lldb/test/benchmarks/expression/TestExpressionCmd.py b/lldb/test/benchmarks/expression/TestExpressionCmd.py index 5f7100442d4..3bce16cdcd4 100644 --- a/lldb/test/benchmarks/expression/TestExpressionCmd.py +++ b/lldb/test/benchmarks/expression/TestExpressionCmd.py @@ -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) ". diff --git a/lldb/test/benchmarks/expression/TestRepeatedExprs.py b/lldb/test/benchmarks/expression/TestRepeatedExprs.py index 1e7338fd8a2..68383c74f6b 100644 --- a/lldb/test/benchmarks/expression/TestRepeatedExprs.py +++ b/lldb/test/benchmarks/expression/TestRepeatedExprs.py @@ -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) ". diff --git a/lldb/test/benchmarks/frame_variable/TestFrameVariableResponse.py b/lldb/test/benchmarks/frame_variable/TestFrameVariableResponse.py index e3acedd33e8..e3521089068 100644 --- a/lldb/test/benchmarks/frame_variable/TestFrameVariableResponse.py +++ b/lldb/test/benchmarks/frame_variable/TestFrameVariableResponse.py @@ -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 diff --git a/lldb/test/benchmarks/startup/TestStartupDelays.py b/lldb/test/benchmarks/startup/TestStartupDelays.py index b9bf90b1dfb..f0b9aeffa16 100644 --- a/lldb/test/benchmarks/startup/TestStartupDelays.py +++ b/lldb/test/benchmarks/startup/TestStartupDelays.py @@ -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 diff --git a/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py b/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py index da3ff22e104..d51da2e9558 100644 --- a/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py +++ b/lldb/test/benchmarks/stepping/TestRunHooksThenSteppings.py @@ -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 diff --git a/lldb/test/benchmarks/stepping/TestSteppingSpeed.py b/lldb/test/benchmarks/stepping/TestSteppingSpeed.py index a62491c4963..974ec20d04c 100644 --- a/lldb/test/benchmarks/stepping/TestSteppingSpeed.py +++ b/lldb/test/benchmarks/stepping/TestSteppingSpeed.py @@ -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 diff --git a/lldb/test/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py b/lldb/test/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py index d9d3f423ae8..6644d993a3c 100644 --- a/lldb/test/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py +++ b/lldb/test/benchmarks/turnaround/TestCompileRunToBreakpointTurnaround.py @@ -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 diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py index e92dd2dcc4f..fa4cde6d72c 100755 --- a/lldb/test/dotest.py +++ b/lldb/test/dotest.py @@ -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) # ======================================== # # # diff --git a/lldb/test/functionalities/command_history/TestCommandHistory.py b/lldb/test/functionalities/command_history/TestCommandHistory.py index ac88e330e0f..0644f4b643a 100644 --- a/lldb/test/functionalities/command_history/TestCommandHistory.py +++ b/lldb/test/functionalities/command_history/TestCommandHistory.py @@ -5,7 +5,6 @@ Test the command history mechanism import os import unittest2 import lldb -import pexpect from lldbtest import * class CommandHistoryTestCase(TestBase): diff --git a/lldb/test/functionalities/command_regex/TestCommandRegex.py b/lldb/test/functionalities/command_regex/TestCommandRegex.py index 5e9950f98a9..c0bfb38a906 100644 --- a/lldb/test/functionalities/command_regex/TestCommandRegex.py +++ b/lldb/test/functionalities/command_regex/TestCommandRegex.py @@ -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" diff --git a/lldb/test/functionalities/completion/TestCompletion.py b/lldb/test/functionalities/completion/TestCompletion.py index 7d99448a9df..32357b93dd9 100644 --- a/lldb/test/functionalities/completion/TestCompletion.py +++ b/lldb/test/functionalities/completion/TestCompletion.py @@ -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 diff --git a/lldb/test/functionalities/connect_remote/TestConnectRemote.py b/lldb/test/functionalities/connect_remote/TestConnectRemote.py index a86e129c6ea..7b838b6f495 100644 --- a/lldb/test/functionalities/connect_remote/TestConnectRemote.py +++ b/lldb/test/functionalities/connect_remote/TestConnectRemote.py @@ -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') diff --git a/lldb/test/functionalities/embedded_interpreter/TestConvenienceVariables.py b/lldb/test/functionalities/embedded_interpreter/TestConvenienceVariables.py index 6892610eb0f..2637a9bceb4 100644 --- a/lldb/test/functionalities/embedded_interpreter/TestConvenienceVariables.py +++ b/lldb/test/functionalities/embedded_interpreter/TestConvenienceVariables.py @@ -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 = ">>> " diff --git a/lldb/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py b/lldb/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py index ba696ad9c31..ccd6cbcb35a 100644 --- a/lldb/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py +++ b/lldb/test/functionalities/single-quote-in-filename-to-lldb/TestSingleQuoteInFilename.py @@ -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]) diff --git a/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py b/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py index 75833acc412..5e71e9021e2 100644 --- a/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py +++ b/lldb/test/functionalities/stop-hook/TestStopHookMechanism.py @@ -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> " diff --git a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py b/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py index 7fd553aa3ef..0627b020229 100644 --- a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py +++ b/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py @@ -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) " diff --git a/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py b/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py index 1fc8e597f7c..22108f51fca 100644 --- a/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py +++ b/lldb/test/macosx/add-dsym/TestAddDsymMidExecutionCommand.py @@ -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 index 00000000000..e56be429823 --- /dev/null +++ b/lldb/test/plugins/builder_win32.py @@ -0,0 +1,4 @@ +from builder_base import * + +def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None, clean=True): + return False diff --git a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py index b23c4974d35..2eeb34f5ced 100644 --- a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -3,7 +3,6 @@ import os import unittest2 import lldb -import pexpect from lldbtest import * class CommandInterpreterAPICase(TestBase): diff --git a/lldb/test/python_api/sbdata/TestSBData.py b/lldb/test/python_api/sbdata/TestSBData.py index 046339ba09b..ca2c7eca50e 100644 --- a/lldb/test/python_api/sbdata/TestSBData.py +++ b/lldb/test/python_api/sbdata/TestSBData.py @@ -3,7 +3,6 @@ import os import unittest2 import lldb -import pexpect from lldbtest import * from math import fabs import lldbutil diff --git a/lldb/test/settings/TestSettings.py b/lldb/test/settings/TestSettings.py index f89dda4cb74..14054c17ddf 100644 --- a/lldb/test/settings/TestSettings.py +++ b/lldb/test/settings/TestSettings.py @@ -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() diff --git a/lldb/test/terminal/TestSTTYBeforeAndAfter.py b/lldb/test/terminal/TestSTTYBeforeAndAfter.py index 26e3defaf72..927b7905269 100644 --- a/lldb/test/terminal/TestSTTYBeforeAndAfter.py +++ b/lldb/test/terminal/TestSTTYBeforeAndAfter.py @@ -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") diff --git a/lldb/test/tools/lldb-gdbserver/gdbremote_testcase.py b/lldb/test/tools/lldb-gdbserver/gdbremote_testcase.py index b0e95121822..a079358579d 100644 --- a/lldb/test/tools/lldb-gdbserver/gdbremote_testcase.py +++ b/lldb/test/tools/lldb-gdbserver/gdbremote_testcase.py @@ -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 diff --git a/lldb/test/warnings/uuid/TestAddDsymCommand.py b/lldb/test/warnings/uuid/TestAddDsymCommand.py index aa9048d79dc..f6c1565285e 100644 --- a/lldb/test/warnings/uuid/TestAddDsymCommand.py +++ b/lldb/test/warnings/uuid/TestAddDsymCommand.py @@ -3,7 +3,6 @@ import os, time import unittest2 import lldb -import pexpect from lldbtest import * @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |

