public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf
@ 2011-03-23 16:22 Steve Ellcey
  2011-03-23 20:34 ` John David Anglin
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Ellcey @ 2011-03-23 16:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: danglin, jakub

This patch moves gcc.c-torture/execute/pr47917.c to
gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf
function so the test does not compile.  On HP-UX 11.[012]*, there is a
snprintf function but it is not C99 compliant so the test compiles but
fails when it is run.  On HP-UX 11.31 it is possible to get the correct
behaviour and I will be submitting a seperate patch to deal with that.

The problem is that on HP-UX snprintf is returning -1 for buffer overflow
instead of returning the number of bytes that would have been output if the
buffer hadn't filled up.

Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.

Steve Ellcey
sje@cup.hp.com


2011-03-23  Steve Ellcey  <sje@cup.hp.com>

	PR target/48209
	* gcc.c-torture/execute/pr47917.c: Move this...
	* gcc.dg/torture/pr47917.c: to here and add xfails.

Index: gcc.c-torture/execute/pr47917.c
===================================================================
--- gcc.c-torture/execute/pr47917.c	(revision 171338)
+++ gcc.c-torture/execute/pr47917.c	(working copy)
@@ -1,32 +0,0 @@
-/* PR middle-end/47917 */
-
-extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
-extern int memcmp (const void *, const void *, __SIZE_TYPE__);
-extern void abort (void);
-
-char buf1[6], buf2[6], buf3[4], buf4[4];
-int i;
-
-int
-foo (void)
-{
-  int ret = snprintf (buf1, sizeof buf1, "abcde");
-  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
-  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
-  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096;
-  return ret;
-}
-
-int
-main (void)
-{
-  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
-    abort ();
-  if (memcmp (buf1, "abcde", 6) != 0
-      || memcmp (buf2, "abcde", 6) != 0
-      || memcmp (buf3, "abc", 4) != 0
-      || memcmp (buf4, "def", 4) != 0
-      || i != 2)
-    abort ();
-  return 0;
-}
Index: gcc.dg/torture/pr47917.c
===================================================================
--- gcc.dg/torture/pr47917.c	(revision 171278)
+++ gcc.dg/torture/pr47917.c	(working copy)
@@ -1,3 +1,8 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+/* { dg-xfail-if "no C99 snprintf function" { *-*-hpux10* } } */
+/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
+
 /* PR middle-end/47917 */
 
 extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf
  2011-03-23 16:22 [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf Steve Ellcey
@ 2011-03-23 20:34 ` John David Anglin
  2011-03-23 20:44   ` Steve Ellcey
  0 siblings, 1 reply; 3+ messages in thread
From: John David Anglin @ 2011-03-23 20:34 UTC (permalink / raw)
  To: sje; +Cc: gcc-patches, danglin, jakub

> This patch moves gcc.c-torture/execute/pr47917.c to
> gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
> and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf

The new gcc.dg/torture/pr47917.c lacks some code.

> Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
> 10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.

This will take some time.  I would just go ahead without this check
if moving the test is ok.

> 2011-03-23  Steve Ellcey  <sje@cup.hp.com>
> 
> 	PR target/48209
> 	* gcc.c-torture/execute/pr47917.c: Move this...
> 	* gcc.dg/torture/pr47917.c: to here and add xfails.
> 
> Index: gcc.c-torture/execute/pr47917.c
> ===================================================================
> --- gcc.c-torture/execute/pr47917.c	(revision 171338)
> +++ gcc.c-torture/execute/pr47917.c	(working copy)
> @@ -1,32 +0,0 @@
> -/* PR middle-end/47917 */
> -
> -extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
> -extern int memcmp (const void *, const void *, __SIZE_TYPE__);
> -extern void abort (void);
> -
> -char buf1[6], buf2[6], buf3[4], buf4[4];
> -int i;
> -
> -int
> -foo (void)
> -{
> -  int ret = snprintf (buf1, sizeof buf1, "abcde");
> -  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
> -  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
> -  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096;
> -  return ret;
> -}
> -
> -int
> -main (void)
> -{
> -  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
> -    abort ();
> -  if (memcmp (buf1, "abcde", 6) != 0
> -      || memcmp (buf2, "abcde", 6) != 0
> -      || memcmp (buf3, "abc", 4) != 0
> -      || memcmp (buf4, "def", 4) != 0
> -      || i != 2)
> -    abort ();
> -  return 0;
> -}
> Index: gcc.dg/torture/pr47917.c
> ===================================================================
> --- gcc.dg/torture/pr47917.c	(revision 171278)
> +++ gcc.dg/torture/pr47917.c	(working copy)
> @@ -1,3 +1,8 @@
> +/* { dg-do run } */
> +/* { dg-options "-std=c99" } */
> +/* { dg-xfail-if "no C99 snprintf function" { *-*-hpux10* } } */
> +/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
> +
>  /* PR middle-end/47917 */
>  
>  extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
> 

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf
  2011-03-23 20:34 ` John David Anglin
@ 2011-03-23 20:44   ` Steve Ellcey
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Ellcey @ 2011-03-23 20:44 UTC (permalink / raw)
  To: John David Anglin; +Cc: gcc-patches, danglin, jakub

On Wed, 2011-03-23 at 16:34 -0400, John David Anglin wrote:
> > This patch moves gcc.c-torture/execute/pr47917.c to
> > gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
> > and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf
> 
> The new gcc.dg/torture/pr47917.c lacks some code.

It's there, but the diff only showed the changes from the original file
that it was moved from.

> > Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
> > 10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.
> 
> This will take some time.  I would just go ahead without this check
> if moving the test is ok.

Sounds good.  I think moving the test is OK, that was what I was told to
do last time I needed to XFAIL a test in gcc.c-torture.

Steve Ellcey
sje@cup.hp.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-23 20:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 16:22 [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf Steve Ellcey
2011-03-23 20:34 ` John David Anglin
2011-03-23 20:44   ` Steve Ellcey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).