diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls')
3 files changed, 111 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/Makefile new file mode 100644 index 00000000000..314f1cb2f07 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/Makefile @@ -0,0 +1,5 @@ +LEVEL = ../../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py new file mode 100644 index 00000000000..fa9338ab51b --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/TestCppChainedCalls.py @@ -0,0 +1,73 @@ +import lldb +from lldbtest import * +import lldbutil + +class TestCppChainedCalls(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureWindows("llvm.org/pr21765") + def test_with_run_command(self): + self.build() + + # Get main source file + src_file = "main.cpp" + src_file_spec = lldb.SBFileSpec(src_file) + self.assertTrue(src_file_spec.IsValid(), "Main source file") + + # Get the path of the executable + cwd = os.getcwd() + exe_file = "a.out" + exe_path = os.path.join(cwd, exe_file) + + # Load the executable + target = self.dbg.CreateTarget(exe_path) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Break on main function + main_breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec) + self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT) + + # Launch the process + args = None + env = None + process = target.LaunchSimple(args, env, self.get_process_working_directory()) + self.assertTrue(process.IsValid(), PROCESS_IS_VALID) + + # Get the thread of the process + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + + # Get frame for current thread + frame = thread.GetSelectedFrame() + + # Test chained calls + test_result = frame.EvaluateExpression("get(set(true))") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "get(set(true)) = true") + + test_result = frame.EvaluateExpression("get(set(false))") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(set(false)) = false") + + test_result = frame.EvaluateExpression("get(t & f)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(t & f) = false") + + test_result = frame.EvaluateExpression("get(f & t)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(f & t) = false") + + test_result = frame.EvaluateExpression("get(t & t)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "get(t & t) = true") + + test_result = frame.EvaluateExpression("get(f & f)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(f & f) = false") + + test_result = frame.EvaluateExpression("get(t & f)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(t & f) = false") + + test_result = frame.EvaluateExpression("get(f) && get(t)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(f) && get(t) = false") + + test_result = frame.EvaluateExpression("get(f) && get(f)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "false", "get(f) && get(t) = false") + + test_result = frame.EvaluateExpression("get(t) && get(t)") + self.assertTrue(test_result.IsValid() and test_result.GetValue() == "true", "get(t) && get(t) = true") diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/main.cpp new file mode 100644 index 00000000000..a888c3f6c55 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/chained-calls/main.cpp @@ -0,0 +1,33 @@ +class Bool { +public: + Bool operator&(const Bool other) + { + Bool result; + result.value = value && other.value; + return result; + } + + bool value; +}; + +bool get(Bool object) +{ + return object.value; +} + +Bool set(bool value) +{ + Bool result; + result.value = value; + return result; +} + +int main() +{ + Bool t = set(true); + Bool f = set(false); + get(t); + get(f); + get(t & f); + return 0; // break here +} |