From cfa23cc1bd01f5c44d7746b8b1839f84d5e1b6eb Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 20 Jul 2013 15:02:37 +0000 Subject: [PATCH] new test system --- AUTHORS | 3 + COPYRIGHT | 29 ++++ Makefile | 93 ++++++++++++- README | 103 +++++++++----- config.mak | 13 ++ dist/config.mak | 15 -- src/api/Makefile | 29 +--- src/common/Makefile | 4 + src/common/fdfill.c | 9 ++ src/common/mtest.c | 144 +++++++++++++++++++ src/common/mtest.h | 123 +++++++++++++++++ src/common/path.c | 17 +++ src/common/rand.c | 169 +++++++++++++++++++++++ src/common/test.h | 47 +++++++ src/common/vmfill.c | 55 ++++++++ src/functional/Makefile | 56 +------- src/functional/basename.c | 6 +- src/functional/dirname.c | 6 +- src/functional/dlopen.c | 44 +++--- src/functional/dlopen.mk | 3 + src/functional/dlopen_dso.mk | 2 + src/functional/env.c | 34 ++--- src/functional/fcntl.c | 6 +- src/functional/fdopen.c | 6 +- src/functional/fnmatch.c | 4 +- src/functional/fscanf.c | 6 +- src/functional/fwscanf.c | 6 +- src/functional/ipc_msg.c | 28 ++-- src/functional/ipc_sem.c | 18 +-- src/functional/ipc_shm.c | 26 ++-- src/functional/mbc.c | 8 +- src/functional/memstream.c | 10 +- src/functional/popen.c | 8 +- src/functional/pthread_cancel.c | 6 +- src/functional/pthread_cond.c | 4 +- src/functional/pthread_robust.c | 8 +- src/functional/pthread_tsd.c | 6 +- src/functional/qsort.c | 74 +++++++--- src/functional/sem.c | 4 +- src/functional/setjmp.c | 4 +- src/functional/snprintf.c | 14 +- src/functional/socket.c | 4 +- src/functional/spawn.c | 6 +- src/functional/sscanf.c | 6 +- src/functional/sscanf_long.c | 14 +- src/functional/stat.c | 4 +- src/functional/string.c | 6 +- src/functional/string_memmem.c | 8 +- src/functional/string_strchr.c | 8 +- src/functional/string_strcspn.c | 4 +- src/functional/string_strstr.c | 8 +- src/functional/strtod.c | 4 +- src/functional/strtod_long.c | 4 +- src/functional/strtod_simple.c | 6 +- src/functional/strtof.c | 4 +- src/functional/strtol.c | 6 +- src/functional/strtold.c | 4 +- src/functional/swprintf.c | 14 +- src/functional/tgmath.c | 26 ++-- src/functional/time.c | 74 +++++++--- src/functional/tls_align.c | 6 +- src/functional/tls_align.mk | 6 + src/functional/tls_align_dlopen.c | 10 +- src/functional/tls_align_dlopen.mk | 2 + src/functional/tls_align_dso.mk | 2 + src/functional/tls_init.c | 12 +- src/functional/udiv.c | 6 +- src/functional/ungetc.c | 8 +- src/functional/wcstol.c | 6 +- src/math/Makefile | 33 +---- src/math/README | 2 +- src/math/acos.c | 2 +- src/math/acosf.c | 2 +- src/math/acosh.c | 2 +- src/math/acoshf.c | 2 +- src/math/acoshl.c | 2 +- src/math/acosl.c | 2 +- src/math/asin.c | 2 +- src/math/asinf.c | 2 +- src/math/asinh.c | 2 +- src/math/asinhf.c | 2 +- src/math/asinhl.c | 2 +- src/math/asinl.c | 2 +- src/math/atan.c | 2 +- src/math/atan2.c | 2 +- src/math/atan2f.c | 2 +- src/math/atan2l.c | 2 +- src/math/atanf.c | 2 +- src/math/atanh.c | 2 +- src/math/atanhf.c | 2 +- src/math/atanhl.c | 2 +- src/math/atanl.c | 2 +- src/math/cbrt.c | 2 +- src/math/cbrtf.c | 2 +- src/math/cbrtl.c | 2 +- src/math/ceil.c | 2 +- src/math/ceilf.c | 2 +- src/math/ceill.c | 2 +- src/math/copysign.c | 2 +- src/math/copysignf.c | 2 +- src/math/copysignl.c | 2 +- src/math/core | Bin 0 -> 118784 bytes src/math/cos.c | 2 +- src/math/cosf.c | 2 +- src/math/cosh.c | 2 +- src/math/coshf.c | 2 +- src/math/coshl.c | 2 +- src/math/cosl.c | 2 +- src/math/erf.c | 2 +- src/math/erfc.c | 2 +- src/math/erfcf.c | 2 +- src/math/erfcl.c | 2 +- src/math/erff.c | 2 +- src/math/erfl.c | 2 +- src/math/exp.c | 2 +- src/math/exp10.c | 2 +- src/math/exp10f.c | 2 +- src/math/exp10l.c | 2 +- src/math/exp2.c | 2 +- src/math/exp2f.c | 2 +- src/math/exp2l.c | 2 +- src/math/expf.c | 2 +- src/math/expl.c | 2 +- src/math/expm1.c | 2 +- src/math/expm1f.c | 2 +- src/math/expm1l.c | 2 +- src/math/fabs.c | 2 +- src/math/fabsf.c | 2 +- src/math/fabsl.c | 2 +- src/math/fdim.c | 2 +- src/math/fdimf.c | 2 +- src/math/fdiml.c | 2 +- src/math/fenv.c | 2 +- src/math/floor.c | 2 +- src/math/floorf.c | 2 +- src/math/floorl.c | 2 +- src/math/fma.c | 2 +- src/math/fmaf.c | 2 +- src/math/fmal.c | 2 +- src/math/fmax.c | 2 +- src/math/fmaxf.c | 2 +- src/math/fmaxl.c | 2 +- src/math/fmin.c | 2 +- src/math/fminf.c | 2 +- src/math/fminl.c | 2 +- src/math/fmod.c | 2 +- src/math/fmodf.c | 2 +- src/math/fmodl.c | 2 +- src/math/frexp.c | 2 +- src/math/frexpf.c | 2 +- src/math/frexpl.c | 2 +- src/math/gen/README | 4 +- src/math/hypot.c | 2 +- src/math/hypotf.c | 2 +- src/math/hypotl.c | 2 +- src/math/ilogb.c | 2 +- src/math/ilogbf.c | 2 +- src/math/ilogbl.c | 2 +- src/math/j0.c | 2 +- src/math/j0f.c | 2 +- src/math/j1.c | 2 +- src/math/j1f.c | 2 +- src/math/jn.c | 2 +- src/math/jnf.c | 2 +- src/math/ldexp.c | 2 +- src/math/ldexpf.c | 2 +- src/math/ldexpl.c | 2 +- src/math/lgamma.c | 2 +- src/math/lgamma_r.c | 2 +- src/math/lgammaf.c | 2 +- src/math/lgammaf_r.c | 2 +- src/math/lgammal.c | 2 +- src/math/lgammal_r.c | 2 +- src/math/llrint.c | 2 +- src/math/llrintf.c | 2 +- src/math/llrintl.c | 2 +- src/math/llround.c | 2 +- src/math/llroundf.c | 2 +- src/math/llroundl.c | 2 +- src/math/log.c | 2 +- src/math/log10.c | 2 +- src/math/log10f.c | 2 +- src/math/log10l.c | 2 +- src/math/log1p.c | 2 +- src/math/log1pf.c | 2 +- src/math/log1pl.c | 2 +- src/math/log2.c | 2 +- src/math/log2f.c | 2 +- src/math/log2l.c | 2 +- src/math/logb.c | 2 +- src/math/logbf.c | 2 +- src/math/logbl.c | 2 +- src/math/logf.c | 2 +- src/math/logl.c | 2 +- src/math/lrint.c | 2 +- src/math/lrintf.c | 2 +- src/math/lrintl.c | 2 +- src/math/lround.c | 2 +- src/math/lroundf.c | 2 +- src/math/lroundl.c | 2 +- src/math/modf.c | 2 +- src/math/modff.c | 2 +- src/math/modfl.c | 2 +- src/math/nearbyint.c | 2 +- src/math/nearbyintf.c | 2 +- src/math/nearbyintl.c | 2 +- src/math/nextafter.c | 2 +- src/math/nextafterf.c | 2 +- src/math/nextafterl.c | 2 +- src/math/nexttoward.c | 2 +- src/math/nexttowardf.c | 2 +- src/math/nexttowardl.c | 2 +- src/math/pow.c | 2 +- src/math/pow10.c | 2 +- src/math/pow10f.c | 2 +- src/math/pow10l.c | 2 +- src/math/powf.c | 2 +- src/math/powl.c | 2 +- src/math/remainder.c | 2 +- src/math/remainderf.c | 2 +- src/math/remainderl.c | 2 +- src/math/remquo.c | 2 +- src/math/remquof.c | 2 +- src/math/remquol.c | 2 +- src/math/rint.c | 2 +- src/math/rintf.c | 2 +- src/math/rintl.c | 2 +- src/math/round.c | 2 +- src/math/roundf.c | 2 +- src/math/roundl.c | 2 +- src/math/scalb.c | 2 +- src/math/scalbf.c | 2 +- src/math/scalbln.c | 2 +- src/math/scalblnf.c | 2 +- src/math/scalblnl.c | 2 +- src/math/scalbn.c | 2 +- src/math/scalbnf.c | 2 +- src/math/scalbnl.c | 2 +- src/math/sin.c | 2 +- src/math/sincos.c | 2 +- src/math/sincosf.c | 2 +- src/math/sincosl.c | 2 +- src/math/sinf.c | 2 +- src/math/sinh.c | 2 +- src/math/sinhf.c | 2 +- src/math/sinhl.c | 2 +- src/math/sinl.c | 2 +- src/math/sqrt.c | 2 +- src/math/sqrtf.c | 2 +- src/math/sqrtl.c | 2 +- src/math/tan.c | 2 +- src/math/tanf.c | 2 +- src/math/tanh.c | 2 +- src/math/tanhf.c | 2 +- src/math/tanhl.c | 2 +- src/math/tanl.c | 2 +- src/math/tgamma.c | 2 +- src/math/tgammaf.c | 2 +- src/math/tgammal.c | 2 +- src/math/trunc.c | 2 +- src/math/truncf.c | 2 +- src/math/truncl.c | 2 +- src/math/y0.c | 2 +- src/math/y0f.c | 2 +- src/math/y1.c | 2 +- src/math/y1f.c | 2 +- src/math/yn.c | 2 +- src/math/ynf.c | 2 +- src/regression/Makefile | 4 + src/regression/daemon-failure.c | 75 ++++++++++ src/regression/malloc-0.c | 19 +++ src/regression/mkdtemp-failure.c | 28 ++++ src/regression/mkstemp-failure.c | 28 ++++ src/regression/printf-fmt-n.c | 34 +++++ src/regression/pthread_create-oom.c | 31 +++++ src/regression/pthread_exit-cancel.c | 36 +++++ src/regression/pthread_exit-dtor.c | 83 +++++++++++ src/regression/scanf-bytes-consumed.c | 19 +++ src/regression/scanf-match-literal-eof.c | 16 +++ src/regression/scanf-nullbyte-char.c | 16 +++ src/regression/sigprocmask-internal.c | 29 ++++ src/regression/sigreturn.c | 20 +++ src/regression/wcsncpy-read-overflow.c | 14 ++ 283 files changed, 1784 insertions(+), 615 deletions(-) create mode 100644 AUTHORS create mode 100644 COPYRIGHT create mode 100644 config.mak delete mode 100644 dist/config.mak create mode 100644 src/common/Makefile create mode 100644 src/common/fdfill.c create mode 100644 src/common/mtest.c create mode 100644 src/common/mtest.h create mode 100644 src/common/path.c create mode 100644 src/common/rand.c create mode 100644 src/common/test.h create mode 100644 src/common/vmfill.c create mode 100644 src/functional/dlopen.mk create mode 100644 src/functional/dlopen_dso.mk create mode 100644 src/functional/tls_align.mk create mode 100644 src/functional/tls_align_dlopen.mk create mode 100644 src/functional/tls_align_dso.mk create mode 100644 src/math/core create mode 100644 src/regression/Makefile create mode 100644 src/regression/daemon-failure.c create mode 100644 src/regression/malloc-0.c create mode 100644 src/regression/mkdtemp-failure.c create mode 100644 src/regression/mkstemp-failure.c create mode 100644 src/regression/printf-fmt-n.c create mode 100644 src/regression/pthread_create-oom.c create mode 100644 src/regression/pthread_exit-cancel.c create mode 100644 src/regression/pthread_exit-dtor.c create mode 100644 src/regression/scanf-bytes-consumed.c create mode 100644 src/regression/scanf-match-literal-eof.c create mode 100644 src/regression/scanf-nullbyte-char.c create mode 100644 src/regression/sigprocmask-internal.c create mode 100644 src/regression/sigreturn.c create mode 100644 src/regression/wcsncpy-read-overflow.c diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..0171aa3 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,3 @@ +Rich Felker +Szabolcs Nagy +Kirill Ternovsky diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..67acf49 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,29 @@ +libc-test is licensed under the following standard MIT license: + +Copyright © 2005-2013 libc-test AUTHORS + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Portions of this software is derived from software authored by +third parties: + +math tests use numbers under BSD and GPL licenses see src/math/ucb/* +and src/math/crlibm/* for details diff --git a/Makefile b/Makefile index 9c9c1a3..353c268 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,91 @@ -DIRS = $(sort $(wildcard src/*)) +SRCS:=$(sort $(wildcard src/*/*.c)) +OBJS:=$(SRCS:%.c=%.o) +DIRS:=$(sort $(wildcard src/*)) +NAMES:=$(OBJS:.o=) +SPEC_PATTERNS:=src/common/% src/api/% src/math/% +CFLAGS:=-Isrc/common +LDLIBS:=src/common/libtest.a + +-include config.mak all: - for i in $(DIRS); do printf "%-20s\n" $$i; make -s -C $$i; done -run: - for i in $(DIRS); do printf "%-20s" $$i; make -s -C $$i run; done +%.mk: + +define template +$(1).BINS := $(1) $(1)-static +D:=$$(dir $(1)) +N:=$(1) +-include $(1).mk +$(1) $(1)-static: $$($(1).OBJS) +$(1).so: $$($(1).LOBJS) +endef + +$(foreach n,$(filter-out $(SPEC_PATTERNS),$(NAMES)),$(eval $(call template,$(n)))) + +MBINS:=$(filter src/math/%,$(NAMES)) +BINS:=$(foreach n,$(NAMES),$($(n).BINS)) src/api/main $(MBINS) +LIBS:=$(foreach n,$(NAMES),$($(n).LIBS)) src/common/libtest.a +ERRS:=$(BINS:%=%.err) + +define target_template +$(1)/all: $(1)/REPORT +$(1)/clean: + rm -f $$(filter $(1)/%,$$(OBJS) $$(BINS) $$(LIBS)) $(1)/*.err +$(1)/REPORT: $$(filter $(1)/%,$$(ERRS)) + cat $(1)/*.err >$$@ +REPORT: $(1)/REPORT +.PHONY: $(1)/all $(1)/clean +endef + +$(foreach d,$(DIRS),$(eval $(call target_template,$(d)))) + +all:REPORT clean: - for i in $(DIRS); do make -s -C $$i clean; done + rm -f $(OBJS) $(BINS) $(LIBS) src/*/*.err +cleanall: clean + rm -f REPORT src/*/REPORT +REPORT: + cat $^ |tee $@ + +src/common/libtest.a: $(filter src/common/%,$(OBJS)) + rm -f $@ + $(AR) rc $@ $^ + $(RANLIB) $@ + +$(BINS): src/common/libtest.a +$(OBJS): src/common/test.h + +src/common/mtest.o: src/common/mtest.h +$(MBINS:%=%.o): src/common/mtest.h + +IOBJS:=$(filter src/api/%,$(OBJS)) +src/api/main: $(IOBJS) +src/api/main.OBJS:=$(IOBJS) +$(IOBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700 +$(IOBJS):CFLAGS+=-DX_PS -DX_TPS -DX_SS + +%.o: %.c + $(CC) $(CFLAGS) $($*.CFLAGS) -c -o $@ $< 2>$@.err || echo BUILDERROR $@ +%.s: %.c + $(CC) $(CFLAGS) $($*.CFLAGS) -S -o $@ $< || echo BUILDERROR $@ +%.lo: %.c + $(CC) $(CFLAGS) $($*.CFLAGS) -fPIC -DSHARED -c -o $@ $< 2>$@.err || echo BUILDERROR $@ +%.so: %.lo + $(CC) -shared $(LDFLAGS) $($@.LDFLAGS) -o $@ $< $($*.LOBJS) $(LDLIBS) $($@.LDLIBS) 2>$@.err || echo BUILDERROR $@ +%-static: %.o + $(CC) -static $(LDFLAGS) $($@.LDFLAGS) -o $@ $< $($*.OBJS) $(LDLIBS) $($@.LDLIBS) 2>$@.err || echo BUILDERROR $@ +%: %.o + $(CC) $(LDFLAGS) $($@.LDFLAGS) -o $@ $< $($@.OBJS) $(LDLIBS) $($@.LDLIBS) 2>$@.err || echo BUILDERROR $@ + +%.o.err: %.o + touch $@ +%.lo.err: %.lo + touch $@ +%.so.err: %.so + touch $@ +%.err: % +# TODO: proper wrapping that records exit status + ./$< 2>/dev/null >$@ || true + +.PHONY: all clean cleanall + diff --git a/README b/README index 658eaf9..3a023f3 100644 --- a/README +++ b/README @@ -1,56 +1,91 @@ -libc tests based on libc-testsuit by Rich Felker -see http://git.musl-libc.org/cgit +libc-test is developed as part of the musl project +http://www.musl-libc.org/ -configure tests: - cp dist/config.mak . - # edit config.mak -build tests: +configuring: + edit config.mak +build and run tests: make -run tests: - make run +clean up: + make clean + +make builds all test binaries and runs them to create +a REPORT file that contains all build and runtime errors +(this means that make does not stop at build failures) + +contributing tests: design goals: -- tests should be easy to run even a single test in isolation +- tests should be easy to run and build even a single test in isolation (so test should be self contained if possible) - failure of one test should not interfere with others (build failure, crash or unexpected results are all failures) -- test output should point to the cause of failure +- test output should point to the cause of the failure - test results should be robust - the test system should have minimal dependency (libc, posix sh, gnu make) - the test system should run on all archs and libcs - tests should leave the system in a clean state -framework: +conventions: + +each test is in a separate file at a path like src/directory/file.c with +its own main + +the test should return 0 on success and non-0 on failure, on failure it +should print error messages to standard out if possible, on success no +message should be printed + +to help with the above test protocol use t_error function for printing +errors and return t_status from main, see src/common/test.h +(t_error allows standard printf formatting, outputs at most 512bytes +in a single write call to fd 1, so there is no buffering, long outputs +are truncated, it sets the global t_status to 1) + +it is common to do many similar checks in a test, in such cases macros +may be used to simplify the code like +#define T1(a,b) (check(a,b) || (t_error("check(%s,%s) failed\n", a, b),0)) +#define T2(f,w) (result=(f), result==(w) || (t_error("%s failed: got %s, want %s\n", #f, result, w),0)) + +directories: + +src/api: interface tests, build time include header tests +src/common: common utilities compiled into libtest.a +src/functional: functional tests aiming for large coverage of libc +src/math: tests for each math function with input-output test vectors +src/regression: regression tests aiming for testing particular bugs -the convention is that each test is in a separate file -at a path like src/directory/file.c with its own main +initial set of functional tests are derived from the libc-testsuit of +Rich Felker, regression tests should contain reference of the bug +(musl commit hash, glibc bug tracker url, etc) -the test should return 0 on success and non-0 on failure -error messages relevant to the test system should be -printed to standard out (fd 1) +build system: -src/functional/test.h usage: +the targets src/directory/all and src/directory/clean build and clean +only the specified directory, each directory has its own Makefile that +invokes the top level make with src/directory/foo for the foo target, +so it is possible to work only under a specific test directory -use error in tests when possible instead of printf -(error truncates the formatted string to 512 bytes and uses a -single write call to output it to fd 1, terminating the error -string with a \n is the responsibility of the caller) -and return test_status from main (set by error, 0 by default) +the build and runtime errors of each target are accumulated into a +target.err file and in the end they are concatenated into a REPORT -when many similar checks are done, helper macros can be used like -#define T1(a,b) (check(a,b) || (error("check(%s,%s) failed\n", a, b),0)) -#define T2(f,w) (result=(f), result==(w) || (error("%s failed: got %s, want %s\n", #f, result, w),0)) +each .c file in src/functional and src/regression are built into a +dynamic linked and a static linked executable test binary by default, +this behaviour can be changed by a similarly named .mk file changing +make variables and specifying additional rules: -a simple example: +$(N) is the name of the binary target (the file name without the .c) +$(N)-static is the name of the static binary target +$(D) is the directory +$(N).CFLAGS are added to the CFLAGS at compilation +$(N).LDFLAGS are added to the LDFLAGS at linking +$(N).LDLIBS are added to the LDLIBS at linking +$(N).BINS are the targets (if empty no binaries are built) +$(N).LIBS are the non-executable targets (shared objects may use it) -#include "test.h" -#define T(c,...) ((c) || (error(#c " failed: " __VA_ARGS__),0)) -int main(void) -{ - T('a'+1=='b', "'a'==%d 'b'==%d\n", 'a', 'b'); - T(-5%3==-2, "bad mod semantics\n"); - return test_status; -} +if a binary is linked together from several .o files then they +have to be specified as prerequisits for the binary targets and +added to the $(N).LDLIBS as well +if a binary depends on a file at runtime (eg. a .so opened by dlopen) +then the $(N).err target should depend on that file diff --git a/config.mak b/config.mak new file mode 100644 index 0000000..07b3e4a --- /dev/null +++ b/config.mak @@ -0,0 +1,13 @@ +CFLAGS += -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces +CFLAGS += -Wno-unknown-pragmas -fno-builtin -frounding-math +CFLAGS += -g +LDFLAGS += -g +LDLIBS += -lpthread -lm -lrt + +# glibc specific settings +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +LDLIBS += -lcrypt -ldl -lresolv -lutil + +AR = $(CROSS_COMPILE)ar +RANLIB = $(CROSS_COMPILE)ranlib + diff --git a/dist/config.mak b/dist/config.mak deleted file mode 100644 index 6face8d..0000000 --- a/dist/config.mak +++ /dev/null @@ -1,15 +0,0 @@ -# copy to ../config.mak - -# to test the native libc with native cc no config is required - -# to test non-native musl with gcc use -#CC = musl-gcc - -# to test non-native musl with installed pcc use -#prefix = /path/to/musl -#includedir = $(prefix)/include -#libdir = $(prefix)/lib -#CC = pcc -#LIBCC = $(shell pcc -v /dev/null 2>&1 |sed -n 's,/crtbegin.o.*,,;s,.* /,/,p') -#CFLAGS += -nostdinc -ffreestanding -fno-stack-protector -isystem $(includedir) -#LDFLAGS += -nostdlib -Wl,-e,_start,-Bstatic $(libdir)/crti.o $(libdir)/crt1.o $(libdir)/crtn.o -L$(libdir) -lc -L$(LIBCC) -l$(CC) diff --git a/src/api/Makefile b/src/api/Makefile index 7b7a19a..c37b86a 100644 --- a/src/api/Makefile +++ b/src/api/Makefile @@ -1,27 +1,4 @@ -CFLAGS+=-std=c99 -pedantic-errors -Wall -Werror -Wno-unused -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -CFLAGS+=-DX_PS -DX_TPS -DX_SS -#CFLAGS+=-DX_RPP_TPP -DX_TYM -DX_FMTMSG -DX_NDBM -LDFLAGS+=-lcrypt -ldl -lm -lpthread -lrt +all: +%: + $(MAKE) -C ../.. src/api/$@ -SRC=$(sort $(wildcard *.c)) -ERR=$(SRC:.c=.err) - --include ../../config.mak - -all: all.err - -run: all.err - cat $< - -all.err: $(ERR) - LC_ALL=C $(CC) $(LDFLAGS) -o main *.o 2>main.err || true - cat $(ERR) |\ - grep -v 'In function .f.' |\ - grep -v 'Each undeclared identifier is reported only once' |\ - grep -v 'for each function it appears in' >$@ || true - -%.err: %.c - LC_ALL=C $(CC) $(CFLAGS) -c $< 2>$@ || true - -clean: - rm -f main *.o *.err diff --git a/src/common/Makefile b/src/common/Makefile new file mode 100644 index 0000000..351583d --- /dev/null +++ b/src/common/Makefile @@ -0,0 +1,4 @@ +all: +%: + $(MAKE) -C ../.. src/common/$@ + diff --git a/src/common/fdfill.c b/src/common/fdfill.c new file mode 100644 index 0000000..da744c1 --- /dev/null +++ b/src/common/fdfill.c @@ -0,0 +1,9 @@ +#include +#include "test.h" + +void t_fdfill(void) +{ + int fd[2]; + while (pipe(fd) == 0); + dup(0); +} diff --git a/src/common/mtest.c b/src/common/mtest.c new file mode 100644 index 0000000..54c4772 --- /dev/null +++ b/src/common/mtest.c @@ -0,0 +1,144 @@ +#include +#include +#include "mtest.h" + +int eulpf(float x) +{ + union { float f; uint32_t i; } u = { x }; + int e = u.i>>23 & 0xff; + + if (!e) + e++; + return e - 0x7f - 23; +} + +int eulp(double x) +{ + union { double f; uint64_t i; } u = { x }; + int e = u.i>>52 & 0x7ff; + + if (!e) + e++; + return e - 0x3ff - 52; +} + +int eulpl(long double x) +{ +#if LDBL_MANT_DIG == 53 + return eulp(x); +#elif LDBL_MANT_DIG == 64 + union { long double f; struct {uint64_t m; uint16_t e; uint16_t pad;} i; } u = { x }; + int e = u.i.e & 0x7fff; + + if (!e) + e++; + return e - 0x3fff - 63; +#else + // TODO + return 0; +#endif +} + +float ulperrf(float got, float want, float dwant) +{ + if (isnan(got) && isnan(want)) + return 0; + if (got == want) { + if (signbit(got) == signbit(want)) + return dwant; + return inf; + } + if (isinf(got)) { + got = copysignf(0x1p127, got); + want *= 0.5; + } + return scalbn(got - want, -eulpf(want)) + dwant; +} + +float ulperr(double got, double want, float dwant) +{ + if (isnan(got) && isnan(want)) + return 0; + if (got == want) { + if (signbit(got) == signbit(want)) + return dwant; + return inf; // treat 0 sign errors badly + } + if (isinf(got)) { + got = copysign(0x1p1023, got); + want *= 0.5; + } + return scalbn(got - want, -eulp(want)) + dwant; +} + +float ulperrl(long double got, long double want, float dwant) +{ +#if LDBL_MANT_DIG == 53 + return ulperr(got, want, dwant); +#elif LDBL_MANT_DIG == 64 + if (isnan(got) && isnan(want)) + return 0; + if (got == want) { + if (signbit(got) == signbit(want)) + return dwant; + return inf; + } + if (isinf(got)) { + got = copysignl(0x1p16383L, got); + want *= 0.5; + } + return scalbnl(got - want, -eulpl(want)) + dwant; +#else + // TODO + return inf; +#endif +} + +#define length(a) (sizeof(a)/sizeof*(a)) +#define flag(x) {x, #x} +static struct { + int flag; + char *s; +} eflags[] = { + flag(INEXACT), + flag(INVALID), + flag(DIVBYZERO), + flag(UNDERFLOW), + flag(OVERFLOW) +}; + +char *estr(int f) +{ + static char buf[256]; + char *p = buf; + int i, all = 0; + + for (i = 0; i < length(eflags); i++) + if (f & eflags[i].flag) { + p += sprintf(p, "%s%s", all ? "|" : "", eflags[i].s); + all |= eflags[i].flag; + } + if (all != f) { + p += sprintf(p, "%s%d", all ? "|" : "", f & ~all); + all = f; + } + p += sprintf(p, "%s", all ? "" : "0"); + return buf; +} + +char *rstr(int r) +{ + switch (r) { + case RN: return "RN"; +#ifdef FE_TOWARDZERO + case RZ: return "RZ"; +#endif +#ifdef FE_UPWARD + case RU: return "RU"; +#endif +#ifdef FE_DOWNWARD + case RD: return "RD"; +#endif + } + return "R?"; +} diff --git a/src/common/mtest.h b/src/common/mtest.h new file mode 100644 index 0000000..9218a75 --- /dev/null +++ b/src/common/mtest.h @@ -0,0 +1,123 @@ +#include +#include +#include + +#undef RN +#undef RZ +#undef RD +#undef RU +#ifdef FE_TONEAREST +#define RN FE_TONEAREST +#else +#define RN 0 +#endif +#ifdef FE_TOWARDZERO +#define RZ FE_TOWARDZERO +#else +#define RZ -1 +#endif +#ifdef FE_DOWNWARD +#define RD FE_DOWNWARD +#else +#define RD -1 +#endif +#ifdef FE_UPWARD +#define RU FE_UPWARD +#else +#define RU -1 +#endif + +#undef INEXACT +#undef INVALID +#undef DIVBYZERO +#undef UNDERFLOW +#undef OVERFLOW +#ifdef FE_INEXACT +#define INEXACT FE_INEXACT +#else +#define INEXACT 0 +#endif +#ifdef FE_INVALID +#define INVALID FE_INVALID +#else +#define INVALID 0 +#endif +#ifdef FE_DIVBYZERO +#define DIVBYZERO FE_DIVBYZERO +#else +#define DIVBYZERO 0 +#endif +#ifdef FE_UNDERFLOW +#define UNDERFLOW FE_UNDERFLOW +#else +#define UNDERFLOW 0 +#endif +#ifdef FE_OVERFLOW +#define OVERFLOW FE_OVERFLOW +#else +#define OVERFLOW 0 +#endif + +#undef inf +#undef nan +#define inf INFINITY +#define nan NAN + +#define T(...) {__FILE__, __LINE__, __VA_ARGS__}, + +#define POS char *file; int line; +struct d_d {POS int r; double x; double y; float dy; int e; }; +struct f_f {POS int r; float x; float y; float dy; int e; }; +struct l_l {POS int r; long double x; long double y; float dy; int e; }; +struct ff_f {POS int r; float x; float x2; float y; float dy; int e; }; +struct dd_d {POS int r; double x; double x2; double y; float dy; int e; }; +struct ll_l {POS int r; long double x; long double x2; long double y; float dy; int e; }; +struct d_di {POS int r; double x; double y; float dy; long long i; int e; }; +struct f_fi {POS int r; float x; float y; float dy; long long i; int e; }; +struct l_li {POS int r; long double x; long double y; float dy; long long i; int e; }; +struct di_d {POS int r; double x; long long i; double y; float dy; int e; }; +struct fi_f {POS int r; float x; long long i; float y; float dy; int e; }; +struct li_l {POS int r; long double x; long long i; long double y; float dy; int e; }; +struct d_i {POS int r; double x; long long i; int e; }; +struct f_i {POS int r; float x; long long i; int e; }; +struct l_i {POS int r; long double x; long long i; int e; }; +struct d_dd {POS int r; double x; double y; float dy; double y2; float dy2; int e; }; +struct f_ff {POS int r; float x; float y; float dy; float y2; float dy2; int e; }; +struct l_ll {POS int r; long double x; long double y; float dy; long double y2; float dy2; int e; }; +struct ff_fi {POS int r; float x; float x2; float y; float dy; long long i; int e; }; +struct dd_di {POS int r; double x; double x2; double y; float dy; long long i; int e; }; +struct ll_li {POS int r; long double x; long double x2; long double y; float dy; long long i; int e; }; +struct fff_f {POS int r; float x; float x2; float x3; float y; float dy; int e; }; +struct ddd_d {POS int r; double x; double x2; double x3; double y; float dy; int e; }; +struct lll_l {POS int r; long double x; long double x2; long double x3; long double y; float dy; int e; }; +#undef POS + +char *estr(int); +char *rstr(int); + +float ulperr(double got, double want, float dwant); +float ulperrf(float got, float want, float dwant); +float ulperrl(long double got, long double want, float dwant); + +static int checkexcept(int got, int want, int r) +{ + if (r == RN) + return got == want || got == (want|INEXACT); + return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW); +} + +static int checkulp(float d, int r) +{ + // TODO: we only care about >=1.5 ulp errors for now, should be 1.0 + if (r == RN) + return fabsf(d) < 1.5; + return 1; +} + +static int checkcr(long double y, long double ywant, int r) +{ + if (isnan(ywant)) + return isnan(y); + return y == ywant && signbit(y) == signbit(ywant); +} + diff --git a/src/common/path.c b/src/common/path.c new file mode 100644 index 0000000..4fd7633 --- /dev/null +++ b/src/common/path.c @@ -0,0 +1,17 @@ +#include +#include "test.h" + +/* relative path to p */ +char *t_pathrel(char *buf, size_t n, char *argv0, char *p) +{ + char *s = strrchr(argv0, '/'); + int k; + + if (s) + k = snprintf(buf, n, "%.*s/%s", (int)(s-argv0), argv0, p); + else + k = snprintf(buf, n, "./%s", p); + if ((size_t)k >= n) + return 0; + return buf; +} diff --git a/src/common/rand.c b/src/common/rand.c new file mode 100644 index 0000000..cdafab5 --- /dev/null +++ b/src/common/rand.c @@ -0,0 +1,169 @@ +#include +#include +#include + +// TODO: use large period prng +static uint64_t seed = -1; +static uint32_t rand32(void) +{ + seed = 6364136223846793005ULL*seed + 1; + return seed >> 32; +} +static uint64_t rand64(void) +{ + uint64_t u = rand32(); + return u<<32 | rand32(); +} +static double frand() +{ + return rand64() * 0x1p-64; +} +static float frandf() +{ + return rand32() * 0x1p-32f; +} +static long double frandl() +{ + return rand64() * 0x1p-64L +#if LDBL_MANT_DIG > 64 ++ rand64() * 0x1p-128L +#endif +; +} + +void t_randseed(uint64_t s) +{ + seed = s; +} + +/* uniform random in [0,n), n > 0 must hold */ +uint64_t t_randn(uint64_t n) +{ + uint64_t r, m; + + /* m is the largest multiple of n */ + m = -1; + m -= m%n; + while ((r = rand64()) >= m); + return r%n; +} + +/* uniform on [a,b], a <= b must hold */ +uint64_t t_randint(uint64_t a, uint64_t b) +{ + uint64_t n = b - a + 1; + if (n) + return a + t_randn(n); + return rand64(); +} + +/* shuffle the elements of p and q until the elements in p are well shuffled */ +static void shuffle2(uint64_t *p, uint64_t *q, size_t np, size_t nq) +{ + size_t r; + uint64_t t; + + while (np) { + r = t_randn(nq+np--); + t = p[np]; + if (r < nq) { + p[np] = q[r]; + q[r] = t; + } else { + p[np] = p[r-nq]; + p[r-nq] = t; + } + } +} + +/* shuffle the elements of p */ +void t_shuffle(uint64_t *p, size_t n) +{ + shuffle2(p,0,n,0); +} + +void t_randrange(uint64_t *p, size_t n) +{ + size_t i; + for (i = 0; i < n; i++) + p[i] = i; + t_shuffle(p, n); +} + +/* hash table insert, 0 means empty, v > 0 must hold, len is power-of-2 */ +static int insert(uint64_t *tab, size_t len, uint64_t v) +{ + size_t i = v & (len-1); + size_t j = 1; + + while (tab[i]) { + if (tab[i] == v) + return -1; + i += j++; + i &= len-1; + } + tab[i] = v; + return 0; +} + +/* choose k unique numbers from [0,n), k <= n */ +int t_choose(uint64_t n, size_t k, uint64_t *p) +{ + uint64_t *tab; + size_t i, j, len; + + if (n < k) + return -1; + + if (n < 16) { + /* no alloc */ + while (k) + if (t_randn(n--) < k) + p[--k] = n; + return 0; + } + + if (k < 8) { + /* no alloc, n > 15 > 2*k */ + for (i = 0; i < k;) { + p[i] = t_randn(n); + for (j = 0; p[j] != p[i]; j++); + if (j == i) + i++; + } + return 0; + } + + // TODO: if k < n/k use k*log(k) solution without alloc + + if (n < 5*k && (n-k)*sizeof *tab < (size_t)-1) { + /* allocation is n-k < 4*k */ + tab = malloc((n-k) * sizeof *tab); + if (!tab) + return -1; + for (i = 0; i < k; i++) + p[i] = i; + for (; i < n; i++) + tab[i-k] = i; + if (k < n-k) + shuffle2(p, tab, k, n-k); + else + shuffle2(tab, p, n-k, k); + free(tab); + return 0; + } + + /* allocation is 2*k <= len < 4*k */ + for (len = 16; len < 2*k; len *= 2); + tab = calloc(len, sizeof *tab); + if (!tab) + return -1; + for (i = 0; i < k; i++) + while (insert(tab, len, t_randn(n)+1)); + for (i = 0; i < len; i++) + if (tab[i]) + *p++ = tab[i]-1; + free(tab); + return 0; +} + diff --git a/src/common/test.h b/src/common/test.h new file mode 100644 index 0000000..e24a1db --- /dev/null +++ b/src/common/test.h @@ -0,0 +1,47 @@ +#include +#include +#include +#include + +/* TODO: not thread-safe nor fork-safe */ +static volatile int t_status; + +#define T_LOC2(l) __FILE__ ":" #l +#define T_LOC1(l) T_LOC2(l) +#define t_error(...) t_printf("ERROR " T_LOC1(__LINE__) ": " __VA_ARGS__) + +static int t_printf(const char *s, ...) +{ + va_list ap; + char buf[512]; + int n; + + t_status = 1; + va_start(ap, s); + n = vsnprintf(buf, sizeof buf, s, ap); + va_end(ap); + if (n < 0) + n = 0; + else if (n >= sizeof buf) { + n = sizeof buf; + buf[n - 1] = '\n'; + buf[n - 2] = '.'; + buf[n - 3] = '.'; + buf[n - 4] = '.'; + } + return write(1, buf, n); +} + +int t_vmfill(void **, size_t *, int); + +void t_fdfill(void); + +void t_randseed(uint64_t s); +uint64_t t_randn(uint64_t n); +uint64_t t_randint(uint64_t a, uint64_t b); +void t_shuffle(uint64_t *p, size_t n); +void t_randrange(uint64_t *p, size_t n); +int t_choose(uint64_t n, size_t k, uint64_t *p); + +char *t_pathrel(char *buf, size_t n, char *argv0, char *p); + diff --git a/src/common/vmfill.c b/src/common/vmfill.c new file mode 100644 index 0000000..86a218d --- /dev/null +++ b/src/common/vmfill.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include "test.h" +#ifndef PAGE_SIZE + #define PAGE_SIZE sysconf(_SC_PAGE_SIZE) +#endif + +/* max mmap size, *start is the largest power-of-2 size considered */ +static size_t mmax(int fd, size_t *start) +{ + size_t i, n; + void *p; + + for (i=n=*start; i>=PAGE_SIZE; i/=2) { + if ((p=mmap(0, n, PROT_NONE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { + n -= i/2; + } else { + munmap(p, n); + if (n == i) + *start = n; + n += i/2; + } + } + return n & -PAGE_SIZE; +} + +/* +fills the virtual memory with anonymous PROT_NONE mmaps, +returns the mappings in *p and *n in decreasing size order, +the return value is the number of mappings or -1 on failure. +*/ +int t_vmfill(void **p, size_t *n, int len) +{ + int fd = open("/dev/zero", O_RDWR); + size_t start = SIZE_MAX/2 + 1; + size_t m; + void *q; + int i; + + for (i=0;;i++) { + m = mmax(fd, &start); + if (!m) + break; + q = mmap(0, m, PROT_NONE, MAP_PRIVATE, fd, 0); + if (q == MAP_FAILED) + return -1; + if (i < len) { + p[i] = q; + n[i] = m; + } + } + return i; +} diff --git a/src/functional/Makefile b/src/functional/Makefile index 2cc41ed..a6e5208 100644 --- a/src/functional/Makefile +++ b/src/functional/Makefile @@ -1,54 +1,4 @@ -CFLAGS+=-pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces -LDFLAGS+= -LDLIBS+= -BUILD?=. - -SRC=$(sort $(wildcard *.c)) -OBJ=$(SRC:%.c=$(BUILD)/%.o) -DSOOBJ=$(filter %_dso.o,$(OBJ)) -BINOBJ=$(filter-out %_dso.o,$(OBJ)) -NO_DL_OBJ=$(filter-out %dlopen.o,$(BINOBJ)) -DSO=$(DSOOBJ:.o=.so) -BIN=$(BINOBJ:.o=) -BIN_STATIC=$(NO_DL_OBJ:.o=-static) -ALL=$(BIN) $(BIN_STATIC) $(DSO) - --include ../../config.mak - -all: $(ALL) -run: all - @N=0; A=0; for i in $(BIN) $(BIN_STATIC);do \ - A=$$((A+1)); ./$$i || { N=$$((N+1)); echo FAIL $$i; } \ - done; \ - [ "$$N" = 0 ] && echo PASS || echo FAILS: $$N/$$A -clean: - rm -f $(OBJ) $(ALL) - -$(BUILD): - mkdir -p $@ -$(OBJ): test.h | $(BUILD) -$(DSOOBJ): CFLAGS+=-fPIC -$(BUILD)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< || echo BUILDERROR $@ -%.so: %.o - $(CC) -shared $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@ -%-static: %.o - $(CC) -static $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@ -%: %.o - $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS) || echo BUILDERROR $@ - -$(BUILD)/dlopen: LDLIBS+=-ldl -rdynamic -$(BUILD)/pthread%: LDLIBS+=-lpthread -$(BUILD)/sem $(BUILD)/sem-static: LDLIBS+=-lpthread -lrt -$(BUILD)/strtod_simple $(BUILD)/strtod_simple-static: LDLIBS+=-lm -$(BUILD)/tgmath tgmath-static: LDLIBS+=-lm -# adding ./lib.so through LDLIBS instead of $^ in the implicit rule because make removes the leading ./ from dependencies -$(BUILD)/tls_align: LDLIBS+=$(BUILD)/tls_align_dso.so -$(BUILD)/tls_align: $(BUILD)/tls_align_dso.so -# make bug: tls_align target specific flags are also set for tls_align_dso.so when both target is built -$(BUILD)/tls_align_dso.so: LDLIBS= -$(BUILD)/tls_align-static: LDLIBS+=$(BUILD)/tls_align_dso.o -$(BUILD)/tls_align-static: $(BUILD)/tls_align_dso.o -$(BUILD)/tls_align_dlopen: LDLIBS+=-ldl -$(BUILD)/tls_init tls_init-static: LDLIBS+=-lpthread +all: +%: + $(MAKE) -C ../.. src/functional/$@ diff --git a/src/functional/basename.c b/src/functional/basename.c index a993587..96a470e 100644 --- a/src/functional/basename.c +++ b/src/functional/basename.c @@ -8,13 +8,13 @@ char tmp[100]; \ char *got = basename(strcpy(tmp, path)); \ if (strcmp(want, got) != 0) \ - error("basename(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \ + t_error("basename(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \ } int main() { if (strcmp(basename(0), ".") != 0) - error("basename(0) returned \"%s\"; expected \".\"\n", basename(0)); + t_error("basename(0) returned \"%s\"; expected \".\"\n", basename(0)); T("", "."); T("/usr/lib", "lib"); T("/usr/", "usr"); @@ -24,5 +24,5 @@ int main() T("//usr//lib//", "lib"); T(".", "."); T("..", ".."); - return test_status; + return t_status; } diff --git a/src/functional/dirname.c b/src/functional/dirname.c index 7a15a0a..766d467 100644 --- a/src/functional/dirname.c +++ b/src/functional/dirname.c @@ -8,13 +8,13 @@ char tmp[100]; \ char *got = dirname(strcpy(tmp, path)); \ if (strcmp(want, got) != 0) \ - error("dirname(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \ + t_error("dirname(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \ } int main() { if (strcmp(dirname(0), ".") != 0) - error("dirname(0) returned \"%s\"; expected \".\"\n", dirname(0)); + t_error("dirname(0) returned \"%s\"; expected \".\"\n", dirname(0)); T("", "."); T("/usr/lib", "/usr"); T("/usr/", "/"); @@ -24,5 +24,5 @@ int main() T("///", "/"); T(".", "."); T("..", "."); - return test_status; + return t_status; } diff --git a/src/functional/dlopen.c b/src/functional/dlopen.c index 3150f6f..ceee83e 100644 --- a/src/functional/dlopen.c +++ b/src/functional/dlopen.c @@ -1,47 +1,55 @@ #include #include "test.h" -int main() +int main(int argc, char *argv[]) { void *h, *g; int *i, *i2; char *s; void (*f)(void); + char buf[512]; - h = dlopen("./dlopen_dso.so", RTLD_LAZY|RTLD_LOCAL); + if (!t_pathrel(buf, sizeof buf, argv[0], "dlopen_dso.so")) { + t_error("failed to obtain relative path to dlopen_dso.so\n"); + return 1; + } + h = dlopen(buf, RTLD_LAZY|RTLD_LOCAL); if (!h) - error("dlopen ./dlopen_dso.so failed: %s\n", dlerror()); + t_error("dlopen %s failed: %s\n", buf, dlerror()); i = dlsym(h, "i"); if (!i) - error("dlsym i failed: %s\n", dlerror()); + t_error("dlsym i failed: %s\n", dlerror()); if (*i != 1) - error("initialization failed: want i=1 got i=%d\n", *i); + t_error("initialization failed: want i=1 got i=%d\n", *i); f = (void (*)(void))dlsym(h, "f"); if (!f) - error("dlsym f failed: %s\n", dlerror()); + t_error("dlsym f failed: %s\n", dlerror()); f(); if (*i != 2) - error("f call failed: want i=2 got i=%d\n", *i); - if (dlclose(h)) - error("dlclose failed: %s\n", dlerror()); + t_error("f call failed: want i=2 got i=%d\n", *i); g = dlopen(0, RTLD_LAZY|RTLD_LOCAL); if (!g) - error("dlopen 0 failed: %s\n", dlerror()); + t_error("dlopen 0 failed: %s\n", dlerror()); i2 = dlsym(g, "i"); s = dlerror(); if (i2 || s == 0) - error("dlsym i should have failed\n"); - if (dlsym(g, "main") == 0) - error("dlsym main failed: %s\n", dlerror()); + t_error("dlsym i should have failed\n"); + if (dlsym(g, "main") != (void*)main) + t_error("dlsym main failed: %s\n", dlerror()); - h = dlopen("./dlopen_dso.so", RTLD_LAZY|RTLD_GLOBAL); + /* close+open reinitializes the dso with glibc but not with musl */ + h = dlopen(buf, RTLD_LAZY|RTLD_GLOBAL); i2 = dlsym(g, "i"); if (!i2) - error("dlsym i failed: %s\n", dlerror()); + t_error("dlsym i failed: %s\n", dlerror()); + if (i2 != i) + t_error("reopened dso should have the same symbols, want %p, got %p\n", i, i2); if (*i2 != 2) - error("want i2=2, got i2=%d\n", *i2); + t_error("reopened dso should have the same symbols, want i2==2, got i2==%d\n", *i2); if (dlclose(g)) - error("dlclose failed: %s\n", dlerror()); - return test_status; + t_error("dlclose failed: %s\n", dlerror()); + if (dlclose(h)) + t_error("dlclose failed: %s\n", dlerror()); + return t_status; } diff --git a/src/functional/dlopen.mk b/src/functional/dlopen.mk new file mode 100644 index 0000000..97d3bcc --- /dev/null +++ b/src/functional/dlopen.mk @@ -0,0 +1,3 @@ +$(N).BINS:=$(N) +$(N).LDFLAGS:=-rdynamic +$(N).err: $(D)/dlopen_dso.so diff --git a/src/functional/dlopen_dso.mk b/src/functional/dlopen_dso.mk new file mode 100644 index 0000000..b691b45 --- /dev/null +++ b/src/functional/dlopen_dso.mk @@ -0,0 +1,2 @@ +$(N).BINS:= +$(N).LIBS:=$(N).so diff --git a/src/functional/env.c b/src/functional/env.c index 7962bf5..ab36381 100644 --- a/src/functional/env.c +++ b/src/functional/env.c @@ -15,37 +15,37 @@ int main() int r; if (clearenv() || (environ && *environ)) - error("clrearenv: %s\n", strerror(errno)); + t_error("clrearenv: %s\n", strerror(errno)); if (putenv("TEST=1")) - error("putenv: %s\n", strerror(errno)); + t_error("putenv: %s\n", strerror(errno)); if ((s=environ[1])) - error("environ[1]: %p, wanted 0\n", s); + t_error("environ[1]: %p, wanted 0\n", s); if (!(s=getenv("TEST"))) - error("getenv(\"TEST\"): 0, wanted \"1\"\n"); + t_error("getenv(\"TEST\"): 0, wanted \"1\"\n"); if (strcmp(s,"1") != 0) - error("getenv(\"TEST\"): \"%s\", wanted \"1\"\n", s); + t_error("getenv(\"TEST\"): \"%s\", wanted \"1\"\n", s); if (unsetenv("TEST")) - error("unsetenv: %s\n", strerror(errno)); + t_error("unsetenv: %s\n", strerror(errno)); if ((s=*environ)) - error("*environ: %p != 0\n", s); + t_error("*environ: %p != 0\n", s); if ((s=getenv("TEST"))) - error("getenv(\"TEST\"): %p, wanted 0\n", s); + t_error("getenv(\"TEST\"): %p, wanted 0\n", s); if (setenv("TEST", "2", 0)) - error("setenv: %s\n", strerror(errno)); + t_error("setenv: %s\n", strerror(errno)); if (strcmp(s=getenv("TEST"),"2") != 0) - error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s); + t_error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s); if (setenv("TEST", "3", 0)) - error("setenv: %s\n", strerror(errno)); + t_error("setenv: %s\n", strerror(errno)); if (strcmp(s=getenv("TEST"),"2") != 0) - error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s); + t_error("getenv(\"TEST\"): \"%s\", wanted \"2\"\n", s); if (setenv("TEST", "3", 1)) - error("setenv: %s\n", strerror(errno)); + t_error("setenv: %s\n", strerror(errno)); if (strcmp(s=getenv("TEST"),"3") != 0) - error("getenv(\"TEST\"): \"%s\", wanted \"3\"\n", s); + t_error("getenv(\"TEST\"): \"%s\", wanted \"3\"\n", s); /* test failures */ if ((r=setenv("","",0)) != -1 || errno != EINVAL) - error("setenv(\"\",\"\",0): %d, errno: %d (%s), wanted -1, %d (EINVAL)\n", r, errno, strerror(errno), EINVAL); + t_error("setenv(\"\",\"\",0): %d, errno: %d (%s), wanted -1, %d (EINVAL)\n", r, errno, strerror(errno), EINVAL); if ((r=setenv(0,"",0)) != -1 || errno != EINVAL) - error("setenv(0,\"\",0): %d, errno: %d (%s), wanted -1, %d (EINVAL)\n", r, errno, strerror(errno), EINVAL); - return test_status; + t_error("setenv(0,\"\",0): %d, errno: %d (%s), wanted -1, %d (EINVAL)\n", r, errno, strerror(errno), EINVAL); + return t_status; } diff --git a/src/functional/fcntl.c b/src/functional/fcntl.c index a49df60..485c00c 100644 --- a/src/functional/fcntl.c +++ b/src/functional/fcntl.c @@ -6,7 +6,7 @@ #include #include "test.h" -#define TEST(c, ...) ((c) ? 1 : (error(#c" failed: " __VA_ARGS__),0)) +#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0)) #define TESTE(c) (errno=0, TEST(c, "errno = %s\n", strerror(errno))) int main(void) @@ -17,7 +17,7 @@ int main(void) pid_t pid; int status; - if (!TESTE(f=tmpfile())) return test_status; + if (!TESTE(f=tmpfile())) return t_status; fd = fileno(f); fl.l_type = F_WRLCK; @@ -45,5 +45,5 @@ int main(void) fclose(f); - return test_status; + return t_status; } diff --git a/src/functional/fdopen.c b/src/functional/fdopen.c index 1f4da03..392a1b1 100644 --- a/src/functional/fdopen.c +++ b/src/functional/fdopen.c @@ -11,7 +11,7 @@ #define TEST(c) do { \ errno = 0; \ if (!(c)) \ - error("%s failed (errno = %d)\n", #c, errno); \ + t_error("%s failed (errno = %d)\n", #c, errno); \ } while(0) int main(void) @@ -29,10 +29,10 @@ int main(void) TEST(fseeko(f, 0, SEEK_SET)==0); TEST(fgets(foo, sizeof foo, f)); if (strcmp(foo,"hello") != 0) - error("fgets read back: \"%s\"; wanted: \"hello\"\n", foo); + t_error("fgets read back: \"%s\"; wanted: \"hello\"\n", foo); fclose(f); } if (fd > 2) TEST(unlink(tmp) != -1); - return test_status; + return t_status; } diff --git a/src/functional/fnmatch.c b/src/functional/fnmatch.c index 33f508f..e822456 100644 --- a/src/functional/fnmatch.c +++ b/src/functional/fnmatch.c @@ -128,11 +128,11 @@ int main(void) r = fnmatch(tests[i].pattern, tests[i].string, tests[i].flags); x = tests[i].expected; if (r != x && (r != FNM_NOMATCH || x != -FNM_NOMATCH)) { - error("fnmatch(\"%s\", \"%s\", %s) failed, got %d want %d\n", + t_error("fnmatch(\"%s\", \"%s\", %s) failed, got %d want %d\n", tests[i].pattern, tests[i].string, flagstr(fnmatch_flags, tests[i].flags), r, x); } } - return test_status; + return t_status; } diff --git a/src/functional/fscanf.c b/src/functional/fscanf.c index c8063e0..17fdb64 100644 --- a/src/functional/fscanf.c +++ b/src/functional/fscanf.c @@ -7,11 +7,11 @@ #define TEST(r, f, x, m) ( \ errno=0, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) static FILE *writetemp(const char *data) { @@ -129,5 +129,5 @@ int main(void) fclose(f); } - return test_status; + return t_status; } diff --git a/src/functional/fwscanf.c b/src/functional/fwscanf.c index 70ba50b..3a96ae0 100644 --- a/src/functional/fwscanf.c +++ b/src/functional/fwscanf.c @@ -8,11 +8,11 @@ #define TEST(r, f, x, m) ( \ errno=0, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) static FILE *writetemp(const char *data) { @@ -106,5 +106,5 @@ int main(void) fclose(f); } - return test_status; + return t_status; } diff --git a/src/functional/ipc_msg.c b/src/functional/ipc_msg.c index 3b91aeb..477a3f4 100644 --- a/src/functional/ipc_msg.c +++ b/src/functional/ipc_msg.c @@ -16,12 +16,12 @@ static const int id = 'x'; #define T(f) do{ \ if ((f)+1 == 0) \ - error("%s failed: %s\n", #f, strerror(errno)); \ + t_error("%s failed: %s\n", #f, strerror(errno)); \ }while(0) #define EQ(a,b,fmt) do{ \ if ((a) != (b)) \ - error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ + t_error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ }while(0) static void snd() @@ -43,13 +43,13 @@ static void snd() T(msgctl(qid, IPC_RMID, 0)); T(qid = msgget(k, IPC_CREAT|IPC_EXCL|0666)); - if (test_status) - exit(test_status); + if (t_status) + exit(t_status); /* check IPC_EXCL */ errno = 0; if (msgget(k, IPC_CREAT|IPC_EXCL|0666) != -1 || errno != EEXIST) - error("msgget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); + t_error("msgget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); /* check if msgget initilaized the msqid_ds structure correctly */ T(msgctl(qid, IPC_STAT, &qid_ds)); @@ -64,9 +64,9 @@ static void snd() EQ((long)qid_ds.msg_stime, 0, "got %ld, want %d"); EQ((long)qid_ds.msg_rtime, 0, "got %ld, want %d"); if (qid_ds.msg_ctime < t) - error("qid_ds.msg_ctime >= t failed: got %ld, want %ld\n", (long)qid_ds.msg_ctime, (long)t); + t_error("qid_ds.msg_ctime >= t failed: got %ld, want %ld\n", (long)qid_ds.msg_ctime, (long)t); if (qid_ds.msg_qbytes <= 0) - error("qid_ds.msg_qbytes > 0 failed: got %d, want 0\n", qid_ds.msg_qbytes, t); + t_error("qid_ds.msg_qbytes > 0 failed: got %d, want 0\n", qid_ds.msg_qbytes, t); /* test send */ T(msgsnd(qid, &msg, sizeof msg.data, IPC_NOWAIT)); @@ -74,7 +74,7 @@ static void snd() EQ(qid_ds.msg_qnum, 1, "got %d, want %d"); EQ(qid_ds.msg_lspid, getpid(), "got %d, want %d"); if (qid_ds.msg_stime < t) - error("msg_stime is %ld want >= %ld\n", (long)qid_ds.msg_stime, (long)t); + t_error("msg_stime is %ld want >= %ld\n", (long)qid_ds.msg_stime, (long)t); } static void rcv() @@ -92,16 +92,16 @@ static void rcv() errno = 0; if (msgrcv(qid, &msg, 0, msgtyp, 0) != -1 || errno != E2BIG) - error("msgrcv should have failed when msgsize==0 with E2BIG, got %s\n", strerror(errno)); + t_error("msgrcv should have failed when msgsize==0 with E2BIG, got %s\n", strerror(errno)); /* test receive */ T(msgrcv(qid, &msg, sizeof msg.data, msgtyp, IPC_NOWAIT)); if (strcmp(msg.data,"test message") != 0) - error("received \"%s\" instead of \"%s\"\n", msg.data, "test message"); + t_error("received \"%s\" instead of \"%s\"\n", msg.data, "test message"); errno = 0; if (msgrcv(qid, &msg, sizeof msg.data, msgtyp, MSG_NOERROR|IPC_NOWAIT) != -1 || errno != ENOMSG) - error("msgrcv should have failed when ther is no msg with ENOMSG, got %s\n", strerror(errno)); + t_error("msgrcv should have failed when ther is no msg with ENOMSG, got %s\n", strerror(errno)); /* cleanup */ T(msgctl(qid, IPC_RMID, 0)); @@ -115,13 +115,13 @@ int main(void) snd(); p = fork(); if (p == -1) - error("fork failed: %s\n", strerror(errno)); + t_error("fork failed: %s\n", strerror(errno)); else if (p == 0) rcv(); else { T(waitpid(p, &status, 0)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - error("child exit status: %d\n", status); + t_error("child exit status: %d\n", status); } - return test_status; + return t_status; } diff --git a/src/functional/ipc_sem.c b/src/functional/ipc_sem.c index 8f69586..5a08b88 100644 --- a/src/functional/ipc_sem.c +++ b/src/functional/ipc_sem.c @@ -16,12 +16,12 @@ static const int id = 'x'; #define T(f) do{ \ if ((f)+1 == 0) \ - error("%s failed: %s\n", #f, strerror(errno)); \ + t_error("%s failed: %s\n", #f, strerror(errno)); \ }while(0) #define EQ(a,b,fmt) do{ \ if ((a) != (b)) \ - error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ + t_error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ }while(0) static void inc() @@ -45,13 +45,13 @@ static void inc() T(semctl(semid, 0, IPC_RMID)); T(semid = semget(k, 1, IPC_CREAT|IPC_EXCL|0666)); - if (test_status) - exit(test_status); + if (t_status) + exit(t_status); /* check IPC_EXCL */ errno = 0; if (semget(k, 1, IPC_CREAT|IPC_EXCL|0666) != -1 || errno != EEXIST) - error("semget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); + t_error("semget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); /* check if msgget initilaized the msqid_ds structure correctly */ arg.buf = &semid_ds; @@ -64,7 +64,7 @@ static void inc() EQ(semid_ds.sem_nsems, 1, "got %d, want %d"); EQ((long)semid_ds.sem_otime, 0, "got %ld, want %d"); if (semid_ds.sem_ctime < t) - error("semid_ds.sem_ctime >= t failed: got %ld, want %ld\n", (long)semid_ds.sem_ctime, (long)t); + t_error("semid_ds.sem_ctime >= t failed: got %ld, want %ld\n", (long)semid_ds.sem_ctime, (long)t); /* test sem_op > 0 */ sops.sem_num = 0; @@ -110,14 +110,14 @@ int main(void) inc(); p = fork(); if (p == -1) - error("fork failed: %s\n", strerror(errno)); + t_error("fork failed: %s\n", strerror(errno)); else if (p == 0) dec(); else { T(waitpid(p, &status, 0)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - error("child exit status: %d\n", status); + t_error("child exit status: %d\n", status); } - return test_status; + return t_status; } diff --git a/src/functional/ipc_shm.c b/src/functional/ipc_shm.c index 7d0086b..6863ad5 100644 --- a/src/functional/ipc_shm.c +++ b/src/functional/ipc_shm.c @@ -16,12 +16,12 @@ static const int id = 'x'; #define T(f) do{ \ if ((f)+1 == 0) \ - error("%s failed: %s\n", #f, strerror(errno)); \ + t_error("%s failed: %s\n", #f, strerror(errno)); \ }while(0) #define EQ(a,b,fmt) do{ \ if ((a) != (b)) \ - error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ + t_error("%s == %s failed: " fmt "\n", #a, #b, a, b); \ }while(0) static void set() @@ -40,13 +40,13 @@ static void set() T(shmctl(shmid, IPC_RMID, 0)); T(shmid = shmget(k, 100, IPC_CREAT|IPC_EXCL|0666)); - if (test_status) - exit(test_status); + if (t_status) + exit(t_status); /* check IPC_EXCL */ errno = 0; if (shmget(k, 100, IPC_CREAT|IPC_EXCL|0666) != -1 || errno != EEXIST) - error("shmget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); + t_error("shmget(IPC_CREAT|IPC_EXCL) should have failed with EEXIST, got %s\n", strerror(errno)); /* check if shmget initilaized the msshmid_ds structure correctly */ T(shmctl(shmid, IPC_STAT, &shmid_ds)); @@ -62,16 +62,16 @@ static void set() EQ((long)shmid_ds.shm_atime, 0, "got %ld, want %d"); EQ((long)shmid_ds.shm_dtime, 0, "got %ld, want %d"); if (shmid_ds.shm_ctime < t) - error("shmid_ds.shm_ctime >= t failed: got %ld, want %ld\n", (long)shmid_ds.shm_ctime, (long)t); + t_error("shmid_ds.shm_ctime >= t failed: got %ld, want %ld\n", (long)shmid_ds.shm_ctime, (long)t); /* test attach */ if ((p=shmat(shmid, 0, 0)) == 0) - error("shmat failed: %s\n", strerror(errno)); + t_error("shmat failed: %s\n", strerror(errno)); T(shmctl(shmid, IPC_STAT, &shmid_ds)); EQ((int)shmid_ds.shm_nattch, 1, "got %d, want %d"); EQ(shmid_ds.shm_lpid, getpid(), "got %d, want %d"); if (shmid_ds.shm_atime < t) - error("shm_atime is %ld want >= %ld\n", (long)shmid_ds.shm_atime, (long)t); + t_error("shm_atime is %ld want >= %ld\n", (long)shmid_ds.shm_atime, (long)t); strcpy(p, "test data"); T(shmdt(p)); } @@ -87,10 +87,10 @@ static void get() errno = 0; if ((p=shmat(shmid, 0, SHM_RDONLY)) == 0) - error("shmat failed: %s\n", strerror(errno)); + t_error("shmat failed: %s\n", strerror(errno)); if (strcmp(p, "test data") != 0) - error("reading shared mem failed: got \"%.100s\" want \"test data\"\n", p); + t_error("reading shared mem failed: got \"%.100s\" want \"test data\"\n", p); /* cleanup */ T(shmdt(p)); @@ -105,13 +105,13 @@ int main(void) set(); p = fork(); if (p == -1) - error("fork failed: %s\n", strerror(errno)); + t_error("fork failed: %s\n", strerror(errno)); else if (p == 0) get(); else { T(waitpid(p, &status, 0)); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) - error("child exit status: %d\n", status); + t_error("child exit status: %d\n", status); } - return test_status; + return t_status; } diff --git a/src/functional/mbc.c b/src/functional/mbc.c index 56c546b..65dceaa 100644 --- a/src/functional/mbc.c +++ b/src/functional/mbc.c @@ -14,11 +14,11 @@ #define T(f, x, m) (void)( \ memset(&st, 0, sizeof st), \ (i = (f)) == (x) || \ - error("%s failed (%s) got %d want %d\n", #f, m, i, x) ) + t_error("%s failed (%s) got %d want %d\n", #f, m, i, x) ) #define TCHAR(f, x, m) (void)( \ memset(&st, 0, sizeof st), \ (i = (f)) == (x) || \ - error("%s failed (%s) got 0x%04x want 0x%04x\n", #f, m, i, x) ) + t_error("%s failed (%s) got 0x%04x want 0x%04x\n", #f, m, i, x) ) int main(void) { @@ -41,7 +41,7 @@ int main(void) T(mbsrtowcs(NULL, (cs="abcdef",&cs), 2, &st), 6, "wrong semantics for NULL wcs"); if (strcmp(nl_langinfo(CODESET), "UTF-8")) - return error("cannot set UTF-8 locale for test (codeset=%s)\n", nl_langinfo(CODESET)); + return t_error("cannot set UTF-8 locale for test (codeset=%s)\n", nl_langinfo(CODESET)); T(mbrtowc(&wc, "\x80", 1, &st), -1, "failed to catch error"); T(mbrtowc(&wc, "\xc0", 1, &st), -1, "failed to catch illegal initial"); @@ -81,5 +81,5 @@ int main(void) TCHAR(wcs[0], 0xa0, "wrong char"); TCHAR(wcs[1], 'a', "wrong char"); T(!cs, 1, "wrong final position"); - return test_status; + return t_status; } diff --git a/src/functional/memstream.c b/src/functional/memstream.c index 749c664..0eef3cc 100644 --- a/src/functional/memstream.c +++ b/src/functional/memstream.c @@ -7,18 +7,18 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ -(error("%s failed (" m ")\n", #f, r, x), 0) ) +(t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_E(f) ( (errno = 0), (f) || \ -(error("%s failed (errno = %d)\n", #f, errno), 0) ) +(t_error("%s failed (errno = %d)\n", #f, errno), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ -(error("[%s] != [%s] (%s)\n", s, x, m), 0) ) +(t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) #define TEST_M(s, x, n, m) ( \ !memcmp((s),(x),(n)) || \ -(error("[%s] != [%s] (%s)\n", s, x, m), 0) ) +(t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) int main(void) { @@ -91,5 +91,5 @@ int main(void) TEST(i, ftell(f), 8, "%d != %d"); TEST_S(buf, "hello104", ""); fclose(f); - return test_status; + return t_status; } diff --git a/src/functional/popen.c b/src/functional/popen.c index f5cf05a..42c32c4 100644 --- a/src/functional/popen.c +++ b/src/functional/popen.c @@ -6,15 +6,15 @@ #include "test.h" #define TEST(r, f, x, m) ( \ - ((r) = (f)) == (x) || (error("%s failed (" m ")\n", #f, r, x), 0) ) + ((r) = (f)) == (x) || (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_E(f) ( \ (errno = 0), \ - (f) || (error("%s failed (errno = %d)\n", #f, errno), 0) ) + (f) || (t_error("%s failed (errno = %d)\n", #f, errno), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) static sig_atomic_t got_sig; @@ -45,5 +45,5 @@ int main(void) TEST(i, got_sig, 1, "child process did not send signal"); } signal(SIGUSR1, SIG_DFL); - return test_status; + return t_status; } diff --git a/src/functional/pthread_cancel.c b/src/functional/pthread_cancel.c index cbdd37a..26db8f3 100644 --- a/src/functional/pthread_cancel.c +++ b/src/functional/pthread_cancel.c @@ -3,9 +3,9 @@ #include #include "test.h" -#define TESTC(c, m) ( (c) || (error("%s failed (" m ")\n", #c), 0) ) +#define TESTC(c, m) ( (c) || (t_error("%s failed (" m ")\n", #c), 0) ) #define TESTR(r, f, m) ( \ - ((r) = (f)) == 0 || (error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) + ((r) = (f)) == 0 || (t_error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) static void *start_async(void *arg) { @@ -94,5 +94,5 @@ int main(void) TESTC(foo[2] == 3, "cleanup handler failed to run"); TESTC(foo[3] == 4, "cleanup handler failed to run"); - return test_status; + return t_status; } diff --git a/src/functional/pthread_cond.c b/src/functional/pthread_cond.c index 23c9924..a9a086a 100644 --- a/src/functional/pthread_cond.c +++ b/src/functional/pthread_cond.c @@ -3,7 +3,7 @@ #include "test.h" #define TEST(r, f, m) ( \ - ((r) = (f)) == 0 || (error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) + ((r) = (f)) == 0 || (t_error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) static void *start_signal(void *arg) @@ -95,5 +95,5 @@ int main(void) TEST(r, pthread_mutex_destroy(&mtx), ""); TEST(r, pthread_cond_destroy(&cond), ""); - return test_status; + return t_status; } diff --git a/src/functional/pthread_robust.c b/src/functional/pthread_robust.c index 0c4ce8d..42957f1 100644 --- a/src/functional/pthread_robust.c +++ b/src/functional/pthread_robust.c @@ -4,9 +4,9 @@ #include "test.h" #define TEST(r, f, m) ( \ - ((r) = (f)) == 0 || (error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) + ((r) = (f)) == 0 || (t_error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) #define TESTX(r, f, x, m) ( \ - ((r) = (f)) == (x) || (error("%s failed: got %d \"%s\" want %d \"%s\" (" m ")\n", #f, r, strerror(r), x, strerror(x)), 0) ) + ((r) = (f)) == (x) || (t_error("%s failed: got %d \"%s\" want %d \"%s\" (" m ")\n", #f, r, strerror(r), x, strerror(x)), 0) ) static void *start_lock(void *arg) { @@ -60,7 +60,7 @@ int main(void) TEST(r, pthread_create(&td, 0, start_wait, (void *[]){ &barrier2, &mtx }), ""); r = pthread_barrier_wait(&barrier2); if (r && r != PTHREAD_BARRIER_SERIAL_THREAD) - error("pthread_barrier_wait failed: got %d \"%s\", wanted either 0 or %d\n", + t_error("pthread_barrier_wait failed: got %d \"%s\", wanted either 0 or %d\n", r, strerror(r), PTHREAD_BARRIER_SERIAL_THREAD); TESTX(r, pthread_mutex_lock(&mtx), EOWNERDEAD, ""); TEST(r, pthread_join(td, &res), ""); @@ -68,5 +68,5 @@ int main(void) TEST(r, pthread_mutex_unlock(&mtx), ""); TEST(r, pthread_mutex_destroy(&mtx), ""); - return test_status; + return t_status; } diff --git a/src/functional/pthread_tsd.c b/src/functional/pthread_tsd.c index 477496a..6e6360d 100644 --- a/src/functional/pthread_tsd.c +++ b/src/functional/pthread_tsd.c @@ -2,9 +2,9 @@ #include #include "test.h" -#define TESTC(c, m) ( (c) || (error("%s failed (" m ")\n", #c), 0) ) +#define TESTC(c, m) ( (c) || (t_error("%s failed (" m ")\n", #c), 0) ) #define TESTR(r, f, m) ( \ - ((r) = (f)) == 0 || (error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) + ((r) = (f)) == 0 || (t_error("%s failed: %s (" m ")\n", #f, strerror(r)), 0) ) static pthread_key_t k1, k2; @@ -45,5 +45,5 @@ int main(void) TESTR(r, pthread_setspecific(k2, 0), "failed to clear tsd"); TESTR(r, pthread_key_delete(k1), "failed to destroy key"); TESTR(r, pthread_key_delete(k2), "failed to destroy key"); - return test_status; + return t_status; } diff --git a/src/functional/qsort.c b/src/functional/qsort.c index 5927340..36c09d1 100644 --- a/src/functional/qsort.c +++ b/src/functional/qsort.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -18,6 +19,12 @@ static int ccmp(const void *a, const void *b) return *(char*)a - *(char*)b; } +static int cmp64(const void *a, const void *b) +{ + const uint64_t *ua = a, *ub = b; + return *ua < *ub ? -1 : *ua != *ub; +} + /* 26 items -- even */ static const char *s[] = { "Bob", "Alice", "John", "Ceres", @@ -50,31 +57,59 @@ static int n_sorted[] = { 93994, 232323, 848405, 879045, 2230404, 3434344, 99405644 }; -static void string_sort(const char **a, const char **a_sorted, int len) +static void str_test(const char **a, const char **a_sorted, int len) { int i; qsort(a, len, sizeof *a, scmp); for (i=0; i #include "test.h" -#define TEST(c, ...) ((c) ? 1 : (error(#c" failed: " __VA_ARGS__),0)) +#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0)) int main(void) { @@ -46,5 +46,5 @@ int main(void) sigprocmask(SIG_SETMASK, &set, &set); TEST(sigismember(&set, SIGUSR1)==0, "siglongjmp failed to restore mask\n"); - return test_status; + return t_status; } diff --git a/src/functional/snprintf.c b/src/functional/snprintf.c index fefe814..2c94d02 100644 --- a/src/functional/snprintf.c +++ b/src/functional/snprintf.c @@ -12,11 +12,11 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) static const struct { const char *fmt; @@ -162,23 +162,23 @@ int main(void) for (j=0; int_tests[j].fmt; j++) { i = snprintf(b, sizeof b, int_tests[j].fmt, int_tests[j].i); if (i != strlen(int_tests[j].expect)) { - error("snprintf(b, sizeof b, \"%s\", %d) returned %d wanted %d\n", + t_error("snprintf(b, sizeof b, \"%s\", %d) returned %d wanted %d\n", int_tests[j].fmt, int_tests[j].i, i, strlen(int_tests[j].expect)); } if (strcmp(b, int_tests[j].expect) != 0) - error("bad integer conversion: got \"%s\", want \"%s\"\n", b, int_tests[j].expect); + t_error("bad integer conversion: got \"%s\", want \"%s\"\n", b, int_tests[j].expect); } for (j=0; fp_tests[j].fmt; j++) { i = snprintf(b, sizeof b, fp_tests[j].fmt, fp_tests[j].f); if (i != strlen(fp_tests[j].expect)) { - error("snprintf(b, sizeof b, \"%s\", %f) returned %d wanted %d\n", + t_error("snprintf(b, sizeof b, \"%s\", %f) returned %d wanted %d\n", fp_tests[j].fmt, fp_tests[j].f, i, strlen(fp_tests[j].expect)); } if (strcmp(b, fp_tests[j].expect) != 0) - error("bad floating-point conversion: got \"%s\", want \"%s\"\n", b, fp_tests[j].expect); + t_error("bad floating-point conversion: got \"%s\", want \"%s\"\n", b, fp_tests[j].expect); } TEST(i, snprintf(0, 0, "%.4a", 1.0), 11, "%d != %d"); - return test_status; + return t_status; } diff --git a/src/functional/socket.c b/src/functional/socket.c index 770630e..b62cf98 100644 --- a/src/functional/socket.c +++ b/src/functional/socket.c @@ -8,7 +8,7 @@ #include #include "test.h" -#define TEST(c, ...) ((c) ? 1 : (error(#c" failed: " __VA_ARGS__),0)) +#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0)) #define TESTE(c) (errno=0, TEST(c, "errno = %s\n", strerror(errno))) int main(void) @@ -54,5 +54,5 @@ int main(void) close(c); close(s); - return test_status; + return t_status; } diff --git a/src/functional/spawn.c b/src/functional/spawn.c index 707b1a5..4ce9772 100644 --- a/src/functional/spawn.c +++ b/src/functional/spawn.c @@ -12,11 +12,11 @@ #define TEST(f, x) (void)( \ (r = (f)) == (x) || \ - error("%s failed, got %d want %d\n", #f, r, x) ) + t_error("%s failed, got %d want %d\n", #f, r, x) ) #define TEST_E(f) (void)( \ (errno = 0), (f) || \ - error("%s failed (errno = %d \"%s\")\n", #f, errno, strerror(errno)) ) + t_error("%s failed (errno = %d \"%s\")\n", #f, errno, strerror(errno)) ) int main(void) { @@ -38,5 +38,5 @@ int main(void) TEST(read(p[0], foo, sizeof foo), 6); close(p[0]); TEST(posix_spawn_file_actions_destroy(&fa), 0); - return test_status; + return t_status; } diff --git a/src/functional/sscanf.c b/src/functional/sscanf.c index c109e5b..4480109 100644 --- a/src/functional/sscanf.c +++ b/src/functional/sscanf.c @@ -5,11 +5,11 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) #define TEST_F(x) ( \ TEST(i, sscanf(# x, "%lf", &d), 1, "got %d fields, expected %d"), \ @@ -82,5 +82,5 @@ int main(void) TEST(i, sscanf("10e", "%lf", &d), 0, "got %d fields, expected no match (%d)"); TEST(i, sscanf("", "%lf\n", &d), -1, "got %d fields, expected input failure (%d)"); - return test_status; + return t_status; } diff --git a/src/functional/sscanf_long.c b/src/functional/sscanf_long.c index a26999d..160648b 100644 --- a/src/functional/sscanf_long.c +++ b/src/functional/sscanf_long.c @@ -11,10 +11,10 @@ static void setrl(int r, long lim) struct rlimit rl; if (getrlimit(r, &rl)) - error("getrlimit %d: %s\n", r, strerror(errno)); + t_error("getrlimit %d: %s\n", r, strerror(errno)); rl.rlim_cur = lim; if (setrlimit(r, &rl)) - error("setrlimit %d: %s\n", r, strerror(errno)); + t_error("setrlimit %d: %s\n", r, strerror(errno)); } int main(void) @@ -26,7 +26,7 @@ int main(void) char c; if (!s) - return error("out of memory"); + return t_error("out of memory"); setrl(RLIMIT_STACK, 128*1024); for (i = 0; i < n; i++) s[i] = '1'; @@ -41,11 +41,11 @@ int main(void) i = sscanf(s, "%f %c", &f, &c); if (i != 2) - error("sscanf returned %d, want 2\n", i); + t_error("sscanf returned %d, want 2\n", i); if (f != INFINITY) - error("sscanf(longnum, \"%%f\") read %f, want inf\n", f); + t_error("sscanf(longnum, \"%%f\") read %f, want inf\n", f); if (c != '1') - error("sscanf(\"1\", %%c) read '%c', want '1'\n", c); + t_error("sscanf(\"1\", %%c) read '%c', want '1'\n", c); free(s); - return test_status; + return t_status; } diff --git a/src/functional/stat.c b/src/functional/stat.c index 12abd7c..d743fc1 100644 --- a/src/functional/stat.c +++ b/src/functional/stat.c @@ -7,7 +7,7 @@ #include #include "test.h" -#define TEST(c, ...) ((c) ? 1 : (error(#c" failed: " __VA_ARGS__),0)) +#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0)) int main(void) { @@ -39,5 +39,5 @@ int main(void) fclose(f); } - return test_status; + return t_status; } diff --git a/src/functional/string.c b/src/functional/string.c index 2e06eb9..5d5d43c 100644 --- a/src/functional/string.c +++ b/src/functional/string.c @@ -11,11 +11,11 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) int main(void) { @@ -112,5 +112,5 @@ int main(void) TEST(i, strlcat(b, "123", 3), 6, "length %d != %d"); TEST_S(b, "abc", "strlcat result"); #endif - return test_status; + return t_status; } diff --git a/src/functional/string_memmem.c b/src/functional/string_memmem.c index d21164a..c01b971 100644 --- a/src/functional/string_memmem.c +++ b/src/functional/string_memmem.c @@ -8,16 +8,16 @@ char *p = s; \ char *q = memmem(p, strlen(p), sub, strlen(sub)); \ if (q) \ - error("memmem(%s,%s) returned str+%d, wanted 0\n", #s, #sub, q-p); \ + t_error("memmem(%s,%s) returned str+%d, wanted 0\n", #s, #sub, q-p); \ } #define T(s, sub, n) { \ char *p = s; \ char *q = memmem(p, strlen(p), sub, strlen(sub)); \ if (q == 0) \ - error("memmem(%s,%s) returned 0, wanted str+%d\n", #s, #sub, n); \ + t_error("memmem(%s,%s) returned 0, wanted str+%d\n", #s, #sub, n); \ else if (q - p != n) \ - error("memmem(%s,%s) returned str+%d, wanted str+%d\n", #s, #sub, q-p, n); \ + t_error("memmem(%s,%s) returned str+%d, wanted str+%d\n", #s, #sub, q-p, n); \ } int main(void) @@ -54,5 +54,5 @@ int main(void) T("nanabanabanana", "banana", 8) T("_ _\xff_ _", "_\xff_", 2) - return test_status; + return t_status; } diff --git a/src/functional/string_strchr.c b/src/functional/string_strchr.c index c05d881..e2df24a 100644 --- a/src/functional/string_strchr.c +++ b/src/functional/string_strchr.c @@ -5,16 +5,16 @@ char *p = s; \ char *q = strchr(p, c); \ if (q) \ - error("strchr(%s,%s) returned str+%d, wanted 0\n", #s, #c, q-p); \ + t_error("strchr(%s,%s) returned str+%d, wanted 0\n", #s, #c, q-p); \ } #define T(s, c, n) { \ char *p = s; \ char *q = strchr(p, c); \ if (q == 0) \ - error("strchr(%s,%s) returned 0, wanted str+%d\n", #s, #c, n); \ + t_error("strchr(%s,%s) returned 0, wanted str+%d\n", #s, #c, n); \ else if (q - p != n) \ - error("strchr(%s,%s) returned str+%d, wanted str+%d\n", #s, #c, q-p, n); \ + t_error("strchr(%s,%s) returned str+%d, wanted str+%d\n", #s, #c, q-p, n); \ } int main(void) @@ -54,5 +54,5 @@ int main(void) T(s, 255, 254) T(s, 0, 255) - return test_status; + return t_status; } diff --git a/src/functional/string_strcspn.c b/src/functional/string_strcspn.c index 87fcd10..88df383 100644 --- a/src/functional/string_strcspn.c +++ b/src/functional/string_strcspn.c @@ -7,7 +7,7 @@ char *q = c; \ size_t r = strcspn(p, q); \ if (r != n) \ - error("strcspn(%s,%s) returned %lu, wanted %lu\n", #s, #c, (unsigned long)r, (unsigned long)(n)); \ + t_error("strcspn(%s,%s) returned %lu, wanted %lu\n", #s, #c, (unsigned long)r, (unsigned long)(n)); \ } int main(void) @@ -30,5 +30,5 @@ int main(void) T("\xff\x80 abc", a, 2) T(s, "\xff", 254) - return test_status; + return t_status; } diff --git a/src/functional/string_strstr.c b/src/functional/string_strstr.c index 2e3b352..67aeaab 100644 --- a/src/functional/string_strstr.c +++ b/src/functional/string_strstr.c @@ -5,16 +5,16 @@ char *p = s; \ char *q = strstr(p, sub); \ if (q) \ - error("strstr(%s,%s) returned str+%d, wanted 0\n", #s, #sub, q-p); \ + t_error("strstr(%s,%s) returned str+%d, wanted 0\n", #s, #sub, q-p); \ } #define T(s, sub, n) { \ char *p = s; \ char *q = strstr(p, sub); \ if (q == 0) \ - error("strstr(%s,%s) returned 0, wanted str+%d\n", #s, #sub, n); \ + t_error("strstr(%s,%s) returned 0, wanted str+%d\n", #s, #sub, n); \ else if (q - p != n) \ - error("strstr(%s,%s) returned str+%d, wanted str+%d\n", #s, #sub, q-p, n); \ + t_error("strstr(%s,%s) returned str+%d, wanted str+%d\n", #s, #sub, q-p, n); \ } int main(void) @@ -51,5 +51,5 @@ int main(void) T("nanabanabanana", "banana", 8) T("_ _\xff_ _", "_\xff_", 2) - return test_status; + return t_status; } diff --git a/src/functional/strtod.c b/src/functional/strtod.c index c6967ac..2e4b3fd 100644 --- a/src/functional/strtod.c +++ b/src/functional/strtod.c @@ -68,8 +68,8 @@ int main(void) for (i = 0; i < length(t); i++) { x = strtod(t[i].s, &p); if (x != t[i].f) - error("strtod(\"%s\") want %a got %a\n", t[i].s, t[i].f, x); + t_error("strtod(\"%s\") want %a got %a\n", t[i].s, t[i].f, x); } - return test_status; + return t_status; } diff --git a/src/functional/strtod_long.c b/src/functional/strtod_long.c index d2db2e8..fa5ac17 100644 --- a/src/functional/strtod_long.c +++ b/src/functional/strtod_long.c @@ -13,7 +13,7 @@ int main(void) buf[sizeof buf - 1] = 0; if ((x=strtod(buf, 0)) != want) - error("strtod(.11[...]1) got %a want %a\n", x, want); - return test_status; + t_error("strtod(.11[...]1) got %a want %a\n", x, want); + return t_status; } diff --git a/src/functional/strtod_simple.c b/src/functional/strtod_simple.c index c95dc9e..53cf93e 100644 --- a/src/functional/strtod_simple.c +++ b/src/functional/strtod_simple.c @@ -7,11 +7,11 @@ * f = function call to test (or any expression) * x = expected result * m = message to print on failure (with formats for r & x) -**/ + */ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x, r-x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x, r-x), 0) ) int main(void) { @@ -27,6 +27,6 @@ int main(void) TEST(d, strtod("0x1p4", 0), 16.0, "hex float %a != %a"); TEST(d, strtod("0x1.1p4", 0), 17.0, "hex float %a != %a"); - return test_status; + return t_status; } diff --git a/src/functional/strtof.c b/src/functional/strtof.c index 29876bc..a998bea 100644 --- a/src/functional/strtof.c +++ b/src/functional/strtof.c @@ -36,7 +36,7 @@ int main(void) for (i = 0; i < length(t); i++) { x = strtof(t[i].s, &p); if (x != t[i].f) - error("strtof(\"%s\") want %a got %a\n", t[i].s, t[i].f, x); + t_error("strtof(\"%s\") want %a got %a\n", t[i].s, t[i].f, x); } - return test_status; + return t_status; } diff --git a/src/functional/strtol.c b/src/functional/strtol.c index 676a2c7..6490913 100644 --- a/src/functional/strtol.c +++ b/src/functional/strtol.c @@ -12,11 +12,11 @@ #define TEST(r, f, x, m) ( \ errno = 0, msg = #f, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST2(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", msg, r, x), 0) ) + (t_error("%s failed (" m ")\n", msg, r, x), 0) ) int main(void) { @@ -76,5 +76,5 @@ int main(void) TEST(l, strtol(s=" 1", &c, 0), 1, "%ld != %ld"); TEST2(i, c-s, 3, "wrong final position %d != %d"); - return test_status; + return t_status; } diff --git a/src/functional/strtold.c b/src/functional/strtold.c index e37f7f0..6ea1672 100644 --- a/src/functional/strtold.c +++ b/src/functional/strtold.c @@ -88,7 +88,7 @@ int main(void) for (i = 0; i < length(t); i++) { x = strtold(t[i].s, &p); if (x != t[i].f) - error("strtold(\"%s\") want %La got %La\n", t[i].s, t[i].f, x); + t_error("strtold(\"%s\") want %La got %La\n", t[i].s, t[i].f, x); } - return test_status; + return t_status; } diff --git a/src/functional/swprintf.c b/src/functional/swprintf.c index 10a8380..2abcb7c 100644 --- a/src/functional/swprintf.c +++ b/src/functional/swprintf.c @@ -13,11 +13,11 @@ #define TEST(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST_S(s, x, m) ( \ !wcscmp((s),(x)) || \ - (error("[%ls] != [%ls] (%s)\n", s, x, m), 0) ) + (t_error("[%ls] != [%ls] (%s)\n", s, x, m), 0) ) static const struct { const wchar_t *fmt; @@ -131,21 +131,21 @@ int main(void) for (j=0; int_tests[j].fmt; j++) { i = swprintf(b, sizeof b, int_tests[j].fmt, int_tests[j].i); if (i != wcslen(int_tests[j].expect)) { - error("swprintf(b, sizeof b, \"%ls\", %d) returned %d wanted %d\n", + t_error("swprintf(b, sizeof b, \"%ls\", %d) returned %d wanted %d\n", int_tests[j].fmt, int_tests[j].i, i, wcslen(int_tests[j].expect)); } if (wcscmp(b, int_tests[j].expect) != 0) - error("bad integer conversion: got \"%ls\", want \"%ls\"\n", b, int_tests[j].expect); + t_error("bad integer conversion: got \"%ls\", want \"%ls\"\n", b, int_tests[j].expect); } for (j=0; fp_tests[j].fmt; j++) { i = swprintf(b, sizeof b, fp_tests[j].fmt, fp_tests[j].f); if (i != wcslen(fp_tests[j].expect)) { - error("swprintf(b, sizeof b, \"%ls\", %f) returned %d wanted %d\n", + t_error("swprintf(b, sizeof b, \"%ls\", %f) returned %d wanted %d\n", fp_tests[j].fmt, fp_tests[j].f, i, wcslen(fp_tests[j].expect)); } if (wcscmp(b, fp_tests[j].expect) != 0) - error("bad floating-point conversion: got \"%ls\", want \"%ls\"\n", b, fp_tests[j].expect); + t_error("bad floating-point conversion: got \"%ls\", want \"%ls\"\n", b, fp_tests[j].expect); } - return test_status; + return t_status; } diff --git a/src/functional/tgmath.c b/src/functional/tgmath.c index 8cc2c3e..dcbc640 100644 --- a/src/functional/tgmath.c +++ b/src/functional/tgmath.c @@ -7,33 +7,33 @@ int main(void) i = lrint(123456789.1f) & 0x7fffffff; if (i != 123456792) - error("lrint(123456789.1f)&0x7fffffff want 123456792 got %ld\n", i); + t_error("lrint(123456789.1f)&0x7fffffff want 123456792 got %ld\n", i); i = lrint(123456789.1) & 0x7fffffff; if (i != 123456789) - error("lrint(123456789.1)&0x7fffffff want 123456789 got %ld\n", i); + t_error("lrint(123456789.1)&0x7fffffff want 123456789 got %ld\n", i); if (sqrt(2.0f) != 1.41421353816986083984375) - error("sqrt(2.0f) want 0x1.6a09e6p+0 got %a\n", sqrt(2.0f)); + t_error("sqrt(2.0f) want 0x1.6a09e6p+0 got %a\n", sqrt(2.0f)); if (sqrt(2.0) != 1.414213562373095145474621858738828450441360) - error("sqrt(2.0) want 0x1.6a09e667f3bcdp+0 got %a\n", sqrt(2.0)); + t_error("sqrt(2.0) want 0x1.6a09e667f3bcdp+0 got %a\n", sqrt(2.0)); if (sqrt(2) != 1.414213562373095145474621858738828450441360) - error("sqrt(2) want 0x1.6a09e667f3bcdp+0 got %a\n", sqrt(2.0)); + t_error("sqrt(2) want 0x1.6a09e667f3bcdp+0 got %a\n", sqrt(2.0)); if (sizeof pow(sqrt(8),0.5f) != sizeof(double)) - error("sizeof pow(sqrt(8),0.5f) want %d got %d\n", (int)sizeof(double), (int)sizeof pow(sqrt(8),0.5f)); + t_error("sizeof pow(sqrt(8),0.5f) want %d got %d\n", (int)sizeof(double), (int)sizeof pow(sqrt(8),0.5f)); if (sizeof pow(2.0,0.5) != sizeof(double)) - error("sizeof pow(2.0,0.5) want %d got %d\n", (int)sizeof(double), (int)sizeof pow(2.0,0.5)); + t_error("sizeof pow(2.0,0.5) want %d got %d\n", (int)sizeof(double), (int)sizeof pow(2.0,0.5)); if (sizeof pow(2.0f,0.5f) != sizeof(float)) - error("sizeof pow(2.0f,0.5f) want %d got %d\n", (int)sizeof(float), (int)sizeof pow(2.0f,0.5f)); + t_error("sizeof pow(2.0f,0.5f) want %d got %d\n", (int)sizeof(float), (int)sizeof pow(2.0f,0.5f)); if (sizeof pow(2.0,0.5+0*I) != sizeof(double complex)) - error("sizeof pow(2.0,0.5+0*I) want %d got %d\n", (int)sizeof(double complex), (int)sizeof pow(2.0,0.5+0*I)); + t_error("sizeof pow(2.0,0.5+0*I) want %d got %d\n", (int)sizeof(double complex), (int)sizeof pow(2.0,0.5+0*I)); if (pow(2.0,0.5) != 1.414213562373095145474621858738828450441360) - error("pow(2.0,0.5) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2.0,0.5)); + t_error("pow(2.0,0.5) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2.0,0.5)); if (pow(2,0.5) != 1.414213562373095145474621858738828450441360) - error("pow(2,0.5) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2,0.5)); + t_error("pow(2,0.5) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2,0.5)); if (pow(2,0.5f) != 1.414213562373095145474621858738828450441360) - error("pow(2,0.5f) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2,0.5f)); + t_error("pow(2,0.5f) want 0x1.6a09e667f3bcdp+0 got %a\n", pow(2,0.5f)); - return test_status; + return t_status; } diff --git a/src/functional/time.c b/src/functional/time.c index 27598b8..46e0fef 100644 --- a/src/functional/time.c +++ b/src/functional/time.c @@ -2,6 +2,9 @@ #include #include #include +#include +#include +#include #include "test.h" /* We use this instead of memcmp because some broken C libraries @@ -42,35 +45,66 @@ char *tm_str(struct tm tm) #define TM_Y2038_1S TM(7,14,3,19,0,138,2,18,0) #define TM_Y2038 TM(8,14,3,19,0,138,2,18,0) -#define TEST_TM(r,x,m) (!tm_cmp((r),(x)) || \ - (error("%s failed:\n\tresult: %s\n\texpect: %s\n", \ - m, tm_str(r), tm_str(x)), 0) ) +static void sec2tm(time_t t, char *m) +{ + struct tm *tm; + time_t r; + + errno = 0; + tm = gmtime(&t); + if (errno != 0) + t_error("%s: gmtime((time_t)%lld) should not set errno, got %s\n", + m, (long long)t, strerror(errno)); + errno = 0; + r = mktime(tm); + if (errno != 0) + t_error("%s: mktime(%s) should not set errno, got %s\n", + m, tm_str(*tm), strerror(errno)); + if (t != r) + t_error("%s: mktime(gmtime(%lld)) roundtrip failed: got %lld (gmtime is %s)\n", + m, (long long)t, (long long)r, tm_str(*tm)); +} -#define TEST(r, f, x, m) ( \ - ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) +static void tm2sec(struct tm *tm, int big, char *m) +{ + struct tm *r; + time_t t; + int overflow = big && (time_t)LLONG_MAX!=LLONG_MAX; + + errno = 0; + t = mktime(tm); + if (overflow && t != -1) + t_error("%s: mktime(%s) expected -1, got (time_t)%ld\n", + m, tm_str(*tm), (long)t); + if (overflow && errno != EOVERFLOW) + t_error("%s: mktime(%s) expected EOVERFLOW (%s), got (%s)\n", + m, tm_str(*tm), strerror(EOVERFLOW), strerror(errno)); + if (!overflow && t == -1) + t_error("%s: mktime(%s) expected success, got (time_t)-1\n", + m, tm_str(*tm)); + if (!overflow && errno) + t_error("%s: mktime(%s) expected no error, got (%s)\n", + m, tm_str(*tm), strerror(errno)); + r = gmtime(&t); + if (!overflow && tm_cmp(*r, *tm)) + t_error("%s: gmtime(mktime(%s)) roundtrip failed: got %s\n", + m, tm_str(*tm), tm_str(*r)); +} int main(void) { - struct tm tm, *tm_p; time_t t; putenv("TZ=GMT"); tzset(); + tm2sec(&TM_EPOCH, 0, "gmtime(0)"); + tm2sec(&TM_Y2038_1S, 0, "2038-1s"); + tm2sec(&TM_Y2038, 1, "2038"); - t=0; tm_p = gmtime(&t); - TEST_TM(*tm_p, TM_EPOCH, "gmtime(0)"); - - tm = TM_Y2038_1S; - t = mktime(&tm); - tm = *(gmtime(&t)); - TEST_TM(*tm_p, TM_Y2038_1S, "mktime/gmtime(Y2038-1)"); - - tm = TM_Y2038; - t = mktime(&tm); - tm = *(gmtime(&t)); - TEST_TM(*tm_p, TM_Y2038, "mktime/gmtime(Y2038)"); + sec2tm(0, "EPOCH"); + for (t = 1; t < 1000; t++) + sec2tm(t*100003, "EPOCH+eps"); /* FIXME: set a TZ var and check DST boundary conditions */ - return test_status; + return t_status; } diff --git a/src/functional/tls_align.c b/src/functional/tls_align.c index 505abf2..c2c1739 100644 --- a/src/functional/tls_align.c +++ b/src/functional/tls_align.c @@ -13,10 +13,10 @@ int main() for (i = 0; i < sizeof t/sizeof *t; i++) { if (!t[i].name) - error("name is not set for t[%d]\n", i); + t_error("name is not set for t[%d]\n", i); if (t[i].addr & (t[i].align-1)) - error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n", + t_error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n", t[i].name, t[i].size, t[i].align, t[i].addr); } - return test_status; + return t_status; } diff --git a/src/functional/tls_align.mk b/src/functional/tls_align.mk new file mode 100644 index 0000000..7058f68 --- /dev/null +++ b/src/functional/tls_align.mk @@ -0,0 +1,6 @@ +$(N).LDLIBS := $(D)/tls_align_dso.so +$(N)-static.LDLIBS := $(D)/tls_align_dso.o + +$(N): $(D)/tls_align_dso.so +$(N)-static: $(D)/tls_align_dso.o + diff --git a/src/functional/tls_align_dlopen.c b/src/functional/tls_align_dlopen.c index 64517e1..709964e 100644 --- a/src/functional/tls_align_dlopen.c +++ b/src/functional/tls_align_dlopen.c @@ -14,17 +14,17 @@ int main() h = dlopen("./tls_align_dso.so", RTLD_LAZY); if (!h) - error("dlopen failed\n"); + t_error("dlopen failed\n"); t = dlsym(h, "t"); if (!t) - error("dlsym failed\n"); + t_error("dlsym failed\n"); for (i = 0; i < 4; i++) { if (!t[i].name) - error("name is not set for t[%d]\n", i); + t_error("name is not set for t[%d]\n", i); if (t[i].addr & (t[i].align-1)) - error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n", + t_error("bad alignment: %s, size: %u, align: %u, addr: 0x%lx\n", t[i].name, t[i].size, t[i].align, t[i].addr); } - return test_status; + return t_status; } diff --git a/src/functional/tls_align_dlopen.mk b/src/functional/tls_align_dlopen.mk new file mode 100644 index 0000000..72f9694 --- /dev/null +++ b/src/functional/tls_align_dlopen.mk @@ -0,0 +1,2 @@ +$(N).BINS=$(N) +$(N).err: $(D)/tls_align_dso.so diff --git a/src/functional/tls_align_dso.mk b/src/functional/tls_align_dso.mk new file mode 100644 index 0000000..b691b45 --- /dev/null +++ b/src/functional/tls_align_dso.mk @@ -0,0 +1,2 @@ +$(N).BINS:= +$(N).LIBS:=$(N).so diff --git a/src/functional/tls_init.c b/src/functional/tls_init.c index 8a43829..d8b6e8f 100644 --- a/src/functional/tls_init.c +++ b/src/functional/tls_init.c @@ -7,15 +7,15 @@ __thread int tls_zero; static void *f(void *arg) { if (tls_fix != 23) - error("fixed init failed: want 23 got %d\n", tls_fix); + t_error("fixed init failed: want 23 got %d\n", tls_fix); if (tls_zero != 0) - error("zero init failed: want 0 got %d\n", tls_zero); + t_error("zero init failed: want 0 got %d\n", tls_zero); tls_fix++; tls_zero++; return 0; } -#define CHECK(f) do{ if(f) error("%s failed.\n", #f); }while(0) +#define CHECK(f) do{ if(f) t_error("%s failed.\n", #f); }while(0) #define length(a) (sizeof(a)/sizeof*(a)) int main() @@ -24,9 +24,9 @@ int main() int i, j; if (tls_fix != 23) - error("fixed init failed: want 23 got %d\n", tls_fix); + t_error("fixed init failed: want 23 got %d\n", tls_fix); if (tls_zero != 0) - error("zero init failed: want 0 got %d\n", tls_zero); + t_error("zero init failed: want 0 got %d\n", tls_zero); for (j = 0; j < 2; j++) { for (i = 0; i < length(t); i++) { @@ -38,5 +38,5 @@ int main() CHECK(pthread_join(t[i], 0)); } - return test_status; + return t_status; } diff --git a/src/functional/udiv.c b/src/functional/udiv.c index e5b6d2c..0dbd619 100644 --- a/src/functional/udiv.c +++ b/src/functional/udiv.c @@ -160,9 +160,9 @@ int main(void) div = x / y; mod = x % y; if (div != t[i].div) - error("udiv %llu/%llu want %llu got %llu\n", x, y, t[i].div, div); + t_error("udiv %llu/%llu want %llu got %llu\n", x, y, t[i].div, div); if (mod != t[i].mod) - error("umod %llu%%%llu want %llu got %llu\n", x, y, t[i].mod, mod); + t_error("umod %llu%%%llu want %llu got %llu\n", x, y, t[i].mod, mod); } - return test_status; + return t_status; } diff --git a/src/functional/ungetc.c b/src/functional/ungetc.c index 9003a1c..97bc3c6 100644 --- a/src/functional/ungetc.c +++ b/src/functional/ungetc.c @@ -7,11 +7,11 @@ #define TEST(r, f, x, m) ( \ errno = 0, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x, strerror(errno)), 0) ) #define TEST_S(s, x, m) ( \ !strcmp((s),(x)) || \ - (error("[%s] != [%s] (%s)\n", s, x, m), 0) ) + (t_error("[%s] != [%s] (%s)\n", s, x, m), 0) ) int main(void) { @@ -21,7 +21,7 @@ int main(void) TEST(i, !(f = tmpfile()), 0, "failed to create temp file %d!=%d (%s)"); - if (!f) return test_status; + if (!f) return t_status; TEST(i, fprintf(f, "hello, world\n"), 13, "%d != %d (%m)"); TEST(i, fseek(f, 0, SEEK_SET), 0, "%d != %d (%m)"); @@ -49,5 +49,5 @@ int main(void) TEST(i, fgetc(f), 'h', "'%c' != '%c'"); fclose(f); - return test_status; + return t_status; } diff --git a/src/functional/wcstol.c b/src/functional/wcstol.c index abd76af..9801f41 100644 --- a/src/functional/wcstol.c +++ b/src/functional/wcstol.c @@ -7,11 +7,11 @@ #define TEST(r, f, x, m) ( \ errno = 0, msg = #f, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST2(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", msg, r, x), 0) ) + (t_error("%s failed (" m ")\n", msg, r, x), 0) ) int main(void) { @@ -63,5 +63,5 @@ int main(void) TEST(l, wcstol(s=L"123", &c, 37), 0, "%ld != %ld"); TEST2(i, c-s, 0, "wrong final position %d != %d"); TEST2(i, errno, EINVAL, "%d != %d"); - return test_status; + return t_status; } diff --git a/src/math/Makefile b/src/math/Makefile index a8b2704..7be5f7a 100644 --- a/src/math/Makefile +++ b/src/math/Makefile @@ -1,31 +1,4 @@ -CFLAGS+=-g -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces -CFLAGS+=-Wno-unknown-pragmas -fno-builtin -frounding-math -CFLAGS+=-D_GNU_SOURCE -O0 -LDFLAGS+=-g -lm -BUILD?=. +all: +%: + $(MAKE) -C ../.. src/math/$@ -SRC=$(sort $(wildcard *.c)) -OBJ=$(SRC:%.c=$(BUILD)/%.o) -BINOBJ=$(filter-out $(BUILD)/util.o,$(OBJ)) -BIN=$(BINOBJ:.o=) - --include ../../config.mak - -all: $(BIN) -run: all - @N=0; for i in $(BIN);do ./$$i || N=$$((N+1)); done; [ "$$N" = 0 ] && echo PASS || echo FAILS: $$N -clean: - rm -f $(OBJ) $(BIN) - -$(BUILD): - mkdir -p $@ -$(BIN): $(BUILD)/util.o -$(OBJ): util.h | $(BUILD) -$(BUILD)/%.o: %.c - $(CC) $(CFLAGS) -c -o $@ $< -%: %.c - -%: %.o - $(CC) $(LDFLAGS) -o $@ $^ - -.PRECIOUS: $(OBJ) diff --git a/src/math/README b/src/math/README index 733b3d3..82d9ca2 100644 --- a/src/math/README +++ b/src/math/README @@ -6,4 +6,4 @@ test vectors are generated like echo 3.14 |./gen sin -using crlibm, ucb and a few random sanity test inputs +using crlibm, ucb and a various other test inputs diff --git a/src/math/acos.c b/src/math/acos.c index f37b41f..42c036e 100644 --- a/src/math/acos.c +++ b/src/math/acos.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/acos.h" diff --git a/src/math/acosf.c b/src/math/acosf.c index a9b3679..0841db8 100644 --- a/src/math/acosf.c +++ b/src/math/acosf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/acosf.h" diff --git a/src/math/acosh.c b/src/math/acosh.c index 4eb07a2..d6a5332 100644 --- a/src/math/acosh.c +++ b/src/math/acosh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/acosh.h" diff --git a/src/math/acoshf.c b/src/math/acoshf.c index 863cc51..a4a9982 100644 --- a/src/math/acoshf.c +++ b/src/math/acoshf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/acoshf.h" diff --git a/src/math/acoshl.c b/src/math/acoshl.c index 0da0538..1e6f7f2 100644 --- a/src/math/acoshl.c +++ b/src/math/acoshl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/acosl.c b/src/math/acosl.c index ffa7d93..0d5bd39 100644 --- a/src/math/acosl.c +++ b/src/math/acosl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/asin.c b/src/math/asin.c index 4b4cab7..f515e54 100644 --- a/src/math/asin.c +++ b/src/math/asin.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/asin.h" diff --git a/src/math/asinf.c b/src/math/asinf.c index 2d3e7f9..136ce27 100644 --- a/src/math/asinf.c +++ b/src/math/asinf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/asinf.h" diff --git a/src/math/asinh.c b/src/math/asinh.c index db59b79..7c82fc2 100644 --- a/src/math/asinh.c +++ b/src/math/asinh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/asinh.h" diff --git a/src/math/asinhf.c b/src/math/asinhf.c index 45de975..c7a398e 100644 --- a/src/math/asinhf.c +++ b/src/math/asinhf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/asinhf.h" diff --git a/src/math/asinhl.c b/src/math/asinhl.c index e0fcddc..921bad8 100644 --- a/src/math/asinhl.c +++ b/src/math/asinhl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/asinl.c b/src/math/asinl.c index 3ee29db..dba6bba 100644 --- a/src/math/asinl.c +++ b/src/math/asinl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/atan.c b/src/math/atan.c index 04a7a0d..9712712 100644 --- a/src/math/atan.c +++ b/src/math/atan.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/atan.h" diff --git a/src/math/atan2.c b/src/math/atan2.c index 8f748f4..b9f7d76 100644 --- a/src/math/atan2.c +++ b/src/math/atan2.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "ucb/atan2.h" diff --git a/src/math/atan2f.c b/src/math/atan2f.c index 5f66b9b..f3d3bf0 100644 --- a/src/math/atan2f.c +++ b/src/math/atan2f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "ucb/atan2f.h" diff --git a/src/math/atan2l.c b/src/math/atan2l.c index be3c8fb..f07314c 100644 --- a/src/math/atan2l.c +++ b/src/math/atan2l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/atanf.c b/src/math/atanf.c index 64c6489..271c178 100644 --- a/src/math/atanf.c +++ b/src/math/atanf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/atanf.h" diff --git a/src/math/atanh.c b/src/math/atanh.c index d7b532e..3b49325 100644 --- a/src/math/atanh.c +++ b/src/math/atanh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/atanh.h" diff --git a/src/math/atanhf.c b/src/math/atanhf.c index 9b264b8..2c0ba91 100644 --- a/src/math/atanhf.c +++ b/src/math/atanhf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/atanhf.h" diff --git a/src/math/atanhl.c b/src/math/atanhl.c index 05cb556..4d7cdea 100644 --- a/src/math/atanhl.c +++ b/src/math/atanhl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/atanl.c b/src/math/atanl.c index db6676d..bfe380a 100644 --- a/src/math/atanl.c +++ b/src/math/atanl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/cbrt.c b/src/math/cbrt.c index 5411dd1..0feff3d 100644 --- a/src/math/cbrt.c +++ b/src/math/cbrt.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/cbrt.h" diff --git a/src/math/cbrtf.c b/src/math/cbrtf.c index b2395b4..6eacc48 100644 --- a/src/math/cbrtf.c +++ b/src/math/cbrtf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/cbrtf.h" diff --git a/src/math/cbrtl.c b/src/math/cbrtl.c index e9547d7..111da1d 100644 --- a/src/math/cbrtl.c +++ b/src/math/cbrtl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/ceil.c b/src/math/ceil.c index d9fd6c3..0b88c25 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "ucb/ceil.h" diff --git a/src/math/ceilf.c b/src/math/ceilf.c index 4f37ae7..03d7dfb 100644 --- a/src/math/ceilf.c +++ b/src/math/ceilf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/ceilf.h" diff --git a/src/math/ceill.c b/src/math/ceill.c index b2707b9..d812dee 100644 --- a/src/math/ceill.c +++ b/src/math/ceill.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/copysign.c b/src/math/copysign.c index 23ab8e3..7ef6423 100644 --- a/src/math/copysign.c +++ b/src/math/copysign.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/copysign.h" diff --git a/src/math/copysignf.c b/src/math/copysignf.c index 705b6ca..eea9b87 100644 --- a/src/math/copysignf.c +++ b/src/math/copysignf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/copysignf.h" diff --git a/src/math/copysignl.c b/src/math/copysignl.c index 6ecf7b1..ff0c3b7 100644 --- a/src/math/copysignl.c +++ b/src/math/copysignl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/core b/src/math/core new file mode 100644 index 0000000000000000000000000000000000000000..b59d43fa7c8770503002fb704de4a5523437c63c GIT binary patch literal 118784 zcmeI43wV^(na9sufKh`43=oArPM4&`lFTG9ApsdpN`_35$)&jfDj0`kAX#&nWsq1g)>gOP@F_kWB*K;rF3^ul|5!I@_8t$zRm6s{)1?g61U^y_QJTG3M+Ck^ux&m z(Mw@ZxCf#WU@w@Wvqs7oN07)Gm@#j##bQAfi`n~Qu_B%Q7F%(SnJahXmefP(% zl-8r9%U1Z_me#)V2iG6|T;Yp7^LAHG`}vl4t~_w{r6miRcHVvT%G)2?dHMRKA3Z+4 zFy0RR>l`rnhFNbf3Y1pXFGbY`TTpFKTWrSIN||GKVG^;JQXdmTazKd3$c{v1<52S zruL)UIjKVRq0PoADEnN6+K#mSfl~D_e2ycZg0XVoV~79asCxkAx59T9&buUwB{`Fn z7B17%JkD0C?d{`ljM2||$gw#NJ$1<*{>svQo1gAq^xiWs zUzTgzW4|Vxvt#)w=h_WD4<5Ygvg&64rpF#xY-^1@`|8Fk58SY0)_1-g{@wG(9z9vq zed_g&x9(i;&er~Z+@<5syVkZQEBt=pcd{PoSW@)p_p~>+Ep4)u?b)@U_Q|Ij((RL< zKH4_(_Qz5ljxHQ}r~2l3OQzK12QYUzFJOvrIFra)2=lcw5_8qv?yk=ZK}aa&i~0dKassR+Z|a@Njth>QKt$eH(HXEplE%+>A9dJ7;aKD>yr6?#i5C?!2bP#yRsm z1>sqrh;JpoZS5UU^sjBZ0D*DqjE)f)?DZ6)^Mn^)9K00 zFUaxa&z&4u&6nbSd&wWa=j`Wqhfpui1$>;yHKfAvc*bFR zg{~jx%Q_Mu0TLhq5+DH*AOR8}0TTHCOhAsE4rZ)xXl3^iKXA{iCxC)QOt)a?iPpC3z9anTD0SHbh!hb%wOno$VtcOtVeFDzpV1@NtqX3`13J8y}aeF_YXX0nP$7( z8TW}{kOHJ90N}&0PFOr9p+A?8tg@`Hsa2L69hPZ$?i~4aXcYDOz3&rjnsaQbvT8Z0 z7OR$(YPD)JQ*Bl)BXx{bo1Qw>s->rnvubIn4y(4{%kZAAduNIFO!3YTZ>M;ti+7rM zr;2w$F~+$S+K93Ao5Cj8wHGXCZqr_|q*`p+UQ4RgrtPw%+H6|CC3TEV>$9YewP`yn zspD+gc1xlN;t?Oe4i^-x!~tuuenT+)Hx%q`4<|V4ur=%ffyY)`yXoXG#`B zu`6^wC-LmaX4Id8mHjsadkgYNerl2L(4R||_Q}&YuXgp`wc`siM&A=g*37@!wNtqw z%@M6r3$9SE=3t~*xti9sN7l6&R_j!*Rqd-?YeJoomX7vOnT96iYVXiO$`xvESlJnD z3pF%1!Qag3Jp|iY8j%QULFLjyYc+}D+(g*Rx(IJsqaCm_<9V3G?}a??BfjD%Yj+s7 z8Y)<^DrJes7x&qCTH|0W`s>`r%3S>A2t8nP^{=q|S;`_!sn~F114lT$S zT!!|q`;vD_wCq(PK}Tx z7KHQ%3F)LX8y(JfjV66E-yh5LdwdSB{8_Bc*3E{onCPT;v%Ku(udLI~dv|(Y zO!~c~&w3xsMSWw$r1Uw&jOn`oX8F!uL(pe!_i_6_`SGl5_XjcUq8~_VWpDSp_SpU& z8;Vu~z8&y;d%KUP3~ok5-MdnD3UiUO-FKQ)5e_xB1X~k#q$-senV;D--?<{#jLz`_bNU$3W0)n(3Oe z(&=?(25}Q=W>DHI)qkaK@KIXnTUxZR4t8--ptM*OmoEPDRag6Js#JYtv9D%PplXS# zS{zT@C}SfQd^D*X7*$iLYOYo_^{S>=)fk;h-(4Hfbz%%Wl`MJ45woo8BQs@G@RI~c zfCNZ@1W14cNPq-L;4@4>j+Nz@*%b4=S*De8sTajTo$}mjci@t{e&4fPE0OmX$+ata zf00}-k#`!&vCa3P<~7C1NXt9fzHy)OWtGtg1rCej}&>YlG)_z z`%Bcu@-j6C)>G?O1$X&XxW}*NTS`^2=2s7_@T(6ZewBgr$*MB-T~(@v_My$rb9{Fc z4rEPEzui=lw{_pdo2~tLkNr)LM%yNr-FFPfQDb&{uW(90@YSzvA^FnfM|X!kDLs}# zybC|+-RLVyUQYN57m+ER{0T!>U2?nhoBY1=tzSLvb&3P}73LxjPk;Nh>b153OTSV- zOuUC3*SLN-_@YxB;4AAQV!lh=TBua=d(!vqJeKg)uXVvU`qUwy@p4-xOHuLKhDn(LPE-H_<3 zD>jnW`!&}s;Tuc%j!H-j=DNiz`jh%fPLFD5W}Ha$$64-;&u2fZTnqg-SXt*|urQQQ zK|uCu4t_XWaqd!-LINZ}0wh2JBtQZrKmsH%LO}jj{+Q#t5l5y-fCNZ@1W14cNPq-L zfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@ z1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14c zNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-L zfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@ z1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14c zNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-L zfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@ z1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14cNPq-LfCNZ@1W14c zNB{(E&|Mc*sLCtK)YO?3YX5)kk4o7m$&rZ_dRy@yJh4Ce%_U`tw$k6F$eUu0k&}~S z7JX){IXB_w0l!;^NBCI_N2dA6Lw@z^>wLoAN4ku)msg!QJuM^+X#g;V?HHZ1?ZFa}BJB;52Y2&%o?l^vru?8<7-wzdEX(Rol zz-B@Vpv$4{(62+cLZ5-|hW-M23OY7>AUY9x1vCWx8uV`HHW&6g^k>ljfPM&_5E+pbtX71Kk51gi0(<(PLZnJ)(|m)t4o9VlX;ZDzQcrVVas}q{bhmai23y@>j4@C7 z>uddisuDC^R1~Q7sU@YA#Z^lXT5gV~ATNJzuBr+YS1&0(t>?~AxWg@hxi!rl>1 zn5`Glt3YkT!m2=3O|93MYki%+p|)yax!0|=h24=zb9UYJb?Y<@Q_pt?SB2U&mn2nr zO>t>W(kMEP;EK?ih}O{=a)-)Sw>E_$s$yY7T}8F-D*d%JX3L-zMWtY|CfMn23%0Zh zMO9r?=TGVm2<9hEK5|+ zyo#Ww$xbS&S?Kr9!6gh|acNx@Rz-FVf(PzUQ;Vjsl}fy!_J;aeSAE^0>;mO4t*u*F zRf(M(@V2aK$AYcsKu_3OivwPd@>f;(M%DrYoNdR0#HtR|SJir3TiREzmF2FL%~;^c z%Tw5=l||@D-)6qr+Nx?_rT0c>BD&U4Bob~3hn$&__&(M*LB1+3t;P1g$~!+t1<-C` wpsE(}n3GCsCM}m1Varz4l-6A}60+O1G`L!8?&xgM)~N<>;%lBr$nV#G158)u9smFU literal 0 HcmV?d00001 diff --git a/src/math/cos.c b/src/math/cos.c index 16f5e04..b2f5de2 100644 --- a/src/math/cos.c +++ b/src/math/cos.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/cos.h" diff --git a/src/math/cosf.c b/src/math/cosf.c index e29c640..509535a 100644 --- a/src/math/cosf.c +++ b/src/math/cosf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/cosf.h" diff --git a/src/math/cosh.c b/src/math/cosh.c index 493ff34..d650214 100644 --- a/src/math/cosh.c +++ b/src/math/cosh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/cosh.h" diff --git a/src/math/coshf.c b/src/math/coshf.c index 8023cd6..32afefb 100644 --- a/src/math/coshf.c +++ b/src/math/coshf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/coshf.h" diff --git a/src/math/coshl.c b/src/math/coshl.c index ffbbde9..bdb21a6 100644 --- a/src/math/coshl.c +++ b/src/math/coshl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/cosl.c b/src/math/cosl.c index 7827659..8c1a389 100644 --- a/src/math/cosl.c +++ b/src/math/cosl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/erf.c b/src/math/erf.c index 81843c8..655e564 100644 --- a/src/math/erf.c +++ b/src/math/erf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/erf.h" diff --git a/src/math/erfc.c b/src/math/erfc.c index 8d83372..799f79f 100644 --- a/src/math/erfc.c +++ b/src/math/erfc.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/erfc.h" diff --git a/src/math/erfcf.c b/src/math/erfcf.c index 6570c92..3fb9762 100644 --- a/src/math/erfcf.c +++ b/src/math/erfcf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/erfcf.h" diff --git a/src/math/erfcl.c b/src/math/erfcl.c index 8a362b8..f8021f3 100644 --- a/src/math/erfcl.c +++ b/src/math/erfcl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/erff.c b/src/math/erff.c index 1fb465a..1dd94f9 100644 --- a/src/math/erff.c +++ b/src/math/erff.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/erff.h" diff --git a/src/math/erfl.c b/src/math/erfl.c index c6f636f..342c810 100644 --- a/src/math/erfl.c +++ b/src/math/erfl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/exp.c b/src/math/exp.c index fcc49d3..68e41d1 100644 --- a/src/math/exp.c +++ b/src/math/exp.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/exp.h" diff --git a/src/math/exp10.c b/src/math/exp10.c index e549839..bc76d14 100644 --- a/src/math/exp10.c +++ b/src/math/exp10.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/exp10.h" diff --git a/src/math/exp10f.c b/src/math/exp10f.c index 1ad776e..1ca2034 100644 --- a/src/math/exp10f.c +++ b/src/math/exp10f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/exp10f.h" diff --git a/src/math/exp10l.c b/src/math/exp10l.c index 30db1d1..2644a4a 100644 --- a/src/math/exp10l.c +++ b/src/math/exp10l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/exp2.c b/src/math/exp2.c index cd73ddd..f98a995 100644 --- a/src/math/exp2.c +++ b/src/math/exp2.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/exp2.h" diff --git a/src/math/exp2f.c b/src/math/exp2f.c index b6c93c5..a3192d0 100644 --- a/src/math/exp2f.c +++ b/src/math/exp2f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/exp2f.h" diff --git a/src/math/exp2l.c b/src/math/exp2l.c index 2a669e0..256f7a4 100644 --- a/src/math/exp2l.c +++ b/src/math/exp2l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/expf.c b/src/math/expf.c index 6391087..e8f3f25 100644 --- a/src/math/expf.c +++ b/src/math/expf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/expf.h" diff --git a/src/math/expl.c b/src/math/expl.c index e4d3065..5231299 100644 --- a/src/math/expl.c +++ b/src/math/expl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/expm1.c b/src/math/expm1.c index 662660a..b02b862 100644 --- a/src/math/expm1.c +++ b/src/math/expm1.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/expm1.h" diff --git a/src/math/expm1f.c b/src/math/expm1f.c index 9c9ef60..f13bc99 100644 --- a/src/math/expm1f.c +++ b/src/math/expm1f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/expm1f.h" diff --git a/src/math/expm1l.c b/src/math/expm1l.c index 02b4e8f..c365d9f 100644 --- a/src/math/expm1l.c +++ b/src/math/expm1l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fabs.c b/src/math/fabs.c index e597ec2..118cdb5 100644 --- a/src/math/fabs.c +++ b/src/math/fabs.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "ucb/fabs.h" diff --git a/src/math/fabsf.c b/src/math/fabsf.c index f572799..9502560 100644 --- a/src/math/fabsf.c +++ b/src/math/fabsf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/fabsf.h" diff --git a/src/math/fabsl.c b/src/math/fabsl.c index 8989792..ef75ced 100644 --- a/src/math/fabsl.c +++ b/src/math/fabsl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fdim.c b/src/math/fdim.c index d73eece..9f4eeea 100644 --- a/src/math/fdim.c +++ b/src/math/fdim.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/fdim.h" diff --git a/src/math/fdimf.c b/src/math/fdimf.c index f48d25b..55dc1dc 100644 --- a/src/math/fdimf.c +++ b/src/math/fdimf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/fdimf.h" diff --git a/src/math/fdiml.c b/src/math/fdiml.c index a709b2e..e08e27e 100644 --- a/src/math/fdiml.c +++ b/src/math/fdiml.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fenv.c b/src/math/fenv.c index c221d7f..ef358f0 100644 --- a/src/math/fenv.c +++ b/src/math/fenv.c @@ -1,7 +1,7 @@ #include #include #include -#include "util.h" +#include "mtest.h" static int test_status; diff --git a/src/math/floor.c b/src/math/floor.c index be08516..ac5ecc8 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "ucb/floor.h" diff --git a/src/math/floorf.c b/src/math/floorf.c index 71fe0fe..1452f7f 100644 --- a/src/math/floorf.c +++ b/src/math/floorf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/floorf.h" diff --git a/src/math/floorl.c b/src/math/floorl.c index f2cf4e8..9681e6d 100644 --- a/src/math/floorl.c +++ b/src/math/floorl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fma.c b/src/math/fma.c index bb83520..cdd4cc3 100644 --- a/src/math/fma.c +++ b/src/math/fma.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ddd_d t[] = { #include "sanity/fma.h" diff --git a/src/math/fmaf.c b/src/math/fmaf.c index 0a0e196..288bd32 100644 --- a/src/math/fmaf.c +++ b/src/math/fmaf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fff_f t[] = { #include "sanity/fmaf.h" diff --git a/src/math/fmal.c b/src/math/fmal.c index ef350c8..1f67aa4 100644 --- a/src/math/fmal.c +++ b/src/math/fmal.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct lll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fmax.c b/src/math/fmax.c index 5479ad9..3492893 100644 --- a/src/math/fmax.c +++ b/src/math/fmax.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/fmax.h" diff --git a/src/math/fmaxf.c b/src/math/fmaxf.c index cd34a3b..8d787ed 100644 --- a/src/math/fmaxf.c +++ b/src/math/fmaxf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/fmaxf.h" diff --git a/src/math/fmaxl.c b/src/math/fmaxl.c index 1706207..1c6e42a 100644 --- a/src/math/fmaxl.c +++ b/src/math/fmaxl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fmin.c b/src/math/fmin.c index 542d6c0..1ee3f4c 100644 --- a/src/math/fmin.c +++ b/src/math/fmin.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/fmin.h" diff --git a/src/math/fminf.c b/src/math/fminf.c index 3d3a97b..c86569a 100644 --- a/src/math/fminf.c +++ b/src/math/fminf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/fminf.h" diff --git a/src/math/fminl.c b/src/math/fminl.c index 64e1167..91f3e87 100644 --- a/src/math/fminl.c +++ b/src/math/fminl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/fmod.c b/src/math/fmod.c index 5424768..3ba4427 100644 --- a/src/math/fmod.c +++ b/src/math/fmod.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "ucb/fmod.h" diff --git a/src/math/fmodf.c b/src/math/fmodf.c index 7709b48..9a4aa52 100644 --- a/src/math/fmodf.c +++ b/src/math/fmodf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "ucb/fmodf.h" diff --git a/src/math/fmodl.c b/src/math/fmodl.c index 51d589a..e10cd8a 100644 --- a/src/math/fmodl.c +++ b/src/math/fmodl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/frexp.c b/src/math/frexp.c index 7c40d73..88d2571 100644 --- a/src/math/frexp.c +++ b/src/math/frexp.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_di t[] = { #include "sanity/frexp.h" diff --git a/src/math/frexpf.c b/src/math/frexpf.c index a406523..33e1405 100644 --- a/src/math/frexpf.c +++ b/src/math/frexpf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_fi t[] = { #include "sanity/frexpf.h" diff --git a/src/math/frexpl.c b/src/math/frexpl.c index a28b0fd..9608504 100644 --- a/src/math/frexpl.c +++ b/src/math/frexpl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_li t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/gen/README b/src/math/gen/README index b156b20..245e814 100644 --- a/src/math/gen/README +++ b/src/math/gen/README @@ -1,8 +1,10 @@ tools for generating testcases and checking ulp error of math functions +(needs cleanup) gen: math functions implemented with mpfr mgen: math functions from libm check: compare input to libm and report errors -# check asinh in the [0.125,0.5] domain over 100k points and report >1.5ulp errors +check asinh in the [0.125,0.5] domain over 100k points and report >1.5ulp errors: + ./rnd -a 0x1p-3 -b 0x1p-1 -n 100000 |./gen asinh |./check asinh 1.5 diff --git a/src/math/hypot.c b/src/math/hypot.c index b2df491..9890ed4 100644 --- a/src/math/hypot.c +++ b/src/math/hypot.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "ucb/hypot.h" diff --git a/src/math/hypotf.c b/src/math/hypotf.c index 82bbcde..bd5830b 100644 --- a/src/math/hypotf.c +++ b/src/math/hypotf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "ucb/hypotf.h" diff --git a/src/math/hypotl.c b/src/math/hypotl.c index c8be939..27ca819 100644 --- a/src/math/hypotl.c +++ b/src/math/hypotl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/ilogb.c b/src/math/ilogb.c index 3d646bc..a636a23 100644 --- a/src/math/ilogb.c +++ b/src/math/ilogb.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_i t[] = { #include "sanity/ilogb.h" diff --git a/src/math/ilogbf.c b/src/math/ilogbf.c index a3d3dcd..d576878 100644 --- a/src/math/ilogbf.c +++ b/src/math/ilogbf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_i t[] = { #include "sanity/ilogbf.h" diff --git a/src/math/ilogbl.c b/src/math/ilogbl.c index f34c891..0944536 100644 --- a/src/math/ilogbl.c +++ b/src/math/ilogbl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_i t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/j0.c b/src/math/j0.c index 7e4742d..0eecc56 100644 --- a/src/math/j0.c +++ b/src/math/j0.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/j0.h" diff --git a/src/math/j0f.c b/src/math/j0f.c index 5a4af20..9166eac 100644 --- a/src/math/j0f.c +++ b/src/math/j0f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/j0f.h" diff --git a/src/math/j1.c b/src/math/j1.c index d9a2489..d884091 100644 --- a/src/math/j1.c +++ b/src/math/j1.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/j1.h" diff --git a/src/math/j1f.c b/src/math/j1f.c index a4e35bd..53135a0 100644 --- a/src/math/j1f.c +++ b/src/math/j1f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/j1f.h" diff --git a/src/math/jn.c b/src/math/jn.c index 94b3152..2b198d4 100644 --- a/src/math/jn.c +++ b/src/math/jn.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct di_d t[] = { #include "sanity/jn.h" diff --git a/src/math/jnf.c b/src/math/jnf.c index 66294d2..ecbc288 100644 --- a/src/math/jnf.c +++ b/src/math/jnf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fi_f t[] = { #include "sanity/jnf.h" diff --git a/src/math/ldexp.c b/src/math/ldexp.c index 7a5ac00..dcf73cc 100644 --- a/src/math/ldexp.c +++ b/src/math/ldexp.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct di_d t[] = { #include "sanity/ldexp.h" diff --git a/src/math/ldexpf.c b/src/math/ldexpf.c index cc0e23f..4a1b742 100644 --- a/src/math/ldexpf.c +++ b/src/math/ldexpf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fi_f t[] = { #include "sanity/ldexpf.h" diff --git a/src/math/ldexpl.c b/src/math/ldexpl.c index 331cb7e..8aa6a22 100644 --- a/src/math/ldexpl.c +++ b/src/math/ldexpl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct li_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/lgamma.c b/src/math/lgamma.c index ecb1dbb..a838bc8 100644 --- a/src/math/lgamma.c +++ b/src/math/lgamma.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_di t[] = { #include "sanity/lgamma.h" diff --git a/src/math/lgamma_r.c b/src/math/lgamma_r.c index 78b66ea..2a5151e 100644 --- a/src/math/lgamma_r.c +++ b/src/math/lgamma_r.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_di t[] = { #include "sanity/lgamma_r.h" diff --git a/src/math/lgammaf.c b/src/math/lgammaf.c index ce73ee4..265d8d9 100644 --- a/src/math/lgammaf.c +++ b/src/math/lgammaf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_fi t[] = { #include "sanity/lgammaf.h" diff --git a/src/math/lgammaf_r.c b/src/math/lgammaf_r.c index 8be26b2..3783b99 100644 --- a/src/math/lgammaf_r.c +++ b/src/math/lgammaf_r.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_fi t[] = { #include "sanity/lgammaf_r.h" diff --git a/src/math/lgammal.c b/src/math/lgammal.c index c5f6041..e1cdd12 100644 --- a/src/math/lgammal.c +++ b/src/math/lgammal.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_li t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/lgammal_r.c b/src/math/lgammal_r.c index 03e3901..5153456 100644 --- a/src/math/lgammal_r.c +++ b/src/math/lgammal_r.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_li t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/llrint.c b/src/math/llrint.c index ac8fea8..b0b0e16 100644 --- a/src/math/llrint.c +++ b/src/math/llrint.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_i t[] = { #include "sanity/llrint.h" diff --git a/src/math/llrintf.c b/src/math/llrintf.c index e8f5fa4..35d7087 100644 --- a/src/math/llrintf.c +++ b/src/math/llrintf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_i t[] = { #include "sanity/llrintf.h" diff --git a/src/math/llrintl.c b/src/math/llrintl.c index 0fea06e..4ebacbe 100644 --- a/src/math/llrintl.c +++ b/src/math/llrintl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_i t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/llround.c b/src/math/llround.c index 62f1a4e..a6c991a 100644 --- a/src/math/llround.c +++ b/src/math/llround.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_i t[] = { #include "sanity/llround.h" diff --git a/src/math/llroundf.c b/src/math/llroundf.c index d4256f5..0a61cf9 100644 --- a/src/math/llroundf.c +++ b/src/math/llroundf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_i t[] = { #include "sanity/llroundf.h" diff --git a/src/math/llroundl.c b/src/math/llroundl.c index a2cd6f0..5025b16 100644 --- a/src/math/llroundl.c +++ b/src/math/llroundl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_i t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/log.c b/src/math/log.c index b2d2d08..ffa8e7a 100644 --- a/src/math/log.c +++ b/src/math/log.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/log.h" diff --git a/src/math/log10.c b/src/math/log10.c index 81917fd..94bd952 100644 --- a/src/math/log10.c +++ b/src/math/log10.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/log10.h" diff --git a/src/math/log10f.c b/src/math/log10f.c index 8ae8d35..d2ece3c 100644 --- a/src/math/log10f.c +++ b/src/math/log10f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/log10f.h" diff --git a/src/math/log10l.c b/src/math/log10l.c index 9cfdf1a..153a9c9 100644 --- a/src/math/log10l.c +++ b/src/math/log10l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/log1p.c b/src/math/log1p.c index ec08393..1200bd6 100644 --- a/src/math/log1p.c +++ b/src/math/log1p.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/log1p.h" diff --git a/src/math/log1pf.c b/src/math/log1pf.c index 90afd4f..96cb6be 100644 --- a/src/math/log1pf.c +++ b/src/math/log1pf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/log1pf.h" diff --git a/src/math/log1pl.c b/src/math/log1pl.c index 53ff8d9..0b598b7 100644 --- a/src/math/log1pl.c +++ b/src/math/log1pl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/log2.c b/src/math/log2.c index a9050e2..b61896a 100644 --- a/src/math/log2.c +++ b/src/math/log2.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/log2.h" diff --git a/src/math/log2f.c b/src/math/log2f.c index dc6f41a..1f549ea 100644 --- a/src/math/log2f.c +++ b/src/math/log2f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/log2f.h" diff --git a/src/math/log2l.c b/src/math/log2l.c index 0578864..a9a60c4 100644 --- a/src/math/log2l.c +++ b/src/math/log2l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/logb.c b/src/math/logb.c index b0ec283..505d402 100644 --- a/src/math/logb.c +++ b/src/math/logb.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/logb.h" diff --git a/src/math/logbf.c b/src/math/logbf.c index 7d60218..076ab26 100644 --- a/src/math/logbf.c +++ b/src/math/logbf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/logbf.h" diff --git a/src/math/logbl.c b/src/math/logbl.c index b314722..7792b78 100644 --- a/src/math/logbl.c +++ b/src/math/logbl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/logf.c b/src/math/logf.c index 4f07980..980c7b4 100644 --- a/src/math/logf.c +++ b/src/math/logf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/logf.h" diff --git a/src/math/logl.c b/src/math/logl.c index d2a351a..5f96d54 100644 --- a/src/math/logl.c +++ b/src/math/logl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/lrint.c b/src/math/lrint.c index 695c3ed..84c410e 100644 --- a/src/math/lrint.c +++ b/src/math/lrint.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_i t[] = { #include "sanity/lrint.h" diff --git a/src/math/lrintf.c b/src/math/lrintf.c index 06fc366..0d48980 100644 --- a/src/math/lrintf.c +++ b/src/math/lrintf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_i t[] = { #include "sanity/lrintf.h" diff --git a/src/math/lrintl.c b/src/math/lrintl.c index 5091b1b..653b4b4 100644 --- a/src/math/lrintl.c +++ b/src/math/lrintl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_i t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/lround.c b/src/math/lround.c index 36d3907..f1ac491 100644 --- a/src/math/lround.c +++ b/src/math/lround.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_i t[] = { #include "sanity/lround.h" diff --git a/src/math/lroundf.c b/src/math/lroundf.c index 9852964..c954482 100644 --- a/src/math/lroundf.c +++ b/src/math/lroundf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_i t[] = { #include "sanity/lroundf.h" diff --git a/src/math/lroundl.c b/src/math/lroundl.c index 1a66be5..42b8479 100644 --- a/src/math/lroundl.c +++ b/src/math/lroundl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_i t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/modf.c b/src/math/modf.c index a8e26c1..5352a77 100644 --- a/src/math/modf.c +++ b/src/math/modf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_dd t[] = { #include "sanity/modf.h" diff --git a/src/math/modff.c b/src/math/modff.c index ce91f98..dfdd3ab 100644 --- a/src/math/modff.c +++ b/src/math/modff.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_ff t[] = { #include "sanity/modff.h" diff --git a/src/math/modfl.c b/src/math/modfl.c index 787fb8b..84abdcd 100644 --- a/src/math/modfl.c +++ b/src/math/modfl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_ll t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/nearbyint.c b/src/math/nearbyint.c index 282580d..675e77c 100644 --- a/src/math/nearbyint.c +++ b/src/math/nearbyint.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/nearbyint.h" diff --git a/src/math/nearbyintf.c b/src/math/nearbyintf.c index 582c146..a894548 100644 --- a/src/math/nearbyintf.c +++ b/src/math/nearbyintf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/nearbyintf.h" diff --git a/src/math/nearbyintl.c b/src/math/nearbyintl.c index 9350be6..0d62313 100644 --- a/src/math/nearbyintl.c +++ b/src/math/nearbyintl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/nextafter.c b/src/math/nextafter.c index 844917e..576a392 100644 --- a/src/math/nextafter.c +++ b/src/math/nextafter.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/nextafter.h" diff --git a/src/math/nextafterf.c b/src/math/nextafterf.c index 9f468f2..822a9b6 100644 --- a/src/math/nextafterf.c +++ b/src/math/nextafterf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/nextafterf.h" diff --git a/src/math/nextafterl.c b/src/math/nextafterl.c index 70fddb2..327258d 100644 --- a/src/math/nextafterl.c +++ b/src/math/nextafterl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/nexttoward.c b/src/math/nexttoward.c index 66c63a6..ebf395c 100644 --- a/src/math/nexttoward.c +++ b/src/math/nexttoward.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" // TODO: fix ldbl static struct ll_l t[] = { diff --git a/src/math/nexttowardf.c b/src/math/nexttowardf.c index d2a1762..b026bd1 100644 --- a/src/math/nexttowardf.c +++ b/src/math/nexttowardf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" // TODO: separate ldbl dir static struct ll_l t[] = { diff --git a/src/math/nexttowardl.c b/src/math/nexttowardl.c index add01bb..f9250e1 100644 --- a/src/math/nexttowardl.c +++ b/src/math/nexttowardl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/pow.c b/src/math/pow.c index 473dea9..341582f 100644 --- a/src/math/pow.c +++ b/src/math/pow.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "crlibm/pow.h" diff --git a/src/math/pow10.c b/src/math/pow10.c index 9197398..f980ce8 100644 --- a/src/math/pow10.c +++ b/src/math/pow10.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/pow10.h" diff --git a/src/math/pow10f.c b/src/math/pow10f.c index efb3207..1a1f172 100644 --- a/src/math/pow10f.c +++ b/src/math/pow10f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/pow10f.h" diff --git a/src/math/pow10l.c b/src/math/pow10l.c index 19b03f8..8cf8478 100644 --- a/src/math/pow10l.c +++ b/src/math/pow10l.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/powf.c b/src/math/powf.c index d2d5236..9709ec2 100644 --- a/src/math/powf.c +++ b/src/math/powf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "ucb/powf.h" diff --git a/src/math/powl.c b/src/math/powl.c index 1cb341e..f66d8c7 100644 --- a/src/math/powl.c +++ b/src/math/powl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/remainder.c b/src/math/remainder.c index 1c65edb..f8278ba 100644 --- a/src/math/remainder.c +++ b/src/math/remainder.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/remainder.h" diff --git a/src/math/remainderf.c b/src/math/remainderf.c index bc22fdc..a06f2bd 100644 --- a/src/math/remainderf.c +++ b/src/math/remainderf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/remainderf.h" diff --git a/src/math/remainderl.c b/src/math/remainderl.c index f1c8be0..83cedc1 100644 --- a/src/math/remainderl.c +++ b/src/math/remainderl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/remquo.c b/src/math/remquo.c index a3b6c92..afcab78 100644 --- a/src/math/remquo.c +++ b/src/math/remquo.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_di t[] = { #include "sanity/remquo.h" diff --git a/src/math/remquof.c b/src/math/remquof.c index 55cbe9d..f27402a 100644 --- a/src/math/remquof.c +++ b/src/math/remquof.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_fi t[] = { #include "sanity/remquof.h" diff --git a/src/math/remquol.c b/src/math/remquol.c index 6a75008..257b044 100644 --- a/src/math/remquol.c +++ b/src/math/remquol.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ll_li t[] = { #include "sanity/remquol.h" diff --git a/src/math/rint.c b/src/math/rint.c index 8826044..54c7df1 100644 --- a/src/math/rint.c +++ b/src/math/rint.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/rint.h" diff --git a/src/math/rintf.c b/src/math/rintf.c index 627c242..e64fa1e 100644 --- a/src/math/rintf.c +++ b/src/math/rintf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/rintf.h" diff --git a/src/math/rintl.c b/src/math/rintl.c index 1879f3c..0079a1b 100644 --- a/src/math/rintl.c +++ b/src/math/rintl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/round.c b/src/math/round.c index 86800d9..65a98fe 100644 --- a/src/math/round.c +++ b/src/math/round.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/round.h" diff --git a/src/math/roundf.c b/src/math/roundf.c index 345d4f3..3af83f1 100644 --- a/src/math/roundf.c +++ b/src/math/roundf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/roundf.h" diff --git a/src/math/roundl.c b/src/math/roundl.c index 53b254f..8473dda 100644 --- a/src/math/roundl.c +++ b/src/math/roundl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/scalb.c b/src/math/scalb.c index 70746b3..786736a 100644 --- a/src/math/scalb.c +++ b/src/math/scalb.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct dd_d t[] = { #include "sanity/scalb.h" diff --git a/src/math/scalbf.c b/src/math/scalbf.c index 9861b8c..3754282 100644 --- a/src/math/scalbf.c +++ b/src/math/scalbf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct ff_f t[] = { #include "sanity/scalbf.h" diff --git a/src/math/scalbln.c b/src/math/scalbln.c index 30be0cc..4aa3f99 100644 --- a/src/math/scalbln.c +++ b/src/math/scalbln.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct di_d t[] = { #include "sanity/scalbln.h" diff --git a/src/math/scalblnf.c b/src/math/scalblnf.c index 1115508..e507582 100644 --- a/src/math/scalblnf.c +++ b/src/math/scalblnf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fi_f t[] = { #include "sanity/scalblnf.h" diff --git a/src/math/scalblnl.c b/src/math/scalblnl.c index 12eb21c..bf07c16 100644 --- a/src/math/scalblnl.c +++ b/src/math/scalblnl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct li_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/scalbn.c b/src/math/scalbn.c index 9b37f96..4d17985 100644 --- a/src/math/scalbn.c +++ b/src/math/scalbn.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct di_d t[] = { #include "sanity/scalbn.h" diff --git a/src/math/scalbnf.c b/src/math/scalbnf.c index 9e1203c..99c748b 100644 --- a/src/math/scalbnf.c +++ b/src/math/scalbnf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fi_f t[] = { #include "sanity/scalbnf.h" diff --git a/src/math/scalbnl.c b/src/math/scalbnl.c index 136112c..758b2af 100644 --- a/src/math/scalbnl.c +++ b/src/math/scalbnl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct li_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/sin.c b/src/math/sin.c index d0c07d9..1449b46 100644 --- a/src/math/sin.c +++ b/src/math/sin.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/sin.h" diff --git a/src/math/sincos.c b/src/math/sincos.c index 1c314f3..47e9eea 100644 --- a/src/math/sincos.c +++ b/src/math/sincos.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_dd t[] = { #include "sanity/sincos.h" diff --git a/src/math/sincosf.c b/src/math/sincosf.c index dcf4bb3..f8a09e1 100644 --- a/src/math/sincosf.c +++ b/src/math/sincosf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_ff t[] = { #include "sanity/sincosf.h" diff --git a/src/math/sincosl.c b/src/math/sincosl.c index 85859b3..8d1e075 100644 --- a/src/math/sincosl.c +++ b/src/math/sincosl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_ll t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/sinf.c b/src/math/sinf.c index 67edfa2..3ebc4d8 100644 --- a/src/math/sinf.c +++ b/src/math/sinf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/sinf.h" diff --git a/src/math/sinh.c b/src/math/sinh.c index 1abaadf..73cdc7d 100644 --- a/src/math/sinh.c +++ b/src/math/sinh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/sinh.h" diff --git a/src/math/sinhf.c b/src/math/sinhf.c index 97a6d46..8126f5d 100644 --- a/src/math/sinhf.c +++ b/src/math/sinhf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/sinhf.h" diff --git a/src/math/sinhl.c b/src/math/sinhl.c index ea8900f..8ea0380 100644 --- a/src/math/sinhl.c +++ b/src/math/sinhl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/sinl.c b/src/math/sinl.c index 78c6623..bd1d78f 100644 --- a/src/math/sinl.c +++ b/src/math/sinl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/sqrt.c b/src/math/sqrt.c index b6b7de6..1c0d502 100644 --- a/src/math/sqrt.c +++ b/src/math/sqrt.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "ucb/sqrt.h" diff --git a/src/math/sqrtf.c b/src/math/sqrtf.c index 1809ef8..d29cc57 100644 --- a/src/math/sqrtf.c +++ b/src/math/sqrtf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/sqrtf.h" diff --git a/src/math/sqrtl.c b/src/math/sqrtl.c index 90f77f4..6329a3e 100644 --- a/src/math/sqrtl.c +++ b/src/math/sqrtl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/tan.c b/src/math/tan.c index 01452f1..88d88b0 100644 --- a/src/math/tan.c +++ b/src/math/tan.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "crlibm/tan.h" diff --git a/src/math/tanf.c b/src/math/tanf.c index 58696e7..1e84776 100644 --- a/src/math/tanf.c +++ b/src/math/tanf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/tanf.h" diff --git a/src/math/tanh.c b/src/math/tanh.c index 1f3541f..df172ad 100644 --- a/src/math/tanh.c +++ b/src/math/tanh.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "ucb/tanh.h" diff --git a/src/math/tanhf.c b/src/math/tanhf.c index 6c46e6a..6772427 100644 --- a/src/math/tanhf.c +++ b/src/math/tanhf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "ucb/tanhf.h" diff --git a/src/math/tanhl.c b/src/math/tanhl.c index 7d34398..4288836 100644 --- a/src/math/tanhl.c +++ b/src/math/tanhl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/tanl.c b/src/math/tanl.c index f8b3f60..aac39d4 100644 --- a/src/math/tanl.c +++ b/src/math/tanl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/tgamma.c b/src/math/tgamma.c index cabe9e8..f10a744 100644 --- a/src/math/tgamma.c +++ b/src/math/tgamma.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/tgamma.h" diff --git a/src/math/tgammaf.c b/src/math/tgammaf.c index 350e63d..c1e9507 100644 --- a/src/math/tgammaf.c +++ b/src/math/tgammaf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/tgammaf.h" diff --git a/src/math/tgammal.c b/src/math/tgammal.c index 4955812..24c94aa 100644 --- a/src/math/tgammal.c +++ b/src/math/tgammal.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/trunc.c b/src/math/trunc.c index 0236a3d..3b20db7 100644 --- a/src/math/trunc.c +++ b/src/math/trunc.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/trunc.h" diff --git a/src/math/truncf.c b/src/math/truncf.c index 499fb4f..1193623 100644 --- a/src/math/truncf.c +++ b/src/math/truncf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/truncf.h" diff --git a/src/math/truncl.c b/src/math/truncl.c index 3cbdc5e..162d918 100644 --- a/src/math/truncl.c +++ b/src/math/truncl.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct l_l t[] = { #if LDBL_MANT_DIG == 53 diff --git a/src/math/y0.c b/src/math/y0.c index f175f62..d6a3364 100644 --- a/src/math/y0.c +++ b/src/math/y0.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/y0.h" diff --git a/src/math/y0f.c b/src/math/y0f.c index b1c43b9..20ebab3 100644 --- a/src/math/y0f.c +++ b/src/math/y0f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/y0f.h" diff --git a/src/math/y1.c b/src/math/y1.c index 4aaf032..12e99e5 100644 --- a/src/math/y1.c +++ b/src/math/y1.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct d_d t[] = { #include "sanity/y1.h" diff --git a/src/math/y1f.c b/src/math/y1f.c index df63f85..78fa3c4 100644 --- a/src/math/y1f.c +++ b/src/math/y1f.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct f_f t[] = { #include "sanity/y1f.h" diff --git a/src/math/yn.c b/src/math/yn.c index cc4f2fe..4ac72fa 100644 --- a/src/math/yn.c +++ b/src/math/yn.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct di_d t[] = { #include "sanity/yn.h" diff --git a/src/math/ynf.c b/src/math/ynf.c index f19bb8b..436c0fa 100644 --- a/src/math/ynf.c +++ b/src/math/ynf.c @@ -1,6 +1,6 @@ #include #include -#include "util.h" +#include "mtest.h" static struct fi_f t[] = { #include "sanity/ynf.h" diff --git a/src/regression/Makefile b/src/regression/Makefile new file mode 100644 index 0000000..ef9690b --- /dev/null +++ b/src/regression/Makefile @@ -0,0 +1,4 @@ +all: +%: + $(MAKE) -C ../.. src/regression/$@ + diff --git a/src/regression/daemon-failure.c b/src/regression/daemon-failure.c new file mode 100644 index 0000000..2cd9c3f --- /dev/null +++ b/src/regression/daemon-failure.c @@ -0,0 +1,75 @@ +// commit: 19e35c500bd2b5e6146e42705ab9b69c155a2006 2011-02-17 +// commit: 187fe29d5b89644b68cade75a34257a1c32a75f6 2011-02-17 +// non-standard musl specific behaviour +// daemon should not fork in case of failure of chdir or open, but +// since setsid and fork may still fail after fork this behaviour +// is not very useful +#define _BSD_SOURCE 1 +#include +#include +#include +#include +#include +#include "test.h" + +int daemon(int, int); + +int main(void) +{ + int r, pid, fd[2], fdout, s; + char c; + + r = pipe(fd); + if (r == -1) { + t_error("pipe failed: %s\n", strerror(errno)); + return 1; + } + fdout = dup(1); + if (fdout == -1) { + t_error("dup(1) failed: %s\n", strerror(errno)); + return 1; + } + r = fork(); + if (r == -1) { + t_error("fork failed: %s\n", strerror(errno)); + return 1; + } + + if (r == 0) { + /* exhausting all fds makes open("/dev/null") fail in daemon */ + t_fdfill(); + pid = getpid(); + errno = 0; + r = daemon(0, 0); + if (dup2(fdout,1) == -1) { + write(fdout, "ERROR:\n", 7); + t_error("failed to dup pipe fd for communicating results: %s\n", strerror(errno)); + } + if (r != -1) + t_error("daemon should have failed\n"); + if (errno != EMFILE) + t_error("daemon should have failed with %d [EMFILE] got %d [%s]\n", EMFILE, errno, strerror(errno)); + if (getpid() != pid || getppid() == 1) + t_error("daemon forked despite failure: ppid is %d, pid is %d, old pid is %d\n", + getppid(), getpid(), pid); + if (write(fd[1], "1" + !t_status, 1) != 1) + t_error("write failed: %s\n", strerror(errno)); + return t_status; + } + close(fd[1]); + if (waitpid(r, &s, 0) != r) + t_error("waitpid failed: %s\n", strerror(errno)); + else if (!WIFEXITED(s)) + t_error("child exited abnormally (signal %d)\n", WIFSIGNALED(s) ? WTERMSIG(s) : 0); + else if (WEXITSTATUS(s)) + t_error("child exited with %d\n", WEXITSTATUS(s)); + r = read(fd[0], &c, 1); + if (r == -1) + t_error("read failed: %s\n", strerror(errno)); + else if (r == 0) + t_error("read failed: child did not send its exit status\n"); + else if (c != 0) + t_error("child failed\n"); + + return t_status; +} diff --git a/src/regression/malloc-0.c b/src/regression/malloc-0.c new file mode 100644 index 0000000..0eded64 --- /dev/null +++ b/src/regression/malloc-0.c @@ -0,0 +1,19 @@ +// commit: 26031da0f83a2a3ed52190077931ee6c18dfd689 2011-02-20 +// malloc(0) should return unique pointers +#include +#include "test.h" + +int main(void) +{ + void *p = malloc(0); + void *q = malloc(0); + void *r = malloc(0); + if (!p || !q || !r) + t_error("malloc(0) returned NULL\n"); + if (p == q || p == r || q == r) + t_error("malloc(0) returned non-unique pointers: %p, %p, %p\n", p, q, r); + free(q); + free(p); + free(r); + return t_status; +} diff --git a/src/regression/mkdtemp-failure.c b/src/regression/mkdtemp-failure.c new file mode 100644 index 0000000..09fa78d --- /dev/null +++ b/src/regression/mkdtemp-failure.c @@ -0,0 +1,28 @@ +// commit: 69ecbd0f3188be97f91cc0d6415836d23e88f7fc 2011-02-19 +// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12 +// mkdtemp should return -1 on bad template +#define _BSD_SOURCE 1 +#include +#include +#include +#include "test.h" + +char *mkdtemp(char *); + +#define S "/dev/null/fooXXXX" + +int main(void) +{ + char p[] = S; + char *r; + + r = mkdtemp(p); + if (r) + t_error("mkdtemp(" S ") did not fail\n"); + if (memcmp(p, S, sizeof p) != 0) + t_error("mkdtemp(" S ") modified the template: %s\n", p); + if (r == 0 && errno != EINVAL) + t_error("mkdtemp(" S ") failed with %d [%s] instead of %d [%s]\n", + errno, strerror(errno), EINVAL, strerror(EINVAL)); + return t_status; +} diff --git a/src/regression/mkstemp-failure.c b/src/regression/mkstemp-failure.c new file mode 100644 index 0000000..762f1fc --- /dev/null +++ b/src/regression/mkstemp-failure.c @@ -0,0 +1,28 @@ +// commit: 2e6239dd064d201c6e1b0f589bae9ff27949d2eb 2011-02-19 +// commit: 382584724308442f03f3d29f7fc6de9e9d140982 2011-06-12 +// mkstemp should return -1 on bad template +#define _BSD_SOURCE 1 +#include +#include +#include +#include "test.h" + +int mkstemp(char *); + +#define S "/dev/null/fooXXXX" + +int main(void) +{ + char p[] = S; + int r; + + r = mkstemp(p); + if (r != -1) + t_error("mkstemp(" S ") did not fail\n"); + if (memcmp(p, S, sizeof p) != 0) + t_error("mkstemp(" S ") modified the template: %s\n", p); + if (r == -1 && errno != EINVAL) + t_error("mkstemp(" S ") failed with %d [%s] instead of %d [%s]\n", + errno, strerror(errno), EINVAL, strerror(EINVAL)); + return t_status; +} diff --git a/src/regression/printf-fmt-n.c b/src/regression/printf-fmt-n.c new file mode 100644 index 0000000..4d1c572 --- /dev/null +++ b/src/regression/printf-fmt-n.c @@ -0,0 +1,34 @@ +// commit: 5cbd76c6b05b381f269e0e204e10690d69f1d6ea 2011-02-16 +// commit: bdc9ed15651b70e89f83c5a9f7d1ba349e624503 2011-02-20 +// printf %n fmt +#include +#include +#include "test.h" + +#define T(n,nfmt,fmt) do { \ + if ((ret = sprintf(buf, "%256d%d" nfmt "%d", 1, 2, &n, 3)) != 258) \ + t_error("expexted sprintf to write 258 chars, got %d\n", ret); \ + if (n != 257) \ + t_error("%%n format failed: wanted 257, got " fmt "\n", n); \ +} while(0) + +int main(void) +{ + char buf[1024]; + int ret; + int i; + long l; + long long ll; + short h; + size_t z; + uintmax_t j; + + T(i, "%n", "%d"); + T(l, "%ln", "%ld"); + T(ll, "%lln", "%lld"); + T(h, "%hn", "%d"); + T(z, "%zn", "%zd"); + T(j, "%jn", "%jd"); + + return t_status; +} diff --git a/src/regression/pthread_create-oom.c b/src/regression/pthread_create-oom.c new file mode 100644 index 0000000..56993ec --- /dev/null +++ b/src/regression/pthread_create-oom.c @@ -0,0 +1,31 @@ +// commit: 59666802fba592a59f2f4ea4dcb053287fd55826 2011-02-15 +// pthread_create should return EAGAIN on failure +#include +#include +#include +#include +#include "test.h" + +static void *start(void *arg) +{ + return 0; +} + +int main(void) +{ + pthread_t td; + int r, arg; + + r = t_vmfill(0, 0, 0); + if (r <= 0) { + t_error("fatal: vmfill has failed\n"); + return 1; + } + r = pthread_create(&td, 0, start, &arg); + if (r == 0) + t_error("pthread_create succeeded\n"); + else if (r != EAGAIN) + t_error("pthread_create should fail with EAGAIN but failed with %d (%s)\n", r, strerror(r)); + + return t_status; +} diff --git a/src/regression/pthread_exit-cancel.c b/src/regression/pthread_exit-cancel.c new file mode 100644 index 0000000..7a8d00b --- /dev/null +++ b/src/regression/pthread_exit-cancel.c @@ -0,0 +1,36 @@ +// commit: 1a9a2ff7b0daf99100db53440a0b18b2801566ca 2011-02-13 +// pthread_exit should call cancelation handlers +#include +#include +#include "test.h" + +#define TEST(r, f) if (((r)=(f))) t_error(#f " failed: %s\n", strerror(r)) + +static void cleanup(void *arg) +{ + *(int *)arg = 1; +} + +static void *start(void *arg) +{ + pthread_cleanup_push(cleanup, arg); + pthread_exit(0); + pthread_cleanup_pop(0); + return arg; +} + +int main(void) +{ + pthread_t td; + void *status; + int arg = 0; + int r; + + TEST(r, pthread_create(&td, 0, start, &arg)); + TEST(r, pthread_join(td, &status)); + if (status) + t_error("expected 0 thread exit status, got 0x%lx\n", (long)status); + if (arg != 1) + t_error("cleanup handler failed to run\n"); + return t_status; +} diff --git a/src/regression/pthread_exit-dtor.c b/src/regression/pthread_exit-dtor.c new file mode 100644 index 0000000..3d8bc49 --- /dev/null +++ b/src/regression/pthread_exit-dtor.c @@ -0,0 +1,83 @@ +// commit: fb11b6b85e1e01daf17228be32d7f98b47517363 2011-02-19 +// pthread_exit should call dtors (even in the last thread) +#include +#include +#include +#include +#include +#include +#include "test.h" + +#define TEST(r, f) if (((r)=(f))) t_error(#f " failed: %s\n", strerror(r)) +#define TESTC(c, m) ( (c) || (t_error("%s failed (" m ")\n", #c), 0) ) + +static pthread_key_t k; +static int data; + +static void dtor(void *p) +{ + *(int *)p = 1; +} + +static void *start(void *arg) +{ + if (pthread_setspecific(k, arg)) + return arg; + return 0; +} + +static void cleanup(void) +{ + TESTC(data == 1, "dtor was not run for the last thread"); + _exit(t_status); +} + +static void die(void) +{ + _exit(1); +} + +int main(void) +{ + pthread_t td; + int r, arg=0, pid; + void *res; + + // test if atexit handlers are run after pthread_exit + // (early musl failed this test) + pid = fork(); + switch (pid) { + case -1: + t_error("fork failed: %s\n", strerror(errno)); + return 1; + case 0: + atexit(die); + pthread_exit(0); + default: + if (waitpid(pid, &r, 0) != pid) { + t_error("waitpid failed: %s\n", strerror(errno)); + return 1; + } + if (!WIFEXITED(r) || WEXITSTATUS(r) != 1) { + t_error("atexit handler was not run after last thread exited" + " (exited=%d, signal=%d, status=%d, want exit status=1)\n", + WIFEXITED(r), !WIFEXITED(r)&&WIFSIGNALED(r)?WTERMSIG(r):0, WIFEXITED(r)?WEXITSTATUS(r):0); + return 1; + } + } + + // dtor should set tsd (arg and data) from 0 to 1 + if (atexit(cleanup)) { + t_error("atexit failed\n"); + return 1; + } + TEST(r, pthread_key_create(&k, dtor)); + TEST(r, pthread_setspecific(k, &data)); + TEST(r, pthread_create(&td, 0, start, &arg)); + TEST(r, pthread_join(td, &res)); + TESTC(res == 0, "pthread_setspecific failed in thread"); + TESTC(arg == 1, "dtor failed to run"); + TESTC(data == 0, "tsd in main thread is corrupted"); + TESTC(pthread_getspecific(k) == &data, "tsd in main thread is corrupted"); + pthread_exit(0); +} diff --git a/src/regression/scanf-bytes-consumed.c b/src/regression/scanf-bytes-consumed.c new file mode 100644 index 0000000..d4e30e4 --- /dev/null +++ b/src/regression/scanf-bytes-consumed.c @@ -0,0 +1,19 @@ +// commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396 2011-04-25 +// scanf misreports bytes consumed when EOF is hit (or null for sscanf) +#include +#include "test.h" + +int main(void) +{ + char buf[] = { 'a', 'a', 0 }; + char dest[3]; + int read_count; + int n; + + n = sscanf(buf, "%s%n", dest, &read_count); + if(n != 1) + t_error("sscanf matched 1 input items but returned %d\n", n); + if(read_count != 2) + t_error("sscanf consumed 2 bytes but reported %d\n", read_count); + return t_status; +} diff --git a/src/regression/scanf-match-literal-eof.c b/src/regression/scanf-match-literal-eof.c new file mode 100644 index 0000000..bd7c5e7 --- /dev/null +++ b/src/regression/scanf-match-literal-eof.c @@ -0,0 +1,16 @@ +// commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396 2011-04-25 +// scanf misreports literal match as input failure when reading EOF (null for sscanf) +#include +#include "test.h" + +int main(void) +{ + char buf[] = { 0 }; + int match_count; + + match_count = sscanf(buf, "a"); + if(match_count != EOF) + t_error("scanf reported match failure instead of input failure on literal EOF match\n"); + + return t_status; +} diff --git a/src/regression/scanf-nullbyte-char.c b/src/regression/scanf-nullbyte-char.c new file mode 100644 index 0000000..449922d --- /dev/null +++ b/src/regression/scanf-nullbyte-char.c @@ -0,0 +1,16 @@ +// commit: ef5507867b59d19f21437970e87b5d0415c07b2e 2013-06-22 +// scanf should not append null byte after scanning %c +#include +#include "test.h" + +int main(void) +{ + char dst[] = { 'a', 'a' }; + char src[] = { 'b', 'b' }; + + if (sscanf(src, "%c", dst) != 1) + t_error("sscanf %%c failed\n"); + if (dst[1] != 'a') + t_error("scanf clobbered the char buffer for %%c conversion\n"); + return t_status; +} diff --git a/src/regression/sigprocmask-internal.c b/src/regression/sigprocmask-internal.c new file mode 100644 index 0000000..57b5c40 --- /dev/null +++ b/src/regression/sigprocmask-internal.c @@ -0,0 +1,29 @@ +// commit: a49c119276742d7d212fb88f83a8f559ca549e72 2011-02-19 +// commit: 96f2197494791f5884c01b5caa908074cc7e90a6 2011-02-20 +// commit: 23815f88df6c45247f3755dc7857f4013264c04f 2013-07-18 +// implementation signals should not be masked +#include +#include +#include +#include "test.h" + +int main(void) +{ + sigset_t s; + int i; + + sigemptyset(&s); + for (i = 32; i < SIGRTMIN; i++) { + sigaddset(&s, i); + if (sigismember(&s, i) == 1) + t_error("sigaddset(&s, %d) set implementation internal rt signal\n", i); + } + if (sigprocmask(SIG_BLOCK, &s, 0)) + t_error("blocking signals failed: %s\n", strerror(errno)); + if (sigprocmask(SIG_BLOCK, 0, &s)) + t_error("querying sigmask failed: %s\n", strerror(errno)); + for (i = 32; i < SIGRTMIN; i++) + if (sigismember(&s, i) == 1) + t_error("implementation internal rt signal %d can be blocked\n", i); + return t_status; +} diff --git a/src/regression/sigreturn.c b/src/regression/sigreturn.c new file mode 100644 index 0000000..86a0fcb --- /dev/null +++ b/src/regression/sigreturn.c @@ -0,0 +1,20 @@ +// commit: dc3776d445957cd3ea4a682db518701b93d34292 2011-02-13 +// sigreturn crash +#include + +static volatile sig_atomic_t x; + +void handler(int s) +{ + x = 1; +} + +int main(void) +{ + signal(SIGINT, handler); + if (raise(SIGINT)) + return 2; + if (x != 1) + return 1; + return 0; +} diff --git a/src/regression/wcsncpy-read-overflow.c b/src/regression/wcsncpy-read-overflow.c new file mode 100644 index 0000000..05c943d --- /dev/null +++ b/src/regression/wcsncpy-read-overflow.c @@ -0,0 +1,14 @@ +// commit: e98136207ad1a6df1cdc1578e4ad56f8f0db4047 2011-05-22 +#include +#include "test.h" + +int main(void) +{ + wchar_t dst[] = { 'a', 'a' }; + wchar_t src[] = { 0, 'b' }; + + wcsncpy(dst, src, 1); + if(dst[1] != 'a') + t_error("wcsncpy copied more than N\n"); + return t_status; +} -- 2.20.1