Re: Testing of memcmp(). Possible patch to tester.c

2008-01-05 Thread Mike Frysinger
On Saturday 27 October 2007, Mats Erik Andersson wrote:
> the attached difference file addresses the problem of
> better detecting a malfunctioning memcmp() call. It concerns
> the file
>
>   uClibc-0.9.29/test/string/tester.c

we blatantly steal this test from glibc ... any enhancements ive made i pushed 
back upstream as appropriate.

> in the test suite. Where possible the old test cases were
> rebuilt to avoid the return values (from memcmp) +1 and -1,
> but still only positivity and negativity are tested for.
> This was done in order to better disclose problems with
> the optimized and architecture specific implementations.
> In addition, there are some new test cases gleaned from
> Dropbear, and which conduct tests with shifting alignment.
> Of course, not all of these twenty test cases are independent,
> but in more verbose forms they were instrumental when I
> debugged architecture specific assembly code for an embedded
> system (not yet incorporated into the code base of uClibc).

going by your description, it sounds like this would be something the glibc 
guys would accept.  can you please resend this entire e-mail to 
[EMAIL PROTECTED] ?  i'll take care of merging it into uClibc's copy.

> It was also essential to use a flag "-fno-builtin" to detect the
> failures, both for the old test cases and these new ones.

which should already be happening ... the string Makefile makes sure to add 
this flag

> Based I on this recent experience, I have begun developing
> a modified testing machinery that better would issue warnings
> for false positives. The effort to avoid return values +1 and -1
> is an afterglow of this methodology. Since the present test
> suite is somewhat awkward to use in cross compiled settings,
> I might come back to that issue another time.

the test framework should be converted to dejagnu ... ive spent a little time 
on this, but much more is needed
-mike


signature.asc
Description: This is a digitally signed message part.
___
uClibc mailing list
uClibc@uclibc.org
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Testing of memcmp(). Possible patch to tester.c

2007-10-27 Thread Mats Erik Andersson
Hello there,

the attached difference file addresses the problem of
better detecting a malfunctioning memcmp() call. It concerns
the file

uClibc-0.9.29/test/string/tester.c

in the test suite. Where possible the old test cases were
rebuilt to avoid the return values (from memcmp) +1 and -1,
but still only positivity and negativity are tested for.
This was done in order to better disclose problems with
the optimized and architecture specific implementations.
In addition, there are some new test cases gleaned from
Dropbear, and which conduct tests with shifting alignment.
Of course, not all of these twenty test cases are independent,
but in more verbose forms they were instrumental when I
debugged architecture specific assembly code for an embedded
system (not yet incorporated into the code base of uClibc).
It was also essential to use a flag "-fno-builtin" to detect the
failures, both for the old test cases and these new ones.

Based I on this recent experience, I have begun developing
a modified testing machinery that better would issue warnings
for false positives. The effort to avoid return values +1 and -1
is an afterglow of this methodology. Since the present test
suite is somewhat awkward to use in cross compiled settings,
I might come back to that issue another time.

Best regards for now

Ynglingatal


--- /tmp/test/string/tester.c.orig	2007-10-27 19:36:22.998411224 +0200
+++ /tmp/test/string/tester.c	2007-10-27 19:36:08.118673288 +0200
@@ -1087,15 +1087,31 @@
 static void
 test_memcmp (void)
 {
+  int i, cnt = 1;
+  char one[21], two[21];
+  
   it = "memcmp";
-  check(memcmp("a", "a", 1) == 0, 1);		/* Identity. */
-  check(memcmp("abc", "abc", 3) == 0, 2);	/* Multicharacter. */
-  check(memcmp("abcd", "abce", 4) < 0, 3);	/* Honestly unequal. */
-  check(memcmp("abce", "abcd", 4) > 0, 4);
-  check(memcmp("alph", "beta", 4) < 0, 5);
-  check(memcmp("a\203", "a\003", 2) > 0, 6);
-  check(memcmp("abce", "abcd", 3) == 0, 7);	/* Count limited. */
-  check(memcmp("abc", "def", 0) == 0, 8);	/* Zero count. */
+  check(memcmp("a", "a", 1) == 0, cnt++);	/* Identity. */
+  check(memcmp("abc", "abc", 3) == 0, cnt++);	/* Multicharacter. */
+  check(memcmp("abcd", "abcf", 4) < 0, cnt++);	/* Honestly unequal. */
+  check(memcmp("abcf", "abcd", 4) > 0, cnt++);
+  check(memcmp("alph", "cold", 4) < 0, cnt++);
+  check(memcmp("a\203", "a\003", 2) > 0, cnt++);
+  check(memcmp("a\003", "a\203", 2) < 0, cnt++);
+  check(memcmp("a\003bc", "a\203bc", 2) < 0, cnt++);
+  check(memcmp("abc\203", "abc\003", 4) > 0, cnt++);
+  check(memcmp("abc\003", "abc\203", 4) < 0, cnt++);
+  check(memcmp("abcf", "abcd", 3) == 0, cnt++);	/* Count limited. */
+  check(memcmp("abc", "def", 0) == 0, cnt++);	/* Zero count. */
+  /* Comparisons with shifting 4-byte boundaries. */
+  for (i=0; i<4; i++)
+  {
+char *a = one + i, *b = two + i;
+strncpy( a, "", 16);
+strncpy( b, "", 16);
+check( memcmp(b, a, 16) > 0, cnt++);
+check( memcmp(a, b, 16) < 0, cnt++);
+  }
 }
 
 static void
___
uClibc mailing list
uClibc@uclibc.org
http://busybox.net/cgi-bin/mailman/listinfo/uclibc