From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32107 invoked by alias); 31 Aug 2012 13:29:40 -0000 Received: (qmail 32098 invoked by uid 22791); 31 Aug 2012 13:29:37 -0000 X-SWARE-Spam-Status: No, hits=-3.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 31 Aug 2012 13:29:22 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1T7RHl-0004t7-7X from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 31 Aug 2012 06:29:21 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 31 Aug 2012 06:29:21 -0700 Received: from qiyao.dyndns.org.dyndns.org (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Fri, 31 Aug 2012 06:29:19 -0700 From: Yao Qi To: Subject: [RFC] Merge mi-cli.exp and mi2-cli.exp Date: Fri, 31 Aug 2012 13:29:00 -0000 Message-ID: <1346419770-5718-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-08/txt/msg00889.txt.bz2 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 * 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