This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC] Merge mi-cli.exp and mi2-cli.exp
- From: Yao Qi <yao at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Fri, 31 Aug 2012 21:29:30 +0800
- Subject: [RFC] Merge mi-cli.exp and mi2-cli.exp
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