This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] testsuite: Disallow newlines in test names
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 24 Apr 2011 11:12:27 +0200
- Subject: [patch] testsuite: Disallow newlines in test names
Hi,
to prevent in the future cases like:
[obv] testsuite: python: name the test
http://sourceware.org/ml/gdb-patches/2011-04/msg00430.html
proposing this change. The problem is the ""-named tests may need an explicit
name now, as it may be used in the cases the test errors out and even in such
case sure no \n (or \r) should get output as the test name.
A comment is welcome. This is similar to the sanity check:
[patch] testsuite: Error on trailing newlines [Re: [obv] testsuite: gdb.cp/ref-types.exp: Excessive newline]
http://sourceware.org/ml/gdb-patches/2010-06/msg00082.html
Thanks,
Jan
gdb/testsuite/
2011-04-24 Jan Kratochvil <jan.kratochvil@redhat.com>
* lib/gdb.exp (gdb_test_multiple): Eror on newline in $message.
* gdb.base/ifelse.exp: Give names to the "" tests as `if true else
false #1', `if true else false #2' and `if true else false #3'.
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -597,6 +597,10 @@ proc gdb_test_multiple { command message user_code } {
error "Invalid trailing newline in \"$message\" test"
}
+ if [string match "*\[\r\n\]*" $message] {
+ error "Invalid newline in \"$message\" test"
+ }
+
# TCL/EXPECT WART ALERT
# Expect does something very strange when it receives a single braced
# argument. It splits it along word separators and performs substitutions.
--- a/gdb/testsuite/gdb.base/ifelse.exp
+++ b/gdb/testsuite/gdb.base/ifelse.exp
@@ -57,7 +57,8 @@ gdb_test_multiple "if 0\nend" $message {
# bodies and hopefully the memory with be dirty and the problem
# will show itself (this works at time of writing).
-gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
+gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" \
+ "if true else false #1"
# with true condition
set message "if 1 .. else with empty body"
@@ -71,7 +72,8 @@ gdb_test_multiple "if 1\nelse\nend" $message {
}
# dirty memory
-gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
+gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" \
+ "if true else false #2"
# with false condition
set message "if 0 .. else with empty body"
@@ -89,7 +91,8 @@ gdb_test_no_output "set confirm off" ""
# Test that a define with an empty else can be replaced.
# If there is memory corruption then free will fail.
# dirty memory
-gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" ""
+gdb_test "if 1\necho true\\n\nelse\necho false\\n\nend" "true" \
+ "if true else false #3"
# create
gdb_test "define abc\nif 1\nelse\nend\nend" "" "create define with empty else"
# call (note that condition is 1 so should pass)