* [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp.
@ 2009-04-19 15:21 Thiago Jung Bauermann
2009-04-20 17:13 ` Tom Tromey
0 siblings, 1 reply; 24+ messages in thread
From: Thiago Jung Bauermann @ 2009-04-19 15:21 UTC (permalink / raw)
To: gdb-patches ml
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" \
^ permalink raw reply [flat|nested] 24+ messages in thread* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-04-19 15:21 [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp Thiago Jung Bauermann @ 2009-04-20 17:13 ` Tom Tromey 2009-04-20 17:23 ` Daniel Jacobowitz 2009-05-18 4:38 ` Thiago Jung Bauermann 0 siblings, 2 replies; 24+ messages in thread From: Tom Tromey @ 2009-04-20 17:13 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: gdb-patches ml >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes: Thiago> This is a cleanup on the testcases in gdb.python. Currently, Thiago> they define the same test functions in each .exp. I put them Thiago> in lib/gdb.exp instead. It looks like the GDB style is to put specific support functions into a new file, e.g., "mi-support.exp". So perhaps we should add "python-support.exp"... WDYT? Thiago> +# Return 1 if Python scripting is supported in GDB, 0 if not. Thiago> +proc python_supported { } { Thiago> + global gdb_prompt I think this proc should do the test only once per runtest invocation, and just return a cached result in subsequent calls. Otherwise this looks reasonable to me. Tom ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-04-20 17:13 ` Tom Tromey @ 2009-04-20 17:23 ` Daniel Jacobowitz 2009-05-18 4:38 ` Thiago Jung Bauermann 1 sibling, 0 replies; 24+ messages in thread From: Daniel Jacobowitz @ 2009-04-20 17:23 UTC (permalink / raw) To: Tom Tromey; +Cc: Thiago Jung Bauermann, gdb-patches ml On Mon, Apr 20, 2009 at 11:13:10AM -0600, Tom Tromey wrote: > >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes: > > Thiago> This is a cleanup on the testcases in gdb.python. Currently, > Thiago> they define the same test functions in each .exp. I put them > Thiago> in lib/gdb.exp instead. > > It looks like the GDB style is to put specific support functions into > a new file, e.g., "mi-support.exp". So perhaps we should add > "python-support.exp"... WDYT? Sounds fine - but please just load it from gdb.exp. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-04-20 17:13 ` Tom Tromey 2009-04-20 17:23 ` Daniel Jacobowitz @ 2009-05-18 4:38 ` Thiago Jung Bauermann 2009-05-18 18:11 ` Eli Zaretskii 1 sibling, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-18 4:38 UTC (permalink / raw) To: tromey; +Cc: gdb-patches ml, Daniel Jacobowitz Hi, Sorry about taking so long to get back to this patch. El lun, 20-04-2009 a las 11:13 -0600, Tom Tromey escribió: > >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes: > Thiago> This is a cleanup on the testcases in gdb.python. Currently, > Thiago> they define the same test functions in each .exp. I put them > Thiago> in lib/gdb.exp instead. > > It looks like the GDB style is to put specific support functions into > a new file, e.g., "mi-support.exp". So perhaps we should add > "python-support.exp"... WDYT? Reasonable. Done. > Thiago> +# Return 1 if Python scripting is supported in GDB, 0 if not. > Thiago> +proc python_supported { } { > Thiago> + global gdb_prompt > > I think this proc should do the test only once per runtest invocation, > and just return a cached result in subsequent calls. Good idea. Done. I also reordered calling of python_supported in the testcases to avoid needlessly compiling test binaries when Python is not supported. Ok to commit? -- []'s Thiago Jung Bauermann IBM Linux Technology Center gdb/testsuite/ * lib/python-support.exp: New file. * lib/gdb.exp: Load python-support.exp. * gdb.python/python-cmd.exp: Use Python test functions from lib/python-support.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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-cmd.exp 2009-05-18 01:22:47.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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-frame.exp 2009-05-18 01:23:23.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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-function.exp 2009-05-18 01:22:47.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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python-value.exp 2009-05-18 01:23:23.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 @@ -242,16 +205,23 @@ proc test_value_in_inferior {} { 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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/lib/gdb.exp 2009-05-18 01:22:47.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-18 01:22:45.000000000 -0300 +++ gdb.git/gdb/testsuite/gdb.python/python.exp 2009-05-18 01:22:47.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/lib/python-support.exp =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gdb.git/gdb/testsuite/lib/python-support.exp 2009-05-18 01:29:07.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 +} ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-18 4:38 ` Thiago Jung Bauermann @ 2009-05-18 18:11 ` Eli Zaretskii 2009-05-19 14:50 ` Thiago Jung Bauermann 0 siblings, 1 reply; 24+ messages in thread From: Eli Zaretskii @ 2009-05-18 18:11 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: tromey, gdb-patches, drow > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > Cc: gdb-patches ml <gdb-patches@sourceware.org>, Daniel Jacobowitz <drow@false.org> > Date: Mon, 18 May 2009 01:37:55 -0300 > > gdb/testsuite/ > * lib/python-support.exp: New file. > * lib/gdb.exp: Load python-support.exp. > * gdb.python/python-cmd.exp: Use Python test functions from > lib/python-support.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. Btw, is it possible to rename these files so as to avoid file-name clashes on 8+3 filesystems, as in python-frame.exp and python-function.exp (and the need to tweak config/djgpp/fnchange.lst accordingly)? The name `gdb.python' already tells that this is about Python, so there should be no need for the "python-" name prefix for the files therein, right? TIA ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-18 18:11 ` Eli Zaretskii @ 2009-05-19 14:50 ` Thiago Jung Bauermann 2009-05-19 14:59 ` Daniel Jacobowitz 0 siblings, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-19 14:50 UTC (permalink / raw) To: Eli Zaretskii; +Cc: tromey, gdb-patches, drow El lun, 18-05-2009 a las 21:11 +0300, Eli Zaretskii escribió: > > gdb/testsuite/ > > * lib/python-support.exp: New file. > > * lib/gdb.exp: Load python-support.exp. > > * gdb.python/python-cmd.exp: Use Python test functions from > > lib/python-support.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. > > Btw, is it possible to rename these files so as to avoid file-name > clashes on 8+3 filesystems, as in python-frame.exp and > python-function.exp (and the need to tweak config/djgpp/fnchange.lst > accordingly)? The name `gdb.python' already tells that this is about > Python, so there should be no need for the "python-" name prefix for > the files therein, right? Yes, I agree with you. I used this naming scheme just to follow the naming scheme used in the gdb/python directory. I don't actually like the filenames there, for the same reason. I just use it to comply with a request when the first Python patch was accepted. I don't dislike it enough to argue and ask for changes though. What do you think? Is it just fine to have the testcase files named differently from the source files? There's not a strict 1:1 mapping between them, but it's close. -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-19 14:50 ` Thiago Jung Bauermann @ 2009-05-19 14:59 ` Daniel Jacobowitz 2009-05-19 19:22 ` Eli Zaretskii 0 siblings, 1 reply; 24+ messages in thread From: Daniel Jacobowitz @ 2009-05-19 14:59 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Eli Zaretskii, tromey, gdb-patches On Tue, May 19, 2009 at 11:50:38AM -0300, Thiago Jung Bauermann wrote: > What do you think? Is it just fine to have the testcase files named > differently from the source files? There's not a strict 1:1 mapping > between them, but it's close. Won't the testcase files have the same 8.3 issues? -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-19 14:59 ` Daniel Jacobowitz @ 2009-05-19 19:22 ` Eli Zaretskii 2009-05-19 22:21 ` Thiago Jung Bauermann 0 siblings, 1 reply; 24+ messages in thread From: Eli Zaretskii @ 2009-05-19 19:22 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: bauerman, tromey, gdb-patches > Date: Tue, 19 May 2009 10:59:08 -0400 > From: Daniel Jacobowitz <drow@false.org> > Cc: Eli Zaretskii <eliz@gnu.org>, tromey@redhat.com, > gdb-patches@sourceware.org > > On Tue, May 19, 2009 at 11:50:38AM -0300, Thiago Jung Bauermann wrote: > > What do you think? Is it just fine to have the testcase files named > > differently from the source files? There's not a strict 1:1 mapping > > between them, but it's close. > > Won't the testcase files have the same 8.3 issues? Yes, they will. Which is why I suggest to rename them as well, and then the problem of file-name differences between source and testcase files will vanish. TIA ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-19 19:22 ` Eli Zaretskii @ 2009-05-19 22:21 ` Thiago Jung Bauermann 2009-05-20 3:11 ` Eli Zaretskii 0 siblings, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-19 22:21 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Daniel Jacobowitz, tromey, gdb-patches El mar, 19-05-2009 a las 22:21 +0300, Eli Zaretskii escribió: > > Date: Tue, 19 May 2009 10:59:08 -0400 > > From: Daniel Jacobowitz <drow@false.org> > > Cc: Eli Zaretskii <eliz@gnu.org>, tromey@redhat.com, > > gdb-patches@sourceware.org > > > > On Tue, May 19, 2009 at 11:50:38AM -0300, Thiago Jung Bauermann wrote: > > > What do you think? Is it just fine to have the testcase files named > > > differently from the source files? There's not a strict 1:1 mapping > > > between them, but it's close. > > > > Won't the testcase files have the same 8.3 issues? > > Yes, they will. Which is why I suggest to rename them as well, and > then the problem of file-name differences between source and testcase > files will vanish. I'm not sure I'm following this conversation. Are you talking just about the gdb/testsuite/gdb.python/*.{c,exp} files or also about gdb/python/*.c? -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-19 22:21 ` Thiago Jung Bauermann @ 2009-05-20 3:11 ` Eli Zaretskii 2009-05-20 3:26 ` Thiago Jung Bauermann 0 siblings, 1 reply; 24+ messages in thread From: Eli Zaretskii @ 2009-05-20 3:11 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: drow, tromey, gdb-patches > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > Cc: Daniel Jacobowitz <drow@false.org>, tromey@redhat.com, > gdb-patches@sourceware.org > Date: Tue, 19 May 2009 19:21:31 -0300 > > > > Won't the testcase files have the same 8.3 issues? > > > > Yes, they will. Which is why I suggest to rename them as well, and > > then the problem of file-name differences between source and testcase > > files will vanish. > > I'm not sure I'm following this conversation. Are you talking just about > the gdb/testsuite/gdb.python/*.{c,exp} files or also about > gdb/python/*.c? I'm talking about both, yes. Is that a problem? ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 3:11 ` Eli Zaretskii @ 2009-05-20 3:26 ` Thiago Jung Bauermann 2009-05-20 3:39 ` Daniel Jacobowitz 0 siblings, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-20 3:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, tromey, gdb-patches El mié, 20-05-2009 a las 06:11 +0300, Eli Zaretskii escribió: > > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > > Cc: Daniel Jacobowitz <drow@false.org>, tromey@redhat.com, > > gdb-patches@sourceware.org > > Date: Tue, 19 May 2009 19:21:31 -0300 > > > > > > Won't the testcase files have the same 8.3 issues? > > > > > > Yes, they will. Which is why I suggest to rename them as well, and > > > then the problem of file-name differences between source and testcase > > > files will vanish. > > > > I'm not sure I'm following this conversation. Are you talking just about > > the gdb/testsuite/gdb.python/*.{c,exp} files or also about > > gdb/python/*.c? > > I'm talking about both, yes. Is that a problem? From my part, not at all! I would gladly remove the python- prefix from everything. -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 3:26 ` Thiago Jung Bauermann @ 2009-05-20 3:39 ` Daniel Jacobowitz 2009-05-20 13:18 ` Thiago Jung Bauermann 0 siblings, 1 reply; 24+ messages in thread From: Daniel Jacobowitz @ 2009-05-20 3:39 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Eli Zaretskii, tromey, gdb-patches On Wed, May 20, 2009 at 12:26:17AM -0300, Thiago Jung Bauermann wrote: > >From my part, not at all! I would gladly remove the python- prefix from > everything. Note that all source files, unlike test cases, share a namespace: they all currently get dropped in gdb/*.o. So this may be tricky. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 3:39 ` Daniel Jacobowitz @ 2009-05-20 13:18 ` Thiago Jung Bauermann 2009-05-20 14:59 ` Daniel Jacobowitz 0 siblings, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-20 13:18 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Eli Zaretskii, tromey, gdb-patches Em Ter, 2009-05-19 Ã s 23:39 -0400, Daniel Jacobowitz escreveu: > On Wed, May 20, 2009 at 12:26:17AM -0300, Thiago Jung Bauermann wrote: > > >From my part, not at all! I would gladly remove the python- prefix from > > everything. > > Note that all source files, unlike test cases, share a namespace: they > all currently get dropped in gdb/*.o. So this may be tricky. If I do the renaming and successfully build GDB and run the python testcases, does it show that there's no problem afoot? -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 13:18 ` Thiago Jung Bauermann @ 2009-05-20 14:59 ` Daniel Jacobowitz 2009-05-20 15:10 ` Thiago Jung Bauermann 0 siblings, 1 reply; 24+ messages in thread From: Daniel Jacobowitz @ 2009-05-20 14:59 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Eli Zaretskii, tromey, gdb-patches On Wed, May 20, 2009 at 10:18:07AM -0300, Thiago Jung Bauermann wrote: > Em Ter, 2009-05-19 Ã s 23:39 -0400, Daniel Jacobowitz escreveu: > > On Wed, May 20, 2009 at 12:26:17AM -0300, Thiago Jung Bauermann wrote: > > > >From my part, not at all! I would gladly remove the python- prefix from > > > everything. > > > > Note that all source files, unlike test cases, share a namespace: they > > all currently get dropped in gdb/*.o. So this may be tricky. > > If I do the renaming and successfully build GDB and run the python > testcases, does it show that there's no problem afoot? Probably, yes. I don't see how it could work though - python/frame.c -> frame.o would clobber gdb/frame.c -> frame.o. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 14:59 ` Daniel Jacobowitz @ 2009-05-20 15:10 ` Thiago Jung Bauermann 2009-05-20 17:22 ` Eli Zaretskii 2009-05-28 0:43 ` Tom Tromey 0 siblings, 2 replies; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-20 15:10 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Eli Zaretskii, tromey, gdb-patches Em Qua, 2009-05-20 Ã s 10:58 -0400, Daniel Jacobowitz escreveu: > On Wed, May 20, 2009 at 10:18:07AM -0300, Thiago Jung Bauermann wrote: > > Em Ter, 2009-05-19 Ã s 23:39 -0400, Daniel Jacobowitz escreveu: > > > On Wed, May 20, 2009 at 12:26:17AM -0300, Thiago Jung Bauermann wrote: > > > > >From my part, not at all! I would gladly remove the python- prefix from > > > > everything. > > > > > > Note that all source files, unlike test cases, share a namespace: they > > > all currently get dropped in gdb/*.o. So this may be tricky. > > > > If I do the renaming and successfully build GDB and run the python > > testcases, does it show that there's no problem afoot? > > Probably, yes. I don't see how it could work though - python/frame.c > -> frame.o would clobber gdb/frame.c -> frame.o. Ah, I didn't think of python-frame.c. It didn't exist when I did this back then. :-( The right solution then is to make them not share a namespace. Tromey, you're the makefile wizard: is there an easy and painless way to make object files which come from different source directories in gdb/ to have different pathnames? -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 15:10 ` Thiago Jung Bauermann @ 2009-05-20 17:22 ` Eli Zaretskii 2009-05-20 19:39 ` Thiago Jung Bauermann 2009-05-28 0:43 ` Tom Tromey 1 sibling, 1 reply; 24+ messages in thread From: Eli Zaretskii @ 2009-05-20 17:22 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: drow, tromey, gdb-patches > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > Cc: Eli Zaretskii <eliz@gnu.org>, tromey@redhat.com, > gdb-patches@sourceware.org > Date: Wed, 20 May 2009 12:10:33 -0300 > > Ah, I didn't think of python-frame.c. It didn't exist when I did this > back then. :-( There are also value.c and utils.c. > The right solution then is to make them not share a namespace. Alternatively, we could use the following band-aid: python-cmd.c -> pycmd.c python-frame.c -> pyframe.c python-function.c -> pyfunction.c python-internal.h -> pyinternal.h python-utils.c -> pyutils.c python-value.c -> pyvalue.c python.c -> python.c python.h -> python.h WDYT? ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 17:22 ` Eli Zaretskii @ 2009-05-20 19:39 ` Thiago Jung Bauermann 2009-05-20 20:00 ` Eli Zaretskii 0 siblings, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-20 19:39 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, tromey, gdb-patches Em Qua, 2009-05-20 Ã s 20:22 +0300, Eli Zaretskii escreveu: > > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > > Cc: Eli Zaretskii <eliz@gnu.org>, tromey@redhat.com, > > gdb-patches@sourceware.org > > Date: Wed, 20 May 2009 12:10:33 -0300 > > > > The right solution then is to make them not share a namespace. > > Alternatively, we could use the following band-aid: > > python-cmd.c -> pycmd.c > python-frame.c -> pyframe.c > python-function.c -> pyfunction.c > python-internal.h -> pyinternal.h > python-utils.c -> pyutils.c > python-value.c -> pyvalue.c > python.c -> python.c > python.h -> python.h > > WDYT? Not too bad, looks reasonably good. But first I'd like to see if we can fix the problem without a band-aid. 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? -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 19:39 ` Thiago Jung Bauermann @ 2009-05-20 20:00 ` Eli Zaretskii 2009-05-20 20:49 ` Thiago Jung Bauermann 2009-05-31 22:26 ` Thiago Jung Bauermann 0 siblings, 2 replies; 24+ messages in thread From: Eli Zaretskii @ 2009-05-20 20:00 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: drow, tromey, gdb-patches > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > 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. ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 20:00 ` Eli Zaretskii @ 2009-05-20 20:49 ` Thiago Jung Bauermann 2009-05-20 23:11 ` Joel Brobecker 2009-05-31 22:26 ` Thiago Jung Bauermann 1 sibling, 1 reply; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-20 20:49 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, tromey, gdb-patches, Joel Brobecker Em Qua, 2009-05-20 Ã s 23:00 +0300, Eli Zaretskii escreveu: > > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > > 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. Joel, can I add a bullet about renaming the Python source and testcase files before 7.0 to the release tracking page on the wiki? -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 20:49 ` Thiago Jung Bauermann @ 2009-05-20 23:11 ` Joel Brobecker 0 siblings, 0 replies; 24+ messages in thread From: Joel Brobecker @ 2009-05-20 23:11 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Eli Zaretskii, drow, tromey, gdb-patches > Joel, can I add a bullet about renaming the Python source and testcase > files before 7.0 to the release tracking page on the wiki? Sure! -- Joel ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 20:00 ` Eli Zaretskii 2009-05-20 20:49 ` Thiago Jung Bauermann @ 2009-05-31 22:26 ` Thiago Jung Bauermann 2009-05-31 22:37 ` Thiago Jung Bauermann 2009-06-04 18:03 ` Tom Tromey 1 sibling, 2 replies; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-31 22:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, tromey, gdb-patches Em Qua, 2009-05-20 Ã s 23:00 +0300, Eli Zaretskii escreveu: > > From: Thiago Jung Bauermann <bauerman@br.ibm.com> > > 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 +} ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-31 22:26 ` Thiago Jung Bauermann @ 2009-05-31 22:37 ` Thiago Jung Bauermann 2009-06-04 18:03 ` Tom Tromey 1 sibling, 0 replies; 24+ messages in thread From: Thiago Jung Bauermann @ 2009-05-31 22:37 UTC (permalink / raw) To: Eli Zaretskii; +Cc: drow, tromey, gdb-patches Em Dom, 2009-05-31 Ã s 19:13 -0300, Thiago Jung Bauermann escreveu: > 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. Sorry, forgot to update the ChangeLog entry. Here's the correct one: gdb/testsuite/ * lib/python-support.exp: New file. * lib/gdb.exp: Load lib/python-support.exp * gdb.python/python.exp: Use Python test functions from lib/python-support.exp instead of defining its own functions. * gdb.python/python-cmd.exp: Likewise. * gdb.python/python-frame.exp: Likewise. * gdb.python/python-function.exp: Likewise. * gdb.python/python-template.exp: Likewise. * gdb.python/python-value.exp: Likewise. -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-31 22:26 ` Thiago Jung Bauermann 2009-05-31 22:37 ` Thiago Jung Bauermann @ 2009-06-04 18:03 ` Tom Tromey 1 sibling, 0 replies; 24+ messages in thread From: Tom Tromey @ 2009-06-04 18:03 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Eli Zaretskii, drow, gdb-patches >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes: Thiago> Great. This is the latest version of the patch then, which Thiago> addresses all comments on it. Thiago> Index: gdb.git/gdb/testsuite/lib/python-support.exp Thiago> =================================================================== Thiago> --- /dev/null 1970-01-01 00:00:00.000000000 +0000 Thiago> +++ gdb.git/gdb/testsuite/lib/python-support.exp 2009-05-31 19:01:31.000000000 -0300 Thiago> @@ -0,0 +1,53 @@ Thiago> +global python_supported_saved This file needs a copyright header. Ok with that change. Thanks. Tom ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp. 2009-05-20 15:10 ` Thiago Jung Bauermann 2009-05-20 17:22 ` Eli Zaretskii @ 2009-05-28 0:43 ` Tom Tromey 1 sibling, 0 replies; 24+ messages in thread From: Tom Tromey @ 2009-05-28 0:43 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Daniel Jacobowitz, Eli Zaretskii, gdb-patches >>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes: Thiago> The right solution then is to make them not share a namespace. Thiago> Tromey, you're the makefile wizard: is there an easy and painless way to Thiago> make object files which come from different source directories in gdb/ Thiago> to have different pathnames? In our case, the python object files all have explicit rules. So, changing the target names should be pretty easy. Tom ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2009-06-04 18:03 UTC | newest] Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2009-04-19 15:21 [rfa][testsuite] Consolidade Python test functions in lib/gdb.exp Thiago Jung Bauermann 2009-04-20 17:13 ` Tom Tromey 2009-04-20 17:23 ` Daniel Jacobowitz 2009-05-18 4:38 ` Thiago Jung Bauermann 2009-05-18 18:11 ` Eli Zaretskii 2009-05-19 14:50 ` Thiago Jung Bauermann 2009-05-19 14:59 ` Daniel Jacobowitz 2009-05-19 19:22 ` Eli Zaretskii 2009-05-19 22:21 ` Thiago Jung Bauermann 2009-05-20 3:11 ` Eli Zaretskii 2009-05-20 3:26 ` Thiago Jung Bauermann 2009-05-20 3:39 ` Daniel Jacobowitz 2009-05-20 13:18 ` Thiago Jung Bauermann 2009-05-20 14:59 ` Daniel Jacobowitz 2009-05-20 15:10 ` Thiago Jung Bauermann 2009-05-20 17:22 ` Eli Zaretskii 2009-05-20 19:39 ` Thiago Jung Bauermann 2009-05-20 20:00 ` Eli Zaretskii 2009-05-20 20:49 ` Thiago Jung Bauermann 2009-05-20 23:11 ` Joel Brobecker 2009-05-31 22:26 ` Thiago Jung Bauermann 2009-05-31 22:37 ` Thiago Jung Bauermann 2009-06-04 18:03 ` Tom Tromey 2009-05-28 0:43 ` Tom Tromey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox