From 722d6dd54060a045919440b68576a4fe79755378 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 17 Oct 2020 00:28:49 +0200 Subject: [PATCH] Make test --- .gitmodules | 3 +++ README.md | 9 ++++++++- munit | 1 + src/Makefile | 3 +++ src/create_makefile.sh | 15 +++++++++++++++ src/qmckl_context.org | 2 +- src/qmckl_memory.org | 2 +- 7 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 munit diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8ad4907 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "munit"] + path = munit + url = https://github.com/nemequ/munit/ diff --git a/README.md b/README.md index 71f31d0..e64cfb3 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,16 @@ See the [source code](https://github.com/TREX-CoE/qmckl/tree/main/src) to read the documentation. +To clone the repository, use: +``` +git clone --recursive https://github.com/TREX-CoE/qmckl.git +``` +to dowload also the [munit](https://github.com/nemequ/munit) unit testing +framework. + ------------------------------ ![European flag](https://trex-coe.eu/sites/default/files/inline-images/euflag.jpg) [TREX: Targeting Real Chemical Accuracy at the Exascale](https://trex-coe.eu) project has received funding from the European Union’s Horizon 2020 - Research and Innovation program - under grant agreement no. 952165. The content of this document does not represent the opinion of the European Union, and the European Union is not responsible for any use that might be made of such content. - + diff --git a/munit b/munit new file mode 160000 index 0000000..fbbdf14 --- /dev/null +++ b/munit @@ -0,0 +1 @@ +Subproject commit fbbdf1467eb0d04a6ee465def2e529e4c87f2118 diff --git a/src/Makefile b/src/Makefile index dc00079..1f7b532 100644 --- a/src/Makefile +++ b/src/Makefile @@ -16,6 +16,9 @@ OBJECT_FILES=$(filter-out $(EXCLUDED_OBJECTS), $(patsubst %.org,%.o,$(ORG_SOURCE libqmckl.so: Makefile.generated $(MAKE) -f Makefile.generated +test: Makefile.generated + $(MAKE) -f Makefile.generated test + clean: rm -f qmckl.h test_qmckl_*.c test_qmckl_*.f90 qmckl_*.f90 qmckl_*.c qmckl_*.o qmckl_*.h Makefile.generated libqmckl.so diff --git a/src/create_makefile.sh b/src/create_makefile.sh index 66b40dc..7562bba 100755 --- a/src/create_makefile.sh +++ b/src/create_makefile.sh @@ -35,6 +35,12 @@ for i in $(ls qmckl_*.f90) ; do OBJECTS="${OBJECTS} ${FILE}.o" done >> $OUTPUT +TESTS="" +for i in $(ls test_*.c) ; do + FILE=${i%.c} + TESTS="${TESTS} ${FILE}" +done >> $OUTPUT + # Write the Makefile @@ -45,6 +51,7 @@ CFLAGS=$CFLAGS FC=$FC FFLAGS=$FFLAGS OBJECT_FILES=$OBJECTS +TESTS=$TESTS libqmckl.so: \$(OBJECT_FILES) \$(CC) -shared \$(OBJECT_FILES) -o libqmckl.so @@ -55,6 +62,13 @@ libqmckl.so: \$(OBJECT_FILES) %.o: %.f90 \$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o +test_%: test_%.c + \$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \ + -I../munit/ ../munit/munit.c test_\$*.c -lqmckl -o test_\$* + +test: libqmckl.so \$(TESTS) + +.PHONY: test EOF for i in $(ls qmckl_*.c) ; do @@ -67,3 +81,4 @@ for i in $(ls qmckl_*.f90) ; do echo "${FILE}.o: ${FILE}.f90" done >> $OUTPUT + diff --git a/src/qmckl_context.org b/src/qmckl_context.org index 9a56cb6..b2706da 100644 --- a/src/qmckl_context.org +++ b/src/qmckl_context.org @@ -441,7 +441,7 @@ int qmckl_context_get_range(const qmckl_context context) { *** Test #+BEGIN_SRC C :tangle test_qmckl_context.c - return QMCKL_SUCCESS; + return rc; } #+END_SRC diff --git a/src/qmckl_memory.org b/src/qmckl_memory.org index e1d5051..bfb9c68 100644 --- a/src/qmckl_memory.org +++ b/src/qmckl_memory.org @@ -89,6 +89,6 @@ void qmckl_free(void *ptr) { *** Test #+BEGIN_SRC C :tangle test_qmckl_memory.c - return QMCKL_SUCCESS; + return rc; } #+END_SRC