summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore13
-rw-r--r--test/Rules.mak88
-rw-r--r--test/Test.mak30
-rw-r--r--test/ctype/ctype.c2
-rw-r--r--test/test-skeleton.c11
-rw-r--r--test/time/tst-futimens1.c90
6 files changed, 156 insertions, 78 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 776a7e0a0..1e7cd584e 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -3,8 +3,13 @@
#
!.gitignore
#
+# Generated files
+#
+*.out
+#
# Executable test
#
+*_glibc
argp/argp-ex[1-4]
argp/argp-test
argp/bug-argp1
@@ -35,6 +40,7 @@ inet/tst-ethers
inet/tst-ethers-line
inet/tst-network
inet/tst-ntoa
+librt/shmtest
locale/bug-iconv-trans
locale/collate-test
locale/dump-ctype
@@ -108,7 +114,10 @@ malloc/tst-[cmv]alloc
malloc/tst-mallocfork
malloc/tst-mcheck
malloc/tst-obstack
-math/gen-libm-test.pl
+math/libm-test-ulps.h
+math/libm-test.c
+math/test-fpucw
+math/tst-definitions
misc/bug-glob2
misc/bug-readdir1
misc/dirent
@@ -228,6 +237,8 @@ string/tst-strxfrm
termios/termios
time/clocktest
time/test_time
+time/tst-ftime_l
+time/tst-futimens1
time/tst-mktime
time/tst-mktime3
time/tst-strptime2
diff --git a/test/Rules.mak b/test/Rules.mak
index d31372f78..492b99706 100644
--- a/test/Rules.mak
+++ b/test/Rules.mak
@@ -31,9 +31,10 @@ export LC_ALL
ifeq ($(strip $(TARGET_ARCH)),)
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
- -e 's/sparc.*/sparc/' \
- -e 's/arm.*/arm/g' \
+ -e 's/sun.*/sparc/' -e 's/sparc.*/sparc/' \
+ -e 's/sa110/arm/' -e 's/arm.*/arm/g' \
-e 's/m68k.*/m68k/' \
+ -e 's/parisc.*/hppa/' \
-e 's/ppc/powerpc/g' \
-e 's/v850.*/v850/g' \
-e 's/sh[234]/sh/' \
@@ -44,76 +45,42 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
endif
export TARGET_ARCH
-
-#--------------------------------------------------------
-# If you are running a cross compiler, you will want to set 'CROSS'
-# to something more interesting... Target architecture is determined
-# by asking the CC compiler what arch it compiles things for, so unless
-# your compiler is broken, you should not need to specify TARGET_ARCH
-#
-# Most people will set this stuff on the command line, i.e.
-# make CROSS=mipsel-linux-
-# will build uClibc for 'mipsel'.
-
-CROSS = $(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
-CC = $(CROSS)gcc
-RM = rm -f
-RM_R = $(RM) -r
-
-# Select the compiler needed to build binaries for your development system
-HOSTCC = gcc
-
-
-#--------------------------------------------------------
-# A nifty macro to make testing gcc features easier
-check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
- then echo "$(1)"; else echo "$(2)"; fi)
-
-# use '-Os' optimization if available, else use -O2, allow Config to override
-# Override optimization settings when debugging
-ifeq ($(DODEBUG),y)
-OPTIMIZATION = -O0
-else
-OPTIMIZATION += $(call check_gcc,-Os,-O2)
-endif
-
-XWARNINGS := $(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes
-XARCH_CFLAGS := $(subst ",, $(strip $(ARCH_CFLAGS))) $(CPU_CFLAGS)
-XCOMMON_CFLAGS := -D_GNU_SOURCE -I$(top_builddir)test
-CFLAGS := $(XWARNINGS) $(OPTIMIZATION) $(XCOMMON_CFLAGS) $(XARCH_CFLAGS) -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
-
-CC_IPREFIX := $(shell $(CC) --print-file-name=include)
-CC_INC := -I$(dir $(CC_IPREFIX))include-fixed -I$(CC_IPREFIX)
-CFLAGS += $(CC_INC)
+RM_R = $(Q)$(RM) -r
ifneq ($(KERNEL_HEADERS),)
ifeq ($(patsubst /%,/,$(KERNEL_HEADERS)),/)
# Absolute path in KERNEL_HEADERS
-CFLAGS += -I$(KERNEL_HEADERS)
+KERNEL_INCLUDES += -I$(KERNEL_HEADERS)
else
# Relative path in KERNEL_HEADERS
-CFLAGS += -I$(top_builddir)$(KERNEL_HEADERS)
+KERNEL_INCLUDES += -I$(top_builddir)$(KERNEL_HEADERS)
endif
endif
+XCOMMON_CFLAGS := -I$(top_builddir)test -D_GNU_SOURCE
+XWARNINGS += $(call check_gcc,-Wstrict-prototypes,)
+CFLAGS := -nostdinc -I$(top_builddir)$(LOCAL_INSTALL_PATH)/usr/include
+CFLAGS += $(XCOMMON_CFLAGS) $(KERNEL_INCLUDES) $(CC_INC)
+CFLAGS += $(OPTIMIZATION) $(CPU_CFLAGS) $(XWARNINGS)
+
# Can't add $(OPTIMIZATION) here, it may be target-specific.
# Just adding -Os for now.
-HOST_CFLAGS += $(XWARNINGS) -Os $(XCOMMON_CFLAGS)
+HOST_CFLAGS += $(XCOMMON_CFLAGS) -Os $(XWARNINGS)
-LDFLAGS := $(CPU_LDFLAGS)
+LDFLAGS := $(CPU_LDFLAGS-y)
ifeq ($(DODEBUG),y)
CFLAGS += -g
HOST_CFLAGS += -g
- LDFLAGS += -g
- HOST_LDFLAGS += -g
+ LDFLAGS += -Wl,-g
+ HOST_LDFLAGS += -Wl,-g
else
- LDFLAGS += -s
- HOST_LDFLAGS += -s
+ LDFLAGS += -Wl,-s
+ HOST_LDFLAGS += -Wl,-s
endif
-ifeq ($(strip $(UCLIBC_STATIC)),y)
- STATIC_LDFLAGS := -static
- HOST_LDFLAGS += -static
+ifneq ($(HAVE_SHARED),y)
+ LDFLAGS += -Wl,-static
+ HOST_LDFLAGS += -Wl,-static
endif
LDFLAGS += -B$(top_builddir)lib -Wl,-rpath,$(top_builddir)lib -Wl,-rpath-link,$(top_builddir)lib
@@ -124,7 +91,7 @@ UCLIBC_LDSO_ABSPATH=$(SHARED_LIB_LOADER_PREFIX)
endif
ifeq ($(findstring -static,$(LDFLAGS)),)
- LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
+LDFLAGS += -Wl,--dynamic-linker,$(UCLIBC_LDSO_ABSPATH)/$(UCLIBC_LDSO)
endif
ifeq ($(LDSO_GNU_HASH_SUPPORT),y)
@@ -133,9 +100,7 @@ LDFLAGS += -Wl,${LDFLAGS_GNUHASH}
endif
-# Filter output
-MAKEFLAGS += --no-print-directory
-ifneq ($(findstring s,$(MAKEFLAGS)),)
+ifneq ($(findstring -s,$(MAKEFLAGS)),)
DISP := sil
Q := @
SCAT := -@true
@@ -150,12 +115,15 @@ Q := @
SCAT := -@true
endif
endif
+ifneq ($(Q),)
+MAKEFLAGS += --no-print-directory
+endif
banner := ---------------------------------
pur_showclean = echo " "CLEAN $(notdir $(CURDIR))
pur_showdiff = echo " "TEST_DIFF $(notdir $(CURDIR))/
pur_showlink = echo " "TEST_LINK $(notdir $(CURDIR))/ $@
-pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(patsubst %.exe,%,$@)
+pur_showtest = echo " "TEST_EXEC $(notdir $(CURDIR))/ $(@:.exe=)
sil_showclean =
sil_showdiff = true
sil_showlink = true
@@ -163,7 +131,7 @@ sil_showtest = true
ver_showclean =
ver_showdiff = true echo
ver_showlink = true echo
-ver_showtest = printf "\n$(banner)\nTEST $(notdir $(PWD))/ $(patsubst %.exe,%,$@)\n$(banner)\n"
+ver_showtest = printf "\n$(banner)\nTEST $(notdir $(CURDIR))/ $(@:.exe=)\n$(banner)\n"
do_showclean = $($(DISP)_showclean)
do_showdiff = $($(DISP)_showdiff)
do_showlink = $($(DISP)_showlink)
diff --git a/test/Test.mak b/test/Test.mak
index e4f4835e1..0c5629144 100644
--- a/test/Test.mak
+++ b/test/Test.mak
@@ -14,12 +14,12 @@ ifeq ($(SHELL_TESTS),)
SHELL_TESTS := $(patsubst %.sh,shell_%,$(wildcard *.sh))
endif
-ifneq ($(filter-out test,$(TESTS)),$(TESTS))
+ifneq ($(filter-out test,$(strip $(TESTS))),$(strip $(TESTS)))
$(error Sanity check: cannot have a test named "test.c")
endif
U_TARGETS := $(TESTS)
-G_TARGETS := $(patsubst %,%_glibc,$(U_TARGETS))
+G_TARGETS := $(addsuffix _glibc,$(U_TARGETS))
ifeq ($(GLIBC_ONLY),)
TARGETS += $(U_TARGETS)
@@ -30,35 +30,39 @@ endif
CLEAN_TARGETS := $(U_TARGETS) $(G_TARGETS)
COMPILE_TARGETS := $(TARGETS)
-RUN_TARGETS := $(patsubst %,%.exe,$(TARGETS))
+RUN_TARGETS := $(addsuffix .exe,$(TARGETS))
TARGETS += $(SHELL_TESTS)
+CFLAGS+=$(CFLAGS_$(notdir $(CURDIR)))
define binary_name
$(patsubst %.exe,%,$@)
endef
+define tst_src_name
+$(patsubst %_glibc,%,$(binary_name))
+endef
define diff_test
$(Q)\
- for x in "$(binary_name).out" "$(patsubst %_glibc,%,$(binary_name)).out" ; do \
+ for x in "$(binary_name).out" "$(tst_src_name).out" ; do \
test -e "$$x.good" && $(do_showdiff) "$(binary_name).out" "$$x.good" && exec diff -u "$(binary_name).out" "$$x.good" ; \
done ; \
true
endef
define uclibc_glibc_diff_test
$(Q)\
- test -z "$(DODIFF_$(patsubst %_glibc,%,$(binary_name)))" && exec true ; \
+ test -z "$(DODIFF_$(tst_src_name))" && exec true ; \
uclibc_out="$(binary_name).out" ; \
- glibc_out="$(patsubst %_glibc,%,$(binary_name)).out" ; \
+ glibc_out="$(tst_src_name).out" ; \
$(do_showdiff) $$uclibc_out $$glibc_out ; \
exec diff -u "$$uclibc_out" "$$glibc_out"
endef
define exec_test
$(showtest)
$(Q)\
- $(WRAPPER) $(WRAPPER_$(patsubst %_glibc,%,$(binary_name))) \
- ./$(binary_name) $(OPTS) $(OPTS_$(patsubst %_glibc,%,$(binary_name))) > "$(binary_name).out" 2>&1 ; \
+ $(WRAPPER) $(WRAPPER_$(tst_src_name)) \
+ ./$(binary_name) $(OPTS) $(OPTS_$(tst_src_name)) > "$(binary_name).out" 2>&1 ; \
ret=$$? ; \
- expected_ret="$(RET_$(patsubst %_glibc,%,$(binary_name)))" ; \
+ expected_ret="$(RET_$(tst_src_name))" ; \
test -z "$$expected_ret" && export expected_ret=0 ; \
if ! test $$ret -eq $$expected_ret ; then \
echo "ret == $$ret ; expected_ret == $$expected_ret" ; \
@@ -78,19 +82,19 @@ endif
compile: $(COMPILE_TARGETS)
-G_TARGET_SRCS := $(patsubst %,%.c,$(G_TARGETS))
-U_TARGET_SRCS := $(patsubst %,%.c,$(U_TARGETS))
+G_TARGET_SRCS := $(addsuffix .c,$(G_TARGETS))
+U_TARGET_SRCS := $(addsuffix .c,$(U_TARGETS))
$(MAKE_SRCS): Makefile $(TESTDIR)Makefile $(TESTDIR)Rules.mak $(TESTDIR)Test.mak
$(U_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
$(showlink)
- $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c $@.c -o $@.o
+ $(Q)$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(notdir $(CURDIR))) $(CFLAGS_$@) -c $@.c -o $@.o
$(Q)$(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$@)
$(G_TARGETS): $(U_TARGET_SRCS) $(MAKE_SRCS)
$(showlink)
- $(Q)$(HOSTCC) $(HOST_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(patsubst %_glibc,%,$@)) -c $(patsubst %_glibc,%,$@).c -o $@.o
+ $(Q)$(HOSTCC) $(HOST_CFLAGS) $(CFLAGS_$(notdir $(CURDIR))) $(CFLAGS_$(patsubst %_glibc,%,$@)) -c $(patsubst %_glibc,%,$@).c -o $@.o
$(Q)$(HOSTCC) $(HOST_LDFLAGS) $@.o -o $@ $(EXTRA_LDFLAGS) $(LDFLAGS_$(patsubst %_glibc,%,$@))
diff --git a/test/ctype/ctype.c b/test/ctype/ctype.c
index 352b2d2c8..f38f722b2 100644
--- a/test/ctype/ctype.c
+++ b/test/ctype/ctype.c
@@ -56,6 +56,7 @@ int main( int argc, char **argv)
+#ifdef __UCLIBC_SUSV4_LEGACY__
/* isascii() */
{
int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1};
@@ -71,6 +72,7 @@ int main( int argc, char **argv)
TEST( isascii(c)==0);
}
}
+#endif
/* iscntrl() */
diff --git a/test/test-skeleton.c b/test/test-skeleton.c
index c61d09e82..752158405 100644
--- a/test/test-skeleton.c
+++ b/test/test-skeleton.c
@@ -137,14 +137,15 @@ timeout_handler (int sig __attribute__ ((unused)))
{
int killed = 0;
int status;
+ int i;
/* Send signal. */
kill (pid, SIGKILL);
/* Wait for it to terminate. */
- int i;
for (i = 0; i < 5; ++i)
{
+ struct timespec ts;
killed = waitpid (pid, &status, WNOHANG|WUNTRACED);
if (killed != 0)
break;
@@ -153,7 +154,6 @@ timeout_handler (int sig __attribute__ ((unused)))
nanosleep() call return prematurely, all the better. We
won't restart it since this probably means the child process
finally died. */
- struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 100000000;
nanosleep (&ts, NULL);
@@ -213,6 +213,7 @@ main (int argc, char *argv[])
int opt;
unsigned int timeoutfactor = 1;
pid_t termpid;
+ char *envstr_timeoutfactor;
/* Make uses of freed and uninitialized memory known. */
#ifdef __MALLOC_STANDARD__
@@ -244,7 +245,7 @@ main (int argc, char *argv[])
/* If set, read the test TIMEOUTFACTOR value from the environment.
This value is used to scale the default test timeout values. */
- char *envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
+ envstr_timeoutfactor = getenv ("TIMEOUTFACTOR");
if (envstr_timeoutfactor != NULL)
{
char *envstr_conv = envstr_timeoutfactor;
@@ -303,6 +304,9 @@ main (int argc, char *argv[])
if (pid == 0)
{
/* This is the child. */
+#ifdef RLIMIT_DATA
+ struct rlimit data_limit;
+#endif
#ifdef RLIMIT_CORE
/* Try to avoid dumping core. */
struct rlimit core_limit;
@@ -313,7 +317,6 @@ main (int argc, char *argv[])
#ifdef RLIMIT_DATA
/* Try to avoid eating all memory if a test leaks. */
- struct rlimit data_limit;
if (getrlimit (RLIMIT_DATA, &data_limit) == 0)
{
if (TEST_DATA_LIMIT == RLIM_INFINITY)
diff --git a/test/time/tst-futimens1.c b/test/time/tst-futimens1.c
new file mode 100644
index 000000000..a452de2c7
--- /dev/null
+++ b/test/time/tst-futimens1.c
@@ -0,0 +1,90 @@
+/* vi: set sw=4 ts=4: */
+/* testcase
+ * Copyright (C) 2009 Bernhard Reutner-Fischer <uClibc@uClibc.org>
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+struct
+{
+ char *name; /* name of file to open */
+ int flags; /* flags for file descriptor */
+ const struct timespec ts[2];
+ int err; /* expected errno */
+} tests [] =
+{
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{99,0},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,99},{0,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{99,0}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{0,0},{0,99}}, 0},
+ {"futimens.tst", (O_CREAT|O_TRUNC), {{11,2},{3,4}}, 0},
+};
+int do_test(int argc, char **argv) {
+ char *name;
+ int i, errors;
+ errors = argc - argc + 0;
+
+ for (i=0; i < (int) (sizeof(tests)/sizeof(tests[0])); ++i) {
+ int err, fd;
+ struct stat sb;
+ name = tests[i].name;
+ if (*name != '.')
+ unlink(name);
+ fd = open(name, tests[i].flags);
+ if (fd < 0)
+ abort();
+ errno = 0;
+ err = futimens(fd, tests[i].ts);
+ if ((errno && !err) || (!errno && err)) {
+ err = errno;
+ printf("%s: FAILED test %d (errno and return value disagree)\n",
+ argv[0], i);
+ ++errors;
+ } else
+ err = errno;
+ if (err != tests[i].err) {
+ printf("%s: FAILED test %d (expected errno %d, got %d)\n",
+ argv[0], i, tests[i].err, err);
+ ++errors;
+ continue;
+ }
+ if (stat(name, &sb) < 0) {
+ printf("%s: FAILED test %d (verification)\n", argv[0], i);
+ ++errors;
+ continue;
+ } else {
+ unsigned wrong = tests[i].ts[0].tv_sec != sb.st_atim.tv_sec ||
+ tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec ||
+ tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec ||
+ tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec;
+ if (wrong) {
+ ++errors;
+ if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec)
+ printf("%s: FAILED test %d (access time, sec: expected %ld, got %ld)\n",
+ argv[0], i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec);
+ if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec)
+ printf("%s: FAILED test %d (access time, nsec: expected %ld, got %ld)\n",
+ argv[0], i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec);
+
+ if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec)
+ printf("%s: FAILED test %d (modification time, sec: expected %ld, got %ld)\n",
+ argv[0], i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec);
+ if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec)
+ printf("%s: FAILED test %d (modification time, nsec: expected %ld, got %ld)\n",
+ argv[0], i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec);
+ }
+ }
+ }
+ if (*name != '.')
+ unlink(name);
+ printf("%d errors.\n", errors);
+ return (!errors) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+#include <test-skeleton.c>