gdb/testsuite: Reduce test name duplication in gdb.base tests
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / charset.exp
index 27e36d6dd060910da42556a66d5438eb397e8718..16e986c51906d4261a703abaef7064c862acf57b 100644 (file)
@@ -1,6 +1,6 @@
 # This testcase is part of GDB, the GNU debugger.
 
-# Copyright 2001, 2004, 2007-2012 Free Software Foundation, Inc.
+# Copyright 2001-2019 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # Test GDB's character set support.
 
 
-set testfile "charset"
-set srcfile ${testfile}.c
-set srcmallocfile ${testfile}-malloc.c
-if { [prepare_for_testing ${testfile}.exp ${testfile} [list $srcfile $srcmallocfile]] } {
+standard_testfile .c charset-malloc.c
+
+if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
     return -1
 }
 
@@ -147,7 +146,7 @@ gdb_expect {
 # sets: "auto" and the default.  In this situation, this set of tests
 # is pointless.
 if {[llength [array names charsets]] < 3} {
-    untested charset.exp
+    untested "fewer than 3 charsets"
     return -1
 }
 
@@ -176,7 +175,7 @@ gdb_expect {
 # We don't want to test all the charset names here, since that would
 # be too many combinations.  We we pick a subset.
 set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047}
-foreach host_charset $charset_subset {
+foreach_with_prefix host_charset $charset_subset {
     if {[valid_host_charset $host_charset]} {
 
         set testname "try `set host-charset $host_charset'"
@@ -325,18 +324,7 @@ gdb_test "break ${srcfile}:[gdb_get_line_number "all strings initialized"]" \
          ".*Breakpoint.* at .*" \
          "set breakpoint after all strings have been initialized"
 gdb_run_cmd
-gdb_expect {
-    -re "Breakpoint.*all strings initialized.*$gdb_prompt $" {
-        pass "run until all strings have been initialized"
-    }
-    -re "$gdb_prompt $" {
-        fail "run until all strings have been initialized"
-    }
-    timeout {
-        fail "run until all strings have been initialized (timeout)"
-    }
-}
-
+gdb_test "" "Breakpoint.*all strings initialized.*" "run until all strings have been initialized"
 
 # We only try the wide character tests on machines where the wchar_t
 # typedef in the test case has the right size.
@@ -578,7 +566,7 @@ if {$ucs2_ok && $ucs4_ok} {
 
 if {$ucs2_ok} {
     set go 1
-    gdb_test_multiple "python print 'hello, world!'" \
+    gdb_test_multiple "python print ('hello, world!')" \
        "verify python support for charset tests" {
            -re "not supported.*$gdb_prompt $"  {
                unsupported "python support is disabled"
@@ -591,7 +579,7 @@ if {$ucs2_ok} {
        gdb_test "print u\"abcdef\"" " = u\"abcdef\"" \
            "set up for python printing of utf-16 string"
 
-       gdb_test "python print gdb.history(0).string()" "abcdef" \
+       gdb_test "python print (gdb.history(0).string())" "abcdef" \
            "extract utf-16 string using python"
     }
 }
@@ -603,8 +591,12 @@ gdb_test "print 'a' == 'a' || 'b' == 'b'" \
 
 
 proc string_display { var_name set_prefix x_size x_type} {
-  gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "Assign ${var_name} with prefix ${set_prefix}"
-  gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" "Display String ${var_name} with x/${x_size}s"
+    with_test_prefix "set_prefix=$set_prefix" {
+       gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\""\
+           "assign ${var_name} with prefix ${set_prefix}"
+       gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" \
+           "display String ${var_name} with x/${x_size}s"
+    }
 }
 
 if {$ucs2_ok} {
This page took 0.027048 seconds and 4 git commands to generate.