From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13339 invoked by alias); 31 May 2009 22:26:37 -0000 Received: (qmail 13330 invoked by uid 22791); 31 May 2009 22:26:35 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_83,SPF_PASS X-Spam-Check-By: sourceware.org Received: from e24smtp04.br.ibm.com (HELO e24smtp04.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 31 May 2009 22:26:29 +0000 Received: from mailhub3.br.ibm.com (mailhub3.br.ibm.com [9.18.232.110]) by e24smtp04.br.ibm.com (8.13.1/8.13.1) with ESMTP id n4VMPEoD025463 for ; Sun, 31 May 2009 19:25:14 -0300 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub3.br.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n4VMQpQ12044044 for ; Sun, 31 May 2009 19:26:51 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n4VMQOOt008798 for ; Sun, 31 May 2009 19:26:25 -0300 Received: from [9.18.201.83] ([9.18.201.83]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n4VMQNUo008787; Sun, 31 May 2009 19:26:24 -0300 Subject: Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. From: Thiago Jung Bauermann To: Eli Zaretskii Cc: drow@false.org, tromey@redhat.com, gdb-patches@sourceware.org In-Reply-To: <83bppnpmta.fsf@gnu.org> References: <1242621476.8085.4.camel@hactar> <83ws8ep9gq.fsf@gnu.org> <1242744639.10143.6.camel@localhost.localdomain> <20090519145908.GA24773@caradoc.them.org> <83k54cq4oe.fsf@gnu.org> <1242771692.6232.1.camel@hactar> <83hbzgpixf.fsf@gnu.org> <1242789977.6232.21.camel@hactar> <20090520033939.GA31983@caradoc.them.org> <1242825492.6644.0.camel@hactar> <20090520145859.GA9276@caradoc.them.org> <1242832233.6644.2.camel@hactar> <83fxezpu3m.fsf@gnu.org> <1242848341.9685.2.camel@hactar> <83bppnpmta.fsf@gnu.org> Content-Type: text/plain; charset="UTF-8" Date: Sun, 31 May 2009 22:26:00 -0000 Message-Id: <1243807990.26363.37.camel@hactar> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit 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: 2009-05/txt/msg00674.txt.bz2 Em Qua, 2009-05-20 às 23:00 +0300, Eli Zaretskii escreveu: > > From: Thiago Jung Bauermann > > Cc: drow@false.org, tromey@redhat.com, gdb-patches@sourceware.org > > Date: Wed, 20 May 2009 16:39:00 -0300 > > > > Since the 8.3 problem already exists in today's repo, do you mind if > > I commit the patch and pledge to fix this before 7.0 is released? > > No, I don't mind. Thanks. Great. This is the latest version of the patch then, which addresses all comments on it. -- []'s Thiago Jung Bauermann IBM Linux Technology Center gdb/testsuite/ * lib/gdb.exp (python_supported, gdb_py_test_silent_cmd, gdb_py_test_multiple): New functions. * gdb.python/python-cmd.exp: Use Python test functions from lib/gdb.exp instead of defining its own functions. * gdb.python/python-frame.exp: Likewise. * gdb.python/python-function.exp: Likewise. * gdb.python/python-value.exp: Likewise. * gdb.python/python.exp: Likewise. Index: gdb.git/gdb/testsuite/gdb.python/python-cmd.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-cmd.exp 2009-05-03 23:05:58.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-cmd.exp 2009-05-31 17:48:49.000000000 -0300 @@ -20,36 +20,15 @@ if $tracelevel then { strace $tracelevel } -# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... -# Run a test named NAME, consisting of multiple lines of input. -# After each input line INPUT, search for result line RESULT. -# Succeed if all results are seen; fail otherwise. -proc gdb_py_test_multiple {name args} { - global gdb_prompt - foreach {input result} $args { - if {[gdb_test_multiple $input "$name - $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { - pass "$name - $input" - } - }]} { - return 1 - } - } - return 0 -} - # Start with a fresh gdb. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir -gdb_test_multiple "python print 'hello, world!'" "verify python support" { - -re "not supported.*$gdb_prompt $" { - unsupported "python support is disabled" - return -1 - } - -re "$gdb_prompt $" {} +if ![python_supported] then { + unsupported "python support is disabled" + return -1 } # Test a simple command. Index: gdb.git/gdb/testsuite/gdb.python/python-frame.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-frame.exp 2009-05-03 23:05:58.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-frame.exp 2009-05-31 19:01:31.000000000 -0300 @@ -20,40 +20,28 @@ if $tracelevel then { strace $tracelevel } +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +if ![python_supported] then { + unsupported "python support is disabled" + return -1 +} + set testfile "python-frame" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested "Couldn't compile ${srcfile}" return -1 } -# Run a command in GDB, and report a failure if a Python exception is thrown. -# If report_pass is true, report a pass if no exception is thrown. -proc gdb_py_test_silent_cmd {cmd name report_pass} { - global gdb_prompt - - gdb_test_multiple $cmd $name { - -re "Traceback.*$gdb_prompt $" { fail $name } - -re "$gdb_prompt $" { if $report_pass { pass $name } } - } -} - -# Start with a fresh gdb. - -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -gdb_test_multiple "python print 'hello, world!'" "verify python support" { - -re "not supported.*$gdb_prompt $" { - unsupported "python support is disabled" - return -1 - } - -re "$gdb_prompt $" {} -} - # The following tests require execution. if ![runto_main] then { Index: gdb.git/gdb/testsuite/gdb.python/python-function.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-function.exp 2009-05-03 23:05:58.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-function.exp 2009-05-31 17:48:49.000000000 -0300 @@ -20,36 +20,15 @@ if $tracelevel then { strace $tracelevel } -# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... -# Run a test named NAME, consisting of multiple lines of input. -# After each input line INPUT, search for result line RESULT. -# Succeed if all results are seen; fail otherwise. -proc gdb_py_test_multiple {name args} { - global gdb_prompt - foreach {input result} $args { - if {[gdb_test_multiple $input "$name - $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { - pass "$name - $input" - } - }]} { - return 1 - } - } - return 0 -} - # Start with a fresh gdb. gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir -gdb_test_multiple "python print 'hello, world!'" "verify python support" { - -re "not supported.*$gdb_prompt $" { - unsupported "python support is disabled" - return -1 - } - -re "$gdb_prompt $" {} +if ![python_supported] then { + unsupported "python support is disabled" + return -1 } gdb_py_test_multiple "input convenience function" \ Index: gdb.git/gdb/testsuite/gdb.python/python-value.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-value.exp 2009-05-31 17:05:44.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-value.exp 2009-05-31 19:01:31.000000000 -0300 @@ -20,43 +20,6 @@ if $tracelevel then { strace $tracelevel } -set testfile "python-value" -set srcfile ${testfile}.c -set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - untested "Couldn't compile ${srcfile}" - return -1 -} - -# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... -# Run a test named NAME, consisting of multiple lines of input. -# After each input line INPUT, search for result line RESULT. -# Succeed if all results are seen; fail otherwise. -proc gdb_py_test_multiple {name args} { - global gdb_prompt - foreach {input result} $args { - if {[gdb_test_multiple $input "$name - $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { - pass "$name - $input" - } - }]} { - return 1 - } - } - return 0 -} - -# Run a command in GDB, and report a failure if a Python exception is thrown. -# If report_pass is true, report a pass if no exception is thrown. -proc gdb_py_test_silent_cmd {cmd name report_pass} { - global gdb_prompt - - gdb_test_multiple $cmd $name { - -re "Traceback.*$gdb_prompt $" { fail $name } - -re "$gdb_prompt $" { if $report_pass { pass $name } } - } -} - proc test_value_creation {} { global gdb_prompt @@ -278,16 +241,23 @@ proc test_value_after_death {} { gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} -gdb_test_multiple "python print 'hello, world!'" "verify python support" { - -re "not supported.*$gdb_prompt $" { - unsupported "python support is disabled" - return -1 - } - -re "$gdb_prompt $" {} +if ![python_supported] then { + unsupported "python support is disabled" + return -1 +} + +set testfile "python-value" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 } +gdb_load ${binfile} + test_value_creation test_value_numeric_ops test_value_boolean Index: gdb.git/gdb/testsuite/lib/gdb.exp =================================================================== --- gdb.git.orig/gdb/testsuite/lib/gdb.exp 2009-05-03 23:05:58.000000000 -0300 +++ gdb.git/gdb/testsuite/lib/gdb.exp 2009-05-31 19:01:31.000000000 -0300 @@ -27,6 +27,7 @@ if {$tool == ""} { } load_lib libgloss.exp +load_lib python-support.exp global GDB @@ -2946,4 +2947,3 @@ proc get_hexadecimal_valueof { exp defau proc get_sizeof { type default } { return [get_integer_valueof "sizeof (${type})" $default] } - Index: gdb.git/gdb/testsuite/gdb.python/python.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python.exp 2009-05-31 17:05:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python.exp 2009-05-31 17:48:49.000000000 -0300 @@ -26,30 +26,9 @@ gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir -gdb_test_multiple "python print 23" "verify python support" { - -re "not supported.*$gdb_prompt $" { - unsupported "python support is disabled" - return -1 - } - -re "$gdb_prompt $" {} -} - -# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... -# Run a test named NAME, consisting of multiple lines of input. -# After each input line INPUT, search for result line RESULT. -# Succeed if all results are seen; fail otherwise. -proc gdb_py_test_multiple {name args} { - global gdb_prompt - foreach {input result} $args { - if {[gdb_test_multiple $input "$name - $input" { - -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { - pass "$name - $input" - } - }]} { - return 1 - } - } - return 0 +if ![python_supported] then { + unsupported "python support is disabled" + return -1 } gdb_py_test_multiple "multi-line python command" \ Index: gdb.git/gdb/testsuite/gdb.python/python-template.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-template.exp 2009-05-31 17:05:44.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-template.exp 2009-05-31 19:01:31.000000000 -0300 @@ -20,15 +20,6 @@ if $tracelevel then { strace $tracelevel } -set testfile "python-template" -set srcfile ${testfile}.cc -set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ - {debug c++}] != "" } { - untested "Couldn't compile ${srcfile}" - return -1 -} - # Start with a fresh gdb. gdb_exit @@ -43,6 +34,15 @@ gdb_test_multiple "python print 23" "ver -re "$gdb_prompt $" {} } +set testfile "python-template" +set srcfile ${testfile}.cc +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \ + {debug c++}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + proc test_template_arg {type} { global testfile srcdir subdir srcfile binfile if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ Index: gdb.git/gdb/testsuite/lib/python-support.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb.git/gdb/testsuite/lib/python-support.exp 2009-05-31 19:01:31.000000000 -0300 @@ -0,0 +1,53 @@ +global python_supported_saved + +# Return 1 if Python scripting is supported in GDB, 0 if not. +proc python_supported { } { + global gdb_prompt + global python_supported_saved + + if [info exists python_supported_saved] { + verbose "python_supported: returning saved $python_supported_saved" 2 + return $python_supported_saved + } + + gdb_test_multiple "python print 'hello, world!'" "verify python support" { + -re "not supported.*$gdb_prompt $" { + return [set python_supported_saved 0] + } + -re "$gdb_prompt $" { + return [set python_supported_saved 1] + } + } + + return [set python_supported_saved 0] +} + +# Run a command in GDB, and report a failure if a Python exception is thrown. +# If report_pass is true, report a pass if no exception is thrown. +proc gdb_py_test_silent_cmd {cmd name report_pass} { + global gdb_prompt + + gdb_test_multiple $cmd $name { + -re "Traceback.*$gdb_prompt $" { fail $name } + -re "$gdb_prompt $" { if $report_pass { pass $name } } + } +} + +# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}... +# Run a test named NAME, consisting of multiple lines of input. +# After each input line INPUT, search for result line RESULT. +# Succeed if all results are seen; fail otherwise. +proc gdb_py_test_multiple {name args} { + global gdb_prompt + + foreach {input result} $args { + if {[gdb_test_multiple $input "$name - $input" { + -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" { + pass "$name - $input" + } + }]} { + return 1 + } + } + return 0 +}