summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/test/unique-types/TestUniqueTypes.py73
-rw-r--r--lldb/test/unique-types/main.cpp10
2 files changed, 82 insertions, 1 deletions
diff --git a/lldb/test/unique-types/TestUniqueTypes.py b/lldb/test/unique-types/TestUniqueTypes.py
new file mode 100644
index 00000000000..a86846a6ebf
--- /dev/null
+++ b/lldb/test/unique-types/TestUniqueTypes.py
@@ -0,0 +1,73 @@
+"""
+Test that template instaniations of std::vector<long> and <short> in the same module have the correct types.
+"""
+
+import unittest2
+import lldb
+from lldbtest import *
+
+class UniqueTypesTestCase(TestBase):
+
+ mydir = "unique-types"
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym(self):
+ """Test for unique types of std::vector<long> and std::vector<short>."""
+ self.buildDsym()
+ self.unique_types()
+
+ def test_with_dwarf(self):
+ """Test for unique types of std::vector<long> and std::vector<short>."""
+ self.buildDwarf()
+ self.unique_types()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number inside main.cpp.
+ self.line = line_number("main.cpp",
+ "// Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.")
+
+ def unique_types(self):
+ """Test for unique types of std::vector<long> and std::vector<short>."""
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ self.expect("breakpoint set -f main.cpp -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['state is stopped',
+ 'stop reason = breakpoint'])
+
+ # Do a "frame variable -t longs" and verify "long" is in each line of output.
+ self.runCmd("frame variable -t longs")
+ output = self.res.GetOutput()
+ for x in [line.strip() for line in output.split(os.linesep)]:
+ # Skip empty line or closing brace.
+ if not x or x == '}':
+ continue
+ self.expect(x, "Expect type 'long'", exe=False,
+ substrs = ['long'])
+
+ # Do a "frame variable -t shorts" and verify "short" is in each line of output.
+ self.runCmd("frame variable -t shorts")
+ output = self.res.GetOutput()
+ for x in [line.strip() for line in output.split(os.linesep)]:
+ # Skip empty line or closing brace.
+ if not x or x == '}':
+ continue
+ self.expect(x, "Expect type 'short'", exe=False,
+ substrs = ['short'])
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
diff --git a/lldb/test/unique-types/main.cpp b/lldb/test/unique-types/main.cpp
index 51ff3ad1f7b..c551c0e2c0d 100644
--- a/lldb/test/unique-types/main.cpp
+++ b/lldb/test/unique-types/main.cpp
@@ -1,3 +1,11 @@
+//===-- main.c --------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
#include <vector>
#include <stdio.h>
@@ -12,5 +20,5 @@ int main (int argc, char const *argv[], char const *envp[])
longs.push_back(i);
shorts.push_back(i);
}
- return 0;
+ return 0; // Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.
}
OpenPOWER on IntegriCloud