-
Notifications
You must be signed in to change notification settings - Fork 47
[DRAFT] Add unit test suites #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Ninja doesn't like the fact that I generate the same Fortran modules twice. Need to find a way to have a precision-qualified module file emitted when each test suite is compiled. |
|
Very nice initiative.
|
Thanks! Yes good points.
|
So far only SETUP_TRANS0 and SETUP_TRANS are covered.
2a323a8 to
dcbf00e
Compare
For now we have no way to gracefully handle aborts. Hopefully in future with some modifications to FIAT, we can enable these tests.
bd09849 to
2b76047
Compare
2b76047 to
a6ded70
Compare
|
Discussions with @marsdeno highlighted that what I've done here is not really "unit tests". A better name would be "interface tests". |
We don't need this anymore :)
Currently we have the following tests in ecTrans:
INV_TRANS,INV_TRANSAD,DIR_TRANS,DIR_TRANSAD, all in oneINV_TRANS/ADandDIR_TRANS/ADGPNORM_TRANSTL/ADI propose to add a mechanism for unit tests, by which I mean specifically an isolated test for a single feature of one of the ecTrans subroutines. I suggest to focus on the external subroutines (at least for now). These tests will complement the tests above, and in some cases possibly replace them (e.g. we won't need
ectrans_test_setup_trans0anymore, and the benchmark program could perhaps finally be repurposed for what it was built for - benchmarking).This draft PR gives an idea of how this could be achieved in vanilla CMake. I have followed this example. Here is how it works:
INTEGER FUNCTIONfor each unit test. These all are namedUNIT_TEST_*. Each function carries out a unit test and returns 0 for success or 1 for failure. They all haveBIND(C)specified so they can be called from a C function linked into the final executable.create_test_sourcelistwe create a C program which provides a callable wrapper for each of the Fortran unit tests. From this we create an executable which CTest can call.The above logic is repeated for each enabled precision.
All unit tests will then be visible when running
ctest -R unit_test.Here are the tests I've implemented so far:
I have implemented a "will fail" logic to handle cases that are expected to fail (e.g. calling
SETUP_TRANSwithoutSETUP_TRANS0or initialising with an odd number of latitudes - both cases above). However this will require modifying the abort behaviour ofSDL_SRLABORT: we need to somehow disable the raising ofSIGABRTand useERROR STOPinstead ofSTOPso an error code 1 is returned. Otherwise I don't think there's any way to recover fromABORT_TRANS.Also, for now I've disabled MPI in these tests. We obviously need to test at least some of the subroutines with MPI enabled (e.g.
DIST_GRID) but I'm not sure how to do this yet without wrapping the whole suite in a for loop over 0, 1, 2 MPI tasks and having the number of tests exploding.Anyway, any thoughts @wdeconinck @marsdeno @ddegrauwe @dhaumont @RyadElKhatibMF?