[Lldb-commits] [lldb] r121814 - in /lldb/trunk/test/abbreviation_tests: ./ Makefile TestAbbreviations.py change_prompt.lldb main.cpp

Caroline Tice ctice at apple.com
Tue Dec 14 15:50:59 PST 2010


Author: ctice
Date: Tue Dec 14 17:50:59 2010
New Revision: 121814

URL: http://llvm.org/viewvc/llvm-project?rev=121814&view=rev
Log:
Add test cases to make sure the Command Interpreter is handling
command completion properly (e.g. abbreviated commands, which are
NOT the same as aliases).


Added:
    lldb/trunk/test/abbreviation_tests/
    lldb/trunk/test/abbreviation_tests/Makefile
    lldb/trunk/test/abbreviation_tests/TestAbbreviations.py
    lldb/trunk/test/abbreviation_tests/change_prompt.lldb
    lldb/trunk/test/abbreviation_tests/main.cpp

Added: lldb/trunk/test/abbreviation_tests/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/Makefile?rev=121814&view=auto
==============================================================================
--- lldb/trunk/test/abbreviation_tests/Makefile (added)
+++ lldb/trunk/test/abbreviation_tests/Makefile Tue Dec 14 17:50:59 2010
@@ -0,0 +1,5 @@
+LEVEL = ../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules

Added: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=121814&view=auto
==============================================================================
--- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (added)
+++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Tue Dec 14 17:50:59 2010
@@ -0,0 +1,157 @@
+"""
+Test some lldb command abbreviations.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class AbbreviationsTestCase(TestBase):
+    
+    mydir = "abbreviation_tests"
+
+    def test_nonrunning_command_abbreviations (self):
+        self.expect("ap script",
+                    startstr = "The following commands may relate to 'script':",
+                    substrs = ['breakpoint command add',
+                               'breakpoint command list',
+                               'breakpoint list',
+                               'commands alias',
+                               'expression',
+                               'script'])
+
+        self.runCmd("com a alias com al")
+        self.runCmd("alias gurp help")
+        self.expect("gurp file",
+                    substrs = ['Syntax: file <cmd-options> <filename>'])
+        self.runCmd("com u gurp")
+        self.expect("gurp",
+                    COMMAND_FAILED_AS_EXPECTED, error = True,
+                    substrs = ["error: 'gurp' is not a valid command."])
+
+        self.expect("h",
+                    startstr = "The following is a list of built-in, permanent debugger commands:")
+
+
+        self.expect("com s ./change_prompt.lldb",
+                    patterns = ["Executing commands in '.*change_prompt.lldb'"])
+
+        self.expect("settings show prompt",
+                    startstr = "prompt (string) = '[old-oak]'")
+
+
+        self.runCmd("settings set -r prompt")
+        self.expect("settings show prompt",
+                    startstr = "prompt (string) = '(lldb) '")
+
+
+        self.expect("lo li",
+                    startstr = "Logging categories for 'lldb':")
+
+        self.runCmd("se se prompt Sycamore> ")
+        self.expect("se sh prompt",
+                    startstr = "prompt (string) = 'Sycamore>'")
+
+        self.runCmd("se se -r prompt")
+        self.expect("set sh prompt",
+                    startstr = "prompt (string) = '(lldb) '")
+
+        self.runCmd (r'''sc print "\n\n\tHello!\n"''')
+
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_with_dsym (self):
+        self.buildDsym ()
+        self.running_abbreviations ()
+
+    def test_with_dwarf (self):
+        self.buildDwarf ()
+        self.running_abbreviations ()
+
+    def running_abbreviations (self):
+        exe = os.path.join (os.getcwd(), "a.out")
+        self.expect("fil " + exe,
+                    patterns = [ "Current executable set to .*a.out.*(x86_64)" ])
+
+        self.expect("regex product",
+                    substrs = [ "breakpoint set --name 'product'",
+                                "Breakpoint created: 1: name = 'product', locations = 1" ])
+
+        self.expect("br s -n sum",
+                    startstr = "Breakpoint created: 2: name = 'sum', locations = 1")
+
+        self.expect("br s -f main.cpp -l 32",
+                    startstr = "Breakpoint created: 3: file ='main.cpp', line = 32, locations = 1")
+
+        self.runCmd("br co a -p 1 -o 'print frame'")
+        self.expect("br co l 1",
+                    substrs = [ "Breakpoint 1:",
+                                "Breakpoint commands:",
+                                "print frame" ])
+
+        self.runCmd("br co rem 1")
+        self.expect("breakpoint command list 1",
+                    startstr = "Breakpoint 1 does not have an associated command.")
+
+        self.expect("br di",
+                    startstr = 'All breakpoints disabled. (3 breakpoints)')
+
+        self.expect("bre e",
+                    startstr = "All breakpoints enabled. (3 breakpoints)")
+
+        self.expect("break list",
+                    substrs = ["1: name = 'product', locations = 1",
+                               "2: name = 'sum', locations = 1",
+                               "3: file ='main.cpp', line = 32, locations = 1"])
+        self.expect("br cl -l 32 -f main.cpp",
+                    startstr = "1 breakpoints cleared:",
+                    substrs = ["3: file ='main.cpp', line = 32, locations = 1"])
+
+        self.expect("pro la",
+                    patterns = [ "Process .* launched: "])
+
+        self.expect("pro st",
+                    patterns = [ "Process .* stopped",
+                                 "thread #1:",
+                                 "a.out",
+                                 "sum\(int, int\)",
+                                 "at main.cpp\:25", 
+                                 "stop reason = breakpoint 2.1" ])
+
+        self.expect("d -f",
+                    startstr = "a.out`sum(int, int):",
+                    substrs = [' pushq ',
+                               ' movq ',
+                               ' addl ',
+                               'leave',
+                               'ret'])
+
+        self.expect("i d l main.cpp",
+                    patterns = ["Line table for .*main.cpp in `a.out"])
+
+        self.expect("i d se",
+                    startstr = "Dumping sections for 5 modules.")
+
+        self.expect("i d symf",
+                    startstr = "Dumping debug symbols for 5 modules.")
+
+        self.expect("i d symt",
+                    startstr = "Dumping symbol table for 5 modules.")
+
+        self.expect("i li",
+                    substrs = [ 'a.out',
+                                '/usr/lib/dyld',
+                                '/usr/lib/libstdc++',
+                                '/usr/lib/libSystem.B.dylib',
+                                '/usr/lib/system/libmathCommon.A.dylib'])
+
+
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()
+

Added: lldb/trunk/test/abbreviation_tests/change_prompt.lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/change_prompt.lldb?rev=121814&view=auto
==============================================================================
--- lldb/trunk/test/abbreviation_tests/change_prompt.lldb (added)
+++ lldb/trunk/test/abbreviation_tests/change_prompt.lldb Tue Dec 14 17:50:59 2010
@@ -0,0 +1 @@
+settings set prompt [old-oak] 

Added: lldb/trunk/test/abbreviation_tests/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/main.cpp?rev=121814&view=auto
==============================================================================
--- lldb/trunk/test/abbreviation_tests/main.cpp (added)
+++ lldb/trunk/test/abbreviation_tests/main.cpp Tue Dec 14 17:50:59 2010
@@ -0,0 +1,62 @@
+//===-- 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 <cstdlib>
+#include <string>
+#include <fstream>
+#include <iostream>
+
+int
+product (int x, int y)
+{
+    int result = x * y;
+    return result;
+}
+
+int
+sum (int a, int b)
+{
+    int result = a + b;
+    return result;
+}
+
+int
+strange_max (int m, int n)
+{
+    if (m > n)
+        return m;
+    else if (n > m)
+        return n;
+    else
+        return 0;
+}
+
+int
+foo (int i, int j)
+{
+    if (strange_max (i, j) == i)
+        return product (i, j);
+    else if (strange_max  (i, j) == j)
+        return sum (i, j);
+    else
+        return product (sum (i, i), sum (j, j));
+}
+
+int
+main(int argc, char const *argv[])
+{
+
+    int array[3];
+
+    array[0] = foo (1238, 78392);
+    array[1] = foo (379265, 23674);
+    array[2] = foo (872934, 234);
+
+    return 0;
+}





More information about the lldb-commits mailing list