Skip to content

Commit

Permalink
Use ExternalData and remove some scripts for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell committed Jan 28, 2024
1 parent 79d3dd4 commit d516ad9
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 335 deletions.
155 changes: 79 additions & 76 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ gaudi_add_module(GaudiTestAlgorithms
EDM4HEP::edm4hep
)

find_program(K4RUN k4run)

include(ExternalData)
set(ExternalData_URL_TEMPLATES
"https://key4hep.web.cern.ch:443/testFiles/ddsimOutput/%(hash)"
)

# Compile the Marlin test processors into a shared library
find_package(Marlin REQUIRED)
Expand All @@ -35,82 +41,79 @@ add_library(MarlinTestProcessors SHARED src/PseudoRecoProcessor.cc src/TrivialMC
target_link_libraries(MarlinTestProcessors PUBLIC ${Marlin_LIBRARIES})
target_include_directories(MarlinTestProcessors PUBLIC ${Marlin_INCLUDE_DIRS})

# Add test scripts

find_program(BASH_PROGRAM bash)

if (BASH_PROGRAM)
# Test simple processors
add_test( simple_processors ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/simple_processors.sh )

# Test simple_processors2
add_test( simple_processors2 ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/simple_processors2.sh )

# CLICPerformance setup is added as a simple test that will always succeed, on
# which other tests that need it can depend, in order to make concurrent
# running of those more easily possible
add_test( CLICPerformance_setup ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/setup_clic_performance.sh )

# Test clicReconstruction
add_test( clicRec ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec.sh )

# Test converter constants
add_test( converter_constants ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/converter_constants.sh )

# Test indicating -1 to go over all events
add_test( all_events_bounds ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/all_events_bounds.sh )
set_tests_properties ( all_events_bounds
PROPERTIES
PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop")

# Test putting more events than available, stopping on last available event gracefully
add_test( over_total_events ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/over_total_events.sh )
set_tests_properties ( over_total_events
PROPERTIES
PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop")

# Test putting more events than available, stopping on last available event gracefully
add_test( same_num_io ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/same_num_io.sh )
set_tests_properties ( same_num_io
PROPERTIES
PASS_REGULAR_EXPRESSION "Input and output have same number of events")

# Test clicReconstruction with EDM4hep input and output
add_test( clicRec_edm4hep_input ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_e4h_input.sh )

# Run clicReconstruction sequence with LCIO input and output, no converters, with inter-event parallelism
add_test( clicRec_lcio_mt ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_lcio_mt.sh )

# Test the GeoSvc and TrackingCellIDEncodingSvc
add_test( clic_geo_test ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicGeoTest.sh )

# Test for checking whether the converters can resolve relations accross
# multiple processors
add_test( global_converter_maps ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/global_converter_maps.sh )

add_test( event_header_conversion ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/event_header.sh )

set_tests_properties (
simple_processors
simple_processors2
clicRec
converter_constants
all_events_bounds
over_total_events
same_num_io
clicRec_lcio_mt
clicRec_edm4hep_input
clic_geo_test
global_converter_maps
event_header_conversion
# Test simple processors
ExternalData_Add_Test( marlinwrapper_tests NAME simple_processors COMMAND ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/simple_processors.py --LcioEvent.Files DATA{${PROJECT_SOURCE_DIR}/test/input_files/muons.slcio})

# Test simple_processors2
ExternalData_Add_Test( marlinwrapper_tests NAME simple_processors2 COMMAND ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/simple_processors2.py --LcioEvent.Files DATA{${PROJECT_SOURCE_DIR}/test/input_files/testSimulation.slcio})

# CLICPerformance setup is added as a simple test that will always succeed, on
# which other tests that need it can depend, in order to make concurrent
# running of those more easily possible
add_test( CLICPerformance_setup bash -c "test -d CLICPerformance || git clone --depth=1 https://github.com/iLCSoft/CLICPerformance")

# Test clicReconstruction
add_test( clicRec ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec.sh )

# Test converter constants
add_test( converter_constants ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/converter_constants.sh )

# Test indicating -1 to go over all events
ExternalData_Add_Test( marlinwrapper_tests NAME all_events_bounds COMMAND ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/simple_processors.py --num-events=1 --LcioEvent.Files DATA{${PROJECT_SOURCE_DIR}/test/input_files/muons.slcio})
# set_tests_properties ( all_events_bounds
# PROPERTIES
# PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop")

# Test putting more events than available, stopping on last available event gracefully
ExternalData_Add_Test( marlinwrapper_tests NAME over_total_events COMMAND ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/simple_processors.py --num-events=15 --LcioEvent.Files DATA{${PROJECT_SOURCE_DIR}/test/input_files/muons.slcio})
set_tests_properties ( over_total_events
PROPERTIES
PASS_REGULAR_EXPRESSION "Application Manager Terminated successfully with a user requested ScheduledStop")

# Test putting more events than available, stopping on last available event gracefully
add_test( same_num_io ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/same_num_io.sh )
set_tests_properties ( same_num_io
PROPERTIES
PASS_REGULAR_EXPRESSION "Input and output have same number of events")

# Test clicReconstruction with EDM4hep input and output
ExternalData_Add_Test( marlinwrapper_tests NAME clicRec_edm4hep_input COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_e4h_input.sh DATA{${PROJECT_SOURCE_DIR}/test/input_files/ttbar_podio230830_edm4hep_frame.root})

# Run clicReconstruction sequence with LCIO input and output, no converters, with inter-event parallelism
ExternalData_Add_Test( marlinwrapper_tests NAME clicRec_lcio_mt COMMAND ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/clicRec_lcio_mt.sh DATA{${PROJECT_SOURCE_DIR}/test/input_files/testSimulation.slcio})

# Test the GeoSvc and TrackingCellIDEncodingSvc
add_test( clic_geo_test ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/geoTest_cld.py )

# Test for checking whether the converters can resolve relations accross
# multiple processors
ExternalData_Add_Test( marlinwrapper_tests NAME global_converter_maps COMMAND ${K4RUN} ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/test_global_converter_maps.py --EventDataSvc.input DATA{${PROJECT_SOURCE_DIR}/test/input_files/ttbar_podio230830_edm4hep_frame.root})

add_test( event_header_conversion bash -c "k4run ${CMAKE_CURRENT_SOURCE_DIR}/gaudi_opts/createEventHeader.py && anajob test.slcio | grep 'EVENT: 42'" )

ExternalData_Add_Target(marlinwrapper_tests)

set_tests_properties (
simple_processors
simple_processors2
clicRec
converter_constants
all_events_bounds
over_total_events
same_num_io
clicRec_lcio_mt
clicRec_edm4hep_input
clic_geo_test
global_converter_maps
event_header_conversion
PROPERTIES
ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so"
)

set_tests_properties(
clicRec clicRec_lcio_mt clicRec_edm4hep_input
PROPERTIES
ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so"
)
DEPENDS CLICPerformance_setup
)

set_tests_properties(
clicRec clicRec_lcio_mt clicRec_edm4hep_input
PROPERTIES
DEPENDS CLICPerformance_setup
)

endif(BASH_PROGRAM)
4 changes: 2 additions & 2 deletions test/gaudi_opts/simple_processors2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#
import os

from Gaudi.Configuration import *
from Gaudi.Configuration import DEBUG
from Configurables import ApplicationMgr

from Configurables import LcioEvent, EventDataSvc, MarlinProcessorWrapper
algList = []
Expand Down Expand Up @@ -90,7 +91,6 @@
}
algList.append(digiVxd2)

from Configurables import ApplicationMgr
ApplicationMgr( TopAlg = algList,
EvtSel = 'NONE',
EvtMax = 4,
Expand Down
7 changes: 2 additions & 5 deletions test/gaudi_opts/test_global_converter_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# limitations under the License.
#

import os

from Gaudi.Configuration import *
from Gaudi.Configuration import INFO, DEBUG
import sys

from Configurables import (
PodioInput,
Expand All @@ -33,9 +33,6 @@
)

evtsvc = k4DataSvc("EventDataSvc")
evtsvc.input = os.path.join(
"$TEST_DIR/inputFiles/", "ttbar_podio230830_edm4hep_frame.root"
)

podioInput = PodioInput("InputReader")
podioInput.collections = ["MCParticles"]
Expand Down
31 changes: 0 additions & 31 deletions test/scripts/all_events_bounds.sh

This file was deleted.

24 changes: 0 additions & 24 deletions test/scripts/clicGeoTest.sh

This file was deleted.

3 changes: 0 additions & 3 deletions test/scripts/clicRec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
# exit if command or variable fails
set -eu

# Clone CLICPerformance for input files
bash $TEST_DIR/scripts/setup_clic_performance.sh

cd CLICPerformance/clicConfig

python \
Expand Down
15 changes: 2 additions & 13 deletions test/scripts/clicRec_e4h_input.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,11 @@
# exit if command or variable fails
set -eu

# Clone CLICPerformance for input files
bash $TEST_DIR/scripts/setup_clic_performance.sh

cd CLICPerformance/clicConfig

export INPUTFILE=ttbar_podio230830_edm4hep_frame.root

# Download root file if not present
if [ ! -f $TEST_DIR/inputFiles/$INPUTFILE ]; then
echo "Input file not found. Getting it from key4hep..."
wget https://key4hep.web.cern.ch/testFiles/ddsimOutput/$INPUTFILE -P $TEST_DIR/inputFiles/
fi

k4run $EXAMPLE_DIR/clicRec_e4h_input.py
k4run $EXAMPLE_DIR/clicRec_e4h_input.py --EventDataSvc.input=$1

input_num_events=$(python $TEST_DIR/python/root_num_events.py $TEST_DIR/inputFiles/$INPUTFILE)
input_num_events=$(python $TEST_DIR/python/root_num_events.py $1)
output_num_events=$(python $TEST_DIR/python/root_num_events.py my_output.root)

# First check do we have the same number of events in input and output
Expand Down
11 changes: 1 addition & 10 deletions test/scripts/clicRec_lcio_mt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,13 @@
# exit if command or variable fails
set -eu

# Clone CLICPerformance for input files
bash $TEST_DIR/scripts/setup_clic_performance.sh

cd CLICPerformance/clicConfig

# Generate slcio file if not present
if [ ! -f $TEST_DIR/inputFiles/testSimulation.slcio ]; then
echo "Input file not found. Getting it from key4hep..."
wget https://key4hep.web.cern.ch/testFiles/ddsimOutput/testSimulation.slcio -P $TEST_DIR/inputFiles/
fi

if [ ! -f clicReconstruction_mt.py ]; then
ln -s $TEST_DIR/gaudi_opts/clicReconstruction_mt.py clicReconstruction_mt.py
fi

k4run clicReconstruction_mt.py
k4run clicReconstruction_mt.py --LcioEvent.Files $1

input_num_events=$(lcio_event_counter $TEST_DIR/inputFiles/testSimulation.slcio)
output_num_events=$(lcio_event_counter Output_REC_mt_lcio.slcio)
Expand Down
24 changes: 0 additions & 24 deletions test/scripts/event_header.sh

This file was deleted.

31 changes: 0 additions & 31 deletions test/scripts/global_converter_maps.sh

This file was deleted.

Loading

0 comments on commit d516ad9

Please sign in to comment.