summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Config12
-rw-r--r--test/Makefile10
-rw-r--r--test/Rules.mak45
-rw-r--r--test/assert/Makefile40
-rw-r--r--test/assert/assert.c29
-rw-r--r--test/ctype/Makefile38
-rw-r--r--test/ctype/ctype.c94
-rw-r--r--test/pwd_grp/Makefile40
-rw-r--r--test/signal/Makefile29
-rw-r--r--test/silly/Makefile27
-rw-r--r--test/stdlib/Makefile51
-rw-r--r--test/string/Makefile56
-rw-r--r--test/testsuite.h87
-rw-r--r--test/unistd/Makefile28
14 files changed, 261 insertions, 325 deletions
diff --git a/test/Config b/test/Config
new file mode 100644
index 000000000..67052f15c
--- /dev/null
+++ b/test/Config
@@ -0,0 +1,12 @@
+# Configuration for uClibc test apps.
+#
+# Copyright (C) 2001 by Lineo, inc.
+#
+
+# Set the following to `true' to make a debuggable build.
+DODEBUG = true
+
+# If you want to compile using uClibc as a shared library, turn this on.
+DODYNAMIC = false
+
+
diff --git a/test/Makefile b/test/Makefile
index 0035b9dea..d842a7232 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -20,7 +20,15 @@
# other sundry sources. Files within this library are copyright by their
# respective copyright holders.
-DIRS = assert ctype pwd_grp signal silly stdlib string
+TOPDIR=../
+include $(TOPDIR)Rules.mak
+
+ifeq ($(TARGET_ARCH), $(NATIVE_ARCH))
+ DIRS = assert ctype pwd_grp signal silly stdlib string
+else
+ DIRS =
+endif
+
all: subdirs
tags:
diff --git a/test/Rules.mak b/test/Rules.mak
new file mode 100644
index 000000000..fd537f337
--- /dev/null
+++ b/test/Rules.mak
@@ -0,0 +1,45 @@
+# Rules.make for uClibc test apps.
+#
+# Copyright (C) 2001 by Lineo, inc.
+#
+#
+#Note: This does not read the top level Rules.mak file
+#
+
+include $(TESTDIR)Config
+
+
+NATIVE_ARCH = $(shell uname -m | sed -e 's/i.86/i386/' -e 's/sparc.*/sparc/' \
+ -e 's/arm.*/arm/g' -e 's/m68k.*/m68k/')
+
+# If you are running a cross compiler, you may want to set this
+# to something more interesting...
+TESTCC = ../$(TESTDIR)extra/gcc-uClibc/gcc-uClibc-$(NATIVE_ARCH)
+CC = gcc
+STRIPTOOL=strip
+
+
+# Check if 'ls -sh' works or not
+LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
+ then echo "-sh"; else echo "-s" ; fi)
+
+# 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)
+
+CFLAGS=$(WARNINGS) $(OPTIMIZATION)
+
+ifeq ($(DODEBUG),true)
+ CFLAGS +=-g
+ LDFLAGS =-Wl,-warn-common
+ STRIPTOOL =/bin/true -Since_we_are_debugging
+else
+ CFLAGS +=-fomit-frame-pointer
+ LDFLAGS =-s -Wl,-warn-common
+ STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
+endif
+
+ifneq ($(DODYNAMIC),true)
+ LDFLAGS +=--static
+endif
+
diff --git a/test/assert/Makefile b/test/assert/Makefile
index 54553ce00..6d71595b9 100644
--- a/test/assert/Makefile
+++ b/test/assert/Makefile
@@ -1,47 +1,19 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
-
-
-TARGETS=assert assert_glibc
+TARGETS=assert
all: $(TARGETS)
-assert: assert.c Makefile $(TOPDIR)libc.a
+assert: assert.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
- $(STRIPTOOL) -x -R .note -R .comment $@
- -./$@
- -@ echo "This was supposed to core dump on test #3"
- -@rm -f core
- -@ echo " "
-
-assert_glibc: assert.c Makefile $(TOPDIR)libc.a
- -@ echo "-------"
- -@ echo " "
- -@ echo "Compiling vs GNU libc: "
- -@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(CFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
- -@ echo "This was supposed to core dump on test #3"
- -@rm -f core
-@ echo " "
clean:
diff --git a/test/assert/assert.c b/test/assert/assert.c
index 6d474ccc2..866c362f0 100644
--- a/test/assert/assert.c
+++ b/test/assert/assert.c
@@ -24,26 +24,37 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
+#include <signal.h>
+#include "../testsuite.h"
+int got_abort;
-int main( int argc, char **argv)
+void aborthandler(int junk)
{
+ got_abort=1;
+}
- printf( "Testing functions defined in assert.h\n");
+int main( int argc, char **argv)
+{
+ signal(SIGABRT, aborthandler);
+
+ init_testsuite("Testing functions defined in assert.h:\n\t");
- printf( "Testing \"assert(0==0)\"\n");
+ got_abort=0;
assert(0==0);
+ TEST_NUMERIC(got_abort, 0);
- printf( "Testing \"assert(0==1)\" with NDEBUG disabled\n");
-#undef NDEBUG
+#define NDEBUG
+ got_abort=0;
+ printf("Don't worry -- This next test is supposed to print an assert message:\n");
+ fprintf(stderr, "\t");
assert(0==1);
+ TEST_NUMERIC(got_abort, 0);
-#define NDEBUG
- printf( "Testing \"assert(0==1)\" with NDEBUG enabled\n");
#undef NDEBUG
+ got_abort=0;
assert(0==1);
-
- printf( "Finished testing assert.h\n");
+ TEST_NUMERIC(got_abort, 1);
exit(0);
}
diff --git a/test/ctype/Makefile b/test/ctype/Makefile
index 3ed4cb411..02d60e1c9 100644
--- a/test/ctype/Makefile
+++ b/test/ctype/Makefile
@@ -1,45 +1,19 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
-
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
-
-
-TARGETS=ctype ctype_glibc
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
+TARGETS=ctype
all: $(TARGETS)
-ctype: ctype.c ../testsuite.h Makefile $(TOPDIR)libc.a
+ctype: ctype.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(CFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
./$@
-@ echo " "
-
-ctype_glibc: ctype.c ../testsuite.h Makefile $(TOPDIR)libc.a
- -@ echo "-------"
- -@ echo " "
- -@ echo "Compiling vs GNU libc: "
- -@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
- $(STRIPTOOL) -x -R .note -R .comment $@
- -./$@
- -@ echo " "
-
clean:
rm -f *.[oa] *~ core $(TARGETS)
diff --git a/test/ctype/ctype.c b/test/ctype/ctype.c
index 53e4e74aa..3f7f703a0 100644
--- a/test/ctype/ctype.c
+++ b/test/ctype/ctype.c
@@ -27,31 +27,28 @@
#include <ctype.h>
#include "../testsuite.h"
-#define TRUE 0
+#define TRUE 1
int main( int argc, char **argv)
{
int i, c;
- printf( "Testing functions defined in ctype.h\n");
-
+ init_testsuite("Testing functions defined in ctype.h\n");
/* isalnum() */
{
int buffer[]={ '1', '4', 'a', 'z', 'A', 'Z', '5', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isalnum(c)==TRUE,
- "isalnum(%c)", c);
+ TEST( isalnum(c)==TRUE);
}
}
{
int buffer[]={ 2, 128, 254, '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isalnum(c)!=TRUE,
- "!isalnum(%d)", c);
+ TEST( isalnum(c)!=TRUE);
}
}
@@ -62,16 +59,14 @@ int main( int argc, char **argv)
int buffer[]={ 'a', 'z', 'A', 'Z', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isalpha(c)==TRUE,
- "isalpha(%c)", c);
+ TEST( isalpha(c)==TRUE);
}
}
{
int buffer[]={ 2, 63, 128, 254, '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isalpha(c)!=TRUE,
- "!isalpha(%d)", c);
+ TEST( isalpha(c)!=TRUE);
}
}
@@ -82,16 +77,14 @@ int main( int argc, char **argv)
int buffer[]={ 'a', 'z', 'A', 'Z', '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isascii(c)==TRUE,
- "isascii(%d)", c);
+ TEST( isascii(c)==TRUE);
}
}
{
int buffer[]={ 128, 254, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isascii(c)!=TRUE,
- "!isascii(%d)", c);
+ TEST( isascii(c)!=TRUE);
}
}
@@ -101,16 +94,14 @@ int main( int argc, char **argv)
int buffer[]={ 0x7F, 6, '\t', '\n', 0x7F, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( iscntrl(c)==TRUE,
- "iscntrl(%d)", c);
+ TEST( iscntrl(c)==TRUE);
}
}
{
int buffer[]={ 63, 128, 254, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( iscntrl(c)!=TRUE,
- "!iscntrl(%d)", c);
+ TEST( iscntrl(c)!=TRUE);
}
}
@@ -120,16 +111,14 @@ int main( int argc, char **argv)
int buffer[]={ '1', '5', '7', '9', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isdigit(c)==TRUE,
- "isdigit(%c)", c);
+ TEST( isdigit(c)==TRUE);
}
}
{
int buffer[]={ 2, 'a', 'z', 'A', 'Z', 63, 128, 254, '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isdigit(c)!=TRUE,
- "!isdigit(%d)", c);
+ TEST( isdigit(c)!=TRUE);
}
}
@@ -140,16 +129,14 @@ int main( int argc, char **argv)
int buffer[]={ ')', '~', '9', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isgraph(c)==TRUE,
- "isgraph(%d)", c);
+ TEST( isgraph(c)==TRUE);
}
}
{
int buffer[]={ 9, ' ', '\t', '\n', 200, 0x7F, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isgraph(c)!=TRUE,
- "!isgraph(%d)", c);
+ TEST( isgraph(c)!=TRUE);
}
}
@@ -159,16 +146,14 @@ int main( int argc, char **argv)
int buffer[]={ 'a', 'g', 'z', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( islower(c)==TRUE,
- "islower(%c)", c);
+ TEST( islower(c)==TRUE);
}
}
{
int buffer[]={ 9, 'A', 'Z', 128, 254, ' ', '\t', '\n', 0x7F, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( islower(c)!=TRUE,
- "!islower(%d)", c);
+ TEST( islower(c)!=TRUE);
}
}
@@ -178,16 +163,14 @@ int main( int argc, char **argv)
int buffer[]={ ' ', ')', '~', '9', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isprint(c)==TRUE,
- "isprint(%c)", c);
+ TEST( isprint(c)==TRUE);
}
}
{
int buffer[]={ '\b', '\t', '\n', 9, 128, 254, 200, 0x7F, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isprint(c)!=TRUE,
- "!isprint(%d)", c);
+ TEST( isprint(c)!=TRUE);
}
}
@@ -197,16 +180,14 @@ int main( int argc, char **argv)
int buffer[]={ '.', '#', '@', ';', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( ispunct(c)==TRUE,
- "ispunct(%c)", c);
+ TEST( ispunct(c)==TRUE);
}
}
{
int buffer[]={ 2, 'a', 'Z', '1', 128, 254, '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( ispunct(c)!=TRUE,
- "!ispunct(%d)", c);
+ TEST( ispunct(c)!=TRUE);
}
}
@@ -216,16 +197,14 @@ int main( int argc, char **argv)
int buffer[]={ ' ', '\t', '\r', '\v', '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isspace(c)==TRUE,
- "isspace(%d)", c);
+ TEST( isspace(c)==TRUE);
}
}
{
int buffer[]={ 2, 'a', 'Z', '1', 128, 254, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isspace(c)!=TRUE,
- "!isspace(%d)", c);
+ TEST( isspace(c)!=TRUE);
}
}
@@ -235,16 +214,14 @@ int main( int argc, char **argv)
int buffer[]={ 'A', 'G', 'Z', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isupper(c)==TRUE,
- "isupper(%c)", c);
+ TEST( isupper(c)==TRUE);
}
}
{
int buffer[]={ 2, 'a', 'z', '1', 128, 254, -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isupper(c)!=TRUE,
- "!isupper(%d)", c);
+ TEST( isupper(c)!=TRUE);
}
}
@@ -255,38 +232,33 @@ int main( int argc, char **argv)
int buffer[]={ 'f', 'A', '1', '8', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isxdigit(c)==TRUE,
- "isxdigit(%c)", c);
+ TEST( isxdigit(c)==TRUE);
}
}
{
int buffer[]={ 2, 'g', 'G', 'x', '\n', -1};
for(i=0; buffer[i]!=-1; i++) {
c = buffer[i];
- TEST_SUCCESS( isxdigit(c)!=TRUE,
- "!isxdigit(%d)", c);
+ TEST( isxdigit(c)!=TRUE);
}
}
/* tolower() */
c='A';
- TEST_NUMERIC_OUTPUT( tolower(c), 'a', "tolower(%c)=%c", c, tolower(c));
+ TEST_NUMERIC( tolower(c), 'a');
c='a';
- TEST_NUMERIC_OUTPUT( tolower(c), 'a', "tolower(%c)=%c", c, tolower(c));
+ TEST_NUMERIC( tolower(c), 'a');
c='#';
- TEST_NUMERIC_OUTPUT( tolower(c), c, "tolower(%c)=%c", c, tolower(c));
+ TEST_NUMERIC( tolower(c), c);
/* toupper() */
c='a';
- TEST_NUMERIC_OUTPUT( toupper(c), 'A', "toupper(%c)=%c", c, toupper(c));
+ TEST_NUMERIC( toupper(c), 'A');
c='A';
- TEST_NUMERIC_OUTPUT( toupper(c), 'A', "toupper(%c)=%c", c, toupper(c));
+ TEST_NUMERIC( toupper(c), 'A');
c='#';
- TEST_NUMERIC_OUTPUT( toupper(c), c, "toupper(%c)=%c", c, toupper(c));
-
-
- printf( "Finished testing ctype.h\n");
+ TEST_NUMERIC( toupper(c), c);
- stop_testing();
+ exit(0);
}
diff --git a/test/pwd_grp/Makefile b/test/pwd_grp/Makefile
index 212765de4..295cc8e23 100644
--- a/test/pwd_grp/Makefile
+++ b/test/pwd_grp/Makefile
@@ -1,17 +1,5 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
-
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
TARGETS=test_pwd test_pwd_glibc
@@ -20,46 +8,46 @@ TARGETS+=test_pwd_diff test_grp_diff
all: $(TARGETS)
-test_pwd: test_pwd.c Makefile $(TOPDIR)libc.a
+test_pwd: test_pwd.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@ 2>&1 >test_pwd.out
-@ echo " "
-test_pwd_glibc: test_pwd.c Makefile $(TOPDIR)libc.a
+test_pwd_glibc: test_pwd.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@ 2>&1 >test_pwd_glibc.out
-@ echo " "
-test_grp: test_grp.c Makefile $(TOPDIR)libc.a
+test_grp: test_grp.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@ 2>&1 >test_grp.out
-@ echo " "
-test_grp_glibc: test_grp.c Makefile $(TOPDIR)libc.a
+test_grp_glibc: test_grp.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(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 7a7bc1dbb..dbd6e2c32 100644
--- a/test/signal/Makefile
+++ b/test/signal/Makefile
@@ -1,41 +1,28 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
-
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
TARGETS=signal signal_glibc
-
all: $(TARGETS)
-signal: signal.c Makefile $(TOPDIR)libc.a
+signal: signal.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
-signal_glibc: signal.c Makefile $(TOPDIR)libc.a
+signal_glibc: signal.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
diff --git a/test/silly/Makefile b/test/silly/Makefile
index 2a14ed16b..717656575 100644
--- a/test/silly/Makefile
+++ b/test/silly/Makefile
@@ -1,17 +1,6 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
TARGETS=hello_source hello hello_glibc
@@ -26,26 +15,26 @@ hello_source:
-@ cat hello.c
-@ echo " "
-hello: hello.c Makefile $(TOPDIR)libc.a
+hello: hello.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
-./$@
-@ echo " "
-hello_glibc: hello.c Makefile $(TOPDIR)libc.a
+hello_glibc: hello.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
diff --git a/test/stdlib/Makefile b/test/stdlib/Makefile
index 3d9666865..1a054fbe3 100644
--- a/test/stdlib/Makefile
+++ b/test/stdlib/Makefile
@@ -1,17 +1,6 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
TARGETS=testmalloc testmalloc_glibc
@@ -27,52 +16,52 @@ testmalloc_source:
-@ cat testmalloc.c
-@ echo " "
-testmalloc: testmalloc.c Makefile $(TOPDIR)libc.a
+testmalloc: testmalloc.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
-./$@
-@ echo " "
-testmalloc_glibc: testmalloc.c Makefile $(TOPDIR)libc.a
+testmalloc_glibc: testmalloc.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
-./$@
-@ echo " "
-mallocbug: mallocbug.c Makefile $(TOPDIR)libc.a
+mallocbug: mallocbug.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uC-Libc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
-./$@
-@ echo " "
-mallocbug_glibc: mallocbug.c Makefile $(TOPDIR)libc.a
+mallocbug_glibc: mallocbug.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls $(LSFLAGS) $@
@@ -86,26 +75,26 @@ teststrtol_source:
-@ cat teststrtol.c
-@ echo " "
-teststrtol: teststrtol.c Makefile $(TOPDIR)libc.a
+teststrtol: teststrtol.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uC-Libc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls -sh $@
-./$@ > $@.out
-@ echo " "
-teststrtol_glibc: teststrtol.c Makefile $(TOPDIR)libc.a
+teststrtol_glibc: teststrtol.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-ldd $@
ls -sh $@
diff --git a/test/string/Makefile b/test/string/Makefile
index 3277334ab..0c3af9e03 100644
--- a/test/string/Makefile
+++ b/test/string/Makefile
@@ -1,23 +1,5 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
-
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-#XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
-# -I$(TOPDIR)include -I/usr/include/linux
-#XLDFLAGS = -nostdlib -s -gc-sections
-STRIPTOOL=/bin/true
-
-
-XCFLAGS = -Wall -g -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
TARGETS=string string_glibc
@@ -26,46 +8,46 @@ TARGETS+=strerror strsignal
all: $(TARGETS)
-string: string.c Makefile $(TOPDIR)libc.a
+string: string.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
-string_glibc: string.c Makefile $(TOPDIR)libc.a
+string_glibc: string.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
-testcopy: testcopy.c Makefile $(TOPDIR)libc.a
+testcopy: testcopy.c Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@ > testcopy.out
-@ echo " "
-testcopy_glibc: testcopy.c Makefile $(TOPDIR)libc.a
+testcopy_glibc: testcopy.c Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@ > testcopy.gnu.out
-@ echo " "
@@ -79,13 +61,13 @@ testcopy_diff: testcopy testcopy_glibc
-@ echo " "
-strerror: ../../string/strerror.c
+strerror: ../../string/strerror.c $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -DCHECK_BUF -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -DCHECK_BUF -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
@@ -95,8 +77,8 @@ strsignal: ../../string/strsignal.c
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -DCHECK_BUF -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(CC) $(CFLAGS) -DCHECK_BUF -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "
diff --git a/test/testsuite.h b/test/testsuite.h
index c6dab6d87..c80804b83 100644
--- a/test/testsuite.h
+++ b/test/testsuite.h
@@ -2,8 +2,8 @@
/*
* Some simple macros for use in test applications.
*
- * Copyright (C) 2000 by Lineo, inc. Written by Erik Andersen
- * <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 2000, 2001 by Lineo, inc.
+ * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
@@ -21,65 +21,74 @@
*
*/
+#ifndef TESTSUITE_H
+#define TESTSUITE_H
-void error_msg(int result, int line, const char* file, const char* msg, ...);
-void success_msg(int result, const char* msg, ...);
-void stop_testing(void) __attribute__((noreturn));;
+size_t test_number = 0;
+static int failures = 0;
-static int failures = 0;
+void init_testsuite(const char* testname);
+void done_testing(void) __attribute__((noreturn));
+void success_msg(int result, const char* command);
+void error_msg(int result, int line, const char* file, const char* command);
-#define TEST_STRING_OUTPUT( command, expected_result, message, args...) \
+#define TEST_STRING_OUTPUT( command, expected_result ) \
do { \
int result=strcmp( command, expected_result); \
- if ( result != 0 ) \
- success_msg( result, message, ## args); \
- else \
- error_msg(result, __LINE__, __FILE__, message, ## args); \
+ test_number++; \
+ if ( result == expected_result ) { \
+ success_msg( result, "command"); \
+ } else { \
+ error_msg(result, __LINE__, __FILE__, command); \
+ }; \
} while (0)
-
-#define TEST_NUMERIC_OUTPUT( command, expected_result, message, args...) \
+#define TEST_NUMERIC( command, expected_result ) \
do { \
int result=(command); \
- if ( result == expected_result ) \
- success_msg( result, message, ## args); \
- else \
- error_msg(result, __LINE__, __FILE__, message, ## args); \
+ test_number++; \
+ if ( result == expected_result ) { \
+ success_msg( result, # command); \
+ } else { \
+ error_msg(result, __LINE__, __FILE__, # command); \
+ }; \
} while (0)
+#define TEST(command) \
+ do { \
+ int result=(command); \
+ test_number++; \
+ if ( result == 1) { \
+ success_msg( result, # command); \
+ } else { \
+ error_msg(result, __LINE__, __FILE__, # command ); \
+ }; \
+ } while (0)
-#define TEST_SUCCESS(command, message, args...) TEST_NUMERIC_OUTPUT( command, EXIT_SUCCESS, message, ## args)
+#define STR_CMD(cmd) cmd
+
-void error_msg(int result, int line, const char* file, const char* msg, ...)
+void error_msg(int result, int line, const char* file, const char* command)
{
- va_list p;
failures++;
- va_start(p, msg);
- printf("FAILED TEST ");
- vprintf(msg, p);
- va_end(p);
- printf(" AT LINE: %d, FILE: %s\n", line, file);
+ printf("\nFAILED TEST %d: \n\t%s\n", test_number, command);
+ printf("AT LINE: %d, FILE: %s\n\n", line, file);
}
-void success_msg(int result, const char* msg, ...)
+void success_msg(int result, const char* command)
{
#if 0
- va_list p;
- va_start(p, msg);
- printf("passed test: ");
- vprintf(msg, p);
- va_end(p);
- printf("\n");
-#endif
+ printf("passed test: %s == 0\n", command);
+#endif
}
-void stop_testing(void)
+void done_testing(void)
{
if (0 < failures) {
printf("Failed %d tests\n", failures);
@@ -89,3 +98,13 @@ void stop_testing(void)
exit( EXIT_SUCCESS );
}
}
+
+void init_testsuite(const char* testname)
+{
+ printf("%s", testname);
+ test_number = 0;
+ failures = 0;
+ atexit(done_testing);
+}
+
+#endif /* TESTSUITE_H */
diff --git a/test/unistd/Makefile b/test/unistd/Makefile
index c922bc676..aff74b4ab 100644
--- a/test/unistd/Makefile
+++ b/test/unistd/Makefile
@@ -1,41 +1,29 @@
-TOPDIR=../../
-include $(TOPDIR)Rules.mak
+TESTDIR=../
+include $(TESTDIR)/Rules.mak
-# Check if 'ls -sh' works or not
-LSFLAGS = $(shell if ls -sh >/dev/null 2>&1; \
- then echo "-sh"; else echo "-s" ; fi)
-
-XCFLAGS = -Wall -Os -fomit-frame-pointer -fno-builtin -nostdinc \
- -I$(TOPDIR)include -I/usr/include/linux
-XLDFLAGS = -nostdlib -s -gc-sections
-EXTRA_LIBS=$(TOPDIR)libc.a -lgcc
-
-YCFLAGS = -Wall -Os -fomit-frame-pointer
-YLDFLAGS = -s --static
TARGETS=fork fork_glibc
-
all: $(TARGETS)
-fork: fork.c ../testsuite.h Makefile $(TOPDIR)libc.a
+fork: fork.c ../testsuite.h Makefile $(TESTDIR)/Config $(TESTDIR)/Rules.mak $(TESTCC)
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs uClibc: "
-@ echo " "
- $(CC) $(XCFLAGS) -c $< -o $@.o
- $(CC) $(XLDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
+ $(TESTCC) $(CFLAGS) -c $< -o $@.o
+ $(TESTCC) $(LDFLAGS) $@.o -o $@ $(EXTRA_LIBS)
$(STRIPTOOL) -x -R .note -R .comment $@
./$@
-@ echo " "
-fork_glibc: fork.c ../testsuite.h Makefile $(TOPDIR)libc.a
+fork_glibc: fork.c ../testsuite.h Makefile
-@ echo "-------"
-@ echo " "
-@ echo "Compiling vs GNU libc: "
-@ echo " "
- $(CC) $(YCFLAGS) -c $< -o $@.o
- $(CC) $(YLDFLAGS) --static $@.o -o $@
+ $(CC) $(CFLAGS) -c $< -o $@.o
+ $(CC) $(LDFLAGS) $@.o -o $@
$(STRIPTOOL) -x -R .note -R .comment $@
-./$@
-@ echo " "