Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [RFC] Merge mi-cli.exp and mi2-cli.exp
Date: Fri, 31 Aug 2012 13:29:00 -0000	[thread overview]
Message-ID: <1346419770-5718-1-git-send-email-yao@codesourcery.com> (raw)

Hi,
When trying to add some new tests in mi-cli.exp, the same stuff should
be added to mi2-cli.exp as well.  Then, looks most part of two tests are
identical, and I start to think about why don't merge them together.

In 2003, Andrew copied mi-*.exp to mi2-*.exp in this patch,

  [patch,6.0,rfc,rfa:doco] Finish "mi2"/"mi3" rollover
  http://sourceware.org/ml/gdb-patches/2003-08/msg00044.html

Unless I miss something, the intention of copying tests here is to test
both '-i=mi' and '-i=mi2' respectively.  However, this duplicates the code,
and increase the effort to maintain, IMO.

Sometimes, people may only update one of two files, and keep them un-sync'ed.
  http://sourceware.org/ml/gdb-patches/2009-03/msg00172.html
  http://sourceware.org/ml/gdb-patches/2009-02/msg00278.html

I am wondering if we can get rid of mi2-cli.exp, and exercise MI with
different MIFLAGS in a single mi-cli.exp.  This is what this patch does.
I don't re-indent the code to make patch readable.  WDYT?  If it is
OK, I'll post a full patch with code indentation and removing
mi2-cli.exp.

I realize other mi-foo.exp and mi2-foo.exp may have the same issue,
but I don't examine the difference of them.  If it is the right way
to go, we can get rid of mi2-foo.exp gradually.

gdb/testsuite:

2012-08-31  Yao Qi  <yao@codesourcery.com>

	* lib/mi-support.exp (mi_run_test_with_miflags): New.
	* gdb.mi/mi-cli.exp (test_mi_cli): New.  Move tests into this
	proc.
	Invoke mi_run_test_with_miflags.
---
 gdb/testsuite/gdb.mi/mi-cli.exp  |   19 +++++++++++++------
 gdb/testsuite/lib/mi-support.exp |   12 ++++++++++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
index f487cbd..fc6229c 100644
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
@@ -20,12 +20,6 @@
 # handlers, etc.
 
 load_lib mi-support.exp
-set MIFLAGS "-i=mi"
-
-gdb_exit
-if [mi_gdb_start] {
-    continue
-}
 
 standard_testfile basics.c
 
@@ -34,6 +28,15 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
+proc test_mi_cli { } {
+    global binfile
+    global async
+
+gdb_exit
+if [mi_gdb_start] {
+    continue
+}
+
 mi_gdb_test "-interpreter-exec" \
   {\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
   "-interpreter-exec with no arguments"
@@ -212,4 +215,8 @@ mi_gdb_test "888-interpreter-exec console \"set \$pc=0x0\"" \
   "-interpreter-exec console \"\""
 
 mi_gdb_exit
+}
+
+mi_run_test_with_miflags test_mi_cli
+
 return 0
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 9de27dd..2ac8ca0 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -36,6 +36,18 @@ set library_loaded_re "=library-loaded\[^\n\]+\"\r\n(?:$gdbindex_warning_re)?"
 set breakpoint_re "=(?:breakpoint-created|breakpoint-deleted)\[^\n\]+\"\r\n"
 
 #
+# Run TEST_PROC with one argument which is the name of MI interpreter.
+#
+proc mi_run_test_with_miflags { test_proc } {
+    foreach mi_interp { "mi" "mi1" "mi2" "mi3" } {
+	set MIFLAGS "-i=${mi_interp}"
+	with_test_prefix "$mi_interp" {
+	    $test_proc
+	}
+    }
+}
+
+#
 # mi_gdb_exit -- exit the GDB, killing the target program if necessary
 #
 proc mi_gdb_exit {} {
-- 
1.7.7.6


             reply	other threads:[~2012-08-31 13:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-31 13:29 Yao Qi [this message]
2012-09-03  9:08 ` Vladimir Prus
2012-09-03 15:55   ` Yao Qi
2012-09-05  0:29   ` Stan Shebs
2012-09-10 20:09     ` Tom Tromey
2012-09-11 15:15     ` Pedro Alves
2012-09-11 21:53       ` Stan Shebs
2012-09-12 15:28         ` Pedro Alves
2012-09-12 13:59       ` Yao Qi
2012-09-19 11:22 ` Yao Qi
2012-09-19 13:47   ` Pedro Alves
2012-09-21  8:40     ` Yao Qi
2012-09-28  0:04 ` [PATCH 0/11] Cleanup MI test cases Yao Qi
2012-09-28  0:04   ` [PATCH 05/11] mi-pthreads.exp Yao Qi
2012-09-28  0:04   ` [PATCH 02/11] mi-var-block.exp Yao Qi
2012-09-28  0:05   ` [PATCH 11/11] mi-syn-frame.exp Yao Qi
2012-09-28  0:05   ` [PATCH 06/11] mi-break.exp Yao Qi
2012-09-28  0:05   ` [PATCH 01/11] Remove mi-FOO.exp which are identical to mi2-FOO.exp Yao Qi
2012-09-28  0:05   ` [PATCH 08/11] mi-var-display.exp Yao Qi
2012-09-28  0:05   ` [PATCH 09/11] mi-console.exp Yao Qi
2012-09-28  0:05   ` [PATCH 10/11] mi-stack.exp Yao Qi
2012-09-28  0:05   ` [PATCH 03/11] mi-file.exp Yao Qi
2012-09-28  0:05   ` [PATCH 04/11] mi-basics.exp Yao Qi
2012-09-28  0:05   ` [PATCH 07/11] mi-var-cmd.exp Yao Qi
2012-09-28 19:36   ` [PATCH 0/11] Cleanup MI test cases Pedro Alves
2012-10-12  9:47     ` Yao Qi
2012-10-12 10:05       ` Pedro Alves
2012-10-14 12:25         ` [committed] : " Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346419770-5718-1-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox