[Lldb-commits] [lldb] r135009 - in /lldb/trunk/test/functionalities/target_command: TestTargetCommand.py globals.c

Johnny Chen johnny.chen at apple.com
Tue Jul 12 16:18:03 PDT 2011


Author: johnny
Date: Tue Jul 12 18:18:03 2011
New Revision: 135009

URL: http://llvm.org/viewvc/llvm-project?rev=135009&view=rev
Log:
Add a test case to exercise 'target variable' command before and after running the inferior.
Currently it fails after the inferior is run.

rdar://problem/9763907

Added:
    lldb/trunk/test/functionalities/target_command/globals.c
Modified:
    lldb/trunk/test/functionalities/target_command/TestTargetCommand.py

Modified: lldb/trunk/test/functionalities/target_command/TestTargetCommand.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/target_command/TestTargetCommand.py?rev=135009&r1=135008&r2=135009&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/target_command/TestTargetCommand.py (original)
+++ lldb/trunk/test/functionalities/target_command/TestTargetCommand.py Tue Jul 12 18:18:03 2011
@@ -1,5 +1,5 @@
 """
-Test some target commands: create, list, select.
+Test some target commands: create, list, select, variable.
 """
 
 import unittest2
@@ -21,19 +21,31 @@
     def test_target_command_with_dwarf(self):
         """Test some target commands: create, list, select."""
         da = {'C_SOURCES': 'a.c', 'EXE': 'a.out'}
-        self.buildDefault(dictionary=da)
+        self.buildDwarf(dictionary=da)
         self.addTearDownCleanup(dictionary=da)
 
         db = {'C_SOURCES': 'b.c', 'EXE': 'b.out'}
-        self.buildDefault(dictionary=db)
+        self.buildDwarf(dictionary=db)
         self.addTearDownCleanup(dictionary=db)
 
         dc = {'C_SOURCES': 'c.c', 'EXE': 'c.out'}
-        self.buildDefault(dictionary=dc)
+        self.buildDwarf(dictionary=dc)
         self.addTearDownCleanup(dictionary=dc)
 
         self.do_target_command()
 
+    # rdar://problem/9763907
+    # 'target variable' command fails if the target program has been run
+    #@unittest2.expectedFailure
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    def test_target_variable_command_with_dsym(self):
+        """Test 'target variable' command before and after starting the inferior."""
+        d = {'C_SOURCES': 'globals.c', 'EXE': 'globals'}
+        self.buildDsym(dictionary=d)
+        self.addTearDownCleanup(dictionary=d)
+
+        self.do_target_variable_command('globals')
+
     def do_target_command(self):
         """Exercise 'target create', 'target list', 'target select' commands."""
         exe_a = os.path.join(os.getcwd(), "a.out")
@@ -87,6 +99,24 @@
 
         self.runCmd("target list")
 
+    def do_target_variable_command(self, exe_name):
+        """Exercise 'target variable' command before and after starting the inferior."""
+        self.runCmd("file " + exe_name, CURRENT_EXECUTABLE_SET)
+
+        self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["my_global_char", "'X'"])
+        self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ['my_global_str', '"abc"'])
+
+        self.runCmd("run")
+
+        # rdar://problem/9763907
+        # 'target variable' command fails if the target program has been run
+        self.expect("target variable my_global_char", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ["my_global_char", "'X'"])
+        self.expect("target variable my_global_str", VARIABLES_DISPLAYED_CORRECTLY,
+            substrs = ['my_global_str', '"abc"'])
+
 
 if __name__ == '__main__':
     import atexit

Added: lldb/trunk/test/functionalities/target_command/globals.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/target_command/globals.c?rev=135009&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/target_command/globals.c (added)
+++ lldb/trunk/test/functionalities/target_command/globals.c Tue Jul 12 18:18:03 2011
@@ -0,0 +1,21 @@
+//===-- 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 <stdio.h>
+
+char my_global_char = 'X';
+const char* my_global_str = "abc";
+
+int main (int argc, char const *argv[])
+{
+    printf("global char: %c\n", my_global_char);
+    
+    printf("global str: %s\n", my_global_str);
+    
+    return 0;
+}





More information about the lldb-commits mailing list