This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] testsuite set_lang_* cleanup
- From: dje at google dot com (Doug Evans)
- To: gdb-patches at sourceware dot org
- Date: Wed, 18 Aug 2010 09:43:43 -0700 (PDT)
- Subject: [commit] testsuite set_lang_* cleanup
Hi.
I committed the following.
There were several copies of various set_lang_* functions,
I moved them to their corresponding language files in lib/*.exp.
I also deleted set_lang_c, and just did "set language c" directly
in the two files that called set_lang_c: callfuncs.exp, printcmds.exp.
It didn't seem worth handling the case where it could fail (vs say pascal).
Regression tested on amd64-linux.
Some of the modified tests (but not all) require a compiler which I didn't have
installed, but the transformations were purely mechanical.
I may have introduced a problem, let me know - it'll be trivial to fix.
2010-08-18 Doug Evans <dje@google.com>
* gdb.base/call-ar-st.exp (set_lang_c): Delete, unused.
* gdb.base/callfuncs.exp (set_lang_c): Delete, set c language directly.
* gdb.base/printcmds.exp (set_lang_c): Delete, set c language directly.
Simplify, early exit if runto_main fails.
* gdb.fortran/exprs.exp: load_lib fortran.exp.
(set_lang_fortran): Moved to lib/fortran.exp.
* gdb.fortran/types.exp: load_lib fortran.exp.
(set_lang_fortran): Moved to lib/fortran.exp.
* gdb.java/jmisc.exp (set_lang_java): Moved to lib/java.exp.
* gdb.java/jprint.exp (set_lang_java): Ditto.
* gdb.java/jv-exp.exp: load_lib java.exp.
If set_lang_java fails, issue a warning instead of failure to be
consistent with other set_lang_foo uses.
(set_lang_java): Moved to lib/java.exp.
* gdb.java/jv-print.exp (set_lang_java): Moved to lib/java.exp.
If set_lang_java fails, issue a warning instead of failure to be
consistent with other set_lang_foo uses.
* gdb.pascal/types.exp: load_lib pascal.exp.
(set_lang_pascal): Moved to lib/pascal.exp.
* lib/fortran.exp: New file.
* lib/java.exp (set_lang_java): New function.
* lib/pascal.exp (set_lang_pascal): New function.
Index: gdb.base/call-ar-st.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/call-ar-st.exp,v
retrieving revision 1.27
diff -u -p -r1.27 call-ar-st.exp
--- gdb.base/call-ar-st.exp 8 Jun 2010 22:58:03 -0000 1.27
+++ gdb.base/call-ar-st.exp 18 Aug 2010 16:26:46 -0000
@@ -55,30 +55,6 @@ if [target_info exists gdb,cannot_call_f
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
-# Set the current language to C. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_c {} {
- global gdb_prompt
-
- gdb_test_no_output "set language c"
-
- gdb_test_multiple "show language" "set language to \"c\"" {
- -re ".* source language is \"c\".*$gdb_prompt $" {
- pass "set language to \"c\""
- return 1
- }
- -re ".*$gdb_prompt $" {
- fail "set language to \"c\""
- return 0
- }
- timeout {
- fail "(timeout) set language to \"c\""
- return 0
- }
- }
-}
-
# Start with a fresh gdb.
gdb_exit
Index: gdb.base/callfuncs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/callfuncs.exp,v
retrieving revision 1.38
diff -u -p -r1.38 callfuncs.exp
--- gdb.base/callfuncs.exp 10 Jun 2010 19:48:19 -0000 1.38
+++ gdb.base/callfuncs.exp 18 Aug 2010 16:26:46 -0000
@@ -21,7 +21,6 @@ if $tracelevel then {
strace $tracelevel
}
-
set testfile "callfuncs"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
@@ -52,25 +51,6 @@ if [target_info exists gdb,cannot_call_f
continue
}
-# Set the current language to C. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_c {} {
- global gdb_prompt
-
- gdb_test_no_output "set language c"
-
- set success 0
-
- gdb_test_multiple "show language" "set language to \"c\"" {
- -re ".* source language is \"c\".*$gdb_prompt $" {
- pass "set language to \"c\""
- set success 1
- }
- }
- return $success
-}
-
# FIXME: Before calling this proc, we should probably verify that
# we can call inferior functions and get a valid integral value
# returned.
@@ -315,12 +295,9 @@ if { $hp_aCC_compiler } {
gdb_test_no_output "set overload-resolution 0"
} else {
- if { ![set_lang_c] } {
+ gdb_test_no_output "set language c"
+ if { ![runto_main] } {
gdb_suppress_tests;
- } else {
- if { ![runto_main] } {
- gdb_suppress_tests;
- }
}
}
Index: gdb.base/printcmds.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/printcmds.exp,v
retrieving revision 1.35
diff -u -p -r1.35 printcmds.exp
--- gdb.base/printcmds.exp 21 Jul 2010 18:08:27 -0000 1.35
+++ gdb.base/printcmds.exp 18 Aug 2010 16:26:46 -0000
@@ -25,7 +25,6 @@ if $tracelevel then {
strace $tracelevel
}
-
set testfile "printcmds"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
@@ -36,22 +35,6 @@ if { [gdb_compile "${srcdir}/${subdir}/
get_compiler_info ${binfile}
-# Set the current language to C. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_c {} {
- global gdb_prompt
-
- if [gdb_test_no_output "set language c" "set language c"] {
- return 0
- }
-
- if [gdb_test "show language" ".* source language is \"c\".*"] {
- return 0
- }
- return 1;
-}
-
proc test_integer_literals_accepted {} {
global gdb_prompt
@@ -781,34 +764,34 @@ gdb_test_no_output "set print sevenbit-s
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
-if [set_lang_c] then {
- if { [test_compiler_info "armcc-*"] } {
- # ARM RealView compresses large arrays in the data segment.
- # Before the program starts, we can not read them. There is
- # nothing in the file to indicate that data is compressed.
- setup_xfail "arm*-*-eabi"
- }
- gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1"
-
- gdb_load ${binfile}
- if [runto_main] then {
- test_integer_literals_accepted
- test_integer_literals_rejected
- test_character_literals_accepted
- test_print_all_chars
- test_print_repeats_10
- test_print_strings
- test_print_int_arrays
- test_print_typedef_arrays
- test_artificial_arrays
- test_print_char_arrays
+if { [test_compiler_info "armcc-*"] } {
+ # ARM RealView compresses large arrays in the data segment.
+ # Before the program starts, we can not read them. There is
+ # nothing in the file to indicate that data is compressed.
+ setup_xfail "arm*-*-eabi"
+}
+gdb_test "p ctable1\[120\]" "120 'x'" "p ctable1\[120\] #1"
+
+gdb_load ${binfile}
+
+if ![runto_main] then {
+ fail "Can't run to main"
+ return 0
+}
+
+test_integer_literals_accepted
+test_integer_literals_rejected
+test_character_literals_accepted
+test_print_all_chars
+test_print_repeats_10
+test_print_strings
+test_print_int_arrays
+test_print_typedef_arrays
+test_artificial_arrays
+test_print_char_arrays
# We used to do the runto main here.
- test_print_string_constants
- test_print_array_constants
- test_print_enums
- test_printf
- test_printf_with_dfp
- }
-} else {
- fail "C print command tests suppressed"
-}
+test_print_string_constants
+test_print_array_constants
+test_print_enums
+test_printf
+test_printf_with_dfp
Index: gdb.fortran/exprs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.fortran/exprs.exp,v
retrieving revision 1.15
diff -u -p -r1.15 exprs.exp
--- gdb.fortran/exprs.exp 5 May 2010 18:06:59 -0000 1.15
+++ gdb.fortran/exprs.exp 18 Aug 2010 16:26:46 -0000
@@ -21,25 +21,9 @@ if $tracelevel then {
strace $tracelevel
}
-if { [skip_fortran_tests] } { continue }
-
+load_lib "fortran.exp"
-# Set the current language to fortran. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_fortran {} {
- global gdb_prompt
-
- if [gdb_test "set language fortran" ""] {
- return 0;
- }
-
- if ![gdb_test "show language" ".* source language is \"fortran\".*"] {
- return 1;
- } else {
- return 0;
- }
-}
+if { [skip_fortran_tests] } { continue }
proc test_integer_literals_accepted {} {
global gdb_prompt
Index: gdb.fortran/types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.fortran/types.exp,v
retrieving revision 1.14
diff -u -p -r1.14 types.exp
--- gdb.fortran/types.exp 5 May 2010 18:07:00 -0000 1.14
+++ gdb.fortran/types.exp 18 Aug 2010 16:26:46 -0000
@@ -21,25 +21,9 @@ if $tracelevel then {
strace $tracelevel
}
-if { [skip_fortran_tests] } { continue }
-
-
-# Set the current language to fortran. This counts as a test. If it
-# fails, then we skip the other tests.
+load_lib "fortran.exp"
-proc set_lang_fortran {} {
- global gdb_prompt
-
- if [gdb_test "set language fortran" ""] {
- return 0;
- }
-
- if ![gdb_test "show language" ".* source language is \"fortran\".*"] {
- return 1;
- } else {
- return 0;
- }
-}
+if { [skip_fortran_tests] } { continue }
proc test_integer_literal_types_accepted {} {
global gdb_prompt
Index: gdb.java/jmisc.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jmisc.exp,v
retrieving revision 1.19
diff -u -p -r1.19 jmisc.exp
--- gdb.java/jmisc.exp 1 Jun 2010 17:22:33 -0000 1.19
+++ gdb.java/jmisc.exp 18 Aug 2010 16:26:46 -0000
@@ -32,32 +32,17 @@ if {[compile_java_from_source ${srcfile}
continue
}
-# Set the current language to java. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_java {} {
- global gdb_prompt
- global binfile objdir subdir
-
- verbose "loading file '$binfile'"
- gdb_load $binfile
-
- gdb_test_no_output "set language java"
-
- return [gdb_test "show language" ".* source language is \"java\".*" \
- "set language to \"java\""]
-}
-
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
gdb_test "set print sevenbit-strings" ".*"
-if ![set_lang_java] then {
+if [set_lang_java] then {
# Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
# As of 2004-02-24 it wasn't working and is being tested separatly.
# Before GCJ 4.1 (approximately) the demangled name did not include
Index: gdb.java/jprint.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jprint.exp,v
retrieving revision 1.15
diff -u -p -r1.15 jprint.exp
--- gdb.java/jprint.exp 26 May 2010 18:34:12 -0000 1.15
+++ gdb.java/jprint.exp 18 Aug 2010 16:26:46 -0000
@@ -31,32 +31,17 @@ if {[compile_java_from_source ${srcfile}
continue
}
-# Set the current language to java. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_java {} {
- global gdb_prompt
- global binfile objdir subdir
-
- verbose "loading file '$binfile'"
- gdb_load $binfile
-
- gdb_test_no_output "set language java"
-
- return [gdb_test "show language" ".* source language is \"java\".*" \
- "set language to \"java\""]
-}
-
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
+gdb_load $binfile
gdb_test "set print sevenbit-strings" ".*"
-if ![set_lang_java] then {
+if [set_lang_java] then {
# Ref PR gdb:java/1565. Don't use the simpler "break jmisc.main".
# As of 2004-02-24 it wasn't working and is being tested separatly.
# Before GCJ 4.1 (approximately) the demangled name did not include
Index: gdb.java/jv-exp.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jv-exp.exp,v
retrieving revision 1.9
diff -u -p -r1.9 jv-exp.exp
--- gdb.java/jv-exp.exp 5 May 2010 18:07:01 -0000 1.9
+++ gdb.java/jv-exp.exp 18 Aug 2010 16:26:46 -0000
@@ -17,22 +17,7 @@ if $tracelevel then {
strace $tracelevel
}
-
-# Set the current language to Java. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_java {} {
- global gdb_prompt
-
- if [gdb_test "set language java" "" "set language java"] {
- return 0
- }
-
- if [gdb_test "show language" ".* source language is \"java\".*"] {
- return 0
- }
- return 1;
-}
+load_lib "java.exp"
proc test_comparisons {} {
global gdb_prompt
@@ -56,5 +41,5 @@ gdb_test "set width 0" ""
if [set_lang_java] then {
test_comparisons
} else {
- fail "Java expression tests suppressed"
+ warning "Java expression tests suppressed"
}
Index: gdb.java/jv-print.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.java/jv-print.exp,v
retrieving revision 1.13
diff -u -p -r1.13 jv-print.exp
--- gdb.java/jv-print.exp 5 May 2010 18:07:01 -0000 1.13
+++ gdb.java/jv-print.exp 18 Aug 2010 16:26:46 -0000
@@ -21,23 +21,6 @@ load_lib "java.exp"
if { [skip_java_tests] } { continue }
-
-# Set the current language to Java. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_java {} {
- global gdb_prompt
-
- if [gdb_test "set language java" "" "set language java"] {
- return 0
- }
-
- if [gdb_test "show language" ".* source language is \"java\".*"] {
- return 0
- }
- return 1;
-}
-
proc test_integer_literals_accepted {} {
global gdb_prompt
@@ -135,5 +118,5 @@ if [set_lang_java] then {
test_character_literals_accepted
test_integer_literals_rejected
} else {
- fail "Java print command tests suppressed"
+ warning "Java print command tests suppressed"
}
Index: gdb.pascal/types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.pascal/types.exp,v
retrieving revision 1.7
diff -u -p -r1.7 types.exp
--- gdb.pascal/types.exp 25 May 2010 21:02:00 -0000 1.7
+++ gdb.pascal/types.exp 18 Aug 2010 16:26:46 -0000
@@ -23,23 +23,7 @@ if $tracelevel then {
strace $tracelevel
}
-
-# Set the current language to pascal. This counts as a test. If it
-# fails, then we skip the other tests.
-
-proc set_lang_pascal {} {
- global gdb_prompt
-
- if [gdb_test "set language pascal" ""] {
- return 0;
- }
-
- if ![gdb_test "show language" ".* source language is \"pascal\".*"] {
- return 1;
- } else {
- return 0;
- }
-}
+load_lib "pascal.exp"
proc test_integer_literal_types_accepted {} {
global gdb_prompt
Index: lib/fortran.exp
===================================================================
RCS file: lib/fortran.exp
diff -N lib/fortran.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lib/fortran.exp 18 Aug 2010 16:26:46 -0000
@@ -0,0 +1,30 @@
+# This test code is part of GDB, the GNU debugger.
+
+# Copyright 2010 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
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Auxiliary function to set the language to fortran.
+# The result is 1 (true) for success, 0 (false) for failure.
+
+proc set_lang_fortran {} {
+ if [gdb_test_no_output "set language fortran"] {
+ return 0
+ }
+ if [gdb_test "show language" ".* source language is \"fortran\"." \
+ "set language to \"fortran\""] {
+ return 0
+ }
+ return 1;
+}
Index: lib/java.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/java.exp,v
retrieving revision 1.14
diff -u -p -r1.14 java.exp
--- lib/java.exp 1 Jan 2010 07:32:07 -0000 1.14
+++ lib/java.exp 18 Aug 2010 16:26:46 -0000
@@ -105,6 +105,20 @@ proc compile_java_from_source { srcfile
return $result
}
+# Auxiliary function to set the language to java.
+# The result is 1 (true) for success, 0 (false) for failure.
+
+proc set_lang_java {} {
+ if [gdb_test_no_output "set language java"] {
+ return 0
+ }
+ if [gdb_test "show language" ".* source language is \"java\"." \
+ "set language to \"java\""] {
+ return 0
+ }
+ return 1;
+}
+
# Local Variables:
# tcl-indent-level:4
# End:
Index: lib/pascal.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/pascal.exp,v
retrieving revision 1.4
diff -u -p -r1.4 pascal.exp
--- lib/pascal.exp 1 Jan 2010 07:32:07 -0000 1.4
+++ lib/pascal.exp 18 Aug 2010 16:26:46 -0000
@@ -150,3 +150,16 @@ proc gdb_compile_pascal {source dest typ
}
}
+# Auxiliary function to set the language to pascal.
+# The result is 1 (true) for success, 0 (false) for failure.
+
+proc set_lang_pascal {} {
+ if [gdb_test_no_output "set language pascal"] {
+ return 0
+ }
+ if [gdb_test "show language" ".* source language is \"pascal\"." \
+ "set language to \"pascal\""] {
+ return 0
+ }
+ return 1;
+}