* [RFC] Avoid using sprintf in the testsuite
@ 2005-03-17 21:12 Mark Kettenis
2005-03-17 21:46 ` Frank Ch. Eigler
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2005-03-17 21:12 UTC (permalink / raw)
To: gdb-patches
Using sprintf in the testsuite causes problems with the upcoming
OpenBSD 3.7. The warning about its usuge printed by the linker makes
us think the compilation failed. Here's a patch that replaces the
usage of sprintf in gdb.base/fileio.{c,exp} with simple string
concatenation. I'd rather do this instead of using snprintf, since
the latter is not available on HP-UX 10.20.
Objections? Otherwise I'll check this in next weekend.
Mark
Index: testsuite/ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* gdb.base/fileio.c (test_system, test_unlink): Avoid using
sprintf.
* gdb.base/fileio.exp: Adjust line number.
Index: testsuite/gdb.base/fileio.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.c,v
retrieving revision 1.8
diff -u -p -r1.8 fileio.c
--- testsuite/gdb.base/fileio.c 10 Jan 2005 15:58:23 -0000 1.8
+++ testsuite/gdb.base/fileio.c 17 Mar 2005 21:04:09 -0000
@@ -334,10 +334,10 @@ test_system ()
* Requires test framework to switch on "set remote system-call-allowed 1"
*/
int ret;
- char sys[512];
+ char *sys;
/* This test prepares the directory for test_rename() */
- sprintf (sys, "mkdir -p %s %s", TESTSUBDIR, TESTDIR2);
+ sys = "mkdir -p " TESTSUBDIR " " TESTDIR2;
ret = system (sys);
if (ret == 127)
printf ("system 1: ret = %d /bin/sh unavailable???\n", ret);
@@ -400,21 +400,21 @@ int
test_unlink ()
{
int ret;
- char name[256];
- char sys[512];
+ char *name;
+ char *sys;
/* Test unlink */
errno = 0;
ret = unlink (RENAMED);
printf ("unlink 1: ret = %d, errno = %d %s\n", ret, errno,
strerrno (errno));
+ name = TESTDIR2 "/" FILENAME;
/* No write access */
- sprintf (name, "%s/%s", TESTDIR2, FILENAME);
errno = 0;
ret = open (name, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR);
if (ret >= 0)
{
- sprintf (sys, "chmod -w %s", TESTDIR2);
+ sys = "chmod -w " TESTDIR2;
ret = system (sys);
if (!ret)
{
Index: testsuite/gdb.base/fileio.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/fileio.exp,v
retrieving revision 1.7
diff -u -p -r1.7 fileio.exp
--- testsuite/gdb.base/fileio.exp 18 Jan 2004 21:17:57 -0000 1.7
+++ testsuite/gdb.base/fileio.exp 17 Mar 2005 21:04:09 -0000
@@ -240,9 +240,9 @@ gdb_test continue \
"Continuing\\..*rename 5:.*ENOENT.*test_rename \\(\\) at.*$srcfile:397.*" \
"Renaming a nonexistant file returns ENOENT"
-send_gdb "tbreak 412\n" ; gdb_expect -re "$gdb_prompt $"
+send_gdb "tbreak 413\n" ; gdb_expect -re "$gdb_prompt $"
gdb_test continue \
-"Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:412.*" \
+"Continuing\\..*unlink 1:.*OK.*test_unlink \\(\\) at.*$srcfile:413.*" \
"Unlink a file"
send_gdb "tbreak 432\n" ; gdb_expect -re "$gdb_prompt $"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Avoid using sprintf in the testsuite
2005-03-17 21:12 [RFC] Avoid using sprintf in the testsuite Mark Kettenis
@ 2005-03-17 21:46 ` Frank Ch. Eigler
2005-03-20 21:28 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Frank Ch. Eigler @ 2005-03-17 21:46 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
Mark Kettenis <kettenis@gnu.org> writes:
> Using sprintf in the testsuite causes problems with the upcoming
> OpenBSD 3.7. The warning about its usuge printed by the linker makes
> us think the compilation failed. [...]
Perhaps instead gdb's testsuite should adopt gcc's warning-pruning
code: see for example gcc/testsuite/lib/prune.exp.
- FChE
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Avoid using sprintf in the testsuite
2005-03-17 21:46 ` Frank Ch. Eigler
@ 2005-03-20 21:28 ` Mark Kettenis
0 siblings, 0 replies; 3+ messages in thread
From: Mark Kettenis @ 2005-03-20 21:28 UTC (permalink / raw)
To: fche; +Cc: gdb-patches
From: fche@redhat.com (Frank Ch. Eigler)
Date: 17 Mar 2005 16:46:30 -0500
Mark Kettenis <kettenis@gnu.org> writes:
> Using sprintf in the testsuite causes problems with the upcoming
> OpenBSD 3.7. The warning about its usuge printed by the linker makes
> us think the compilation failed. [...]
Perhaps instead gdb's testsuite should adopt gcc's warning-pruning
code: see for example gcc/testsuite/lib/prune.exp.
Better yet, I should add OpenBSD linker warning pruning to DejaGnu
itself. Thanks for the suggestion. I withdraw the patch.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-03-20 21:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-17 21:12 [RFC] Avoid using sprintf in the testsuite Mark Kettenis
2005-03-17 21:46 ` Frank Ch. Eigler
2005-03-20 21:28 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox