From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32016 invoked by alias); 19 Apr 2009 15:21:05 -0000 Received: (qmail 31996 invoked by uid 22791); 19 Apr 2009 15:21:03 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_36,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, 19 Apr 2009 15:20:58 +0000 Received: from mailhub1.br.ibm.com (mailhub1.br.ibm.com [9.18.232.109]) by e24smtp04.br.ibm.com (8.13.1/8.13.1) with ESMTP id n3JFGXul018209 for ; Sun, 19 Apr 2009 12:16:33 -0300 Received: from d24av01.br.ibm.com (d24av01.br.ibm.com [9.18.232.46]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n3JFLFjk1335434 for ; Sun, 19 Apr 2009 12:21:15 -0300 Received: from d24av01.br.ibm.com (loopback [127.0.0.1]) by d24av01.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n3JFKtxS010602 for ; Sun, 19 Apr 2009 12:20:55 -0300 Received: from [9.8.2.127] ([9.8.2.127]) by d24av01.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n3JFKsBa010595 for ; Sun, 19 Apr 2009 12:20:55 -0300 Subject: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. From: Thiago Jung Bauermann To: gdb-patches ml Content-Type: text/plain Date: Sun, 19 Apr 2009 15:21:00 -0000 Message-Id: <1240154454.19777.39.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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-04/txt/msg00495.txt.bz2 Hi, This is a cleanup on the testcases in gdb.python. Currently, they define the same test functions in each .exp. I put them in lib/gdb.exp instead. Ok to commit? -- []'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-04-19 10:35:25.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-cmd.exp 2009-04-19 12:02:53.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-04-19 10:35:25.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-frame.exp 2009-04-19 12:02:53.000000000 -0300 @@ -28,17 +28,6 @@ if { [gdb_compile "${srcdir}/${subdir}/$ 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 @@ -46,12 +35,9 @@ 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 } # The following tests require execution. Index: gdb.git/gdb/testsuite/gdb.python/python-function.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python-function.exp 2009-04-19 10:35:25.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-function.exp 2009-04-19 12:02:53.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-04-19 10:35:25.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-value.exp 2009-04-19 12:02:53.000000000 -0300 @@ -28,35 +28,6 @@ if { [gdb_compile "${srcdir}/${subdir}/$ 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 @@ -244,12 +215,9 @@ 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 } test_value_creation Index: gdb.git/gdb/testsuite/lib/gdb.exp =================================================================== --- gdb.git.orig/gdb/testsuite/lib/gdb.exp 2009-04-19 10:35:25.000000000 -0300 +++ gdb.git/gdb/testsuite/lib/gdb.exp 2009-04-19 12:02:53.000000000 -0300 @@ -2937,3 +2937,44 @@ proc get_sizeof { type default } { return [get_integer_valueof "sizeof (${type})" $default] } +# Return 1 if Python scripting is supported in GDB, 0 if not. +proc python_supported { } { + global gdb_prompt + + gdb_test_multiple "python print 'hello, world!'" "verify python support" { + -re "not supported.*$gdb_prompt $" { return 0 } + -re "$gdb_prompt $" { 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 } } + } +} + +# 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 +} Index: gdb.git/gdb/testsuite/gdb.python/python.exp =================================================================== --- gdb.git.orig/gdb/testsuite/gdb.python/python.exp 2009-02-02 12:27:37.000000000 -0200 +++ gdb.git/gdb/testsuite/gdb.python/python.exp 2009-04-19 12:10:28.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" \