radiasoft / zgoubi

Git repo for zgoubi source code
https://sourceforge.net/projects/zgoubi/
GNU General Public License v2.0
9 stars 3 forks source link

Simple test harness #29

Open robnagler opened 6 years ago

robnagler commented 6 years ago

Zgoubi has a nice feature that it can read a .res file to get the .dat used to generate it. We can use his feature to build as simple test harness called full_test.sh:

#!/bin/bash
set -euo pipefail
prog=$(cd ../build && pwd)/zgoubi
rm -rf full_work
cd full_work
for f in ../full_data/*.res; do
        echo "$(basename $f .res)"
        cp "$f" zgoubi.dat
        "$prog"
        diff "$f" zgoubi.res
done
echo PASS

We can then add any *.res files in full_work, and they'll be copied to full_data one by one until one fails, and the test will exit without a PASS.

Per @dtabell's suggestion we should probably use ndiff or the newer numdiff.

zbeekman commented 6 years ago

@robnagler It's up to you, but the proposed approach would either make the process appear as 1 test to CTest, or be completely outside of CTest. This is fine, but CTest has some nice bells and whistles that you won't be getting if you use a shell script test harness like this.

Currently, we could easily implement an analogous solution with CTest. We can populate a directory in the build tree or source tree called full_data with .res files, then copy them to full_work/zgoubi.dat.

Current impediments to this approach are:

Modernizing zgoubi to use dynamic memory allocation will fix the first issue. I'm not sure how many tests require additional files beyond zgoubi.dat, so I can't speak to the difficulty of solving the second point. @dtabell may be able to weigh in here.

zbeekman commented 6 years ago

Reading @robnagler's comment here I think it might make more sense to create one directory per test in the full_work directory, so that we can see all the inputs and outputs, rather than running all the tests in the same directory. (Also easily accomplished with CMake.)

robnagler commented 6 years ago

What are the bells and whistles of CTest?

zbeekman commented 6 years ago

CTest has quite a long list of features, however the most immediately beneficial and useful (also, CTest was explicitly part of the SOW1) are: