* [PATCH v2] Rewrite the "show environment" test
@ 2025-12-09 18:02 Tom Tromey
2025-12-09 18:22 ` Simon Marchi
2025-12-10 8:30 ` Aktemur, Tankut Baris
0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2025-12-09 18:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
In a review early in the year:
https://inbox.sourceware.org/gdb-patches/874iz3f4ek.fsf@redhat.com/
Andrew pointed out that a new test I proposed failed with read1.
This test was essentially a copy of gdb.base/environ.exp.
I couldn't reproduce the read1 problem, but this patch rewrites the
one test there that seems like it could possibly fail in this mode.
Now it uses line-by-line mode and checks for a certain environment
variable appearing in the output.
---
gdb/testsuite/gdb.base/environ.exp | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp
index 36cc5f48813..091010acfda 100644
--- a/gdb/testsuite/gdb.base/environ.exp
+++ b/gdb/testsuite/gdb.base/environ.exp
@@ -13,7 +13,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
-gdb_start
+# Make sure there is at least one environment variable.
+save_vars { env(GDB_TEST_ENV_VAR) } {
+ setenv GDB_TEST_ENV_VAR abc
+ gdb_start
+}
proc test_set_show_env_var { name value test_name } {
gdb_test_no_output "set environment $name $value" "$test_name"
@@ -29,11 +33,20 @@ proc test_set_show_env_var_equal { name value test_name } {
# Verify that we can show all currently-set environment variables.
# It's hard to do this verification since we can't really compare each
-# entry with the current environment. So we just check to see if
-# there is anything that looks like an environment variable being
-# printed.
-gdb_test "show environment" "(\[A-Za-z_\]+=.*)+" \
- "show environment works"
+# entry with the current environment. So we just check to see if the
+# environment variable we set at startup is printed.
+set saw_env 0
+gdb_test_multiple "show environment" "show environment works" -lbl {
+ -re "\r\nGDB_TEST_ENV_VAR=abc" {
+ incr saw_env 1
+ exp_continue
+ }
+
+ -re "\r\n$gdb_prompt $" {
+ }
+}
+
+gdb_assert {$saw_env == 1} "show environment displayed variable"
# Verify that we can unset a specific environment variable.
gdb_test_no_output "unset environment EDITOR" "unset environment variable"
base-commit: 8eeed95625ab7283032ed73e8866ace82daf30aa
--
2.52.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Rewrite the "show environment" test
2025-12-09 18:02 [PATCH v2] Rewrite the "show environment" test Tom Tromey
@ 2025-12-09 18:22 ` Simon Marchi
2025-12-10 8:30 ` Aktemur, Tankut Baris
1 sibling, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2025-12-09 18:22 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 12/9/25 1:02 PM, Tom Tromey wrote:
> In a review early in the year:
>
> https://inbox.sourceware.org/gdb-patches/874iz3f4ek.fsf@redhat.com/
>
> Andrew pointed out that a new test I proposed failed with read1.
> This test was essentially a copy of gdb.base/environ.exp.
>
> I couldn't reproduce the read1 problem, but this patch rewrites the
> one test there that seems like it could possibly fail in this mode.
> Now it uses line-by-line mode and checks for a certain environment
> variable appearing in the output.
Seems fine to me.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] Rewrite the "show environment" test
2025-12-09 18:02 [PATCH v2] Rewrite the "show environment" test Tom Tromey
2025-12-09 18:22 ` Simon Marchi
@ 2025-12-10 8:30 ` Aktemur, Tankut Baris
2025-12-11 22:03 ` Tom Tromey
1 sibling, 1 reply; 4+ messages in thread
From: Aktemur, Tankut Baris @ 2025-12-10 8:30 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On Tuesday, December 9, 2025 7:03 PM, Tom Tromey wrote:
> In a review early in the year:
>
> https://inbox.sourceware.org/gdb-patches/874iz3f4ek.fsf@redhat.com/
>
> Andrew pointed out that a new test I proposed failed with read1.
> This test was essentially a copy of gdb.base/environ.exp.
>
> I couldn't reproduce the read1 problem, but this patch rewrites the
> one test there that seems like it could possibly fail in this mode.
> Now it uses line-by-line mode and checks for a certain environment
> variable appearing in the output.
...
> + -re "\r\n$gdb_prompt $" {
I know I'm late and the patch is already merged, but nevertheless:
For a slight simplification, we could have written this case as
-re -wrap "" {
Regards,
-Baris
Intel Deutschland GmbH
Registered Address: Dornacher Straße 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht München HRB 186928
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Rewrite the "show environment" test
2025-12-10 8:30 ` Aktemur, Tankut Baris
@ 2025-12-11 22:03 ` Tom Tromey
0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2025-12-11 22:03 UTC (permalink / raw)
To: Aktemur, Tankut Baris; +Cc: Tom Tromey, gdb-patches
>> + -re "\r\n$gdb_prompt $" {
> I know I'm late and the patch is already merged, but nevertheless:
> For a slight simplification, we could have written this case as
> -re -wrap "" {
I'm sending a patch to do this, thanks.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-11 22:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-09 18:02 [PATCH v2] Rewrite the "show environment" test Tom Tromey
2025-12-09 18:22 ` Simon Marchi
2025-12-10 8:30 ` Aktemur, Tankut Baris
2025-12-11 22:03 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox