svn commit: branches/uClibc-nptl: test test/assert test/dlopen test/pwd_gr etc...
sjhill at uclibc.org
sjhill at uclibc.org
Sat Jan 20 12:09:05 PST 2007
Author: sjhill
Date: 2007-01-20 12:09:04 -0800 (Sat, 20 Jan 2007)
New Revision: 17404
Log:
Merge from trunk.
Modified:
branches/uClibc-nptl/test/Makefile
branches/uClibc-nptl/test/README
branches/uClibc-nptl/test/Rules.mak
branches/uClibc-nptl/test/Test.mak
branches/uClibc-nptl/test/assert/assert.c
branches/uClibc-nptl/test/dlopen/libtest2.c
branches/uClibc-nptl/test/pwd_grp/getgroups.c
branches/uClibc-nptl/test/setjmp/jmpbug.c
branches/uClibc-nptl/test/string/tester.c
branches/uClibc-nptl/utils/ldd.c
branches/uClibc-nptl/utils/readelf.c
Changeset:
Modified: branches/uClibc-nptl/test/Makefile
===================================================================
--- branches/uClibc-nptl/test/Makefile 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/Makefile 2007-01-20 20:09:04 UTC (rev 17404)
@@ -6,7 +6,6 @@
#
top_builddir=../
--include $(top_builddir).config
include Rules.mak
ALL_SUBDIRS := $(patsubst %/Makefile,%,$(wildcard */Makefile))
Modified: branches/uClibc-nptl/test/README
===================================================================
--- branches/uClibc-nptl/test/README 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/README 2007-01-20 20:09:04 UTC (rev 17404)
@@ -6,7 +6,7 @@
- UCLIBC_ONLY - only run tests against uClibc
- GLIBC_ONLY - only run tests against glibc
- COMPILE_ONLY - just build the tests, don't run them
- - CHECK_ONLY - only run the tests, don't compile or link them
+ - CHECK_ONLY - only run the tests, don't compile or link them
- V / VERBOSE - run tests with a lot of output
So, to just run the uClibc tests, try this:
Modified: branches/uClibc-nptl/test/Rules.mak
===================================================================
--- branches/uClibc-nptl/test/Rules.mak 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/Rules.mak 2007-01-20 20:09:04 UTC (rev 17404)
@@ -9,12 +9,18 @@
# Note: This does not read the top level Rules.mak file
#
-top_builddir = ../../
+top_builddir ?= ../
TESTDIR=$(top_builddir)test/
--include $(top_builddir).config
+include $(top_builddir)/Rules.mak
-UCLIBC_LDSO ?= $(firstword $(wildcard $(top_builddir)lib/ld*))
+ifdef UCLIBC_LDSO
+ifeq (,$(findstring /,$(UCLIBC_LDSO)))
+UCLIBC_LDSO := $(top_builddir)lib/$(UCLIBC_LDSO)
+endif
+else
+UCLIBC_LDSO := $(firstword $(wildcard $(top_builddir)lib/ld*))
+endif
#--------------------------------------------------------
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
@@ -30,8 +36,7 @@
-e 's/ppc/powerpc/g' \
-e 's/v850.*/v850/g' \
-e 's/sh[234]/sh/' \
- -e 's/mips-.*/mips/' \
- -e 's/mipsel-.*/mipsel/' \
+ -e 's/mips.*/mips/' \
-e 's/cris.*/cris/' \
)
endif
@@ -70,11 +75,12 @@
endif
XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
-XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS)))
+XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
-CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include
+CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -I$(top_builddir)include $(PTINC)
HOST_CFLAGS += $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS)
+LDFLAGS := $(CPU_LDFLAGS)
ifeq ($(DODEBUG),y)
CFLAGS += -g
HOST_CFLAGS += -g
Modified: branches/uClibc-nptl/test/Test.mak
===================================================================
--- branches/uClibc-nptl/test/Test.mak 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/Test.mak 2007-01-20 20:09:04 UTC (rev 17404)
@@ -18,6 +18,7 @@
$(error Sanity check: cannot have a test named "test.c")
endif
+top_builddir = ../../
include ../Rules.mak
U_TARGETS := $(TESTS)
Modified: branches/uClibc-nptl/test/assert/assert.c
===================================================================
--- branches/uClibc-nptl/test/assert/assert.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/assert/assert.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -16,29 +16,31 @@
void aborthandler(int junk)
{
- got_abort=1;
+ got_abort = 1;
}
-int main( int argc, char **argv)
+int main(int argc, char *argv[])
{
signal(SIGABRT, aborthandler);
init_testsuite("Testing functions defined in assert.h:\n\t");
got_abort=0;
- assert(0==0);
+ assert(0 == 0);
TEST_NUMERIC(got_abort, 0);
-#define NDEBUG
- got_abort=0;
+#ifndef NDEBUG
+# define NDEBUG
+#endif
+ got_abort = 0;
printf("Don't worry -- This next test is supposed to print an assert message:\n");
fprintf(stderr, "\t");
- assert(0==1);
+ assert(0 == 1);
TEST_NUMERIC(got_abort, 0);
-#undef NDEBUG
- got_abort=0;
- assert(0==1);
+#undef NDEBUG
+ got_abort = 0;
+ assert(0 == 1);
TEST_NUMERIC(got_abort, 1);
exit(0);
Modified: branches/uClibc-nptl/test/dlopen/libtest2.c
===================================================================
--- branches/uClibc-nptl/test/dlopen/libtest2.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/dlopen/libtest2.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -1,9 +1,6 @@
#include <stdio.h>
#include <pthread.h>
-
-extern int __pthread_mutex_init (void);
-
void __attribute__((constructor)) libtest2_ctor(void)
{
printf("libtest2: constructor!\n");
@@ -34,5 +31,3 @@
function2();
return 0;
}
-
-
Modified: branches/uClibc-nptl/test/pwd_grp/getgroups.c
===================================================================
--- branches/uClibc-nptl/test/pwd_grp/getgroups.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/pwd_grp/getgroups.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -1,9 +1,9 @@
/* This test was ripped out of GNU 'id' from coreutils-5.0
- * by Erik Andersen.
+ * by Erik Andersen.
*
*
* id is Copyright (C) 1989-2003 Free Software Foundation, Inc.
- * and licensed under the GPL v2 or later, and was written by
+ * and licensed under the GPL v2 or later, and was written by
* Arnold Robbins, with a major rewrite by David MacKenzie,
*/
@@ -19,90 +19,81 @@
static int problems = 0;
/* Print the name or value of group ID GID. */
-static void
-print_group (gid_t gid)
+static void print_group(gid_t gid)
{
- struct group *grp = NULL;
+ struct group *grp = NULL;
- grp = getgrgid (gid);
- if (grp == NULL)
- {
- warn("cannot find name for group ID %u", gid);
- problems++;
- }
+ grp = getgrgid(gid);
+ if (grp == NULL) {
+ warn("cannot find name for group ID %u", gid);
+ problems++;
+ }
- if (grp == NULL)
- printf ("%u", (unsigned) gid);
- else
- printf ("%s", grp->gr_name);
+ if (grp == NULL)
+ printf("%u", (unsigned)gid);
+ else
+ printf("%s", grp->gr_name);
}
-static int
-xgetgroups (gid_t gid, int *n_groups, gid_t **groups)
+static int xgetgroups(gid_t gid, int *n_groups, gid_t ** groups)
{
- int max_n_groups;
- int ng;
- gid_t *g;
- int fail = 0;
+ int max_n_groups;
+ int ng;
+ gid_t *g;
+ int fail = 0;
- max_n_groups = getgroups (0, NULL);
+ max_n_groups = getgroups(0, NULL);
- /* Add 1 just in case max_n_groups is zero. */
- g = (gid_t *) malloc (max_n_groups * sizeof (gid_t) + 1);
- if (g==NULL)
- err(EXIT_FAILURE, "out of memory");
- ng = getgroups (max_n_groups, g);
+ /* Add 1 just in case max_n_groups is zero. */
+ g = (gid_t *) malloc(max_n_groups * sizeof(gid_t) + 1);
+ if (g == NULL)
+ err(EXIT_FAILURE, "out of memory");
+ ng = getgroups(max_n_groups, g);
- if (ng < 0)
- {
- warn("cannot get supplemental group list");
- ++fail;
- free (groups);
- }
- if (!fail)
- {
- *n_groups = ng;
- *groups = g;
- }
- return fail;
+ if (ng < 0) {
+ warn("cannot get supplemental group list");
+ ++fail;
+ free(groups);
+ }
+ if (!fail) {
+ *n_groups = ng;
+ *groups = g;
+ }
+ return fail;
}
/* Print all of the distinct groups the user is in. */
-int main (int argc, char **argv)
+int main(int argc, char *argv[])
{
- struct passwd *pwd;
+ struct passwd *pwd;
- pwd = getpwuid (getuid());
- if (pwd == NULL)
- problems++;
+ pwd = getpwuid(getuid());
+ if (pwd == NULL)
+ problems++;
- print_group (getgid());
- if (getegid() != getgid())
- {
- putchar (' ');
- print_group (getegid());
- }
+ print_group(getgid());
+ if (getegid() != getgid()) {
+ putchar(' ');
+ print_group(getegid());
+ }
- {
- int n_groups;
- gid_t *groups;
- register int i;
-
- if (xgetgroups ((pwd ? pwd->pw_gid : (gid_t) -1),
- &n_groups, &groups))
{
- return ++problems;
- }
+ int n_groups = 0;
+ gid_t *groups;
+ register int i;
- for (i = 0; i < n_groups; i++)
- if (groups[i] != getgid() && groups[i] != getegid())
- {
- putchar (' ');
- print_group (groups[i]);
- }
- free (groups);
- }
- putchar('\n');
- return (problems != 0);
-}
+ if (xgetgroups((pwd ? pwd->pw_gid : (gid_t) - 1),
+ &n_groups, &groups)) {
+ return ++problems;
+ }
+ for (i = 0; i < n_groups; i++)
+ if (groups[i] != getgid() && groups[i] != getegid()) {
+ putchar(' ');
+ print_group(groups[i]);
+ }
+ free(groups);
+ }
+ putchar('\n');
+ return (problems != 0);
+}
Modified: branches/uClibc-nptl/test/setjmp/jmpbug.c
===================================================================
--- branches/uClibc-nptl/test/setjmp/jmpbug.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/setjmp/jmpbug.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -4,6 +4,9 @@
#include <setjmp.h>
#include <alloca.h>
+int ret;
+int verbose;
+
static void
sub5 (jmp_buf buf)
{
@@ -17,10 +20,14 @@
char *foo;
int arr[100];
+ ++ret;
+
arr[77] = x;
if (setjmp (buf))
{
- printf ("made it ok; %d\n", arr[77]);
+ --ret;
+ if (verbose)
+ printf ("made it ok; %d\n", arr[77]);
return;
}
@@ -29,12 +36,15 @@
}
int
-main (void)
+main (int argc, char *argv[])
{
int i;
+ verbose = (argc != 1);
+ ret = 0;
+
for (i = 123; i < 345; ++i)
test (i);
- return 0;
+ return ret;
}
Modified: branches/uClibc-nptl/test/string/tester.c
===================================================================
--- branches/uClibc-nptl/test/string/tester.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/test/string/tester.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -40,6 +40,12 @@
# undef __TEST_BSD_FUNCS__
#endif
+#if defined(__UCLIBC_SUSV3_LEGACY__) || defined(__UCLIBC_SUSV3_LEGACY_MACROS__)
+# define __TEST_SUSV3_LEGACY__
+#else
+# undef __TEST_SUSV3_LEGACY__
+#endif
+
#define STREQ(a, b) (strcmp((a), (b)) == 0)
const char *it = "<UNSET>"; /* Routine name for message routines. */
@@ -646,6 +652,7 @@
static void
test_index (void)
{
+#ifdef __TEST_SUSV3_LEGACY__
it = "index";
check (index ("abcd", 'z') == NULL, 1); /* Not found. */
(void) strcpy (one, "abcd");
@@ -658,6 +665,7 @@
(void) strcpy (one, "");
check (index (one, 'b') == NULL, 7); /* Empty string. */
check (index (one, '\0') == one, 8); /* NUL in empty string. */
+#endif
}
static void
@@ -738,6 +746,7 @@
static void
test_rindex (void)
{
+#ifdef __TEST_SUSV3_LEGACY__
it = "rindex";
check (rindex ("abcd", 'z') == NULL, 1); /* Not found. */
(void) strcpy (one, "abcd");
@@ -750,6 +759,7 @@
(void) strcpy (one, "");
check (rindex (one, 'b') == NULL, 7); /* Empty string. */
check (rindex (one, '\0') == one, 8); /* NUL in empty string. */
+#endif
}
static void
@@ -1346,6 +1356,7 @@
static void
test_bcopy (void)
{
+#ifdef __TEST_SUSV3_LEGACY__
/* Much like memcpy. Berklix manual is silent about overlap, so
don't test it. */
it = "bcopy";
@@ -1365,11 +1376,13 @@
(void) bcopy(one, two, 9);
equal(two, "hi there", 4); /* Just paranoia. */
equal(one, "hi there", 5); /* Stomped on source? */
+#endif
}
static void
test_bzero (void)
{
+#ifdef __TEST_SUSV3_LEGACY__
it = "bzero";
(void) strcpy(one, "abcdef");
bzero(one+2, 2);
@@ -1380,6 +1393,7 @@
(void) strcpy(one, "abcdef");
bzero(one+2, 0);
equal(one, "abcdef", 4); /* Zero-length copy. */
+#endif
}
static void
@@ -1409,6 +1423,7 @@
static void
test_bcmp (void)
{
+#ifdef __TEST_SUSV3_LEGACY__
it = "bcmp";
check(bcmp("a", "a", 1) == 0, 1); /* Identity. */
check(bcmp("abc", "abc", 3) == 0, 2); /* Multicharacter. */
@@ -1417,6 +1432,7 @@
check(bcmp("alph", "beta", 4) != 0, 5);
check(bcmp("abce", "abcd", 3) == 0, 6); /* Count limited. */
check(bcmp("abc", "def", 0) == 0, 8); /* Zero count. */
+#endif
}
static void
Modified: branches/uClibc-nptl/utils/ldd.c
===================================================================
--- branches/uClibc-nptl/utils/ldd.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/utils/ldd.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -27,8 +27,8 @@
#include "bswap.h"
#include "link.h"
-#include "elf.h"
#include "dl-defs.h"
+/* makefile will include elf.h for us */
#ifdef DMALLOC
#include <dmalloc.h>
@@ -287,7 +287,7 @@
if (stat(LDSO_CACHE, &st)
|| (fd = open(LDSO_CACHE, O_RDONLY, 0)) < 0) {
- dprintf(2, "ldd: can't open cache '%s'\n", LDSO_CACHE);
+ fprintf(stderr, "ldd: can't open cache '%s'\n", LDSO_CACHE);
cache_addr = (caddr_t) - 1; /* so we won't try again */
return -1;
}
@@ -296,7 +296,7 @@
cache_addr = (caddr_t) mmap(0, cache_size, PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if (cache_addr == MAP_FAILED) {
- dprintf(2, "ldd: can't map cache '%s'\n", LDSO_CACHE);
+ fprintf(stderr, "ldd: can't map cache '%s'\n", LDSO_CACHE);
return -1;
}
@@ -309,7 +309,7 @@
(sizeof(header_t) + header->nlibs * sizeof(libentry_t))
|| cache_addr[cache_size - 1] != '\0')
{
- dprintf(2, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
+ fprintf(stderr, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
goto fail;
}
@@ -321,7 +321,7 @@
if (libent[i].sooffset >= strtabsize ||
libent[i].liboffset >= strtabsize)
{
- dprintf(2, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
+ fprintf(stderr, "ldd: cache '%s' is corrupt\n", LDSO_CACHE);
goto fail;
}
}
Modified: branches/uClibc-nptl/utils/readelf.c
===================================================================
--- branches/uClibc-nptl/utils/readelf.c 2007-01-20 20:02:29 UTC (rev 17403)
+++ branches/uClibc-nptl/utils/readelf.c 2007-01-20 20:09:04 UTC (rev 17404)
@@ -24,8 +24,8 @@
#include <sys/types.h>
#include "bswap.h"
-#include "elf.h"
#include "link.h"
+/* makefile will include elf.h for us */
int byteswap;
inline uint32_t byteswap32_to_host(uint32_t value)
More information about the uClibc-cvs
mailing list