[pushed,gdb/testsuite] Fix failure in gdb.python/py-startup-opt.exp

Message ID 20241204092115.14629-1-tdevries@suse.de
State Committed
Headers
Series [pushed,gdb/testsuite] Fix failure in gdb.python/py-startup-opt.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom de Vries Dec. 4, 2024, 9:21 a.m. UTC
  In commit 922ab963e1c ("[gdb/python] Handle empty PYTHONDONTWRITEBYTECODE") I
added a test in gdb.python/py-startup-opt.exp that checks the
"show python dont-write-bytecode" output.

Then in commit 348290c7ef4 ("[gdb/python] Warn and ignore ineffective python
settings") I changed the output of "show python dont-write-bytecode" after
python initialization.

I tested these changes individually, and found no problems but after
committing both the test started failing, which the Linaro CI reported.

Fix this by updating the expected output.

While we're at it, make the test a bit more generic by testing
"show python $setting" in all cases.

Tested on x86_64-linux, using:
- PYTHONDONTWRITEBYTECODE=
- PYTHONDONTWRITEBYTECODE=1
- unset PYTHONDONTWRITEBYTECODE
---
 gdb/testsuite/gdb.python/py-startup-opt.exp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)


base-commit: 0c57d55c4479231bd63d6623d1bfbcb340ffdb20
  

Patch

diff --git a/gdb/testsuite/gdb.python/py-startup-opt.exp b/gdb/testsuite/gdb.python/py-startup-opt.exp
index df35a378658..038814a1d63 100644
--- a/gdb/testsuite/gdb.python/py-startup-opt.exp
+++ b/gdb/testsuite/gdb.python/py-startup-opt.exp
@@ -94,13 +94,15 @@  proc test_python_settings { exp_state } {
 	    "  print (\"${attr} is off\")" "" \
 	    "end" "${attr} is ${answer}"
 
-	if { $attr == "dont_write_bytecode" && $exp_state == "off" } {
+	if { $attr == "dont_write_bytecode" } {
 	    set setting dont-write-bytecode
-	    set show_setting \
-		"Python's $setting setting is auto (currently $answer)."
-	    gdb_test "show python $setting" \
-		[string_to_regexp $show_setting]
+	} else {
+	    set setting ignore-environment
 	}
+	set show_setting \
+	    "Python's $setting setting is $answer."
+	gdb_test "show python $setting" \
+	    [string_to_regexp $show_setting]
     }
 
     gdb_exit