Raw File
README
This tests/ directory contains many tests.

To run them, run "make check" at the top-level cado-nfs directory.

Note that "make check" and "make test" do the same thing (although the
former enables some extra verbose flags). The reason why both exist is
historical only.

** Running tests in parallel
----------------------------

Typing
  make -j check 
is not enough: this will use parallelism only during the build process.
In order to get parallelism during the tests themselves, use:
  make check ARGS="-j"
The combination
  make -j check ARGS="-j"
should work and use parallelism at every level (except a bug in cmake might
make some tests fail with ARGS="-j" due to a collision in dependencies).

Of course you are free to cap the number of processes spawned, by
providing an integer argument to the -j option. Note that running tests
also entails some build work, since tests may have dependencies which are
not otherwise built by default.

** Running only one test
------------------------

If only one test is wanted, it is possible to specify it, again within
the ARGS parameter. For instance, to run only the 'test_memusage' check,
use:
  make check ARGS="-R test_memusage"

Note that the argument to -R is a regular expression, so in the example
above, if a test called test_memusage2 exists it gets run too.

If one wants to see exactly which commands are run and keep the
intermediate data, even if the test succeeds, here is the incantation:
  CADO_DEBUG=1 ctest_filter=no make check ARGS="-R test_memusage"

Note also that due to a bug in CTest, some dependencies are not properly
run first when doing say make check ARGS="-R F9_fakereltest". You should
first run manually make check ARGS="-R F9_makefb".

** Expensive tests
------------------

Some tests are costly and we do not expect users to run them after each
compilation. They can however be activated by setting the environment
variable CHECKS_EXPENSIVE.
For instance, under bash, run:
  export CHECKS_EXPENSIVE=yes
  make cmake
  make check
The second line is necessary, so that cmake really takes the newly set
environment into account.

** Adding new tests
-------------------

Unitary tests should go in the subdirectory of tests/ corresponding to
the same subdirectory where the function is defined in the source tree.
Then, add a new C-file, with a name like test_myfunction.c, and the main
should exercise myfunction(). If everything is ok, the main should return
EXIT_SUCCESS (and anything else otherwise, from segfault to
EXIT_FAILURE). 
Finally, edit CMakeLists.txt in the same directory, and add a line like
    cado_define_test(test_init_norms_bucket_region.cpp
        LIBRARIES las-norms utils tests)
The two cmake macros to be used for defining new tests are
        cado_define_test
    and cado_divert_test.
Their documentation is in tests/CMakeLists.txt ; In greater generality,
these functions also allow to run a shell script or more generally any
executable. Browse the subdirectories and the CMakeLists.txt to get
examples.
back to top