diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2017-01-26 16:12:12 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-01-26 16:12:12 -0500 |
commit | 72ca04104418e4926790872a203f404af9453024 (patch) | |
tree | e1315a30ae264a92846f1c92b83ecb7b9b15df71 /gdb | |
parent | e3ceef3544fb2178cef284b5fb8b267bf0ab4397 (diff) | |
download | gdb-72ca04104418e4926790872a203f404af9453024.zip gdb-72ca04104418e4926790872a203f404af9453024.tar.gz gdb-72ca04104418e4926790872a203f404af9453024.tar.bz2 |
Change method of loading .py files in Python tests
With my debug build of Python (--with-pydebug), many tests fails because
of the same issue. Python scripts are loaded by the tests using this
pattern:
(gdb) python exec (open ('file.py').read ())
This causes Python to output this warning:
__main__:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='file.py' mode='r' encoding='ANSI_X3.4-1968'>
and the test to fail because of that extra output. Instead of using the
open + read + exec trick which leaks the file and causes the warning,
why not just source the files?
(gdb) source file.py
This patch changes this, and standardizes the test names of the tests I
touched to "load python file" (some of them were empty, others were
overly complicated).
gdb/testsuite/ChangeLog:
* gdb.python/py-bad-printers.exp: Load python file using "source".
* gdb.python/py-events.exp: Likewise.
* gdb.python/py-evsignal.exp: Likewise.
* gdb.python/py-evthreads.exp: Likewise.
* gdb.python/py-frame-args.exp: Likewise.
* gdb.python/py-framefilter-invalidarg.exp: Likewise.
* gdb.python/py-framefilter-mi.exp: Likewise.
* gdb.python/py-framefilter.exp: Likewise.
* gdb.python/py-mi.exp: Likewise.
* gdb.python/py-pp-maint.exp: Likewise.
* gdb.python/py-pp-registration.exp: Likewise.
* gdb.python/py-prettyprint.exp: Likewise.
(run_lang_tests): Likewise.
* gdb.python/py-typeprint.exp: Likewise.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/ChangeLog | 17 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-bad-printers.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-evsignal.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-evthreads.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-frame-args.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-framefilter-mi.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-framefilter.exp | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-mi.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-pp-maint.exp | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-pp-registration.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-prettyprint.exp | 6 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-typeprint.exp | 3 |
14 files changed, 32 insertions, 24 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3427db8..ec5a8d7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,20 @@ +2017-01-26 Simon Marchi <simon.marchi@polymtl.ca> + + * gdb.python/py-bad-printers.exp: Load python file using "source". + * gdb.python/py-events.exp: Likewise. + * gdb.python/py-evsignal.exp: Likewise. + * gdb.python/py-evthreads.exp: Likewise. + * gdb.python/py-frame-args.exp: Likewise. + * gdb.python/py-framefilter-invalidarg.exp: Likewise. + * gdb.python/py-framefilter-mi.exp: Likewise. + * gdb.python/py-framefilter.exp: Likewise. + * gdb.python/py-mi.exp: Likewise. + * gdb.python/py-pp-maint.exp: Likewise. + * gdb.python/py-pp-registration.exp: Likewise. + * gdb.python/py-prettyprint.exp: Likewise. + (run_lang_tests): Likewise. + * gdb.python/py-typeprint.exp: Likewise. + 2017-01-26 Luis Machado <lgustavo@codesourcery.com> * lib/memory.exp: New file. diff --git a/gdb/testsuite/gdb.python/py-bad-printers.exp b/gdb/testsuite/gdb.python/py-bad-printers.exp index ecc259e..0e39763 100644 --- a/gdb/testsuite/gdb.python/py-bad-printers.exp +++ b/gdb/testsuite/gdb.python/py-bad-printers.exp @@ -35,8 +35,7 @@ if ![runto_main ] then { set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "load python file" +gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_breakpoint [gdb_get_line_number "break here"] gdb_continue_to_breakpoint "break here" ".* break here .*" diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 12936f3..16ea110 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -43,7 +43,7 @@ clean_restart ${testfile} if { [skip_python_tests] } { continue } -gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" +gdb_test_no_output "source ${pyfile}" "load python file" gdb_test "test-objfile-events" "Object file events registered." diff --git a/gdb/testsuite/gdb.python/py-evsignal.exp b/gdb/testsuite/gdb.python/py-evsignal.exp index 65a558c..8a39f4e 100644 --- a/gdb/testsuite/gdb.python/py-evsignal.exp +++ b/gdb/testsuite/gdb.python/py-evsignal.exp @@ -31,7 +31,7 @@ clean_restart $testfile if { [skip_python_tests] } { continue } -gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" +gdb_test_no_output "source ${pyfile}" "load python file" gdb_test "test-events" "Event testers registered." gdb_test_no_output "set non-stop on" diff --git a/gdb/testsuite/gdb.python/py-evthreads.exp b/gdb/testsuite/gdb.python/py-evthreads.exp index 1ebab40..64b2af5 100644 --- a/gdb/testsuite/gdb.python/py-evthreads.exp +++ b/gdb/testsuite/gdb.python/py-evthreads.exp @@ -36,7 +36,7 @@ clean_restart $testfile if { [skip_python_tests] } { continue } -gdb_test_no_output "python exec (open ('${pyfile}').read ())" "" +gdb_test_no_output "source ${pyfile}" "load python file" gdb_test "test-events" "Event testers registered." gdb_test_no_output "set non-stop on" diff --git a/gdb/testsuite/gdb.python/py-frame-args.exp b/gdb/testsuite/gdb.python/py-frame-args.exp index 91f200f..08f2171 100644 --- a/gdb/testsuite/gdb.python/py-frame-args.exp +++ b/gdb/testsuite/gdb.python/py-frame-args.exp @@ -29,8 +29,7 @@ if ![runto_main] { set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "python exec (open ('[file tail ${remote_python_file}]').read ())" +gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_breakpoint [gdb_get_line_number "break-here"] gdb_continue_to_breakpoint "break-here" ".* break-here .*" diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp index bf9d076..881ebe4 100644 --- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp +++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp @@ -61,7 +61,6 @@ gdb_test_no_output "set python print-stack full" \ # Load global frame-filters set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "load python file" +gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_test "bt" " in niam \\(argc=<error reading variable: dwarf expression stack underflow>, argv=0x\[0-9a-f\]+\\) at py-framefilter-invalidarg.c:\[0-9\]+" "bt full with filters" diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp index eef7a1e..91e07dd 100644 --- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp +++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp @@ -46,8 +46,7 @@ mi_runto main set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}] -mi_gdb_test "python exec (open ('${remote_python_file}').read ())" ".*\\^done." \ - "Load python file" +mi_gdb_test "source ${remote_python_file}" ".*\\^done." "load python file" # Multiple blocks test mi_continue_to_line [gdb_get_line_number {Inner test breakpoint} ${srcfile}] \ diff --git a/gdb/testsuite/gdb.python/py-framefilter.exp b/gdb/testsuite/gdb.python/py-framefilter.exp index 76184c0..bbec48d 100644 --- a/gdb/testsuite/gdb.python/py-framefilter.exp +++ b/gdb/testsuite/gdb.python/py-framefilter.exp @@ -63,8 +63,7 @@ gdb_test_no_output "set python print-stack full" \ # Load global frame-filters set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "load python file" +gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"] gdb_breakpoint [gdb_get_line_number "Inner test breakpoint"] @@ -253,7 +252,7 @@ gdb_test_no_output "set python print-stack full" \ # Load global frame-filters set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ +gdb_test_no_output "source ${remote_python_file}" \ "load python file for no debuginfo tests" # Disable Reverse diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp index 920e9d6..736dc7a 100644 --- a/gdb/testsuite/gdb.python/py-mi.exp +++ b/gdb/testsuite/gdb.python/py-mi.exp @@ -44,7 +44,7 @@ mi_runto main set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}] -mi_gdb_test "python exec (open ('${remote_python_file}').read ())" "" +mi_gdb_test "source ${remote_python_file}" "load python file" mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${srcfile}] \ "step to breakpoint" diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp index ba0d0f0..6ca0ee6 100644 --- a/gdb/testsuite/gdb.python/py-pp-maint.exp +++ b/gdb/testsuite/gdb.python/py-pp-maint.exp @@ -43,7 +43,7 @@ gdb_test "continue" ".*Breakpoint.*" set python_file ${srcdir}/${subdir}/${testfile}.py -gdb_test_no_output "python exec (open ('${python_file}').read ())" "" +gdb_test_no_output "source ${python_file}" "load python file" gdb_test "info pretty-printer" \ {.*function_lookup_test.*pp-test.*struct ss.*} diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp index def4416..0bd6d87 100644 --- a/gdb/testsuite/gdb.python/py-pp-registration.exp +++ b/gdb/testsuite/gdb.python/py-pp-registration.exp @@ -46,8 +46,7 @@ proc prepare_test { } { return 0 } - gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "read file" + gdb_test_no_output "source ${remote_python_file}" "read file" gdb_test_no_output "py progspace = gdb.current_progspace()" gdb_test_no_output "py my_pretty_printer1 = build_pretty_printer1()" diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index 2ba2a8f..b0a9e32 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -56,8 +56,7 @@ proc run_lang_tests {exefile lang} { set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] - gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "python exec (open ('[file tail ${remote_python_file}]').read ())" + gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>" @@ -137,8 +136,7 @@ if ![runto_main ] then { set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "python exec (open ('[file tail ${remote_python_file}]').read ())" +gdb_test_no_output "source ${remote_python_file}" "load python file" gdb_breakpoint [gdb_get_line_number "eval-break"] gdb_continue_to_breakpoint "eval-break" ".* eval-break .*" diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp index 73db732..28e5053 100644 --- a/gdb/testsuite/gdb.python/py-typeprint.exp +++ b/gdb/testsuite/gdb.python/py-typeprint.exp @@ -29,8 +29,7 @@ if { [skip_python_tests] } { continue } set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -gdb_test_no_output "python exec (open ('${remote_python_file}').read ())" \ - "python exec (open ('[file tail ${remote_python_file}]').read ())" +gdb_test_no_output "source ${remote_python_file}" "load python file" cp_test_ptype_class s "basic test" "class" "templ<string>" { { field public "T x;" } |