From 9d20d9a04edaed1972a0cca9c74b1676a2577048 Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Tue, 1 Dec 2020 14:30:54 +0100 Subject: [PATCH] Add check to test library dependencies Load a single library to check if there is some dependency missing. --- macro/CMakeLists.txt | 4 ++++ scripts/checklibs.sh | 40 ++++++++++++++++++++++++++++++++++++++++ scripts/loadlib.C | 4 ++++ 3 files changed, 48 insertions(+) create mode 100755 scripts/checklibs.sh create mode 100644 scripts/loadlib.C diff --git a/macro/CMakeLists.txt b/macro/CMakeLists.txt index da6622a130..3698a4e48b 100644 --- a/macro/CMakeLists.txt +++ b/macro/CMakeLists.txt @@ -25,6 +25,10 @@ If($ENV{ctest_model} MATCHES Weekly) Message("Additional long running Weekly tests") EndIf() +# Test if all libraries can be loaded +GENERATE_TEST_SCRIPT(${CBMROOT_SOURCE_DIR}/scripts/checklibs.sh ${CBMROOT_BINARY_DIR}/macro/) +add_test(load_libraries ${CBMROOT_BINARY_DIR}/macro/checklibs.sh) + # Install in any case Install(FILES KF/DecayConfig.C KF/registerGeantDecays.C KF/registerLightIons.C KF/registerPythiaDecays.C KF/kf_kfparticle.C KF/kf_thermal_signal_generator.C KF/kf_transport.C diff --git a/scripts/checklibs.sh b/scripts/checklibs.sh new file mode 100755 index 0000000000..d419e1054b --- /dev/null +++ b/scripts/checklibs.sh @@ -0,0 +1,40 @@ +#/!bin/bash + +# check if the libraries have the proper dependencies +# load a single library in root and check the return value + +# Allow to run the script in th test suite without parameters +# or from the command line passing the proper parameters +SCRIPTDIR=${1:-$VMCWORKDIR/scripts} +LIBDIR=${2:-../lib} + +# find all libs +# libraries are real files with the extensions .so and for macosx .dylib +all_libs=$(find $LIBDIR -type f | grep -e \.dylib -e \.so) + +tmpfile=$(mktemp) + +ok=true +for lib in $all_libs; do + echo "Loading the library $lib" + root -l -q -b $SCRIPTDIR/loadlib.C\(\"$lib\"\) &> $tmpfile + retval=$? + if [[ retval -ne 0 ]]; then + echo "" + echo "Problem loading the library $lib" + cat $tmpfile + echo "" + okay=false + fi +done + +rm $tmpfile + +if [[ "$okay" = "false" ]]; then + echo "" + echo "Not all libraries could be loaded" + echo "Test failed" + exit 1 +else + exit 0 +fi diff --git a/scripts/loadlib.C b/scripts/loadlib.C new file mode 100644 index 0000000000..334dc34843 --- /dev/null +++ b/scripts/loadlib.C @@ -0,0 +1,4 @@ +Int_t loadlib(TString libname) { + Int_t retval = gSystem->Load(libname); + return retval; +} -- GitLab