mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-12-22 12:23:56 +01:00
Merge tests into single exe
This commit is contained in:
parent
8c9a10cae6
commit
5f5465eaf9
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@ -4,3 +4,4 @@
|
||||
*~
|
||||
*.so
|
||||
Makefile.generated
|
||||
test_qmckl
|
||||
|
@ -1,5 +1,5 @@
|
||||
CC=gcc
|
||||
CFLAGS=-fPIC -fexceptions -Wall -Werror -Wpedantic -Wextra -g
|
||||
CFLAGS=-fPIC -fexceptions -Wall -Werror -Wpedantic -Wextra -g
|
||||
|
||||
FC=gfortran
|
||||
FFLAGS=-fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wno-tabs -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant -Wuninitialized -fbacktrace -ffpe-trap=zero,overflow,underflow -finit-real=nan
|
||||
@ -7,16 +7,16 @@ FFLAGS=-fcheck=all -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics
|
||||
|
||||
export CC CFLAGS FC FFLAGS
|
||||
|
||||
ORG_SOURCE_FILES=$(wildcard qmckl*.org)
|
||||
ORG_SOURCE_FILES=$(wildcard qmckl*.org) test_qmckl.org
|
||||
OBJECT_FILES=$(filter-out $(EXCLUDED_OBJECTS), $(patsubst %.org,%.o,$(ORG_SOURCE_FILES)))
|
||||
|
||||
.PHONY: clean
|
||||
.PHONY: clean
|
||||
.SECONDARY: # Needed to keep the produced C and Fortran files
|
||||
|
||||
libqmckl.so: Makefile.generated
|
||||
$(MAKE) -f Makefile.generated
|
||||
|
||||
test: Makefile.generated
|
||||
test: Makefile.generated
|
||||
$(MAKE) -f Makefile.generated test
|
||||
|
||||
clean:
|
||||
|
@ -36,8 +36,8 @@ for i in $(ls qmckl_*.f90) ; do
|
||||
done >> $OUTPUT
|
||||
|
||||
TESTS=""
|
||||
for i in $(ls test_*.c) ; do
|
||||
FILE=${i%.c}
|
||||
for i in $(ls test_qmckl_*.c) ; do
|
||||
FILE=${i}
|
||||
TESTS="${TESTS} ${FILE}"
|
||||
done >> $OUTPUT
|
||||
|
||||
@ -46,7 +46,7 @@ done >> $OUTPUT
|
||||
|
||||
cat << EOF > $OUTPUT
|
||||
CC=$CC
|
||||
CFLAGS=$CFLAGS
|
||||
CFLAGS=$CFLAGS -I../munit/
|
||||
|
||||
FC=$FC
|
||||
FFLAGS=$FFLAGS
|
||||
@ -62,12 +62,13 @@ libqmckl.so: \$(OBJECT_FILES)
|
||||
%.o: %.f90
|
||||
\$(FC) \$(FFLAGS) -c \$*.f90 -o \$*.o
|
||||
|
||||
test_%: test_%.c
|
||||
test_qmckl: test_qmckl.c libqmckl.so \$(TESTS)
|
||||
echo \$(TESTS)
|
||||
\$(CC) \$(CFLAGS) -Wl,-rpath,$PWD -L. \
|
||||
-I../munit/ ../munit/munit.c test_\$*.c -lqmckl -o test_\$*
|
||||
../munit/munit.c \$(TESTS) -lqmckl test_qmckl.c -o test_qmckl
|
||||
|
||||
test: libqmckl.so \$(TESTS)
|
||||
for i in \$(TESTS) ; do ./\$\$i ; done
|
||||
test: test_qmckl
|
||||
./test_qmckl
|
||||
|
||||
.PHONY: test
|
||||
EOF
|
||||
@ -82,4 +83,9 @@ for i in $(ls qmckl_*.f90) ; do
|
||||
echo "${FILE}.o: ${FILE}.f90"
|
||||
done >> $OUTPUT
|
||||
|
||||
for i in $(ls test_qmckl_*.c) ; do
|
||||
FILE=${i%.c}
|
||||
echo "${FILE}.o: ${FILE}.c qmckl.h"
|
||||
done >> $OUTPUT
|
||||
|
||||
|
||||
|
@ -11,22 +11,22 @@ C than in Fortran.
|
||||
- a test file : =test_qmckl_context.c=
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
#ifndef QMCKL_CONTEXT_H
|
||||
#define QMCKL_CONTEXT_H
|
||||
#include "qmckl.h"
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
#include "qmckl.h"
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
#include "qmckl.h"
|
||||
#include "munit.h"
|
||||
static MunitResult test_qmckl_context() {
|
||||
MunitResult test_qmckl_context() {
|
||||
#+END_SRC
|
||||
|
||||
* Context
|
||||
@ -39,13 +39,13 @@ static MunitResult test_qmckl_context() {
|
||||
A value of 0 for the context is equivalent to a NULL pointer.
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
/* 64-bit integer */
|
||||
typedef long long int qmckl_context ;
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
typedef struct qmckl_context_struct {
|
||||
struct qmckl_context_struct * prev;
|
||||
unsigned int tag;
|
||||
@ -62,7 +62,7 @@ typedef struct qmckl_context_struct {
|
||||
|
||||
*** Test
|
||||
We declare here the variables used in the tests.
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
qmckl_context context;
|
||||
qmckl_context new_context;
|
||||
#+END_SRC
|
||||
@ -74,12 +74,12 @@ typedef struct qmckl_context_struct {
|
||||
Returns the input =qmckl_context= if the context is valid, 0 otherwise.
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_check(qmckl_context context) ;
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_check(qmckl_context context) {
|
||||
qmckl_context_struct * ctx;
|
||||
|
||||
@ -99,12 +99,12 @@ qmckl_context qmckl_context_check(qmckl_context context) {
|
||||
- Returns 0 upon failure to allocate the internal data structure
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_create();
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_create() {
|
||||
|
||||
qmckl_context_struct* context;
|
||||
@ -124,7 +124,7 @@ qmckl_context qmckl_context_create() {
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
context = qmckl_context_create();
|
||||
munit_assert_long( context, !=, (qmckl_context) 0);
|
||||
munit_assert_long( qmckl_context_check(context), ==, context);
|
||||
@ -139,12 +139,12 @@ qmckl_context qmckl_context_create() {
|
||||
for the new context
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_copy(const qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_copy(const qmckl_context context) {
|
||||
|
||||
qmckl_context_struct* old_context;
|
||||
@ -175,7 +175,7 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
new_context = qmckl_context_copy(context);
|
||||
munit_assert_long(new_context, !=, (qmckl_context) 0);
|
||||
munit_assert_long(new_context, !=, context);
|
||||
@ -190,12 +190,12 @@ qmckl_context qmckl_context_copy(const qmckl_context context) {
|
||||
- Returns 0 for the 0-valued context
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_previous(const qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_previous(const qmckl_context context) {
|
||||
|
||||
qmckl_context checked_context;
|
||||
@ -212,7 +212,7 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
munit_assert_long(qmckl_context_previous(new_context), !=, (qmckl_context) 0);
|
||||
munit_assert_long(qmckl_context_previous(new_context), ==, context);
|
||||
munit_assert_long(qmckl_context_previous(context), ==, (qmckl_context) 0);
|
||||
@ -228,12 +228,12 @@ qmckl_context qmckl_context_previous(const qmckl_context context) {
|
||||
- Fails if the the pointer is not a valid context
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_exit_code qmckl_context_destroy(qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_exit_code qmckl_context_destroy(qmckl_context context) {
|
||||
|
||||
qmckl_context_struct* ctx;
|
||||
@ -252,7 +252,7 @@ qmckl_exit_code qmckl_context_destroy(qmckl_context context) {
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
munit_assert_long(qmckl_context_check(new_context), ==, new_context);
|
||||
munit_assert_long(new_context, !=, (qmckl_context) 0);
|
||||
munit_assert_int(qmckl_context_destroy(new_context), ==, QMCKL_SUCCESS);
|
||||
@ -274,11 +274,11 @@ qmckl_exit_code qmckl_context_destroy(qmckl_context context) {
|
||||
|
||||
** =qmckl_context_update_precision=
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, int precision);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, int precision) {
|
||||
qmckl_context_struct* ctx;
|
||||
|
||||
@ -294,11 +294,11 @@ qmckl_exit_code qmckl_context_update_precision(const qmckl_context context, int
|
||||
#+END_SRC
|
||||
|
||||
** =qmckl_context_update_range=
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_exit_code qmckl_context_update_range(const qmckl_context context, int range);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_exit_code qmckl_context_update_range(const qmckl_context context, int range) {
|
||||
qmckl_context_struct* ctx;
|
||||
|
||||
@ -317,11 +317,11 @@ qmckl_exit_code qmckl_context_update_range(const qmckl_context context, int rang
|
||||
|
||||
** =qmckl_context_set_precision=
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_set_precision(const qmckl_context context, int precision);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_set_precision(const qmckl_context context, const int precision) {
|
||||
qmckl_context new_context;
|
||||
|
||||
@ -335,11 +335,11 @@ qmckl_context qmckl_context_set_precision(const qmckl_context context, const int
|
||||
#+END_SRC
|
||||
|
||||
** =qmckl_context_set_range=
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
qmckl_context qmckl_context_set_range(const qmckl_context context, int range);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
qmckl_context qmckl_context_set_range(const qmckl_context context, int range) {
|
||||
qmckl_context new_context;
|
||||
|
||||
@ -356,11 +356,11 @@ qmckl_context qmckl_context_set_range(const qmckl_context context, int range) {
|
||||
|
||||
** =qmckl_context_get_precision=
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
int qmckl_context_get_precision(const qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
int qmckl_context_get_precision(const qmckl_context context) {
|
||||
qmckl_context_struct* ctx;
|
||||
ctx = (qmckl_context_struct*) context;
|
||||
@ -370,11 +370,11 @@ int qmckl_context_get_precision(const qmckl_context context) {
|
||||
|
||||
** =qmckl_context_get_range=
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
int qmckl_context_get_range(const qmckl_context context);
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :tangle qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.c
|
||||
int qmckl_context_get_range(const qmckl_context context) {
|
||||
qmckl_context_struct* ctx;
|
||||
ctx = (qmckl_context_struct*) context;
|
||||
@ -387,28 +387,13 @@ int qmckl_context_get_range(const qmckl_context context) {
|
||||
* End of files
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_context.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_context.h
|
||||
#endif
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_context.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_context.c
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
||||
static MunitTest test_suite_tests[] =
|
||||
{
|
||||
{ (char*) "qmckl_context", test_qmckl_context, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
|
||||
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
|
||||
};
|
||||
|
||||
static const MunitSuite test_suite =
|
||||
{
|
||||
(char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
||||
};
|
||||
|
||||
return munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
|
@ -11,34 +11,34 @@ optimized libraries to fine-tune the memory allocation.
|
||||
- a test file : =test_qmckl_memory.c=
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
||||
#ifndef QMCKL_MEMORY_H
|
||||
#define QMCKL_MEMORY_H
|
||||
#include "qmckl.h"
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
||||
#include <stdlib.h>
|
||||
#include "qmckl_memory.h"
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
||||
#include "qmckl.h"
|
||||
#include "munit.h"
|
||||
static MunitResult test_qmckl_memory() {
|
||||
MunitResult test_qmckl_memory() {
|
||||
#+END_SRC
|
||||
|
||||
** =qmckl_malloc=
|
||||
Analogous of =malloc, but passing signed 64-bit integers as argument.=
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
||||
void* qmckl_malloc(long long int size);
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
||||
void* qmckl_malloc(long long int size) {
|
||||
return malloc( (size_t) size );
|
||||
}
|
||||
@ -46,7 +46,7 @@ void* qmckl_malloc(long long int size) {
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
||||
int *a;
|
||||
a = (int*) qmckl_malloc(3*sizeof(int));
|
||||
a[0] = 1;
|
||||
@ -60,46 +60,32 @@ void* qmckl_malloc(long long int size) {
|
||||
** =qmckl_free=
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
||||
void qmckl_free(void *ptr);
|
||||
#+END_SRC
|
||||
|
||||
*** Source
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.c
|
||||
void qmckl_free(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
||||
qmckl_free(a);
|
||||
#+END_SRC
|
||||
|
||||
* End of files
|
||||
|
||||
*** Header
|
||||
#+BEGIN_SRC C :tangle qmckl_memory.h
|
||||
#+BEGIN_SRC C :comments link :tangle qmckl_memory.h
|
||||
#endif
|
||||
#+END_SRC
|
||||
|
||||
*** Test
|
||||
#+BEGIN_SRC C :tangle test_qmckl_memory.c
|
||||
#+BEGIN_SRC C :comments link :tangle test_qmckl_memory.c
|
||||
return MUNIT_OK;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
||||
static MunitTest test_suite_tests[] =
|
||||
{
|
||||
{ (char*) "qmckl_memory", test_qmckl_memory, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL },
|
||||
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
|
||||
};
|
||||
|
||||
static const MunitSuite test_suite =
|
||||
{
|
||||
(char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
||||
};
|
||||
|
||||
return munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
|
||||
}
|
||||
#+END_SRC
|
||||
|
79
src/test_qmckl.org
Normal file
79
src/test_qmckl.org
Normal file
@ -0,0 +1,79 @@
|
||||
#+TITLE: QMCkl test
|
||||
|
||||
This file is the main program of the unit tests. The tests rely on the
|
||||
$\mu$unit framework, which is provided as a git submodule.
|
||||
|
||||
First, we use a script to find the list of all the produced test files:
|
||||
#+NAME: test-files
|
||||
#+BEGIN_SRC sh :exports none :results value
|
||||
grep BEGIN_SRC *.org | \
|
||||
grep test_qmckl_ | \
|
||||
rev | \
|
||||
cut -d ' ' -f 1 | \
|
||||
rev | \
|
||||
sort | \
|
||||
uniq
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS: test-files
|
||||
| test_qmckl_context.c |
|
||||
| test_qmckl_memory.c |
|
||||
|
||||
We generate the function headers
|
||||
#+BEGIN_SRC sh :var files=test-files :exports output :results raw
|
||||
echo "#+NAME: headers"
|
||||
echo "#+BEGIN_SRC C :tangle no"
|
||||
for file in $files
|
||||
do
|
||||
routine=${file%.c}
|
||||
echo "MunitResult ${routine}();"
|
||||
done
|
||||
echo "#+END_SRC"
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
#+NAME: headers
|
||||
#+BEGIN_SRC C :tangle no
|
||||
MunitResult test_qmckl_context();
|
||||
MunitResult test_qmckl_memory();
|
||||
#+END_SRC
|
||||
|
||||
and the required function calls:
|
||||
#+BEGIN_SRC sh :var files=test-files :exports output :results raw
|
||||
echo "#+NAME: calls"
|
||||
echo "#+BEGIN_SRC C :tangle no"
|
||||
for file in $files
|
||||
do
|
||||
routine=${file%.c}
|
||||
echo " { (char*) \"${routine}\", ${routine}, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},"
|
||||
done
|
||||
echo "#+END_SRC"
|
||||
#+END_SRC
|
||||
|
||||
#+RESULTS:
|
||||
#+NAME: calls
|
||||
#+BEGIN_SRC C :tangle no
|
||||
{ (char*) "test_qmckl_context", test_qmckl_context, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||
{ (char*) "test_qmckl_memory", test_qmckl_memory, NULL,NULL,MUNIT_TEST_OPTION_NONE,NULL},
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC C :comments link :noweb yes :tangle test_qmckl.c
|
||||
#include "qmckl.h"
|
||||
#include "munit.h"
|
||||
<<headers>>
|
||||
|
||||
int main(int argc, char* argv[MUNIT_ARRAY_PARAM(argc + 1)]) {
|
||||
static MunitTest test_suite_tests[] =
|
||||
{
|
||||
<<calls>>
|
||||
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
|
||||
};
|
||||
|
||||
static const MunitSuite test_suite =
|
||||
{
|
||||
(char*) "", test_suite_tests, NULL, 1, MUNIT_SUITE_OPTION_NONE
|
||||
};
|
||||
|
||||
return munit_suite_main(&test_suite, (void*) "µnit", argc, argv);
|
||||
}
|
||||
#+END_SRC
|
Loading…
Reference in New Issue
Block a user