From 545e51be154967ab3e8d82fff5f7c25487076e72 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 23 Jan 2003 16:28:10 +0000 Subject: Update tests to be somewhat consistant with the rest of the world --- test/Config | 3 --- test/Rules.mak | 69 ++++++++++++++++++++++++++++++--------------------- test/crypt/Makefile | 6 ++--- test/malloc/Makefile | 12 ++++----- test/math/.cvsignore | 4 +++ test/math/Makefile | 37 ++++++++++++++++++++++++--- test/math/rint.c | 11 ++++++++ test/pwd_grp/Makefile | 8 +++--- test/signal/Makefile | 8 +++--- test/silly/Makefile | 4 +-- test/stat/Makefile | 4 +-- test/stdlib/Makefile | 16 ++++++------ test/string/Makefile | 8 +++--- test/termios/Makefile | 4 +-- test/unistd/Makefile | 8 +++--- 15 files changed, 129 insertions(+), 73 deletions(-) create mode 100644 test/math/rint.c (limited to 'test') diff --git a/test/Config b/test/Config index 866c0ec29..3536acf88 100644 --- a/test/Config +++ b/test/Config @@ -1,7 +1,4 @@ # Configuration for uClibc test apps. -# -# Copyright (C) 2001 by Lineo, inc. -# # Set the following to `true' to make a debuggable build. DODEBUG = false diff --git a/test/Rules.mak b/test/Rules.mak index 6090fd700..4d79db0e6 100644 --- a/test/Rules.mak +++ b/test/Rules.mak @@ -9,19 +9,11 @@ -include $(TESTDIR)../.config include $(TESTDIR)Config +#-------------------------------------------------------- +# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc. +LC_ALL:= C +export LC_ALL -# Use HOST_ARCH here since running these test is not -# even possible when cross compiling... -HOST_ARCH:= $(shell uname -m | sed \ - -e 's/i.86/i386/' \ - -e 's/sparc.*/sparc/' \ - -e 's/arm.*/arm/g' \ - -e 's/m68k.*/m68k/' \ - -e 's/ppc/powerpc/g' \ - -e 's/v850.*/v850/g' \ - -e 's/sh[234].*/sh/' \ - -e 's/mips.*/mips/' \ - ) ifeq ($(strip $(TARGET_ARCH)),) TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ -e 's/i.86/i386/' \ @@ -38,41 +30,62 @@ TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \ endif export TARGET_ARCH -# If you are running a cross compiler, you may want to set this -# to something more interesting... -CC = ../$(TESTDIR)extra/gcc-uClibc/$(TARGET_ARCH)-uclibc-gcc -HOST_CC = gcc + +#-------------------------------------------------------- +# 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=../$(TESTDIR)extra/gcc-uClibc/$(TARGET_ARCH)-uclibc- +CC= $(CROSS)gcc STRIPTOOL=strip -LDD = ../$(TESTDIR)ldso/util/ldd +LDD=../$(TESTDIR)ldso/util/ldd +# Select the compiler needed to build binaries for your development system +HOSTCC=gcc +HOSTCFLAGS=-O2 -Wall + +#-------------------------------------------------------- # Check if 'ls -sh' works or not LSFLAGS = -l -# turn all the warnings on -WARNINGS=-Wall +# 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 +OPTIMIZATION+=$(call check_gcc,-Os,-O2) +# Override optimization settings when debugging +ifeq ($(DODEBUG),y) +OPTIMIZATION=-O0 +endif -# use '-Os' optimization if available, else use -O2 -OPTIMIZATION = ${shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "-Os"; else echo "-O2" ; fi} +XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing +XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS))) +CFLAGS=$(XWARNINGS) $(OPTIMIZATION) $(XARCH_CFLAGS) +GLIBC_CFLAGS+=$(XWARNINGS) $(OPTIMIZATION) ifeq ($(DODEBUG),true) - CFLAGS +=$(WARNINGS) $(OPTIMIZATION) -g - GLIBC_CFLAGS +=$(WARNINGS) $(OPTIMIZATION) -g + CFLAGS+=-g + GLIBC_CFLAGS+=-g LDFLAGS =-Wl,-warn-common GLIBC_LDFLAGS =-Wl,-warn-common STRIPTOOL =true -Since_we_are_debugging else - CFLAGS +=$(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer - GLIBC_CFLAGS +=$(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer LDFLAGS =-s -Wl,-warn-common GLIBC_LDFLAGS =-s -Wl,-warn-common STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG) endif ifneq ($(DODYNAMIC),true) - LDFLAGS +=--static - GLIBC_LDFLAGS +=--static + LDFLAGS +=-static + GLIBC_LDFLAGS +=-static endif CFLAGS+=--uclibc-use-build-dir LDFLAGS+=--uclibc-use-build-dir diff --git a/test/crypt/Makefile b/test/crypt/Makefile index a965466f3..78732ec8c 100644 --- a/test/crypt/Makefile +++ b/test/crypt/Makefile @@ -40,10 +40,10 @@ crypt: crypt.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC) crypt_glibc: crypt.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC) -@ echo "-------" -@ echo " " - -@ echo "Compiling vs uClibc: " + -@ echo "Compiling vs glibc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ < crypt.input > $@.out 2>&1 -@ echo " " diff --git a/test/malloc/Makefile b/test/malloc/Makefile index ba0c86e50..dc10cc74f 100644 --- a/test/malloc/Makefile +++ b/test/malloc/Makefile @@ -62,8 +62,8 @@ testmalloc_glibc: testmalloc.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ @@ -88,8 +88,8 @@ mallocbug_glibc: mallocbug.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ @@ -114,8 +114,8 @@ realloc0_glibc: realloc0.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ diff --git a/test/math/.cvsignore b/test/math/.cvsignore index 31ed5f055..3c0a8a6fc 100644 --- a/test/math/.cvsignore +++ b/test/math/.cvsignore @@ -6,3 +6,7 @@ test-float test-ifloat test-ldouble test-ildouble +rint +rint.out +rint_glibc +rint_glibc.out diff --git a/test/math/Makefile b/test/math/Makefile index d41074939..c9231c5fc 100644 --- a/test/math/Makefile +++ b/test/math/Makefile @@ -25,8 +25,9 @@ EXTRA_LIBS=-lm PERL=/usr/bin/perl TARGETS:= -libm-tests:= +libm-tests=libm-test.c libm-tests+= test-double test-idouble +libm-tests+= diff #libm-tests+= test-float test-ifloat #libm-tests+= test-ldouble test-ildouble libm-tests.o = $(addsuffix .o,$(libm-tests)) @@ -35,7 +36,7 @@ libm-tests-generated = libm-test-ulps.h libm-test.c generated += $(libm-tests-generated) libm-test.stmp TARGETS += $(libm-tests) #$(libm-tests-generated) -all: libm-test.c $(TARGETS) +all: $(TARGETS) test-double: test-double.o $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) @@ -56,6 +57,36 @@ test-ildouble: test-ildoubl.o $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) -./$@ +rint: rint.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC) + -@ echo "-------" + -@ echo " " + -@ echo "Compiling vs uClibc: " + -@ echo " " + $(CC) $(CFLAGS) -c $< -o $@.o + $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) + $(STRIPTOOL) -x -R .note -R .comment $@ + -./$@ > $@.out 2>&1 + -@ echo " " + +rint_glibc: rint.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(CC) + -@ echo "-------" + -@ echo " " + -@ echo "Compiling vs glibc: " + -@ echo " " + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(EXTRA_LIBS) + $(STRIPTOOL) -x -R .note -R .comment $@ + -./$@ > $@.out 2>&1 + -@ echo " " + +diff: rint_glibc rint + -@ echo "-------" + -@ echo " " + -@ echo "Diffing output: " + -@ echo " " + -diff -u rint_glibc.out rint.out + -@ echo " " + test-float.o: libm-test.c test-ifloat.o: libm-test.c test-double.o: libm-test.c @@ -69,6 +100,6 @@ libm-test.c: $(ulps-file) libm-test.inc gen-libm-test.pl $(PERL) ./gen-libm-test.pl -u $< ./libm-test.inc -o "." 2>&1 > /dev/null clean: - rm -f *.[oa] *~ core $(TARGETS) $(generated) + rm -f *.[oa] *~ core $(TARGETS) $(generated) rint_glibc.out rint.out diff --git a/test/math/rint.c b/test/math/rint.c new file mode 100644 index 000000000..399fb90e3 --- /dev/null +++ b/test/math/rint.c @@ -0,0 +1,11 @@ +#include +#include +#include + +int main(void) { + double d1, d2; + d1 = 0.6; d2 = rint(d1); + printf("d1 = %f, d2 = %f\n", d1, d2); + return 0; +} + diff --git a/test/pwd_grp/Makefile b/test/pwd_grp/Makefile index 71a3f3b97..3a3b3b572 100644 --- a/test/pwd_grp/Makefile +++ b/test/pwd_grp/Makefile @@ -42,8 +42,8 @@ test_pwd_glibc: test_pwd.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ 2>&1 >test_pwd_glibc.out -@ echo " " @@ -64,8 +64,8 @@ test_grp_glibc: test_grp.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ 2>&1 >test_grp_glibc.out -@ echo " " diff --git a/test/signal/Makefile b/test/signal/Makefile index b3c6eee79..662ee4da5 100644 --- a/test/signal/Makefile +++ b/test/signal/Makefile @@ -40,8 +40,8 @@ signal_glibc: signal.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ -@ echo " " @@ -62,8 +62,8 @@ sigchld_glibc: sigchld.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ -@ echo " " diff --git a/test/silly/Makefile b/test/silly/Makefile index 751fa76e6..afe591f9a 100644 --- a/test/silly/Makefile +++ b/test/silly/Makefile @@ -51,8 +51,8 @@ hello_glibc: hello.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ diff --git a/test/stat/Makefile b/test/stat/Makefile index 448e13e2d..c2d4e75cc 100644 --- a/test/stat/Makefile +++ b/test/stat/Makefile @@ -51,8 +51,8 @@ stat_glibc: stat.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ diff --git a/test/stdlib/Makefile b/test/stdlib/Makefile index 957d324b0..8747c2a37 100644 --- a/test/stdlib/Makefile +++ b/test/stdlib/Makefile @@ -54,8 +54,8 @@ teststrtol_glibc: teststrtol.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ @@ -88,8 +88,8 @@ qsort_glibc: qsort.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ @@ -122,8 +122,8 @@ teston_exit_glibc: teston_exit.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ @@ -156,8 +156,8 @@ testatexit_glibc: testatexit.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ diff --git a/test/string/Makefile b/test/string/Makefile index 236dc68ea..df83b78fa 100644 --- a/test/string/Makefile +++ b/test/string/Makefile @@ -42,8 +42,8 @@ string_glibc: string.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ -@ echo " " @@ -64,8 +64,8 @@ testcopy_glibc: testcopy.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ > testcopy.gnu.out -@ echo " " diff --git a/test/termios/Makefile b/test/termios/Makefile index 683886a0b..881cf48e5 100644 --- a/test/termios/Makefile +++ b/test/termios/Makefile @@ -43,8 +43,8 @@ termios_glibc: termios.c Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -$(LDD) $@ ls -l $@ diff --git a/test/unistd/Makefile b/test/unistd/Makefile index b4a959233..f64b5428c 100644 --- a/test/unistd/Makefile +++ b/test/unistd/Makefile @@ -51,8 +51,8 @@ fork_glibc: fork.c ../testsuite.h Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ -@ echo " " @@ -73,8 +73,8 @@ vfork_glibc: vfork.c ../testsuite.h Makefile -@ echo " " -@ echo "Compiling vs GNU libc: " -@ echo " " - $(HOST_CC) $(GLIBC_CFLAGS) -c $< -o $@.o - $(HOST_CC) $(GLIBC_LDFLAGS) $@.o -o $@ + $(HOSTCC) $(GLIBC_CFLAGS) -c $< -o $@.o + $(HOSTCC) $(GLIBC_LDFLAGS) $@.o -o $@ $(STRIPTOOL) -x -R .note -R .comment $@ -./$@ -@ echo " " -- cgit v1.2.3