Skip to content

Commit 435bb5d

Browse files
committed
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.
1 parent 090b095 commit 435bb5d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

test/PostInstall/CMakeLists.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
2+
3+
project(PostInstall)
4+
5+
find_package(ROOT REQUIRED)
6+
7+
add_executable(readHSimple readHSimple.cxx)
8+
target_link_libraries(readHSimple PUBLIC ROOT::Hist ROOT::RIO)
9+
10+
include(CTest)
11+
12+
if(BUILD_TESTING)
13+
add_test(NAME run-hsimple
14+
COMMAND ${ROOT_BINDIR}/root.exe -b -q -l -e ".x ${CMAKE_SOURCE_DIR}/../../tutorials/hsimple.C" -e "return"
15+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
16+
add_test(NAME read-hsimple
17+
COMMAND $<TARGET_FILE:readHSimple>
18+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
19+
set_tests_properties(run-hsimple PROPERTIES FIXTURES_SETUP HSIMPLE)
20+
set_tests_properties(read-hsimple PROPERTIES FIXTURES_REQUIRED HSIMPLE)
21+
endif()

test/PostInstall/readHSimple.cxx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <TH1.h>
2+
#include <TFile.h>
3+
4+
int main() {
5+
TFile file("hsimple.root", "READ");
6+
if (!file.IsOpen()) return 1;
7+
8+
TH1 * histo = file.Get<TH1>("hpx");
9+
if (!histo) return 2;
10+
11+
if (histo->GetEntries() != 25000) return 3;
12+
histo->Print();
13+
14+
return 0;
15+
}

0 commit comments

Comments
 (0)