diff options
| -rw-r--r-- | test/Makefile | 1 | ||||
| -rw-r--r-- | test/README | 2 | ||||
| -rw-r--r-- | test/Rules.mak | 20 | ||||
| -rw-r--r-- | test/Test.mak | 1 | ||||
| -rw-r--r-- | test/assert/assert.c | 20 | ||||
| -rw-r--r-- | test/dlopen/libtest2.c | 5 | ||||
| -rw-r--r-- | test/pwd_grp/getgroups.c | 137 | ||||
| -rw-r--r-- | test/setjmp/jmpbug.c | 16 | ||||
| -rw-r--r-- | test/string/tester.c | 16 | ||||
| -rw-r--r-- | utils/ldd.c | 10 | ||||
| -rw-r--r-- | utils/readelf.c | 2 |
11 files changed, 125 insertions, 105 deletions
diff --git a/test/Makefile b/test/Makefile index 4063e60ee..0028f4a86 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,7 +6,6 @@ # top_builddir=../ --include $(top_builddir).config include Rules.mak ALL_SUBDIRS := $(patsubst %/Makefile,%,$(wildcard */Makefile)) diff --git a/test/README b/test/README index 4704b57c5..fe07a53f5 100644 --- a/test/README +++ b/test/README @@ -6,7 +6,7 @@ The following make variables may help you in testing: - 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: diff --git a/test/Rules.mak b/test/Rules.mak index 430f789da..6a7612b44 100644 --- a/test/Rules.mak +++ b/test/Rules.mak @@ -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 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ -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 @@ OPTIMIZATION += $(call check_gcc,-Os,-O2) 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 diff --git a/test/Test.mak b/test/Test.mak index 6477e26ad..9123d288f 100644 --- a/test/Test.mak +++ b/test/Test.mak @@ -18,6 +18,7 @@ ifneq ($(filter-out test,$(TESTS)),$(TESTS)) $(error Sanity check: cannot have a test named "test.c") endif +top_builddir = ../../ include ../Rules.mak U_TARGETS := $(TESTS) diff --git a/test/assert/assert.c b/test/assert/assert.c index 095609411..b0f54c625 100644 --- a/test/assert/assert.c +++ b/test/assert/assert.c @@ -16,29 +16,31 @@ int got_abort; 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); diff --git a/test/dlopen/libtest2.c b/test/dlopen/libtest2.c index b2eb02e88..529f8bb66 100644 --- a/test/dlopen/libtest2.c +++ b/test/dlopen/libtest2.c @@ -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 @@ int libtest2_func(const char *s) function2(); return 0; } - - diff --git a/test/pwd_grp/getgroups.c b/test/pwd_grp/getgroups.c index ea31b5829..0c093081a 100644 --- a/test/pwd_grp/getgroups.c +++ b/test/pwd_grp/getgroups.c @@ -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; - - 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); - - if (ng < 0) - { - warn("cannot get supplemental group list"); - ++fail; - free (groups); - } - if (!fail) - { - *n_groups = ng; - *groups = g; - } - return fail; + int max_n_groups; + int ng; + gid_t *g; + int fail = 0; + + 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); + + 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; - - pwd = getpwuid (getuid()); - if (pwd == NULL) - problems++; + struct passwd *pwd; - print_group (getgid()); - if (getegid() != getgid()) - { - putchar (' '); - print_group (getegid()); - } + pwd = getpwuid(getuid()); + if (pwd == NULL) + problems++; - { - int n_groups; - gid_t *groups; - register int i; + print_group(getgid()); + if (getegid() != getgid()) { + putchar(' '); + print_group(getegid()); + } - if (xgetgroups ((pwd ? pwd->pw_gid : (gid_t) -1), - &n_groups, &groups)) { - return ++problems; + int n_groups = 0; + gid_t *groups; + register int i; + + 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); } - - 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); + putchar('\n'); + return (problems != 0); } - diff --git a/test/setjmp/jmpbug.c b/test/setjmp/jmpbug.c index 125977b2f..4337e527a 100644 --- a/test/setjmp/jmpbug.c +++ b/test/setjmp/jmpbug.c @@ -4,6 +4,9 @@ #include <setjmp.h> #include <alloca.h> +int ret; +int verbose; + static void sub5 (jmp_buf buf) { @@ -17,10 +20,14 @@ test (int x) 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 @@ test (int x) } 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; } diff --git a/test/string/tester.c b/test/string/tester.c index f89cf01fa..71fee0c9b 100644 --- a/test/string/tester.c +++ b/test/string/tester.c @@ -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 @@ test_rawmemchr (void) 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 @@ test_index (void) (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 @@ test_memrchr (void) 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 @@ test_rindex (void) (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 @@ test_memset (void) 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 @@ test_bcopy (void) (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 @@ test_bzero (void) (void) strcpy(one, "abcdef"); bzero(one+2, 0); equal(one, "abcdef", 4); /* Zero-length copy. */ +#endif } static void @@ -1409,6 +1423,7 @@ test_strndup (void) 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 @@ test_bcmp (void) 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 diff --git a/utils/ldd.c b/utils/ldd.c index b454779e1..65aeb31fb 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -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 @@ int map_cache(void) 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 @@ int map_cache(void) 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 @@ int map_cache(void) (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 @@ int map_cache(void) 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; } } diff --git a/utils/readelf.c b/utils/readelf.c index d562b1138..0ff5d2563 100644 --- a/utils/readelf.c +++ b/utils/readelf.c @@ -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) |
