Skip to content

Commit

Permalink
test file contents with script rather than algo
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila committed Sep 10, 2024
1 parent 29768fb commit a52175f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 119 deletions.
4 changes: 1 addition & 3 deletions test/k4FWCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,12 @@ add_test_with_env(FunctionalFilterFile options/ExampleFunctionalFilterFile.py)
add_test_with_env(FunctionalMetadata options/ExampleFunctionalMetadata.py)
add_test_with_env(FunctionalMetadataOldAlgorithm options/ExampleFunctionalMetadataOldAlgorithm.py)
add_test_with_env(createEventHeaderConcurrent options/createEventHeaderConcurrent.py)
add_test_with_env(checkEventHeaderConcurrent options/checkEventHeaderConcurrent.py PROPERTIES DEPENDS createEventHeaderConcurrent)


add_test_with_env(FunctionalWrongImport options/ExampleFunctionalWrongImport.py)
set_tests_properties(FunctionalWrongImport PROPERTIES PASS_REGULAR_EXPRESSION "ImportError: Importing ApplicationMgr or IOSvc from Configurables is not allowed.")

add_test(NAME FunctionalCheckFiles COMMAND python3 ${CMAKE_CURRENT_LIST_DIR}/options/CheckOutputFiles.py)
set_tests_properties(FunctionalCheckFiles PROPERTIES DEPENDS "FunctionalFile;FunctionalMTFile;FunctionalMultipleFile;FunctionalOutputCommands;FunctionalProducerAbsolutePath;FunctionalTransformerRuntimeEmpty;FunctionalMix;FunctionalMixIOSvc;FunctionalTransformerHist;FunctionalCollectionMerger;FunctionalFilterFile;FunctionalMetadata;FunctionalMetadataOldAlgorithm")
set_tests_properties(FunctionalCheckFiles PROPERTIES DEPENDS "FunctionalFile;FunctionalMTFile;FunctionalMultipleFile;FunctionalOutputCommands;FunctionalProducerAbsolutePath;FunctionalTransformerRuntimeEmpty;FunctionalMix;FunctionalMixIOSvc;FunctionalTransformerHist;FunctionalCollectionMerger;FunctionalFilterFile;FunctionalMetadata;FunctionalMetadataOldAlgorithm;createEventHeaderConcurrent")

# Do this after checking the files not to overwrite them
add_test_with_env(FunctionalFile_toolong options/ExampleFunctionalFile.py -n 999 PROPERTIES DEPENDS FunctionalCheckFiles PASS_REGULAR_EXPRESSION
Expand Down
21 changes: 21 additions & 0 deletions test/k4FWCoreTest/options/CheckOutputFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,24 @@ def check_events(filename, number):
raise RuntimeError(
f"Metadata parameter {key} does not match the expected value, got {metadata.get_parameter(key)} but expected {value}"
)

reader = podio.root_io.Reader("eventHeaderConcurrent.root")
events = reader.get("events")
expected_events_length = 10
expected_run_number = 42
expected_event_numbers = set(range(42, 42 + expected_events_length))
seen_event_numbers = set()
if len(events) != expected_events_length:
raise RuntimeError("Number of events does not match expected number")
for frame in events:
event_header = frame.get("EventHeader")[0]
if (run_number := event_header.getRunNumber()) != expected_run_number:
raise RuntimeError(
f"Run number is not set correctly (expected {expected_run_number}, actual {run_number})"
)
event_number = event_header.getEventNumber()
if event_number not in expected_event_numbers:
raise RuntimeError(f"Event number {event_number} is not in expected numbers")
if event_number in seen_event_numbers:
raise RuntimeError(f"Event number {event_number} is duplicated")
seen_event_numbers.add(event_number)
48 changes: 0 additions & 48 deletions test/k4FWCoreTest/options/checkEventHeaderConcurrent.py

This file was deleted.

68 changes: 0 additions & 68 deletions test/k4FWCoreTest/src/components/ExampleEventHeaderCheck.cpp

This file was deleted.

0 comments on commit a52175f

Please sign in to comment.