[Lldb-commits] [PATCH] Enhance lldb-mi arguments test (MI)

Phabricator reviews at reviews.llvm.org
Mon Jun 22 13:46:30 PDT 2015


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D10523

Files:
  lldb/trunk/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
  lldb/trunk/test/tools/lldb-mi/interpreter/main.cpp

Index: lldb/trunk/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
===================================================================
--- lldb/trunk/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
+++ lldb/trunk/test/tools/lldb-mi/interpreter/TestMiInterpreterExec.py
@@ -61,8 +61,8 @@
         self.spawnLldbMi(args = None)
 
         # Test that "settings set target.run-args" passes arguments to executable
-        #FIXME: "--arg1 \"2nd arg\" third_arg fourth=\"4th arg\"" causes an error
-        self.runCmd("-interpreter-exec console \"setting set target.run-args arg1\"")
+        #FIXME: --arg1 causes an error
+        self.runCmd("-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"")
         self.expect("\^done")
 
         # Load executable
@@ -74,7 +74,15 @@
         self.expect("\^running")
 
         # Test that arguments were passed properly
-        self.expect("@\"argc=2\\\\r\\\\n\"")
+        self.expect("@\"argc=5\\\\r\\\\n\"")
+        self.expect("@\"argv.0.=.*lldb-mi")
+        self.expect("@\"argv.1.=arg1\\\\r\\\\n\"")
+        self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"")
+        self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"")
+        self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"")
+
+        # Test that program exited normally
+        self.expect("\*stopped,reason=\"exited-normally\"")
 
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
@@ -89,16 +97,35 @@
         self.expect("\^done")
 
         # Test that "settings set target.run-args" passes arguments to executable
-        #FIXME: "--arg1 \"2nd arg\" third_arg fourth=\"4th arg\"" causes an error
-        self.runCmd("-interpreter-exec console \"setting set target.run-args arg1\"")
+        #FIXME: --arg1 causes an error
+        self.runCmd("-interpreter-exec console \"setting set target.run-args arg1 \\\"2nd arg\\\" third_arg fourth=\\\"4th arg\\\"\"")
         self.expect("\^done")
 
-        # Run
+        # Run to BP_printf
+        line = line_number('main.cpp', '// BP_printf')
+        self.runCmd("-break-insert main.cpp:%d" % line)
+        self.expect("\^done,bkpt={number=\"1\"")
         self.runCmd("-exec-run")
-        self.expect("\^running")
+        self.expect("\^running");
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+        # Run to BP_return
+        line = line_number('main.cpp', '// BP_return')
+        self.runCmd("-break-insert main.cpp:%d" % line)
+        self.expect("\^done,bkpt={number=\"2\"")
+        self.runCmd("-exec-continue")
+        self.expect("\^running");
 
         # Test that arguments were passed properly
-        self.expect("@\"argc=2\\\\r\\\\n\"")
+        self.expect("@\"argc=5\\\\r\\\\n\"")
+        self.expect("@\"argv.0.=.*lldb-mi")
+        self.expect("@\"argv.1.=arg1\\\\r\\\\n\"")
+        self.expect("@\"argv.2.=2nd arg\\\\r\\\\n\"")
+        self.expect("@\"argv.3.=third_arg\\\\r\\\\n\"")
+        self.expect("@\"argv.4.=fourth=4th arg\\\\r\\\\n\"")
+
+        # Hit BP_return
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
 
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
Index: lldb/trunk/test/tools/lldb-mi/interpreter/main.cpp
===================================================================
--- lldb/trunk/test/tools/lldb-mi/interpreter/main.cpp
+++ lldb/trunk/test/tools/lldb-mi/interpreter/main.cpp
@@ -12,6 +12,8 @@
 int
 main(int argc, char const *argv[])
 {
-    printf("argc=%d\n", argc);
-    return 0;
+    printf("argc=%d\n", argc);  // BP_printf
+    for (int i = 0; i < argc; ++i)
+        printf("argv[%d]=%s\n", i, argv[i]);
+    return 0;   // BP_return
 }

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10523.28154.patch
Type: text/x-patch
Size: 3789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150622/c7de078f/attachment.bin>


More information about the lldb-commits mailing list