From 772321482bf0707c4a6a996af8fc75d32ce219e0 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Thu, 20 Mar 2025 14:10:12 +0100
Subject: [PATCH 1/5] [CI] Also try to load all libraries when checking the
 installed version

---
 cmake/scripts/execute_installation_test.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/cmake/scripts/execute_installation_test.sh b/cmake/scripts/execute_installation_test.sh
index 2f9fb61808..6161df1eff 100755
--- a/cmake/scripts/execute_installation_test.sh
+++ b/cmake/scripts/execute_installation_test.sh
@@ -3,9 +3,15 @@
 install_dir=$1
 source $install_dir/bin/CbmRootConfig.sh -a
 
+cd $install_dir/share/cbmroot/macro
+
+$install_dir/share/cbmroot/macro/checklibs.sh $install_dir/share/cbmroot/macro/ $install_dir/lib
+return_value_libs=$?
+
 cd $install_dir/share/cbmroot/macro/run
 
 $install_dir/share/cbmroot/macro/run/run_tests.sh
-return_value=$?
+return_value_runs=$?
 
+(( return_value = return_value_libs || return_value_runs ))
 exit $return_value
-- 
GitLab


From 65af14fb5ec1c4b7d59964a4b44ac97ce54cdf8f Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Thu, 20 Mar 2025 14:10:54 +0100
Subject: [PATCH 2/5] [CI] Run the installation check both before and after
 removing the source folder

---
 CbmRoot_test.cmake | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/CbmRoot_test.cmake b/CbmRoot_test.cmake
index 151c66b86d..6655379682 100644
--- a/CbmRoot_test.cmake
+++ b/CbmRoot_test.cmake
@@ -175,10 +175,14 @@ If(NOT _RETVAL)
                     RESULTS_VARIABLE _install_ret_value
                    )
     if (NOT _install_ret_value)
+      message("executing test suite in ${CTEST_BINARY_DIRECTORY}/install with source folder available")
+      execute_process(COMMAND ${CTEST_SOURCE_DIRECTORY}/cmake/scripts/execute_installation_test.sh ${CTEST_SOURCE_DIRECTORY}/install
+                      RESULTS_VARIABLE _install_ret_value
+                     )
       execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E rm -R build MQ algo analysis core external fles mvd reco sim
                       WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY}
                      )
-      message("executing test suite in ${CTEST_BINARY_DIRECTORY}/install")
+      message("executing test suite in ${CTEST_BINARY_DIRECTORY}/install wihout source folder available")
       execute_process(COMMAND ${CTEST_SOURCE_DIRECTORY}/cmake/scripts/execute_installation_test.sh ${CTEST_SOURCE_DIRECTORY}/install
                       RESULTS_VARIABLE _install_ret_value
                      )
-- 
GitLab


From 29b3b2a8989756dc330e127a3cccb0ec1f7751c3 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Fri, 21 Mar 2025 14:27:42 +0100
Subject: [PATCH 3/5] [CI] Remove mvd from folders to delete when testing
 installed version (folder removed from repo)

---
 CbmRoot_test.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CbmRoot_test.cmake b/CbmRoot_test.cmake
index 6655379682..4a556a9e3e 100644
--- a/CbmRoot_test.cmake
+++ b/CbmRoot_test.cmake
@@ -179,7 +179,7 @@ If(NOT _RETVAL)
       execute_process(COMMAND ${CTEST_SOURCE_DIRECTORY}/cmake/scripts/execute_installation_test.sh ${CTEST_SOURCE_DIRECTORY}/install
                       RESULTS_VARIABLE _install_ret_value
                      )
-      execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E rm -R build MQ algo analysis core external fles mvd reco sim
+      execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E rm -R build MQ algo analysis core external fles reco sim
                       WORKING_DIRECTORY ${CTEST_SOURCE_DIRECTORY}
                      )
       message("executing test suite in ${CTEST_BINARY_DIRECTORY}/install wihout source folder available")
-- 
GitLab


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 4/5] [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


From 4613e86e59cf998ef12b4c3225a059014291f314 Mon Sep 17 00:00:00 2001
From: P-A Loizeau <p.-a.loizeau@gsi.de>
Date: Fri, 28 Mar 2025 17:16:01 +0100
Subject: [PATCH 5/5] Fix new checklibs feature to support both mawk and gawk
 variants of awk

---
 scripts/checklibs.sh | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/scripts/checklibs.sh b/scripts/checklibs.sh
index 25553ce95d..9c95ff650f 100755
--- a/scripts/checklibs.sh
+++ b/scripts/checklibs.sh
@@ -25,17 +25,24 @@ for lib in $all_libs; do
   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
-
+    # Need 4 * \ because gawk (GNU awk, Ubuntu 22.04) parse such strings twice before trying to use the string...
+    # So \\\\ becomes \\ which becomes \
+    # => Seems to still work with mawk (Mike's awk, debian 10) on run2, so ok like this?
+    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}"}"
+
+  # Printouts commented out to limit spam in test logs
+  # FIXME: make it a "-v" option
+  #  echo "Loading the library ${lib} and parsing it for class ${first_class}"
+  #else
+  #  echo "Loading the library ${lib}"
   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=$?
-- 
GitLab