From b2b2d4891e813ecde1e1ed97ca6547f154f63994 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 21 Oct 2024 16:32:53 +0200 Subject: [PATCH 1/2] Add test using signal DDCore handler --- examples/ClientTests/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index a32a0cc97..a6b208cda 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -469,6 +469,15 @@ dd4hep_add_test_reg( box_shape_build_type REGEX_FAIL "Exception;EXCEPTION;ERROR" ) # +# Test interrupt handling in the middle of the geometry construction +dd4hep_add_test_reg( ClientTests_interrupt_geometry_construction + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" + EXEC_ARGS geoDisplay -compact ${ClientTestsEx_INSTALL}/compact/InterruptTrigger.xml + -load -print INFO + REGEX_PASS "\\+\\+\\+ Caught signal: 2 context: 0xfeedbabe. exit process." + REGEX_FAIL "Exception;EXCEPTION;ERROR" +) +# # EXEC_ARGS test_with_root.sh ${script} # if (DD4HEP_USE_GEANT4) From cdd0c26496f8bef182760abc83eed82b2d5076e3 Mon Sep 17 00:00:00 2001 From: Markus Frank Date: Mon, 21 Oct 2024 16:33:04 +0200 Subject: [PATCH 2/2] Add test using signal DDCore handler --- .../ClientTests/compact/InterruptTrigger.xml | 104 ++++++++++++++++++ examples/ClientTests/src/InterruptTrigger.cpp | 50 +++++++++ 2 files changed, 154 insertions(+) create mode 100644 examples/ClientTests/compact/InterruptTrigger.xml create mode 100644 examples/ClientTests/src/InterruptTrigger.cpp diff --git a/examples/ClientTests/compact/InterruptTrigger.xml b/examples/ClientTests/compact/InterruptTrigger.xml new file mode 100644 index 000000000..3cc6512b6 --- /dev/null +++ b/examples/ClientTests/compact/InterruptTrigger.xml @@ -0,0 +1,104 @@ + + + + + + Alignment test with 2 simple boxes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + system:8,x:24:-12,y:-12 + + + + system:8,x:24:-12,y:-12 + + + + + + + + + diff --git a/examples/ClientTests/src/InterruptTrigger.cpp b/examples/ClientTests/src/InterruptTrigger.cpp new file mode 100644 index 000000000..43b664cec --- /dev/null +++ b/examples/ClientTests/src/InterruptTrigger.cpp @@ -0,0 +1,50 @@ +//========================================================================== +// AIDA Detector description implementation +//-------------------------------------------------------------------------- +// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) +// All rights reserved. +// +// For the licensing terms see $DD4hepINSTALL/LICENSE. +// For the list of contributors see $DD4hepINSTALL/doc/CREDITS. +// +// Author : M.Frank +// +//========================================================================== + +// Framework includes +#include "DD4hep/DetFactoryHelper.h" +#include "DD4hep/SignalHandler.h" +#include "DD4hep/Printout.h" + +// C/C++ include files +#include +#include +#include + +using namespace dd4hep; + +static bool signal_handler(void* user_context, int signal) { + printout(ALWAYS,"SignalHandler", + "+++ Caught signal: %d context: %p. exit process.", + signal, user_context); + ::fflush(stdout); + ::exit(EINVAL); + return true; +} + +static Ref_t create_detector(Detector& , xml_h e, SensitiveDetector ) { + // XML detector object: DDCore/XML/XMLDetector.h + xml_dim_t x_det = e; + //Create the DetElement for dd4hep + DetElement d_det(x_det.nameStr(),x_det.id()); + + SignalHandler handler; + handler.registerHandler(SIGINT, (void*)0xFEEDBABE, signal_handler); + + printout(ALWAYS,"SignalTrigger","+++ Sending interrupt signal to self..."); + ::kill(::getpid(), SIGINT); + + return d_det; +} + +DECLARE_DETELEMENT(InterruptTrigger,create_detector)