This patch fixes/enhances the testsuite:

I removed the checks which called endmntent() multiple times resp. with a
    NULL pointer. Behavior in first case is undefined and latter causes a
    segfault (I could not find documentation that this is allowed). Hence,
    it does not make sense to test this.
test 'malloc(0)' only, when WANT_MALLOC_ZERO is set
the '%Zu' printf format specifier is bogus (from libc5 ages). I replaced it
    with the '%zu' one.
Please note, that this test still fails because it uses glibc specific
    features.
removed tests which set a non-C locale. Broken usage of 'strptime()' result
    was fixed too. This test should succeed now.
this test was added while working on the '%F/%G' patch and verifies the
    isinf() + isnan() functions.
Please see
http://cvs.fedora.redhat.com/viewcvs/rpms/dietlibc/devel/runtests-X.sh?root
    =extras&view=markup
for tests which are known to be broken.
This commit is contained in:
ensc 2008-04-13 14:01:03 +00:00
commit bc919cc87e

View file

@ -0,0 +1,176 @@
diff -up dietlibc-0.31.20080409/test/getmntent.c.testsuite dietlibc-0.31.20080409/test/getmntent.c
--- dietlibc-0.31.20080409/test/getmntent.c.testsuite 2003-12-15 14:07:42.000000000 +0100
+++ dietlibc-0.31.20080409/test/getmntent.c 2008-04-13 15:49:19.000000000 +0200
@@ -33,10 +33,6 @@ while ((e = getmntent(fstab))) {
printf("closing /etc/fstab\n");
assert ( 1 == endmntent(fstab));
- printf("closing /etc/fstab again\n");
- assert ( 1 == endmntent(fstab)); /* endmntent must always return 1 */
- printf("entmntent(0)\n");
- assert ( 1 == endmntent(0)); /* causes a segfault with diet libc */
+
return 0;
}
-
diff -up dietlibc-0.31.20080409/test/runtests.sh.testsuite dietlibc-0.31.20080409/test/runtests.sh
--- dietlibc-0.31.20080409/test/runtests.sh.testsuite 2008-04-13 14:54:58.000000000 +0200
+++ dietlibc-0.31.20080409/test/runtests.sh 2008-04-13 14:54:58.000000000 +0200
@@ -1,6 +1,6 @@
SUBDIRS="dirent inet stdio string stdlib time"
-TESTPROGRAMS="adjtime argv atexit bsearch byteswap calloc confstr empty flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysconf sysenter ungetc waitpid"
+TESTPROGRAMS="adjtime argv atexit bsearch byteswap calloc confstr empty flush fputc ffs fnmatch ftw fwrite getaddrinfo getenv getdelim getgrnam gethostbyaddr gethostbyname gethostbyname_r getmntent getopt getpwnam getservbyname getservbyport getusershell glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger math md5_testharness memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest protoent prototypes putenv pwent rand48 readdir regex select sendfile servent siglist speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr strstr strtol sysconf sysenter ungetc waitpid"
STDIN="read1"
PASS="getpass"
diff -up dietlibc-0.31.20080409/test/Makefile.testsuite dietlibc-0.31.20080409/test/Makefile
--- dietlibc-0.31.20080409/test/Makefile.testsuite 2008-04-13 14:54:58.000000000 +0200
+++ dietlibc-0.31.20080409/test/Makefile 2008-04-13 14:54:58.000000000 +0200
@@ -10,7 +10,7 @@ LCOMPAT=-lcompat
TESTPROGRAMS=adjtime argv asprintf atexit bsearch byteswap calloc confstr cycles empty flush fnmatch \
fputc ftw fwrite getaddrinfo getenv getgrnam gethostbyaddr gethostbyname \
gethostbyname_r getmntent getopt getpass getpwnam getservbyname getservbyport getusershell \
-glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger md5_testharness \
+glob grent hasmntopt hello iconv if_nameindex ltostr malloc-debugger math md5_testharness \
memccpy memchr memcmp memrchr memusage mktime mmap_test pipe printf printftest \
protoent prototypes putenv pwent rand48 read1 readdir regex select sendfile servent siglist \
speed spent sprintf sscanf stdarg strcasecmp strcmp strncat strncpy strptime strrchr \
diff -up dietlibc-0.31.20080409/test/stdlib/tst-malloc.c.testsuite dietlibc-0.31.20080409/test/stdlib/tst-malloc.c
--- dietlibc-0.31.20080409/test/stdlib/tst-malloc.c.testsuite 2003-12-15 14:07:42.000000000 +0100
+++ dietlibc-0.31.20080409/test/stdlib/tst-malloc.c 2008-04-13 14:54:58.000000000 +0200
@@ -21,13 +21,15 @@
#include <stdlib.h>
#include <stdio.h>
+#include "../../dietfeatures.h"
+
static int errors = 0;
static void
merror (const char *msg)
{
++errors;
- printf ("Error: %s\n", msg);
+ fprintf (stderr, "Error: %s\n", msg);
}
int
@@ -56,9 +58,11 @@ main (void)
if (p != NULL)
merror ("realloc (p, 0) failed.");
+#ifdef WANT_MALLOC_ZERO
p = malloc (0);
if (p == NULL)
merror ("malloc (0) failed.");
+#endif
p = realloc (p, 0);
if (p != NULL)
diff -up dietlibc-0.31.20080409/test/time/tst-strftime.c.testsuite dietlibc-0.31.20080409/test/time/tst-strftime.c
--- dietlibc-0.31.20080409/test/time/tst-strftime.c.testsuite 2003-12-15 14:07:42.000000000 +0100
+++ dietlibc-0.31.20080409/test/time/tst-strftime.c 2008-04-13 14:54:58.000000000 +0200
@@ -49,18 +49,18 @@ int main (void) {
if (res == 0)
{
- printf ("%Zu: %s: res == 0 despite size == %Zu\n",
+ printf ("%zu: %s: res == 0 despite size == %zu\n",
cnt, tests[cnt].fmt, size);
result = 1;
}
else if (size < tests[cnt].min)
{
- printf ("%Zu: %s: size == %Zu was enough\n",
+ printf ("%zu: %s: size == %zu was enough\n",
cnt, tests[cnt].fmt, size);
result = 1;
}
else
- printf ("%Zu: %s: size == %Zu: OK\n", cnt, tests[cnt].fmt, size);
+ printf ("%zu: %s: size == %zu: OK\n", cnt, tests[cnt].fmt, size);
free (buf);
}
diff -up dietlibc-0.31.20080409/test/time/tst-strptime.c.testsuite dietlibc-0.31.20080409/test/time/tst-strptime.c
--- dietlibc-0.31.20080409/test/time/tst-strptime.c.testsuite 2003-12-15 14:07:42.000000000 +0100
+++ dietlibc-0.31.20080409/test/time/tst-strptime.c 2008-04-13 14:54:58.000000000 +0200
@@ -41,10 +41,12 @@ static const struct
{ "C", "03/03/00", "%D", 5, 62, 2, 3 },
{ "C", "9/9/99", "%x", 4, 251, 8, 9 },
{ "C", "19990502123412", "%Y%m%d%H%M%S", 0, 121, 4, 2 },
+#if 0 /* dietlibc does not support %U/%W/%j and non-POSIX locales */
{ "C", "2001 20 Mon", "%Y %U %a", 1, 140, 4, 21 },
{ "C", "2001 21 Mon", "%Y %W %a", 1, 140, 4, 21 },
{ "ja_JP.EUC-JP", "2001 20 \xb7\xee", "%Y %U %a", 1, 140, 4, 21 },
{ "ja_JP.EUC-JP", "2001 21 \xb7\xee", "%Y %W %a", 1, 140, 4, 21 },
+#endif
};
@@ -72,9 +74,16 @@ test_tm (void)
for (i = 0; i < sizeof (tm_tests) / sizeof (tm_tests[0]); ++i)
{
+ char *pres;
memset (&tm, '\0', sizeof (tm));
-
- if (strptime (tm_tests[i].input, tm_tests[i].format, &tm) != '\0')
+
+ pres = strptime (tm_tests[i].input, tm_tests[i].format, &tm);
+ if (!pres)
+ {
+ fprintf(stderr, "failed to parse '%s'\n", day_tests[i].input);
+ result = 1;
+ }
+ else if (*pres != '\0')
{
printf ("not all of `%s' read\n", tm_tests[i].input);
result = 1;
@@ -118,6 +127,7 @@ int main (void) {
for (i = 0; i < sizeof (day_tests) / sizeof (day_tests[0]); ++i)
{
+ char *pres;
memset (&tm, '\0', sizeof (tm));
if (setlocale (LC_ALL, day_tests[i].locale) == NULL)
@@ -125,7 +135,14 @@ int main (void) {
printf ("cannot set locale %s: %m\n", day_tests[i].locale);
}
- if (*strptime (day_tests[i].input, day_tests[i].format, &tm) != '\0')
+ pres = strptime (day_tests[i].input, day_tests[i].format, &tm);
+ if (!pres)
+ {
+ fprintf(stderr, "failed to parse '%s' for locale '%s'\n",
+ day_tests[i].input, day_tests[i].locale);
+ result = 1;
+ }
+ else if (*pres != '\0')
{
printf ("not all of `%s' read\n", day_tests[i].input);
result = 1;
diff -up /dev/null dietlibc-0.31.20080409/test/math.c
--- /dev/null 2008-03-18 07:40:22.289057188 +0100
+++ dietlibc-0.31.20080409/test/math.c 2008-04-13 14:54:58.000000000 +0200
@@ -0,0 +1,18 @@
+#include <math.h>
+#include <float.h>
+#include <assert.h>
+
+int main()
+{
+#if (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))
+ assert(isinf(__builtin_inff())==1);
+ assert(isinf(-__builtin_inff())==-1);
+ assert(isnan(__builtin_nan("")));
+#endif
+
+ assert(isinf((DBL_MAX * DBL_MAX))==1);
+ assert(isinf(-(DBL_MAX * DBL_MAX))==-1);
+ //assert(isnan(nan("")));
+
+ return 0;
+}