public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [patch, testsuite] skip tests in with_target_charset if no ICONV support
@ 2015-09-15 18:52 Sandra Loosemore
  2015-09-17  4:20 ` Doug Evans
  0 siblings, 1 reply; 3+ messages in thread
From: Sandra Loosemore @ 2015-09-15 18:52 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

If GDB is configured without ICONV support, it only knows about the 
charset "ISO-8859-1".  Tests that use with_target_charset with some 
other character set (e.g., gdb.base/printcmds.exp) presumably depend on 
exactly that character set being supported and can't be expected to work 
properly in its absence.  This patch makes with_target_charset skip 
those tests as unsupported if switching to the specified character set 
fails.  OK to commit?

-Sandra


[-- Attachment #2: iconv.log --]
[-- Type: text/x-log, Size: 200 bytes --]

2015-09-15  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/gdb.exp (with_target_charset): Skip tests as unsupported
	if target_charset is not valid, e.g. due to no ICONV support.

[-- Attachment #3: iconv.patch --]
[-- Type: text/x-patch, Size: 711 bytes --]

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 56cde7a..747d66e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2043,7 +2043,17 @@ proc with_target_charset { target_charset body } {
 	}
     }
 
-    gdb_test_no_output "set target-charset $target_charset" ""
+    # Setting the charset may fail if GDB was configured without
+    # ICONV support.
+    gdb_test_multiple "set target-charset $target_charset" "" {
+	-re "Undefined item.*$gdb_prompt " {
+	    unsupported "Unknown charset $target_charset"
+	    return -1
+	}
+	-re ".*$gdb_prompt " {
+	    pass "set target-charset $target_charset"
+	}
+    }
 
     set code [catch {uplevel 1 $body} result]
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, testsuite] skip tests in with_target_charset if no ICONV support
  2015-09-15 18:52 [patch, testsuite] skip tests in with_target_charset if no ICONV support Sandra Loosemore
@ 2015-09-17  4:20 ` Doug Evans
  2016-01-08  2:34   ` [v2] " Sandra Loosemore
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2015-09-17  4:20 UTC (permalink / raw)
  To: Sandra Loosemore; +Cc: gdb-patches

Sandra Loosemore <sandra@codesourcery.com> writes:
> If GDB is configured without ICONV support, it only knows about the
> charset "ISO-8859-1".  Tests that use with_target_charset with some
> other character set (e.g., gdb.base/printcmds.exp) presumably depend
> on exactly that character set being supported and can't be expected to
> work properly in its absence.  This patch makes with_target_charset
> skip those tests as unsupported if switching to the specified
> character set fails.  OK to commit?
>
> -Sandra
>
>
> 2015-09-15  Sandra Loosemore  <sandra@codesourcery.com>
>
> 	gdb/testsuite/
> 	* lib/gdb.exp (with_target_charset): Skip tests as unsupported
> 	if target_charset is not valid, e.g. due to no ICONV support.
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 56cde7a..747d66e 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -2043,7 +2043,17 @@ proc with_target_charset { target_charset body } {
>  	}
>      }
>  
> -    gdb_test_no_output "set target-charset $target_charset" ""
> +    # Setting the charset may fail if GDB was configured without
> +    # ICONV support.
> +    gdb_test_multiple "set target-charset $target_charset" "" {
> +	-re "Undefined item.*$gdb_prompt " {
> +	    unsupported "Unknown charset $target_charset"
> +	    return -1
> +	}
> +	-re ".*$gdb_prompt " {
> +	    pass "set target-charset $target_charset"
> +	}
> +    }
>  
>      set code [catch {uplevel 1 $body} result]
>  

Hi.

The return value of with_target_charset is not well defined.
It's never used AFAICT (modulo the case where there's a tcl error).

    if {$code == 1} {
	global errorInfo errorCode
	return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
    } else {
	return -code $code $result
    }

$ grep with_target_charset */*.exp
gdb.base/printcmds.exp:    with_target_charset "ASCII" {
gdb.base/printcmds.exp:    with_target_charset "ASCII" {
gdb.base/printcmds.exp:    with_target_charset "ASCII" {
gdb.base/setvar.exp:with_target_charset "ASCII" {
gdb.base/setvar.exp:with_target_charset "ASCII" {
gdb.base/setvar.exp:with_target_charset "ASCII" {
lib/gdb.exp:proc with_target_charset { target_charset body } {

I just wonder whether "return -1" is correct.
Can we document that the function is "void" and don't return
anything (except in the case of a tcl error: code == 1)?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v2] [patch, testsuite] skip tests in with_target_charset if no ICONV support
  2015-09-17  4:20 ` Doug Evans
@ 2016-01-08  2:34   ` Sandra Loosemore
  0 siblings, 0 replies; 3+ messages in thread
From: Sandra Loosemore @ 2016-01-08  2:34 UTC (permalink / raw)
  To: Doug Evans; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1626 bytes --]

On 09/16/2015 10:19 PM, Doug Evans wrote:
> Sandra Loosemore <sandra@codesourcery.com> writes:
>> If GDB is configured without ICONV support, it only knows about the
>> charset "ISO-8859-1".  Tests that use with_target_charset with some
>> other character set (e.g., gdb.base/printcmds.exp) presumably depend
>> on exactly that character set being supported and can't be expected to
>> work properly in its absence.  This patch makes with_target_charset
>> skip those tests as unsupported if switching to the specified
>> character set fails.  OK to commit?
>
> The return value of with_target_charset is not well defined.
> It's never used AFAICT (modulo the case where there's a tcl error).
>
>      if {$code == 1} {
> 	global errorInfo errorCode
> 	return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
>      } else {
> 	return -code $code $result
>      }
>
> $ grep with_target_charset */*.exp
> gdb.base/printcmds.exp:    with_target_charset "ASCII" {
> gdb.base/printcmds.exp:    with_target_charset "ASCII" {
> gdb.base/printcmds.exp:    with_target_charset "ASCII" {
> gdb.base/setvar.exp:with_target_charset "ASCII" {
> gdb.base/setvar.exp:with_target_charset "ASCII" {
> gdb.base/setvar.exp:with_target_charset "ASCII" {
> lib/gdb.exp:proc with_target_charset { target_charset body } {
>
> I just wonder whether "return -1" is correct.
> Can we document that the function is "void" and don't return
> anything (except in the case of a tcl error: code == 1)?

I've revised the patch to do that.  Is the attached version OK to 
commit?  There were no other comments on the original post.

-Sandra


[-- Attachment #2: with-target-charset.log --]
[-- Type: text/x-log, Size: 200 bytes --]

2017-01-07  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/testsuite/
	* lib/gdb.exp (with_target_charset): Skip tests as unsupported
	if target_charset is not valid, e.g. due to no ICONV support.

[-- Attachment #3: with-target-charset.patch --]
[-- Type: text/x-patch, Size: 1023 bytes --]

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 015e202..f746388 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2028,6 +2028,7 @@ proc with_gdb_prompt { prompt body } {
 
 # Run tests in BODY with target-charset setting to TARGET_CHARSET.  When
 # BODY is finished, restore target-charset.
+# Returns 1 in case of a TCL error and void otherwise.
 
 proc with_target_charset { target_charset body } {
     global gdb_prompt
@@ -2045,7 +2046,17 @@ proc with_target_charset { target_charset body } {
 	}
     }
 
-    gdb_test_no_output "set target-charset $target_charset" ""
+    # Setting the charset may fail if GDB was configured without
+    # ICONV support.
+    gdb_test_multiple "set target-charset $target_charset" "" {
+	-re "Undefined item.*$gdb_prompt " {
+	    unsupported "Unknown charset $target_charset"
+	    return
+	}
+	-re ".*$gdb_prompt " {
+	    pass "set target-charset $target_charset"
+	}
+    }
 
     set code [catch {uplevel 1 $body} result]
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-08  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-15 18:52 [patch, testsuite] skip tests in with_target_charset if no ICONV support Sandra Loosemore
2015-09-17  4:20 ` Doug Evans
2016-01-08  2:34   ` [v2] " Sandra Loosemore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).