This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3] Make environ.exp run on all platforms (and create info-program.exp)


On 04/26/2017 11:28 PM, Sergio Durigan Junior wrote:
> Changes since v2:
> 
> - Removed \t when matching the output of 'info program'.
> 
> This has been on my TODO list for a while.  There's a really old bug
> about this (PR testsuite/8595), and there was no reason for
> environ.exp to be specific for hppa* targets.  So this patch removes
> this constraint, modernizes the testcase, and cleans up some things.
> Most of the tests remained, and some were rewritten (especially the
> one that checks if "show environment" works, which is something kind
> of hard to do).

It'd be good to cross check for overlap with gdb.base/testenv.exp.

>  # Verify that we can show all currently-set environment variables.
> -# (It's a bit hacky, but nonetheless probably safe to check for at
> -# least the SHELL variable.)
> -#
> -# need to increase timeout because of very long output
> -set oldtimeout $timeout
> -set timeout [expr "$timeout + 300"]
> -
> -send_gdb "show environment\n"
> -gdb_expect {
> -  -re ".*SHELL=(\[a-zA-Z0-9\]*).*$gdb_prompt $"\
> -          {pass "show environment"}
> -  -re "$gdb_prompt $"\
> -          {fail "show environment"}
> -  timeout {fail "(timeout) show environment"}
> -}
> -set timeout $oldtimeout
> +# 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"

We can easily set a variable in the environment before spawning GDB.
We'd just have to limit that specific test to when not testing with a
remote host, I think?  See gdb.base/gdbhistsize-history.exp for example.

> +gdb_test_multiple "unset environment" $msg {
> +    -re "Delete all environment variables.*y or n.*$" {
> +	gdb_test_no_output "y" $msg
> +    }
> +    -re "$gdb_prompt $" {
> +	fail $msg
> +    }
>  }

The '-re "$gdb_prompt $"' part is not necessary because
gdb_test_multiple already does that by default.
And then you can use gdb_test for this:

  gdb_test "unset environment" "" $msg \
    "Delete all environment variables. .y or n. $" \
    "y"

> -# Verify that GDB can manipulate the distinguished PATH variable.
> -#
> -send_gdb "path /tmp/FOOBARBAZGRUNGESPAZBALL\n"
> -gdb_expect {
> -  -re ".*Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
> -          {pass "issue path"}
> -  -re "$gdb_prompt $"\
> -          {fail "issue path"}
> -  timeout {fail "(timeout) issue path"}
> -}
> -send_gdb "show paths\n"
> -gdb_expect {
> -  -re "Executable and object file path: /tmp/FOOBARBAZGRUNGESPAZBALL.*$gdb_prompt $"\
> -          {pass "show paths"}
> -  -re "$gdb_prompt $"\
> -          {fail "show paths"}
> -  timeout {fail "(timeout) show paths"}

Any reason these "path" command tests are dropped?
(AFAICS, the MI equivalent is tested by gdb.mi/mi-basics.exp).

> -}
> +gdb_test_no_output "set environment FOOBARBAZGRUNGESPAZBALL =        foo" \
> +    "set environment variable with trailing whitespace"
> +gdb_test "show environment FOOBARBAZGRUNGESPAZBALL" \
> +    "FOOBARBAZGRUNGESPAZBALL = foo" \
> +    "confirm set environment variable with trailing whitespace"
>  
>  gdb_exit
>  return 0
> diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp
> new file mode 100644
> index 0000000..e5e5fb9
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/info-program.exp
> @@ -0,0 +1,45 @@
> +# Copyright 2017 Free Software Foundation, Inc.

If the moved code is based on older code, the original copyright year
must be preserved.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]