From 2615d55083bcdf7f248d158db812b37210eefe71 Mon Sep 17 00:00:00 2001 From: P-A Loizeau <p.-a.loizeau@gsi.de> Date: Fri, 21 Mar 2025 11:27:44 +0100 Subject: [PATCH] [CI] Add parsing of library to lib loading test (using f1st class in lib from rootmap) --- scripts/checklibs.sh | 27 ++++++++++++++++++++++----- scripts/loadlib.C | 17 ++++++++++++++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/scripts/checklibs.sh b/scripts/checklibs.sh index 119ead0a48..25553ce95d 100755 --- a/scripts/checklibs.sh +++ b/scripts/checklibs.sh @@ -15,16 +15,33 @@ LIBDIR=${2:-../lib} # libraries are real files with the extensions .so and for macosx .dylib all_libs=$(find $LIBDIR -type f -o -type l | grep -e \.dylib$ -e \.so$) +# Token used to find the first line with a class definition in the .rootmap files +start_token_class="class " + tmpfile=$(mktemp) -ok=true +okay=true for lib in $all_libs; do - echo "Loading the library $lib" - root -l -q -b $SCRIPTDIR/loadlib.C\(\"$lib\"\) &> $tmpfile + first_class="" + rootmap_file="${lib%%".so"}".rootmap + if [ -f "${rootmap_file}" ]; then + rootmap_defs_token="\[ lib" + if [[ ${rootmap_file} == *"libHal"* ]]; then + # Commented out for now as lead to missing headers detection in 60% of HAL libraries (9/14) + # rootmap_defs_token="\[ Hal" + fi + + first_class=$(awk -v token="${rootmap_defs_token}" '$0 ~ token ,0' ${rootmap_file} | grep -m1 "${start_token_class}" | tr -d ';') + first_class="${first_class##"${start_token_class}"}" + fi + + # echo "Loading the library ${lib} and parsing it for class ${first_class}" + + root -l -q -b "${SCRIPTDIR}/loadlib.C(\"${lib}\", \"${first_class}\")" &> ${tmpfile} retval=$? if [[ retval -ne 0 ]]; then echo "" - echo "Problem loading the library $lib" + echo "Problem loading or parsing the library $lib: ${retval}" cat $tmpfile echo "" okay=false @@ -35,7 +52,7 @@ rm $tmpfile if [[ "$okay" = "false" ]]; then echo "" - echo "Not all libraries could be loaded" + echo "Not all libraries could be loaded and parsed" echo "Test failed" exit 1 else diff --git a/scripts/loadlib.C b/scripts/loadlib.C index ca8b0b4d51..8fd8b5cc0d 100644 --- a/scripts/loadlib.C +++ b/scripts/loadlib.C @@ -1,9 +1,20 @@ -/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2020-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only - Authors: Florian Uhlig [committer] */ + Authors: Florian Uhlig [committer], Pierre-Alain Loizeau */ -Int_t loadlib(TString libname) +Int_t loadlib(TString libname, TString classname = "") { + // This method returns 0 if it succeed, 1 if already loaded, -1 if lib not found and -2 if failed Int_t retval = gSystem->Load(libname); + if (0 == retval && "" != classname) { + // This one returns 1 in case of success and 0 in case of failure + // => Remap to next negative code after those used by the Load thod above + if (1 == gInterpreter->AutoParse(classname)) { + retval = 0; + } + else { + retval = -3; + } + } return retval; } -- GitLab