From 04b07248f76a69d003a8c5ca53f1b4b7e934f14b Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 11 Mar 2025 16:34:59 +0100 Subject: [PATCH 1/5] [Post-install] Add a simple post-install test. To test that ROOT is usable after it has been installed, a small CMake project is added that checks the outputs of hsimple. --- test/PostInstall/CMakeLists.txt | 21 +++++++++++++++++++++ test/PostInstall/readHSimple.cxx | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/PostInstall/CMakeLists.txt create mode 100644 test/PostInstall/readHSimple.cxx diff --git a/test/PostInstall/CMakeLists.txt b/test/PostInstall/CMakeLists.txt new file mode 100644 index 0000000000000..50a98b1ff5722 --- /dev/null +++ b/test/PostInstall/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) + +project(PostInstall) + +find_package(ROOT REQUIRED) + +add_executable(readHSimple readHSimple.cxx) +target_link_libraries(readHSimple PUBLIC ROOT::Hist ROOT::RIO) + +include(CTest) + +if(BUILD_TESTING) + add_test(NAME run-hsimple + COMMAND ${ROOT_BINDIR}/root.exe -b -q -l -e ".x ${CMAKE_SOURCE_DIR}/../../tutorials/hsimple.C" -e "return" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME read-hsimple + COMMAND $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + set_tests_properties(run-hsimple PROPERTIES FIXTURES_SETUP HSIMPLE) + set_tests_properties(read-hsimple PROPERTIES FIXTURES_REQUIRED HSIMPLE) +endif() diff --git a/test/PostInstall/readHSimple.cxx b/test/PostInstall/readHSimple.cxx new file mode 100644 index 0000000000000..8ddb6e8ed8068 --- /dev/null +++ b/test/PostInstall/readHSimple.cxx @@ -0,0 +1,19 @@ +#include +#include + +int main() +{ + TFile file("hsimple.root", "READ"); + if (!file.IsOpen()) + return 1; + + TH1 *histo = file.Get("hpx"); + if (!histo) + return 2; + + if (histo->GetEntries() != 25000) + return 3; + histo->Print(); + + return 0; +} From 2811cdc30060cdf505610fd68f7a54202bea0248 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 18 Mar 2025 10:38:33 +0100 Subject: [PATCH 2/5] [Post-install] Add a script to check that ROOT's headers are valid. Add a script that checks all installed headers for syntax errors. This tests if the include statements of our headers are sufficient, but it does less than include-what-you-use. --- test/PostInstall/check-headers.sh | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/PostInstall/check-headers.sh diff --git a/test/PostInstall/check-headers.sh b/test/PostInstall/check-headers.sh new file mode 100644 index 0000000000000..821deda11af06 --- /dev/null +++ b/test/PostInstall/check-headers.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Adapted from the XRootD project with friendly permission from G. Amadio. +# +# This script checks that each installed ROOT header can be included individually +# without errors. The intention is to identify which headers may have missing +# includes, missing forward declarations, or missing header dependencies, that is, +# headers from ROOT which it includes, but were not installed by the install target. + +# We need to split CXXFLAGS +# shellcheck disable=SC2086 + +: "${CXX:=c++}" +: "${CXXFLAGS:=-std=c++17 -Wall -Wextra -Wno-unused-parameter -Wno-unused-const-variable}" +: "${INCLUDE_DIR:=${1}}" +: "${NCPU:=$(getconf _NPROCESSORS_ONLN)}" + +if ! command -v "${CXX}" >/dev/null; then + echo "Please set CXX to a valid compiler" + exit 2 +fi +if [ ! -d "${INCLUDE_DIR}" ]; then + echo "Usage: ${0} " + echo "Alternatively, set INCLUDE_DIR in the environment" + exit 2 +fi + + +# Check all installed headers for include errors. +HEADERS=$(find "${INCLUDE_DIR}" -type f -name '*.h*') + +xargs -P ${NCPU:-1} -n 1 "${CXX}" -fsyntax-only -x c++ ${CXXFLAGS} -I"${INCLUDE_DIR}" <<< "${HEADERS}" || exit 1 + From 82898a837d0cb7af599dc5f9a5c687119d4a03e2 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 11 Mar 2025 16:35:55 +0100 Subject: [PATCH 3/5] [CI] Enable a small post-install CMake build test. --- .github/workflows/root-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index 5f464b1979722..3c713ca2129ca 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -563,6 +563,18 @@ jobs: run: | ccache -s || true + - name: Install + run: "cmake --install /github/home/ROOT-CI/build/ --prefix /github/home/ROOT-CI/install" + + - name: Post-install build + run: | + cmake -S test/PostInstall/ -B /github/home/ROOT-CI/PostInstall -DCMAKE_PREFIX_PATH=/github/home/ROOT-CI/install; + cmake --build /github/home/ROOT-CI/PostInstall; + + - name: Post-install test + working-directory: /github/home/ROOT-CI/PostInstall + run: ctest -j $(nproc) + event_file: # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. From 669f8d482a544e59f91495fde8f15f375f7e709b Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 18 Mar 2025 11:24:56 +0100 Subject: [PATCH 4/5] [CI] Enable a post-install header test. --- .github/workflows/root-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index 3c713ca2129ca..ff199cd872472 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -575,6 +575,9 @@ jobs: working-directory: /github/home/ROOT-CI/PostInstall run: ctest -j $(nproc) + - name: Check installed headers + run: bash test/PostInstall/check-headers.sh /github/home/ROOT-CI/install/include + event_file: # For any event that is not a PR, the CI will always run. In PRs, the CI # can be skipped if the tag [skip-ci] or [skip ci] is written in the title. From d3934a1b231fcf7d4990cbfb8d9b8b60594a8308 Mon Sep 17 00:00:00 2001 From: Stephan Hageboeck Date: Tue, 18 Mar 2025 16:10:18 +0100 Subject: [PATCH 5/5] [WIP] Use env context to set directories for post-install tests. --- .github/workflows/root-ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/root-ci.yml b/.github/workflows/root-ci.yml index ff199cd872472..32dfb441361a8 100644 --- a/.github/workflows/root-ci.yml +++ b/.github/workflows/root-ci.yml @@ -420,6 +420,11 @@ jobs: CONTAINER_IMAGE: "registry.cern.ch/root-ci/${{ matrix.image }}:buildready" #KEEP IN SYNC WITH ABOVE CONTAINER_OPTIONS: "--security-opt label=disable --rm ${{ matrix.property == 'gpu' && '--device nvidia.com/gpu=all' || '' }}" #KEEP IN SYNC WITH ABOVE + env: + BUILD_DIR: /github/home/ROOT-CI/build + INSTALL_DIR: /github/home/ROOT-CI/install + POST_INSTALL_DIR: /github/home/ROOT-CI/PostInstall + steps: - name: Configure large ccache if: ${{ matrix.is_special }} @@ -564,19 +569,19 @@ jobs: ccache -s || true - name: Install - run: "cmake --install /github/home/ROOT-CI/build/ --prefix /github/home/ROOT-CI/install" + run: "cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}" - name: Post-install build run: | - cmake -S test/PostInstall/ -B /github/home/ROOT-CI/PostInstall -DCMAKE_PREFIX_PATH=/github/home/ROOT-CI/install; - cmake --build /github/home/ROOT-CI/PostInstall; + cmake -S test/PostInstall/ -B ${{ env.POST_INSTALL_DIR }} -DCMAKE_PREFIX_PATH=${{ env.INSTALL_DIR }}; + cmake --build ${{ env.POST_INSTALL_DIR }}; - name: Post-install test - working-directory: /github/home/ROOT-CI/PostInstall + working-directory: ${{ env.POST_INSTALL_DIR }} run: ctest -j $(nproc) - name: Check installed headers - run: bash test/PostInstall/check-headers.sh /github/home/ROOT-CI/install/include + run: bash test/PostInstall/check-headers.sh ${{ env.INSTALL_DIR }}/include event_file: # For any event that is not a PR, the CI will always run. In PRs, the CI