create mtest_opponent
instead of alt version of test
This commit is contained in:
parent
6e160216b0
commit
f8d64c645a
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,6 +23,8 @@ test
|
|||||||
test.exe
|
test.exe
|
||||||
mtest
|
mtest
|
||||||
mtest.exe
|
mtest.exe
|
||||||
|
mtest_opponent
|
||||||
|
mtest_opponent.exe
|
||||||
|
|
||||||
# ignore eclipse project files
|
# ignore eclipse project files
|
||||||
.cproject
|
.cproject
|
||||||
|
13
README.md
13
README.md
@ -24,15 +24,20 @@ API/ABI changes: [check here](https://abi-laboratory.pro/tracker/timeline/libtom
|
|||||||
|
|
||||||
The `develop` branch contains the in-development version. Stable releases are tagged.
|
The `develop` branch contains the in-development version. Stable releases are tagged.
|
||||||
|
|
||||||
Documentation is built from the LaTeX file `bn.tex`. There is also limited documentation in `tommath.h`. There is also a document, `tommath.pdf`, which describes the goals of the project and many of the algorithms used.
|
Documentation is built from the LaTeX file `bn.tex`. There is also limited documentation in `tommath.h`.
|
||||||
|
There is also a document, `tommath.pdf`, which describes the goals of the project and many of the algorithms used.
|
||||||
|
|
||||||
The project can be build by using `make`. Along with the usual `make`, `make clean` and `make install`, there are several other build targets, see the makefile for details. There are also makefiles for certain specific platforms.
|
The project can be build by using `make`. Along with the usual `make`, `make clean` and `make install`,
|
||||||
|
there are several other build targets, see the makefile for details.
|
||||||
|
There are also makefiles for certain specific platforms.
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
Tests are located in `demo/` and can be built in two flavors.
|
Tests are located in `demo/` and can be built in two flavors.
|
||||||
* `make test` creates a test binary that is intended to be run against `mtest`. `mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./test`. `mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm
|
* `make test` creates a stand-alone test binary that executes several test routines.
|
||||||
* `make test_standalone` creates a stand-alone test binary that executes several test routines.
|
* `make mtest_opponent` creates a test binary that is intended to be run against `mtest`.
|
||||||
|
`mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./mtest_opponent`.
|
||||||
|
`mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm
|
||||||
|
|
||||||
## Building and Installing
|
## Building and Installing
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ static void draw(mp_int *a)
|
|||||||
if (!ret) { fprintf(stderr, "\n%d: fgets failed\n", __LINE__); goto LBL_ERR; } \
|
if (!ret) { fprintf(stderr, "\n%d: fgets failed\n", __LINE__); goto LBL_ERR; } \
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtest_opponent(void)
|
static int mtest_opponent(void)
|
||||||
{
|
{
|
||||||
char cmd[4096];
|
char cmd[4096];
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
@ -394,3 +394,10 @@ LBL_ERR:
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
print_header();
|
||||||
|
|
||||||
|
return mtest_opponent();
|
||||||
|
}
|
@ -1,8 +1,5 @@
|
|||||||
#include "shared.h"
|
#include "shared.h"
|
||||||
|
|
||||||
int mtest_opponent(void);
|
|
||||||
int unit_tests(int argc, char **argv);
|
|
||||||
|
|
||||||
void ndraw(mp_int *a, const char *name)
|
void ndraw(mp_int *a, const char *name)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
@ -24,7 +21,7 @@ void ndraw(mp_int *a, const char *name)
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
void print_header(void)
|
||||||
{
|
{
|
||||||
#ifdef MP_8BIT
|
#ifdef MP_8BIT
|
||||||
printf("Digit size 8 Bit \n");
|
printf("Digit size 8 Bit \n");
|
||||||
@ -42,9 +39,4 @@ int main(int argc, char **argv)
|
|||||||
printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
|
printf("Size of mp_word: %u\n", (unsigned int)sizeof(mp_word));
|
||||||
printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
|
printf("MP_DIGIT_BIT: %d\n", MP_DIGIT_BIT);
|
||||||
printf("MP_PREC: %d\n", MP_PREC);
|
printf("MP_PREC: %d\n", MP_PREC);
|
||||||
|
|
||||||
if (LTM_DEMO_TEST_VS_MTEST) {
|
|
||||||
return mtest_opponent();
|
|
||||||
}
|
|
||||||
return unit_tests(argc, argv);
|
|
||||||
}
|
}
|
@ -5,10 +5,6 @@
|
|||||||
/*
|
/*
|
||||||
* Configuration
|
* Configuration
|
||||||
*/
|
*/
|
||||||
#ifndef LTM_DEMO_TEST_VS_MTEST
|
|
||||||
#define LTM_DEMO_TEST_VS_MTEST 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LTM_DEMO_TEST_REDUCE_2K_L
|
#ifndef LTM_DEMO_TEST_REDUCE_2K_L
|
||||||
/* This test takes a moment so we disable it by default, but it can be:
|
/* This test takes a moment so we disable it by default, but it can be:
|
||||||
* 0 to disable testing
|
* 0 to disable testing
|
||||||
@ -22,3 +18,4 @@
|
|||||||
#include "tommath_private.h"
|
#include "tommath_private.h"
|
||||||
|
|
||||||
extern void ndraw(mp_int* a, const char* name);
|
extern void ndraw(mp_int* a, const char* name);
|
||||||
|
extern void print_header(void);
|
||||||
|
@ -2214,7 +2214,7 @@ LTM_ERR:
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int unit_tests(int argc, char **argv)
|
static int unit_tests(int argc, char **argv)
|
||||||
{
|
{
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -2304,3 +2304,10 @@ int unit_tests(int argc, char **argv)
|
|||||||
if (fail != 0) return EXIT_FAILURE;
|
if (fail != 0) return EXIT_FAILURE;
|
||||||
else return EXIT_SUCCESS;
|
else return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
print_header();
|
||||||
|
|
||||||
|
return unit_tests(argc, argv);
|
||||||
|
}
|
||||||
|
7
makefile
7
makefile
@ -95,8 +95,11 @@ uninstall:
|
|||||||
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
|
||||||
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
|
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
|
||||||
|
|
||||||
test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
|
test_standalone: test
|
||||||
$(CC) $(LTM_CFLAGS) $^ $(LTM_LFLAGS) -o test
|
@echo "test_standalone is deprecated, please use make-target 'test'"
|
||||||
|
|
||||||
|
test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
|
||||||
|
$(CC) $(LTM_CFLAGS) $(LTM_LFLAGS) demo/$@.o $^ -o $@
|
||||||
|
|
||||||
.PHONY: mtest
|
.PHONY: mtest
|
||||||
mtest:
|
mtest:
|
||||||
|
@ -81,14 +81,15 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
|
|||||||
$(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTM_LDFLAGS)
|
$(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTM_LDFLAGS)
|
||||||
$(STRIP) -S $(LIBMAIN_D)
|
$(STRIP) -S $(LIBMAIN_D)
|
||||||
|
|
||||||
#Build test_standalone suite
|
#Build test suite
|
||||||
test.exe: demo/main.c demo/opponent.c demo/test.c $(LIBMAIN_S)
|
test.exe: demo/shared.o demo/test.o $(LIBMAIN_S)
|
||||||
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -DLTM_DEMO_TEST_VS_MTEST=0 -o $@
|
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
|
||||||
@echo NOTICE: start the tests by launching test.exe
|
@echo NOTICE: start the tests by launching test.exe
|
||||||
|
|
||||||
test_standalone: test.exe
|
test_standalone: test.exe
|
||||||
|
@echo test_standalone is deprecated, please use make-target 'test.exe'
|
||||||
|
|
||||||
all: $(LIBMAIN_S) test_standalone
|
all: $(LIBMAIN_S) test.exe
|
||||||
|
|
||||||
tune: $(LIBNAME_S)
|
tune: $(LIBNAME_S)
|
||||||
$(MAKE) -C etc tune
|
$(MAKE) -C etc tune
|
||||||
|
@ -67,14 +67,15 @@ $(OBJECTS): $(HEADERS)
|
|||||||
$(LIBMAIN_S): $(OBJECTS)
|
$(LIBMAIN_S): $(OBJECTS)
|
||||||
lib /out:$(LIBMAIN_S) $(OBJECTS)
|
lib /out:$(LIBMAIN_S) $(OBJECTS)
|
||||||
|
|
||||||
#Build test_standalone suite
|
#Build test suite
|
||||||
test.exe: $(LIBMAIN_S) demo/main.c demo/opponent.c demo/test.c
|
test.exe: $(LIBMAIN_S) demo/shared.obj demo/test.obj
|
||||||
cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/main.c demo/opponent.c demo/test.c /DLTM_DEMO_TEST_VS_MTEST=0 /Fe$@
|
cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/shared.c demo/test.c /Fe$@
|
||||||
@echo NOTICE: start the tests by launching test.exe
|
@echo NOTICE: start the tests by launching test.exe
|
||||||
|
|
||||||
test_standalone: test.exe
|
test_standalone: test.exe
|
||||||
|
@echo test_standalone is deprecated, please use make-target 'test.exe'
|
||||||
|
|
||||||
all: $(LIBMAIN_S) test_standalone
|
all: $(LIBMAIN_S) test.exe
|
||||||
|
|
||||||
tune: $(LIBMAIN_S)
|
tune: $(LIBMAIN_S)
|
||||||
$(MAKE) -C etc tune
|
$(MAKE) -C etc tune
|
||||||
|
@ -79,8 +79,11 @@ uninstall:
|
|||||||
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
|
rm $(HEADERS_PUB:%=$(DESTDIR)$(INCPATH)/%)
|
||||||
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
|
rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
|
||||||
|
|
||||||
test test_standalone: demo/main.o demo/opponent.o demo/test.o $(LIBNAME)
|
test_standalone: test
|
||||||
$(LTLINK) $(LTM_LDFLAGS) $^ -o test
|
@echo "test_standalone is deprecated, please use make-target 'test'"
|
||||||
|
|
||||||
|
test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
|
||||||
|
$(LTLINK) $(LTM_LDFLAGS) demo/$@.o $^ -o $@
|
||||||
|
|
||||||
.PHONY: mtest
|
.PHONY: mtest
|
||||||
mtest:
|
mtest:
|
||||||
|
@ -80,13 +80,14 @@ $(LIBMAIN_S): $(OBJECTS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
#Build test_standalone suite
|
#Build test_standalone suite
|
||||||
test: demo/main.c demo/opponent.c demo/test.c $(LIBMAIN_S)
|
test: demo/shared.o demo/test.o $(LIBMAIN_S)
|
||||||
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -DLTM_DEMO_TEST_VS_MTEST=0 -o $@
|
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
|
||||||
@echo "NOTICE: start the tests by: ./test"
|
@echo "NOTICE: start the tests by: ./test"
|
||||||
|
|
||||||
test_standalone: test
|
test_standalone: test
|
||||||
|
@echo "test_standalone is deprecated, please use make-target 'test'"
|
||||||
|
|
||||||
all: $(LIBMAIN_S) test_standalone
|
all: $(LIBMAIN_S) test
|
||||||
|
|
||||||
tune: $(LIBMAIN_S)
|
tune: $(LIBMAIN_S)
|
||||||
$(MAKE) -C etc tune
|
$(MAKE) -C etc tune
|
||||||
|
@ -126,8 +126,6 @@ endif
|
|||||||
HEADERS_PUB=tommath.h
|
HEADERS_PUB=tommath.h
|
||||||
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
|
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h $(HEADERS_PUB)
|
||||||
|
|
||||||
test_standalone: LTM_CFLAGS+=-DLTM_DEMO_TEST_VS_MTEST=0
|
|
||||||
|
|
||||||
#LIBPATH The directory for libtommath to be installed to.
|
#LIBPATH The directory for libtommath to be installed to.
|
||||||
#INCPATH The directory to install the header files for libtommath.
|
#INCPATH The directory to install the header files for libtommath.
|
||||||
#DATAPATH The directory to install the pdf docs.
|
#DATAPATH The directory to install the pdf docs.
|
||||||
|
@ -130,7 +130,7 @@ _runtest()
|
|||||||
_make "$1" "$2" ""
|
_make "$1" "$2" ""
|
||||||
$_timeout $TUNE_CMD > test_${suffix}.log || _die "running autotune" $?
|
$_timeout $TUNE_CMD > test_${suffix}.log || _die "running autotune" $?
|
||||||
else
|
else
|
||||||
_make "$1" "$2" "test_standalone"
|
_make "$1" "$2" "test"
|
||||||
echo -e "\rRun test $1 $2"
|
echo -e "\rRun test $1 $2"
|
||||||
$_timeout ./test > test_${suffix}.log || _die "running tests" $?
|
$_timeout ./test > test_${suffix}.log || _die "running tests" $?
|
||||||
fi
|
fi
|
||||||
@ -156,7 +156,7 @@ echo "autotune branch"
|
|||||||
echo -e "\rRun etc/tune $1 $2 once inside valgrind"
|
echo -e "\rRun etc/tune $1 $2 once inside valgrind"
|
||||||
$_timeout $VALGRIND_BIN $VALGRIND_OPTS $TUNE_CMD > test_${suffix}.log || _die "running etc/tune" $?
|
$_timeout $VALGRIND_BIN $VALGRIND_OPTS $TUNE_CMD > test_${suffix}.log || _die "running etc/tune" $?
|
||||||
else
|
else
|
||||||
_make "$1" "$2" "test_standalone"
|
_make "$1" "$2" "test"
|
||||||
echo -e "\rRun test $1 $2 inside valgrind"
|
echo -e "\rRun test $1 $2 inside valgrind"
|
||||||
$_timeout $VALGRIND_BIN $VALGRIND_OPTS ./test > test_${suffix}.log || _die "running tests" $?
|
$_timeout $VALGRIND_BIN $VALGRIND_OPTS ./test > test_${suffix}.log || _die "running tests" $?
|
||||||
fi
|
fi
|
||||||
@ -336,14 +336,14 @@ _banner
|
|||||||
if [[ "$TEST_VS_MTEST" != "" ]]
|
if [[ "$TEST_VS_MTEST" != "" ]]
|
||||||
then
|
then
|
||||||
make clean > /dev/null
|
make clean > /dev/null
|
||||||
_make "${compilers[0]} ${archflags[0]}" "$CFLAGS" "test"
|
_make "${compilers[0]} ${archflags[0]}" "$CFLAGS" "mtest_opponent"
|
||||||
echo
|
echo
|
||||||
_make "gcc" "$MTEST_RAND" "mtest"
|
_make "gcc" "$MTEST_RAND" "mtest"
|
||||||
echo
|
echo
|
||||||
echo "Run test vs. mtest for $TEST_VS_MTEST iterations"
|
echo "Run test vs. mtest for $TEST_VS_MTEST iterations"
|
||||||
_timeout=""
|
_timeout=""
|
||||||
which timeout >/dev/null && _timeout="timeout --foreground 1800"
|
which timeout >/dev/null && _timeout="timeout --foreground 1800"
|
||||||
$_timeout ./mtest/mtest $TEST_VS_MTEST | $VALGRIND_BIN $VALGRIND_OPTS ./test > valgrind_test.log 2> test_vs_mtest_err.log
|
$_timeout ./mtest/mtest $TEST_VS_MTEST | $VALGRIND_BIN $VALGRIND_OPTS ./mtest_opponent > valgrind_test.log 2> test_vs_mtest_err.log
|
||||||
retval=$?
|
retval=$?
|
||||||
head -n 5 valgrind_test.log
|
head -n 5 valgrind_test.log
|
||||||
tail -n 2 valgrind_test.log
|
tail -n 2 valgrind_test.log
|
||||||
|
Loading…
Reference in New Issue
Block a user