gdb/gdb-testsuite-fix-gdb.base-empty-host-env-vars.exp.patch
Tom de Vries f61a679e8e - Maintenance script qa.sh:
* Fix 16.0 handling.
- Patches added:
  * gdb-testsuite-fix-gdb.python-py-format-string.exp-wi.patch
  * gdb-testsuite-fix-gdb.python-py-mi-cmd.exp-with-pyth.patch
  * gdb-testsuite-fix-gdb.ada-mi_task_arg.exp-on-arm-lin.patch
  * gdb-testsuite-fix-regexp-in-gdb.ada-mi_var_access.ex.patch
  * gdb-testsuite-check-gnatmake-version-in-gdb.ada-scal.patch
  * gdb-testsuite-fix-gdb.arch-arm-pseudo-unwind.exp-wit.patch
  * gdb-symtab-fix-target-type-of-complex-long-double-on.patch
  * gdb-testsuite-don-t-use-set-auto-solib-add-off.patch
  * gdb-tdep-fix-arm-thumb2-hw-breakpoint.patch
  * gdb-testsuite-fix-gdb.cp-m-static.exp-on-arm.patch
  * gdb-testsuite-fix-gdb.dwarf2-dw2-fixed-point.exp-on-.patch
  * gdb-testsuite-fix-gdb.dwarf2-dw2-lines.exp-on-arm-li.patch
  * gdb-exp-fix-gdb.fortran-intrinsics.exp-fail-on-arm.patch
  * gdb-tdep-handle-sycall-statx-for-arm-linux.patch
  * gdb-tdep-fix-recording-of-t1-push.patch
  * gdb-tdep-handle-syscall-clock_gettime64-for-arm-linu.patch
  * fix-gdb.dwarf2-shortpiece.exp-on-s390x.patch
  * handle-address-class-annotation-for-s390x-in-some-te.patch
  * fix-gdb.dap-step-out.exp-on-s390x.patch
  * use-setvariable-in-gdb.dap-scopes.exp.patch
  * fix-gdb.base-finish-pretty.exp-on-s390x.patch
  * fix-gdb.base-readnever.exp-on-s390x.patch
  * add-dwarf_expr_piece.op.patch
  * add-gdbarch_dwarf2_reg_piece_offset-hook.patch
  * fix-gdb.base-store.exp-on-s390x.patch
  * fix-gdb.ada-o2_float_param.exp-on-s390x-linux.patch
  * gdb-testsuite-fix-gdb.base-branch-to-self.exp-on-arm.patch
  * gdb-tdep-fix-gdb.cp-non-trivial-retval.exp-on-riscv6.patch
  * gdb-testsuite-fix-gdb.cp-non-trivial-retval.exp-on-a.patch
  * gdb-testsuite-fix-gdb.rust-completion.exp-timeout-on.patch
  * gdb-testsuite-require-supports_process_record-in-gdb.patch
  * gdb-testsuite-fix-regexp-in-gdb.arch-i386-disp-step-.patch
  * gdb-testsuite-fix-gdb.arch-arm-single-step-kernel-he.patch
  * gdb-testsuite-fix-gdb.python-py-format-address.exp-o.patch
  * gdb-testsuite-fix-gdb.arch-riscv-tdesc-regs.exp.patch
  * gdb-testsuite-fix-gdb.base-list-dot-nodebug-and-make.patch
  * gdb-testsuite-fix-gdb.base-list-dot-nodebug.exp-on-o.patch
  * gdb-testsuite-fix-gdb.base-empty-host-env-vars.exp.patch
  * gdb-prune-inferior-after-switching-inferior.patch
  * gdb-testsuite-use-nostdlib-in-gdb.base-list-dot-node.patch
  * gdb-testsuite-fix-timeout-in-gdb.mi-mi-multi-command.patch
  * gdb-testsuite-require-can_spawn_for_attach-in-gdb.ba.patch
  * fixup-gdb-6.5-gcore-buffer-limit-test.patch
  * gdb-testsuite-fix-gdb.ada-big_packed_array.exp-on-s3.patch
  * gdb-testsuite-fix-gdb.ada-convvar_comp.exp-on-s390x-.patch
  * gdb-testsuite-fix-regexp-in-gdb.threads-stepi-over-c.patch

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gdb?expand=0&rev=437
2025-02-13 14:36:11 +00:00

133 lines
4.5 KiB
Diff

From bb7497a27dc37f9775c2c00ecb464b7b44a9e8bb Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Mon, 23 Sep 2024 07:57:49 +0200
Subject: [PATCH 38/46] [gdb/testsuite] Fix gdb.base/empty-host-env-vars.exp
On aarch64-linux (debian testing) with test-case
gdb.base/empty-host-env-vars.exp I ran into:
...
(gdb) show index-cache directory^M
The directory of the index cache is "/home/linux/.cache/gdb".^M
(gdb) FAIL: $exp: env_var_name=HOME: show index-cache directory
...
Without changing any environment variables, the value of the index-cache dir
is:
...
$ gdb -q -batch -ex "show index-cache directory"
The directory of the index cache is "/home/linux/.cache/gdb".
...
and the expectation of the test-case is that setting HOME to empty will
produce an empty dir, but what it actually produces is:
...
$ HOME= gdb -q -batch -ex "show index-cache directory"
The directory of the index cache is "/home/linux/.cache/gdb".
...
There's nothing wrong with that behaviour, the dir is simply constructed using
XDG_CACHE_HOME which happens to be explictly set to its default value
$HOME/.cache [1]:
...
$ echo $XDG_CACHE_HOME
/home/linux/.cache
...
and indeed also setting that variable to empty gets us the expected empty dir:
...
$ XDG_CACHE_HOME= HOME= gdb -q -batch -ex "show index-cache directory"
gdb: warning: Couldn't determine a path for the index cache directory.
The directory of the index cache is "".
...
Furthermore, the test-case assumption that setting variables to empty either
produces the original dir or an empty dir is incorrect.
Say that XDG_CACHE_HOME has a non-default value:
...
$ echo $XDG_CACHE_HOME
/home/linux/my-xdg-cache-home
$ gdb -q -batch -ex "show index-cache directory"
The directory of the index cache is "/home/linux/my-xdg-cache-home/gdb".
...
then setting that variable to empty:
...
$ XDG_CACHE_HOME= gdb -q -batch -ex "show index-cache directory"
The directory of the index cache is "/home/linux/.cache/gdb".
...
does change the value of the dir.
Fix this by making the test-case less specific.
While we're at it, factor out regexps re_pre and re_post to make regexps more
readable, and use string_to_regexp to reduce quoting.
Tested on aarch64-linux.
PR testsuite/32132
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32132
[1] https://specifications.freedesktop.org/basedir-spec/latest/index.html#variables
---
.../gdb.base/empty-host-env-vars.exp | 32 ++++++-------------
1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/gdb/testsuite/gdb.base/empty-host-env-vars.exp b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
index e6e9d6e3156..5fab65a3607 100644
--- a/gdb/testsuite/gdb.base/empty-host-env-vars.exp
+++ b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
@@ -21,16 +21,14 @@ require {!is_remote host}
set all_env_vars { HOME XDG_CACHE_HOME LOCALAPPDATA XDG_CONFIG_HOME }
-# Record the initial value of the index-cache directory.
+set re_pre \
+ [string_to_regexp {The directory of the index cache is "}]
+set re_post \
+ [string_to_regexp {".}]
+
+# Show the initial value of the index-cache directory.
clean_restart
-set index_cache_directory ""
-gdb_test_multiple "show index-cache directory" "" {
- -re -wrap "The directory of the index cache is \"(.*)\"\\." {
- set index_cache_directory $expect_out(1,string)
- set index_cache_directory [string_to_regexp $index_cache_directory]
- pass $gdb_test_name
- }
-}
+gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
foreach_with_prefix env_var_name $all_env_vars {
# Restore the original state of the environment variable.
@@ -38,18 +36,7 @@ foreach_with_prefix env_var_name $all_env_vars {
set env($env_var_name) {}
clean_restart
- # Verify that the empty environment variable didn't affect the
- # index-cache directory setting, that we still see the initial value.
- # "HOME" is different, because if that one is unset, GDB isn't even
- # able to compute the default location. In that case, we expect it to
- # be empty.
- if { $env_var_name == "HOME" } {
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"\"\\."
- } else {
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"$index_cache_directory\"\\."
- }
+ gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
}
}
@@ -69,7 +56,6 @@ with_test_prefix "all env vars" {
clean_restart
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"\"\\."
+ gdb_test "show index-cache directory" $re_pre$re_post
}
}
--
2.43.0