[Lldb-commits] [lldb] r222838 - Improve lldb-mi tests.

Hafiz Abid Qadeer hafiz_abid at mentor.com
Wed Nov 26 08:37:51 PST 2014


Author: abidh
Date: Wed Nov 26 10:37:51 2014
New Revision: 222838

URL: http://llvm.org/viewvc/llvm-project?rev=222838&view=rev
Log:
Improve lldb-mi tests. 

summary of changes:
  Cleanup: Use "line_number" API instead of hardcoded source lines
  Combine child.sendline with previous child.send command.
  test_lldbmi_tokens: Add test for MI tokens.
  test_lldbmi_badpathexe: Remove check for prompt so test for bad path can be enabled.

Patch from dawn at burble.org.


Modified:
    lldb/trunk/test/tools/lldb-mi/TestMiBreakpoint.py
    lldb/trunk/test/tools/lldb-mi/TestMiEvaluate.py
    lldb/trunk/test/tools/lldb-mi/TestMiInterrupt.py
    lldb/trunk/test/tools/lldb-mi/TestMiLaunch.py
    lldb/trunk/test/tools/lldb-mi/TestMiProgramArgs.py
    lldb/trunk/test/tools/lldb-mi/loop.c

Modified: lldb/trunk/test/tools/lldb-mi/TestMiBreakpoint.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiBreakpoint.py?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiBreakpoint.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiBreakpoint.py Wed Nov 26 10:37:51 2014
@@ -41,29 +41,23 @@ class MiBreakpointTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
-                child.send("-break-insert -f a_MyFunction")
-                child.sendline('')
+                child.sendline("-break-insert -f a_MyFunction")
                 child.expect("\^done,bkpt={number=\"1\"")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.
@@ -102,29 +96,26 @@ class MiBreakpointTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
-                child.send("-break-insert -f main.c:22")
-                child.sendline('')
+                # Find the line number to break inside main() and set
+                # pending BP.
+                self.line = line_number('main.c', '//BP_source')
+                child.sendline("-break-insert -f main.c:%d" % self.line)
                 child.expect("\^done,bkpt={number=\"1\"")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.
@@ -163,50 +154,41 @@ class MiBreakpointTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
-                child.send("-break-insert -f main")
-                child.sendline('')
+                child.sendline("-break-insert -f main")
                 child.expect("\^done,bkpt={number=\"1\"")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #break on symbol
-                child.send("-break-insert a_MyFunction")
-                child.sendline('')
+                child.sendline("-break-insert a_MyFunction")
                 child.expect("\^done,bkpt={number=\"2\"")
 
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #break on source
-                child.send("-break-insert main.c:29")
-                child.sendline('')
+                self.line = line_number('main.c', '//BP_source')
+                child.sendline("-break-insert main.c:%d" % self.line)
                 child.expect("\^done,bkpt={number=\"3\"")
 
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #run to exit
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.

Modified: lldb/trunk/test/tools/lldb-mi/TestMiEvaluate.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiEvaluate.py?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiEvaluate.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiEvaluate.py Wed Nov 26 10:37:51 2014
@@ -41,103 +41,79 @@ class MiEvaluateTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
                 #run to main
-                child.send("-break-insert -f main")
-                child.sendline('')
+                child.sendline("-break-insert -f main")
                 child.expect("\^done,bkpt={number=\"1\"")
 
-                child.send("-exec-run")
-                child.sendline('') #FIXME: hangs here; extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") #FIXME: hangs here; extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
-                #run to program return
-                child.send("-break-insert main.c:30") #BP_source
-                child.sendline('')
+                #run to program return (marked BP_source)
+                self.line = line_number('main.c', '//BP_source')
+                child.sendline("-break-insert main.c:%d" % self.line)
                 child.expect("\^done,bkpt={number=\"2\"")
 
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #print non-existant variable
-                #child.send("-var-create var1 --thread 1 --frame 0 * undef")
-                #child.sendline('') #FIXME: shows undef as {...}
+                #child.sendline("-var-create var1 --thread 1 --frame 0 * undef") #FIXME: shows undef as {...}
                 #child.expect("error")
-                #child.send("-data-evaluate-expression undef")
-                #child.sendline('') #FIXME: gets value="undef"
+                #child.sendline("-data-evaluate-expression undef") #FIXME: gets value="undef"
                 #child.expect("error")
 
                 #print global "g_MyVar"
-                child.send("-var-create var1 --thread 1 --frame 0 * g_MyVar")
-                child.sendline('') #FIXME: shows name=<unnamedvariable>"
+                child.sendline("-var-create var1 --thread 1 --frame 0 * g_MyVar") #FIXME: shows name=<unnamedvariable>"
                 child.expect("value=\"3\",type=\"int\"")
-                #child.send("-var-evaluate-expression var1")
-                #child.sendline('') #FIXME: gets var1 does not exist
-                child.send("-var-show-attributes var1")
-                child.sendline('')
+                #child.sendline("-var-evaluate-expression var1") #FIXME: gets var1 does not exist
+                child.sendline("-var-show-attributes var1")
                 child.expect("status=\"editable\"")
-                child.send("-var-delete var1")
-                child.sendline('')
+                child.sendline("-var-delete var1")
                 child.expect("\^done")
-                child.send("-var-create var1 --thread 1 --frame 0 * g_MyVar")
-                child.sendline('')
+                child.sendline("-var-create var1 --thread 1 --frame 0 * g_MyVar")
                 child.expect("value=\"3\",type=\"int\"")
 
                 #print static "s_MyVar" and modify
-                child.send("-data-evaluate-expression s_MyVar")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression s_MyVar")
                 child.expect("value=\"30\"")
-                child.send("-var-create var3 --thread 1 --frame 0 * \"s_MyVar=3\"")
-                child.sendline('')
+                child.sendline("-var-create var3 --thread 1 --frame 0 * \"s_MyVar=3\"")
                 child.expect("value=\"3\",type=\"int\"")
-                child.send("-data-evaluate-expression \"s_MyVar=30\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"s_MyVar=30\"")
                 child.expect("value=\"30\"")
 
                 #print local "b" and modify
-                child.send("-data-evaluate-expression b")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression b")
                 child.expect("value=\"20\"")
-                child.send("-var-create var3 --thread 1 --frame 0 * \"b=3\"")
-                child.sendline('')
+                child.sendline("-var-create var3 --thread 1 --frame 0 * \"b=3\"")
                 child.expect("value=\"3\",type=\"int\"")
-                child.send("-data-evaluate-expression \"b=20\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"b=20\"")
                 child.expect("value=\"20\"")
 
                 #print "a + b"
-                child.send("-data-evaluate-expression \"a + b\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"a + b\"")
                 child.expect("value=\"30\"")
-                child.send("-var-create var3 --thread 1 --frame 0 * \"a + b\"")
-                child.sendline('')
+                child.sendline("-var-create var3 --thread 1 --frame 0 * \"a + b\"")
                 child.expect("value=\"30\",type=\"int\"")
 
                 #print "argv[0]"
-                child.send("-data-evaluate-expression \"argv[0]\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"argv[0]\"")
                 child.expect("value=\"0x")
-                child.send("-var-create var3 --thread 1 --frame 0 * \"argv[0]\"")
-                child.sendline('')
+                child.sendline("-var-create var3 --thread 1 --frame 0 * \"argv[0]\"")
                 child.expect("numchild=\"1\",value=\"0x.*\",type=\"const char \*\"")
 
                 #run to exit
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.

Modified: lldb/trunk/test/tools/lldb-mi/TestMiInterrupt.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiInterrupt.py?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiInterrupt.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiInterrupt.py Wed Nov 26 10:37:51 2014
@@ -42,55 +42,43 @@ class MiInterruptTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
                 #run to main
-                child.send("-break-insert -f main")
-                child.sendline('')
+                child.sendline("-break-insert -f main")
                 child.expect("\^done,bkpt={number=\"1\"")
-                child.send("-exec-run")
-                child.sendline('') #FIXME: hangs here; extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") #FIXME: hangs here; extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #set doloop=1 and run (to loop forever)
-                child.send("-data-evaluate-expression \"doloop=1\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"doloop=1\"")
                 child.expect("value=\"1\"")
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
 
-                #issue interrupt, set a bp, and resume
-                child.send("-exec-interrupt")
-                child.sendline('')
+                #issue interrupt, set BP in loop (marked BP_loop), and resume
+                child.sendline("-exec-interrupt")
                 child.expect("\*stopped,reason=\"signal-received\"")
-                child.send("-break-insert loop.c:11")
-                child.sendline('')
+                self.line = line_number('loop.c', '//BP_loop')
+                child.sendline("-break-insert loop.c:%d" % self.line)
                 child.expect("\^done,bkpt={number=\"2\"")
-                #child.send("-exec-resume")
-                #child.sendline('') #FIXME: command not recognized
-                child.send("-exec-continue")
-                child.sendline('')
+                #child.sendline("-exec-resume") #FIXME: command not recognized
+                child.sendline("-exec-continue")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
-                #we should be sitting at loop.c:12
+                #we should have hit BP
                 #set loop=-1 so we'll exit the loop
-                child.send("-data-evaluate-expression \"loop=-1\"")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression \"loop=-1\"")
                 child.expect("value=\"-1\"")
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.

Modified: lldb/trunk/test/tools/lldb-mi/TestMiLaunch.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiLaunch.py?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiLaunch.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiLaunch.py Wed Nov 26 10:37:51 2014
@@ -42,20 +42,16 @@ class MiLaunchTestCase(TestBase):
                 child.logfile_read = f_read
 
                 #use no path
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.
@@ -93,20 +89,16 @@ class MiLaunchTestCase(TestBase):
 
                 #use full path
                 exe = os.path.join(os.getcwd(), "a.out")
-                child.send("-file-exec-and-symbols " + exe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + exe)
                 child.expect("\^done")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.
@@ -144,20 +136,16 @@ class MiLaunchTestCase(TestBase):
 
                 #use relative path
                 exe = "../../" + self.mydir + "/" + self.myexe
-                child.send("-file-exec-and-symbols " + exe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + exe)
                 child.expect("\^done")
 
-                child.send("-exec-run")
-                child.sendline('') # FIXME: lldb-mi hangs here, so the extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") # FIXME: lldb-mi hangs here, so extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"exited-normally\"")
                 child.expect_exact(prompt)
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.
@@ -174,7 +162,6 @@ class MiLaunchTestCase(TestBase):
                 print "\n\nContents of child_read.txt:"
                 print from_child
 
-    @unittest2.skip("lldb-mi badpath hang")
     @lldbmi_test
     def test_lldbmi_badpathexe(self):
         """Test that 'lldb-mi --interpreter' works for -file-exec-and-symbols badpath/exe."""
@@ -194,17 +181,13 @@ class MiLaunchTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                #use relative path
+                #use non-existant path
                 exe = "badpath/" + self.myexe
-                #print ("-file-exec-and-symbols " + exe)
-                child.send("-file-exec-and-symbols " + exe)
-                child.sendline('') #FIXME: non-existant directory caused hang
+                child.sendline("-file-exec-and-symbols " + exe)
                 child.expect("\^error")
+                #child.expect_exact(prompt) #FIXME: no prompt after error
 
-                child.expect_exact(prompt)
-
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.

Modified: lldb/trunk/test/tools/lldb-mi/TestMiProgramArgs.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/TestMiProgramArgs.py?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/TestMiProgramArgs.py (original)
+++ lldb/trunk/test/tools/lldb-mi/TestMiProgramArgs.py Wed Nov 26 10:37:51 2014
@@ -42,42 +42,33 @@ class MiProgramArgsTestCase(TestBase):
                 child.logfile_send = f_send
                 child.logfile_read = f_read
 
-                child.send("-file-exec-and-symbols " + self.myexe)
-                child.sendline('')
+                child.sendline("-file-exec-and-symbols " + self.myexe)
                 child.expect("\^done")
 
-                #child.send("-exec-arguments l")
-                #child.sendline('') #FIXME: not recognized and hung lldb-mi
-                child.send("settings set target.run-args l")
-                child.sendline('') #FIXME: args not passed
+                child.sendline("settings set target.run-args l") #FIXME: args not passed
+                #child.sendline("-exec-arguments l") #FIXME: not recognized and hung lldb-mi
 
                 #run to main
-                child.send("-break-insert -f main")
-                child.sendline('')
+                child.sendline("-break-insert -f main")
                 child.expect("\^done,bkpt={number=\"1\"")
-                child.send("-exec-run")
-                child.sendline('') #FIXME: hangs here; extra return below is needed
-                child.send("")
-                child.sendline('')
+                child.sendline("-exec-run")
+                child.sendline("") #FIXME: hangs here; extra return is needed
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
                 #check argc to see if arg passed
-                child.send("-data-evaluate-expression argc")
-                child.sendline('')
+                child.sendline("-data-evaluate-expression argc")
                 child.expect("value=\"2\"")
 
-                #set BP on code which is only executed if "l" was passed correctly
-                child.send("-break-insert main.c:27") #BP_argtest
-                child.sendline('')
+                #set BP on code which is only executed if "l" was passed correctly (marked BP_argtest)
+                self.line = line_number('main.c', '//BP_argtest')
+                child.sendline("-break-insert main.c:%d" % self.line)
                 child.expect("\^done,bkpt={number=\"2\"")
-                child.send("-exec-continue")
-                child.sendline('')
+                child.sendline("-exec-continue")
                 child.expect("\^running")
                 child.expect("\*stopped,reason=\"breakpoint-hit\"")
 
-                child.send("quit")
-                child.sendline('')
+                child.sendline("quit")
 
         # Now that the necessary logging is done, restore logfile to None to
         # stop further logging.

Modified: lldb/trunk/test/tools/lldb-mi/loop.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/loop.c?rev=222838&r1=222837&r2=222838&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/loop.c (original)
+++ lldb/trunk/test/tools/lldb-mi/loop.c Wed Nov 26 10:37:51 2014
@@ -8,7 +8,7 @@ infloop ()
             sleep(1);
             loop = 1;
         }
-        loop++; // Set break point at this line.
+        loop++; //BP_loop
     }
     return loop;
 }





More information about the lldb-commits mailing list