Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(973)

Unified Diff: gdb/testsuite/gdb.python/python.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gdb/testsuite/gdb.python/python.c ('k') | gdb/testsuite/gdb.python/python-1.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gdb/testsuite/gdb.python/python.exp
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 9683b1ccf7a66aa75a7d9758a7f8832294aa0978..69ba900c9d7e6da4a8524db5ecc476cf830af0cb 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,10 +30,9 @@ gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
-# Skip all tests if Python scripting is not enabled.
-if { [skip_python_tests] } { continue }
-
-gdb_test_multiple "python print 23" "verify python support" {
+# Do this instead of the skip_python_check.
+# We want to do some tests when Python is not present.
+gdb_test_multiple "python print (23)" "verify python support" {
-re "not supported.*$gdb_prompt $" {
unsupported "python support is disabled"
@@ -49,21 +48,21 @@ gdb_test_multiple "python print 23" "verify python support" {
gdb_py_test_multiple "multi-line python command" \
"python" "" \
- "print 23" "" \
+ "print (23)" "" \
"end" "23"
gdb_py_test_multiple "show python command" \
"define zzq" "Type commands for definition of .* just \"end\"\\.*" \
"python" "" \
- "print 23" "" \
+ "print (23)" "" \
"end" "" \
"end" "" \
- "show user zzq" "User command \"zzq\":.* python.*print 23.* end"
+ "show user zzq" "User command \"zzq\":.* python.*print \\(23\\).* end"
gdb_py_test_multiple "indented multi-line python command" \
"python" "" \
"def foo ():" "" \
- " print 'hello, world!'" "" \
+ " print ('hello, world!')" "" \
"foo ()" "" \
"end" "hello, world!"
@@ -71,15 +70,15 @@ gdb_test "source $srcdir/$subdir/source2.py" "yes" "source source2.py"
gdb_test "source -s source2.py" "yes" "source -s source2.py"
-gdb_test "python print gdb.current_objfile()" "None"
-gdb_test "python print gdb.objfiles()" "\\\[\\\]"
+gdb_test "python print (gdb.current_objfile())" "None"
+gdb_test "python print (gdb.objfiles())" "\\\[\\\]"
# Test http://bugs.python.org/issue4434 workaround in configure.ac
-gdb_test "python import itertools; print 'IMPOR'+'TED'" "IMPORTED" "pythonX.Y/lib-dynload/*.so"
+gdb_test "python import itertools; print ('IMPOR'+'TED')" "IMPORTED" "pythonX.Y/lib-dynload/*.so"
gdb_test_no_output \
"python x = gdb.execute('printf \"%d\", 23', to_string = True)"
-gdb_test "python print x" "23"
+gdb_test "python print (x)" "23"
# Test post_event.
gdb_py_test_multiple "post event insertion" \
@@ -92,7 +91,7 @@ gdb_py_test_multiple "post event insertion" \
"gdb.post_event(Foo())" "" \
"end" ""
-gdb_test "python print someVal" "1" "test post event execution"
+gdb_test "python print (someVal)" "1" "test post event execution"
gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" "Test non callable class"
# Test (no) pagination of the executed command.
@@ -101,7 +100,7 @@ set lines 10
gdb_test_no_output "set height $lines"
set test "verify pagination beforehand"
-gdb_test_multiple "python print \"\\n\" * $lines" $test {
+gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
-re "---Type <return>" {
exp_continue
}
@@ -114,10 +113,10 @@ gdb_test_multiple "python print \"\\n\" * $lines" $test {
}
gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q"
-gdb_test "python if gdb.execute('python print \"\\\\n\" * $lines', to_string=True) == \"\\n\" * [expr $lines + 1]: print \"yes\"" "yes" "gdb.execute does not page"
+gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page"
set test "verify pagination afterwards"
-gdb_test_multiple "python print \"\\n\" * $lines" $test {
+gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
-re "---Type <return>" {
exp_continue
}
@@ -134,12 +133,30 @@ gdb_test_no_output "set height 0"
gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect help from uiout"
-gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "verify help to uiout"
+gdb_test "python print (a)" ".*aliases -- Aliases of other commands.*" "verify help to uiout"
# Test PR 12212, using InfThread.selected_thread() when no inferior is
# loaded.
gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1
-gdb_test "python print nothread == None" "True" "Ensure that no threads are returned"
+gdb_test "python print (nothread == None)" "True" "Ensure that no threads are returned"
+
+gdb_py_test_multiple "register atexit function" \
+ "python" "" \
+ "import atexit" "" \
+ "def printit(arg):" "" \
+ " print (arg)" "" \
+ "atexit.register(printit, 'good bye world')" "" \
+ "end" ""
+
+send_gdb "quit\n"
+gdb_expect {
+ -re "good bye world" {
+ pass "atexit handling"
+ }
+ default {
+ fail "atexit handling"
+ }
+}
# Start with a fresh gdb.
clean_restart ${testfile}
@@ -158,47 +175,41 @@ gdb_test "python gdb.decode_line(\"main.c:43\")" \
"gdb.error: No source file named main.c.*" "test decode_line no source named main"
gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "test decode_line current location" 1
-gdb_test "python print len(symtab)" "2" "Test decode_line current location"
-gdb_test "python print symtab\[0\]" "None" "Test decode_line expression parse"
-gdb_test "python print len(symtab\[1\])" "1" "Test decode_line current location"
-gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python.c.*" "Test decode_line current locationn filename"
-gdb_test "python print symtab\[1\]\[0\].line" "22" "Test decode_line current location line number"
+gdb_test "python print (len(symtab))" "2" "Test decode_line current location"
+gdb_test "python print (symtab\[0\])" "None" "Test decode_line expression parse"
+gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line current location"
+gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python.c.*" "Test decode_line current locationn filename"
+gdb_test "python print (symtab\[1\]\[0\].line)" "22" "Test decode_line current location line number"
gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"python.c:26 if foo\")" "test decode_line python.c:26" 1
-gdb_test "python print len(symtab)" "2" "Test decode_line python.c:26 length"
-gdb_test "python print symtab\[0\]" "if foo" "Test decode_line expression parse"
-gdb_test "python print len(symtab\[1\])" "1" "Test decode_line python.c:26 length"
-gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python.c.*" "Test decode_line python.c:26 filename"
-gdb_test "python print symtab\[1\]\[0\].line" "26" "Test decode_line python.c:26 line number"
+gdb_test "python print (len(symtab))" "2" "Test decode_line python.c:26 length"
+gdb_test "python print (symtab\[0\])" "if foo" "Test decode_line expression parse"
+gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line python.c:26 length"
+gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python.c.*" "Test decode_line python.c:26 filename"
+gdb_test "python print (symtab\[1\]\[0\].line)" "26" "Test decode_line python.c:26 line number"
gdb_test "python gdb.decode_line(\"randomfunc\")" \
"gdb.error: Function \"randomfunc\" not defined.*" "test decode_line randomfunc"
gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "test decode_line func1()" 1
-gdb_test "python print len(symtab)" "2" "Test decode_line func1 length"
-gdb_test "python print len(symtab\[1\])" "1" "Test decode_line func1 length"
-gdb_test "python print symtab\[1\]\[0\].symtab" ".*gdb.python/python-1.c.*" "Test decode_line func1 filename"
-gdb_test "python print symtab\[1\]\[0\].line" "19" "Test decode_line func1 line number"
+gdb_test "python print (len(symtab))" "2" "Test decode_line func1 length"
+gdb_test "python print (len(symtab\[1\]))" "1" "Test decode_line func1 length"
+gdb_test "python print (symtab\[1\]\[0\].symtab)" ".*gdb.python/python-1.c.*" "Test decode_line func1 filename"
+gdb_test "python print (symtab\[1\]\[0\].line)" "19" "Test decode_line func1 line number"
gdb_py_test_silent_cmd {python symtab = gdb.decode_line ("func1,func2")} \
"test decode_line func1,func2" 1
-gdb_test {python print symtab[0]} ",func2" "stop at comma in linespec"
+gdb_test {python print (symtab[0])} ",func2" "stop at comma in linespec"
# gdb.write
-gdb_test "python print sys.stderr" ".*__main__.GdbOutputErrorFile instance at.*" "Test stderr location"
-gdb_test "python print sys.stdout" ".*__main__.GdbOutputFile instance at.*" "Test stdout location"
+gdb_test "python print (sys.stderr)" ".*gdb.GdbOutputErrorFile (instance|object) at.*" "Test stderr location"
+gdb_test "python print (sys.stdout)" ".*gdb.GdbOutputFile (instance|object) at.*" "Test stdout location"
gdb_test "python gdb.write(\"Foo\\n\")" "Foo" "Test default write"
gdb_test "python gdb.write(\"Error stream\\n\", stream=gdb.STDERR)" "Error stream" "Test stderr write"
gdb_test "python gdb.write(\"Normal stream\\n\", stream=gdb.STDOUT)" "Normal stream" "Test stdout write"
gdb_test "python gdb.write(\"Log stream\\n\", stream=gdb.STDLOG)" "Log stream" "Test stdlog write"
-# print-stack
-gdb_test "show python print-stack" \
- "The mode of Python stack printing on error is \"message\".*" \
- "Test print-backtrace show setting. Default is message."
+# Turn on full stack printing for subsequent tests.
gdb_py_test_silent_cmd "set python print-stack full" \
- "Test print-backtrace set setting" 1
-gdb_test "show python print-stack" \
- "The mode of Python stack printing on error is \"full\".*" \
- "Test print-backtrace show setting to full."
+ "Set print-stack full for prompt tests" 1
# Test prompt substituion
@@ -321,20 +332,20 @@ if ![runto_main] then {
# print-stack settings
gdb_test "show python print-stack" \
"The mode of Python stack printing on error is \"message\".*" \
- "Test print-backtrace show setting. Default is message."
+ "Test print-stack show setting. Default is message."
gdb_py_test_silent_cmd "set python print-stack full" \
- "Test print-backtrace set setting" 1
+ "Test print-stack set setting to full" 1
gdb_test "show python print-stack" \
"The mode of Python stack printing on error is \"full\".*" \
- "Test print-backtrace show setting to full."
+ "Test print-stack show setting to full"
gdb_py_test_silent_cmd "set python print-stack none" \
- "Test print-backtrace set setting" 1
+ "Test print-stack set setting to none" 1
gdb_test "show python print-stack" \
"The mode of Python stack printing on error is \"none\".*" \
- "Test print-backtrace show setting to none."
+ "Test print-stack show setting to none"
gdb_py_test_silent_cmd "set python print-stack message" \
- "Test print-backtrace set setting" 1
+ "Test print-stack set setting to message" 1
gdb_py_test_multiple "prompt substitution readline" \
"python" "" \
@@ -344,7 +355,7 @@ gdb_py_test_multiple "prompt substitution readline" \
"end" ""
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
- -re "Python Exception <type 'exceptions.RuntimeError'> Python exception called.*" {
+ -re "Python Exception (exceptions.RuntimeError|<(type 'exceptions.|class ')RuntimeError'>) Python exception called.*" {
pass "set hook"
}
}
@@ -353,7 +364,7 @@ gdb_py_test_silent_cmd "python gdb.prompt_hook = None" \
"set the hook to default" 1
gdb_py_test_silent_cmd "set python print-stack full" \
- "Test print-backtrace set setting" 1
+ "set print-stack full for prompt error test" 1
gdb_test_multiple "python gdb.prompt_hook = error_prompt" "set the hook" {
-re "Traceback.*File.*line.*RuntimeError.*Python exception called.*" {
@@ -377,9 +388,9 @@ if ![runto_main] then {
runto [gdb_get_line_number "Break at func2 call site."]
gdb_py_test_silent_cmd "python line = gdb.selected_frame().find_sal().line" "Get line number of func2 call site" 1
-gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line == line" "True" "Test find_pc_line at func2 call site"
+gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line == line)" "True" "Test find_pc_line at func2 call site"
gdb_py_test_silent_cmd "step" "Step into func2" 1
gdb_py_test_silent_cmd "up" "Step out of func2" 1
-gdb_test "python print gdb.find_pc_line(gdb.selected_frame().pc()).line > line" "True" "Test find_pc_line with resume address"
+gdb_test "python print (gdb.find_pc_line(gdb.selected_frame().pc()).line > line)" "True" "Test find_pc_line with resume address"
« no previous file with comments | « gdb/testsuite/gdb.python/python.c ('k') | gdb/testsuite/gdb.python/python-1.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698