| 1 | #!/bin/bash |
| 2 | |
| 3 | # Check that selected examples can build and run without segfaulting |
| 4 | |
| 5 | err_code=0 |
| 6 | |
| 7 | DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) |
| 8 | |
| 9 | cd examples |
| 10 | |
| 11 | mkdir test_build |
| 12 | cd test_build |
| 13 | |
| 14 | export HOME=${PWD} |
| 15 | |
| 16 | # build examples |
| 17 | cmake -DCMAKE_PREFIX_PATH=/usr/lib/${DEB_HOST_MULTIARCH}/cmake/adios2/serial \ |
| 18 | -DCMAKE_VERBOSE_MAKEFILE=ON \ |
| 19 | -DCMAKE_BUILD_TYPE=Debug \ |
| 20 | -DTEST_SERIAL=On \ |
| 21 | .. |
| 22 | err_code=$(( $? | err_code )) |
| 23 | make |
| 24 | err_code=$(( $? | err_code )) |
| 25 | echo |
| 26 | |
| 27 | # don't run examples which do not run cleanly |
| 28 | declare -a SKIP_TEST_LIST |
| 29 | |
| 30 | # plugin engine examples are not fully configured to run as-is (plugin name is mangled) |
| 31 | SKIP_TEST_LIST=("${SKIP_TEST_LIST[@]}" adios2_plugins_examplePluginEngineRead \ |
| 32 | adios2_plugins_examplePluginEngineWrite) |
| 33 | |
| 34 | SKIP_TESTS="" |
| 35 | for t in "${SKIP_TEST_LIST[@]}"; do |
| 36 | SKIP_TESTS="${SKIP_TESTS} -not -name $t" |
| 37 | done |
| 38 | echo "skipping examples: SKIP_TEST_LIST=${SKIP_TEST_LIST[@]}" |
| 39 | |
| 40 | # *Write must be run before *Read to generate the test file needed to read |
| 41 | # and *Read before *Write_mpi or the read may fail |
| 42 | declare -a TEST_LIST |
| 43 | TEST_LIST=(`find . -maxdepth 3 -executable -type f -name *Write ${SKIP_TESTS}`) |
| 44 | TEST_LIST=(${TEST_LIST[@]} `find . -maxdepth 3 -executable -type f -name *Read ${SKIP_TESTS}`) |
| 45 | TEST_LIST=(${TEST_LIST[@]} `find . -maxdepth 3 -executable -type f -not -path "*CMakeFiles*" ${SKIP_TESTS}`) |
| 46 | # get a unique list (preserving order) cf. https://stackoverflow.com/questions/13648410/how-can-i-get-unique-values-from-an-array-in-bash#comment99138701_13648438 |
| 47 | TEST_LIST=(`echo "${TEST_LIST[@]}" | tr " " "\n" | awk '!seen[$0]++'`) |
| 48 | |
| 49 | # run examples |
| 50 | for f in ${TEST_LIST[@]}; do |
| 51 | echo Running $f |
| 52 | ADIOS2_PLUGIN_PATH=/usr/lib/${DEB_HOST_MULTIARCH}/adios2/serial/plugins $f 2>$f.err >$f.out |
| 53 | this_err=$? |
| 54 | if [ $this_err -ne 0 ]; then |
| 55 | echo "Error ${this_err} in $f" |
| 56 | cat $f.out |
| 57 | cat $f.err |
| 58 | else |
| 59 | echo "Passed: $f" |
| 60 | fi |
| 61 | err_code=$(( this_err | err_code )) |
| 62 | done |
| 63 | |
| 64 | cd .. |
| 65 | |
| 66 | # confirm serial Python module is accessible |
| 67 | for pyver in `py3versions -sv`; do |
| 68 | echo -e "\nChecking Python $pyver installation" |
| 69 | python$pyver -c "import adios2; print('adios2 version', adios2.__version__); assert not adios2.is_built_with_mpi" |
| 70 | err_code=$(( $? | err_code )) |
| 71 | done |
| 72 | # all example python scripts use MPI, so don't test any here |
| 73 | |
| 74 | exit ${err_code} |