mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-11-19 20:42:50 +01:00
80 lines
1.9 KiB
Org Mode
80 lines
1.9 KiB
Org Mode
|
#+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
|