diff --git a/demo/test.c b/demo/test.c index 3c5e70c..5ee2d1e 100644 --- a/demo/test.c +++ b/demo/test.c @@ -3,6 +3,11 @@ #include #include + +#ifndef TFM_DEMO_TEST_VS_MTEST +#define TFM_DEMO_TEST_VS_MTEST 1 +#endif + void draw(fp_int *a) { int x; @@ -30,9 +35,11 @@ int myrng(unsigned char *dst, int len, void *dat) int main(void) { fp_int a,b,c,d,e,f; + unsigned long ix; +#if TFM_DEMO_TEST_VS_MTEST unsigned long expt_n, add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n, gcd_n, lcm_n, inv_n, - div2_n, mul2_n, add_d_n, sub_d_n, mul_d_n, cnt, rr, ix; -#ifndef TESTING + div2_n, mul2_n, add_d_n, sub_d_n, mul_d_n, cnt, rr; +#else fp_digit fp; int n, err; #endif @@ -42,7 +49,7 @@ int main(void) fp_zero(&b); fp_zero(&c); fp_zero(&d); fp_zero(&e); fp_zero(&f); fp_zero(&a); -#ifndef TESTING +#if TFM_DEMO_TEST_VS_MTEST == 0 draw(&a); @@ -179,7 +186,8 @@ int main(void) printf("\n\n"); return 0; -#endif + +#else fp_zero(&b); fp_zero(&c); fp_zero(&d); fp_zero(&e); fp_zero(&f); fp_zero(&a); @@ -422,6 +430,7 @@ draw(&a);draw(&b);draw(&c);draw(&d); } } +#endif } diff --git a/makefile b/makefile index 6fb2137..de90f66 100644 --- a/makefile +++ b/makefile @@ -111,6 +111,12 @@ demo/test.o: CFLAGS+=-Wno-unused-result test: $(LIBNAME) demo/test.o $(CC) $(CFLAGS) demo/test.o $(LIBNAME) $(PROF) -o test +test_standalone: CFLAGS+=-DTFM_DEMO_TEST_VS_MTEST=0 + +.PHONY: test_standalone +test_standalone: $(LIBNAME) demo/test.o + $(CC) $(CFLAGS) demo/test.o $(LIBNAME) $(PROF) -o test + timing: $(LIBNAME) demo/timing.o $(CC) $(CFLAGS) demo/timing.o $(LIBNAME) $(PROF) -o timing diff --git a/makefile.shared b/makefile.shared index 54e7d45..39d2148 100644 --- a/makefile.shared +++ b/makefile.shared @@ -98,10 +98,18 @@ install: $(LIBNAME) mtest/mtest: mtest/mtest.c cd mtest ; make mtest +demo/test.o: CFLAGS+=-Wno-unused-result + .PHONY: test test: $(LIBNAME) demo/test.o $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o test demo/test.o $(LIBNAME) +test_standalone: CFLAGS+=-DTFM_DEMO_TEST_VS_MTEST=0 + +.PHONY: test_standalone +test_standalone: $(LIBNAME) demo/test.o + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o test demo/test.o $(LIBNAME) + stest: $(LIBNAME) demo/stest.o $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o stest demo/stest.o $(LIBNAME) diff --git a/testme.sh b/testme.sh index e97efdc..90fa34f 100755 --- a/testme.sh +++ b/testme.sh @@ -7,7 +7,7 @@ _runtest() echo -n "Run test $1 $2" trap 'echo " - build not successful, errors are:" && cat test_gcc_errors.txt' INT TERM make clean > /dev/null - CC="${1}" make test -j9 $2 > /dev/null 2>test_gcc_errors.txt + CC="${1}" make test_standalone -j9 $2 > /dev/null 2>test_gcc_errors.txt trap - INT TERM local outfile="test_$(echo ${1}${2} | tr -d '\"' | tr ' ' '_').txt" trap 'echo " - tests not successful, failed at:" && tail ${outfile}' INT TERM