summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/nested_alias
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:50:09 +0000
commitf3fbd1c0586ff6ec7895991e6c28f61a503c36a8 (patch)
tree48d008fd3df8c0e73271a4b18474e0aac6dbfe33 /packages/Python/lldbsuite/test/functionalities/nested_alias
parent2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/nested_alias')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py68
-rw-r--r--packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp22
3 files changed, 95 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile b/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile
new file mode 100644
index 0000000000000..8a7102e347af2
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py
new file mode 100644
index 0000000000000..6a74ddb727dff
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/TestNestedAlias.py
@@ -0,0 +1,68 @@
+"""
+Test that an alias can reference other aliases without crashing.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import re
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class NestedAliasTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.cpp', '// break here')
+
+ def test_nested_alias(self):
+ """Test that an alias can reference other aliases without crashing."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break in main() aftre the variables are assigned values.
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped', 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ # This is the function to remove the custom aliases in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('command unalias read', check=False)
+ self.runCmd('command unalias rd', check=False)
+ self.runCmd('command unalias fo', check=False)
+ self.runCmd('command unalias foself', check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd('command alias read memory read -f A')
+ self.runCmd('command alias rd read -c 3')
+
+ self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef'])
+ self.expect('rd `&my_ptr[0]`', substrs=['deadbeef', 'main.cpp:', 'feedbeef'])
+
+ self.expect('memory read -f A -c 3 `&my_ptr[0]`', substrs=['deadfeed'], matching=False)
+ self.expect('rd `&my_ptr[0]`', substrs=['deadfeed'], matching=False)
+
+ self.runCmd('command alias fo frame variable -O --')
+ self.runCmd('command alias foself fo self')
+
+ self.expect('help foself', substrs=['--show-all-children', '--raw-output'], matching=False)
+ self.expect('help foself', substrs=['Show variables for the current', 'stack frame.'], matching=True)
diff --git a/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp
new file mode 100644
index 0000000000000..4424cf30c3a46
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/nested_alias/main.cpp
@@ -0,0 +1,22 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+
+int main (int argc, char const *argv[])
+{
+ void* my_ptr[] = {
+ reinterpret_cast<void*>(0xDEADBEEF),
+ reinterpret_cast<void*>(main),
+ reinterpret_cast<void*>(0xFEEDBEEF),
+ reinterpret_cast<void*>(0xFEEDDEAD),
+ reinterpret_cast<void*>(0xDEADFEED)
+ };
+ return 0; // break here
+}
+