[Lldb-commits] [lldb] r149421 - in /lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map: Makefile TestDataFormatterStdMap.py main.cpp
Enrico Granata
granata.enrico at gmail.com
Tue Jan 31 13:30:00 PST 2012
Author: enrico
Date: Tue Jan 31 15:30:00 2012
New Revision: 149421
URL: http://llvm.org/viewvc/llvm-project?rev=149421&view=rev
Log:
Test case for std::map synthetic children provider (currently an expected failure)
Added:
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/Makefile
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/TestDataFormatterStdMap.py
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/main.cpp
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/Makefile?rev=149421&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/Makefile Tue Jan 31 15:30:00 2012
@@ -0,0 +1,5 @@
+LEVEL = ../../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/TestDataFormatterStdMap.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/TestDataFormatterStdMap.py?rev=149421&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/TestDataFormatterStdMap.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/TestDataFormatterStdMap.py Tue Jan 31 15:30:00 2012
@@ -0,0 +1,317 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class StdMapDataFormatterTestCase(TestBase):
+
+ mydir = os.path.join("functionalities", "data-formatter", "data-formatter-stl", "map")
+
+ #rdar://problem/10334911
+ #@unittest2.expectedFailure
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDsym()
+ self.data_formatter_commands()
+
+ #rdar://problem/10334911
+ #@unittest2.expectedFailure
+ def test_with_dwarf_and_run_command(self):
+ """Test data formatter commands."""
+ self.buildDwarf()
+ self.data_formatter_commands()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break at.
+ self.line = line_number('main.cpp', '// Set break point at this line.')
+
+ def data_formatter_commands(self):
+ """Test that that file and class static variables display correctly."""
+ self.runCmd("file a.out", 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" %
+ 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 = ['stopped',
+ 'stop reason = breakpoint'])
+
+ # This is the function to remove the custom formats in order to have a
+ # clean slate for the next test case.
+ def cleanup():
+ self.runCmd('type format clear', check=False)
+ self.runCmd('type summary clear', check=False)
+ self.runCmd('type filter clear', check=False)
+ self.runCmd('type synth clear', check=False)
+ self.runCmd("settings set target.max-children-count 256", check=False)
+
+ # Execute the cleanup function during test case tear down.
+ self.addTearDownHook(cleanup)
+
+ self.runCmd("frame variable ii -T")
+
+ self.runCmd("type summary add -x \"std::map<\" --summary-string \"map has ${svar%#} items\" -e")
+
+ self.expect('frame variable ii',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n");self.runCmd("n");
+
+ self.expect('frame variable ii',
+ substrs = ['map has 2 items',
+ '[0] = {',
+ 'first = 0',
+ 'second = 0',
+ '[1] = {',
+ 'first = 1',
+ 'second = 1'])
+
+ self.runCmd("n");self.runCmd("n");
+
+ self.expect('frame variable ii',
+ substrs = ['map has 4 items',
+ '[2] = {',
+ 'first = 2',
+ 'second = 0',
+ '[3] = {',
+ 'first = 3',
+ 'second = 1'])
+
+ self.runCmd("n");self.runCmd("n");
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable ii",
+ substrs = ['map has 9 items',
+ '[5] = {',
+ 'first = 5',
+ 'second = 0',
+ '[7] = {',
+ 'first = 7',
+ 'second = 1'])
+
+ self.expect("p ii",
+ substrs = ['map has 9 items',
+ '[5] = {',
+ 'first = 5',
+ 'second = 0',
+ '[7] = {',
+ 'first = 7',
+ 'second = 1'])
+
+ # check access-by-index
+ self.expect("frame variable ii[0]",
+ substrs = ['first = 0',
+ 'second = 0']);
+ self.expect("frame variable ii[3]",
+ substrs = ['first =',
+ 'second =']);
+
+ # but check that expression does not rely on us
+ self.expect("expression ii[0]", matching=False, error=True,
+ substrs = ['first = 0'])
+
+ self.runCmd("n")
+
+ self.expect('frame variable ii',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n")
+ self.runCmd("frame variable si -T")
+
+ #self.runCmd("type summary add std::strint_map strint_map --summary-string \"map has ${svar%#} items\" -e")
+ #self.runCmd("type synth add std::strint_map strint_map -l StdMapSynthProvider")
+
+ self.expect('frame variable si',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n")
+
+ self.expect('frame variable si',
+ substrs = ['map has 1 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable si",
+ substrs = ['map has 5 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3',
+ '[4] = ',
+ 'first = \"four\"',
+ 'second = 4'])
+
+ self.expect("p si",
+ substrs = ['map has 5 items',
+ '[0] = ',
+ 'first = \"zero\"',
+ 'second = 0',
+ '[1] = ',
+ 'first = \"one\"',
+ 'second = 1',
+ '[2] = ',
+ 'first = \"two\"',
+ 'second = 2',
+ '[3] = ',
+ 'first = \"three\"',
+ 'second = 3',
+ '[4] = ',
+ 'first = \"four\"',
+ 'second = 4'])
+
+ # check access-by-index
+ self.expect("frame variable si[0]",
+ substrs = ['first = ', 'four',
+ 'second = 4']);
+
+ # but check that expression does not rely on us
+ self.expect("expression si[0]", matching=False, error=True,
+ substrs = ['first = ', 'zero'])
+
+ self.runCmd("n")
+
+ self.expect('frame variable si',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n")
+ self.runCmd("frame variable is -T")
+
+ #self.runCmd("type summary add std::intstr_map intstr_map --summary-string \"map has ${svar%#} items\" -e")
+ #self.runCmd("type synth add std::intstr_map intstr_map -l StdMapSynthProvider")
+
+ self.expect('frame variable is',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable is",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 0',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ self.expect("p is",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"goofy\"',
+ 'first = 0',
+ '[1] = ',
+ 'second = \"is\"',
+ 'first = 1',
+ '[2] = ',
+ 'second = \"smart\"',
+ 'first = 2',
+ '[3] = ',
+ 'second = \"!!!\"',
+ 'first = 3'])
+
+ # check access-by-index
+ self.expect("frame variable is[0]",
+ substrs = ['first = ', '0',
+ 'second =', 'goofy']);
+
+ # but check that expression does not rely on us
+ self.expect("expression is[0]", matching=False, error=True,
+ substrs = ['first = ', 'goofy'])
+
+ self.runCmd("n")
+
+ self.expect('frame variable is',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n")
+ self.runCmd("frame variable ss -T")
+
+ self.expect('frame variable ss',
+ substrs = ['map has 0 items',
+ '{}'])
+
+ self.runCmd("n");self.runCmd("n");self.runCmd("n");self.runCmd("n");
+
+ self.expect("frame variable ss",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"',
+ '[3] = ',
+ 'second = \"..is always a Mac!\"',
+ 'first = \"a Mac..\"'])
+
+ self.expect("p ss",
+ substrs = ['map has 4 items',
+ '[0] = ',
+ 'second = \"hello\"',
+ 'first = \"ciao\"',
+ '[1] = ',
+ 'second = \"house\"',
+ 'first = \"casa\"',
+ '[2] = ',
+ 'second = \"cat\"',
+ 'first = \"gatto\"',
+ '[3] = ',
+ 'second = \"..is always a Mac!\"',
+ 'first = \"a Mac..\"'])
+
+ # check access-by-index
+ self.expect("frame variable ss[3]",
+ substrs = ['gatto', 'cat']);
+
+ # but check that expression does not rely on us
+ self.expect("expression ss[3]", matching=False, error=True,
+ substrs = ['gatto'])
+
+ self.runCmd("n")
+
+ self.expect('frame variable ss',
+ substrs = ['map has 0 items',
+ '{}'])
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
Added: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/main.cpp?rev=149421&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/map/main.cpp Tue Jan 31 15:30:00 2012
@@ -0,0 +1,55 @@
+#include <map>
+#include <string>
+
+#define intint_map std::map<int, int>
+#define strint_map std::map<std::string, int>
+#define intstr_map std::map<int, std::string>
+#define strstr_map std::map<std::string, std::string>
+
+
+int main()
+{
+ intint_map ii;
+
+ ii[0] = 0; // Set break point at this line.
+ ii[1] = 1;
+ ii[2] = 0;
+ ii[3] = 1;
+ ii[4] = 0;
+ ii[5] = 1;
+ ii[6] = 0;
+ ii[7] = 1;
+ ii[8] = 0;
+
+ ii.clear();
+
+ strint_map si;
+
+ si["zero"] = 0;
+ si["one"] = 1;
+ si["two"] = 2;
+ si["three"] = 3;
+ si["four"] = 4;
+
+ si.clear();
+
+ intstr_map is;
+
+ is[0] = "goofy";
+ is[1] = "is";
+ is[2] = "smart";
+ is[3] = "!!!";
+
+ is.clear();
+
+ strstr_map ss;
+
+ ss["ciao"] = "hello";
+ ss["casa"] = "house";
+ ss["gatto"] = "cat";
+ ss["a Mac.."] = "..is always a Mac!";
+
+ ss.clear();
+
+ return 0;
+}
\ No newline at end of file
More information about the lldb-commits
mailing list