[4/4] gdb/testsuite: gdb.base/args.exp: add KFAIL for native-extended-gdbserver

Message ID 20210616193751.468795-4-simon.marchi@efficios.com
State New
Headers show
Series
  • [1/4] gdb/testsuite: gdb.base/args.exp: use save_vars
Related show

Commit Message

Simon Marchi via Gdb-patches June 16, 2021, 7:37 p.m.
This test tests passing arguments made of exactly two single-quotes
('') or a single newline character through the --args argument of GDB.
For some reason, GDB adds some extra single quotes when transmitting the
arguments to GDBserver.  This produces some FAILs when testing with the
native-extended-gdbserver board:

    FAIL: gdb.base/args.exp: argv[2] for one empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[2] for two empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[3] for two empty (with single quotes)
    FAIL: gdb.base/args.exp: argv[2] for one newline
    FAIL: gdb.base/args.exp: argv[2] for two newlines
    FAIL: gdb.base/args.exp: argv[3] for two newlines

This is documented as PR 27989.  Add some appropriate KFAILs.

gdb/testsuite/ChangeLog:

	* gdb.base/args.exp: Check target, KFAIL if remote.
	(args_test): Add parameter and use it.

Change-Id: I49225d1c7df7ebaba480ebdd596df80f8fbf62f0
---
 gdb/testsuite/gdb.base/args.exp | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

-- 
2.31.1

Comments

Pedro Alves June 17, 2021, 10:35 a.m. | #1
On 2021-06-16 8:37 p.m., Simon Marchi via Gdb-patches wrote:
> +    # Start GDB just to see if we are using the native or extended-remote target.

> +    clean_restart

> +    set single_quotes_newline_kfail [gdb_is_target_remote]

> +


You don't need to do that.  You can check 

if {[target_info exists gdb_protocol]
    && ([target_info gdb_protocol] == "remote"
        || [target_info gdb_protocol] == "extended-remote")} {


The series looks good to me.

Pedro Alves
Simon Marchi via Gdb-patches June 17, 2021, 1:41 p.m. | #2
On 2021-06-17 6:35 a.m., Pedro Alves wrote:
> On 2021-06-16 8:37 p.m., Simon Marchi via Gdb-patches wrote:

>> +    # Start GDB just to see if we are using the native or extended-remote target.

>> +    clean_restart

>> +    set single_quotes_newline_kfail [gdb_is_target_remote]

>> +

> 

> You don't need to do that.  You can check 

> 

> if {[target_info exists gdb_protocol]

>     && ([target_info gdb_protocol] == "remote"

>         || [target_info gdb_protocol] == "extended-remote")} {


Oh, right.  The "remote" case is not applicable here due to the nature
of the test, so I'll just check for extended-remote:

    set single_quotes_newline_kfail \
	[expr { [target_info exists gdb_protocol] \
	        && [target_info gdb_protocol] == "extended-remote" }]

I'll push with that fixed.

Simon

Patch

diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp
index e76368f544e..29bb5984245 100644
--- a/gdb/testsuite/gdb.base/args.exp
+++ b/gdb/testsuite/gdb.base/args.exp
@@ -34,7 +34,10 @@  if {[build_executable $testfile.exp $testfile \
     return -1
 }
 
-proc args_test { name arglist } {
+# If SINGLE_QUOTES_NEWLINE_KFAIL true, arguments made of exactly '' or a
+# newline character will fail, so kfail those tests.
+
+proc args_test { name arglist {single_quotes_newline_kfail false}} {
     global srcdir
     global subdir
     global testfile
@@ -52,6 +55,10 @@  proc args_test { name arglist } {
 
     set i 1
     foreach arg $arglist {
+	if { $single_quotes_newline_kfail
+	     && ($arg == {''} || $arg == {\\n}) } {
+	    setup_kfail "gdb/27989" "*-*-*"
+	}
 	gdb_test "print argv\[$i\]" "\\\$$decimal = $hex \"$arg\"" \
 	    "argv\[$i\] for $name"
 	set i [expr $i + 1]
@@ -65,6 +72,10 @@  proc args_test { name arglist } {
 save_vars { GDBFLAGS } {
     set old_gdbflags $GDBFLAGS
 
+    # Start GDB just to see if we are using the native or extended-remote target.
+    clean_restart
+    set single_quotes_newline_kfail [gdb_is_target_remote]
+
     set GDBFLAGS "$old_gdbflags --args $binfile 1 3"
     args_test basic {{1} {3}}
 
@@ -85,16 +96,16 @@  save_vars { GDBFLAGS } {
     # Try with arguments containing literal single quotes.
 
     set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3"
-    args_test "one empty with single quotes" {{1} {''} {3}}
+    args_test "one empty with single quotes" {{1} {''} {3}} $single_quotes_newline_kfail
 
     set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3"
-    args_test "two empty with single quotes" {{1} {''} {''} {3}}
+    args_test "two empty with single quotes" {{1} {''} {''} {3}} $single_quotes_newline_kfail
 
     # try with arguments containing literal newlines.
 
     set GDBFLAGS "$old_gdbflags --args $binfile 1 {\n} 3"
-    args_test "one newline" {{1} {\\n} {3}}
+    args_test "one newline" {{1} {\\n} {3}} $single_quotes_newline_kfail
 
     set GDBFLAGS "$old_gdbflags --args $binfile 1 {\n} {\n} 3"
-    args_test "two newlines" {{1} {\\n} {\\n} {3}}
+    args_test "two newlines" {{1} {\\n} {\\n} {3}} $single_quotes_newline_kfail
 }