-
Notifications
You must be signed in to change notification settings - Fork 47
Add API 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?
Add API test suites #313
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.
|
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". |
f2c123c to
752609e
Compare
752609e to
ddab404
Compare
|
I have renamed the "unit" tests to "API" tests. |
So far only SETUP_TRANS0 is covered
For now we have no way to gracefully handle aborts. Hopefully in future with some modifications to FIAT, we can enable these tests.
We don't need this anymore :)
There seems to be an issue in EC_MEMINFO for programs with a top-level C main function, like in the unit tests. The number of command line arguments is assumed to start at 0 rather than 1. Or something like that.
ddab404 to
c75b1b4
Compare
|
PR reduced in scope to only include new testing infrastructure and test suite (actually just a single test) for |
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?