diff mbox

[testsuite] skip tests in with_target_charset if no ICONV support

Message ID 55F868D7.3070309@codesourcery.com
State New
Headers show

Commit Message

Sandra Loosemore Sept. 15, 2015, 6:52 p.m. UTC
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

Comments

Doug Evans Sept. 17, 2015, 4:19 a.m. UTC | #1
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)?
diff mbox

Patch

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]