From c939d75f3796b471bbc9de5384ee53b4ac84a8a9 Mon Sep 17 00:00:00 2001 From: blaakmeer <sdos@astron.nl> Date: Thu, 28 Sep 2006 13:13:44 +0000 Subject: [PATCH] BugID: 802 Added abort handler to check application cleanup --- MAC/Test/GCF/MAC/src/Application1.cc | 23 ++++++++++++++++++++--- MAC/Test/GCF/MAC/src/Application1.h | 3 ++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/MAC/Test/GCF/MAC/src/Application1.cc b/MAC/Test/GCF/MAC/src/Application1.cc index 57fb1895f1b..b80e39bc83d 100644 --- a/MAC/Test/GCF/MAC/src/Application1.cc +++ b/MAC/Test/GCF/MAC/src/Application1.cc @@ -14,6 +14,7 @@ #include <math.h> #include <stdio.h> #include <unistd.h> +#include <csignal> #include "TST_Protocol.ph" #include <Suite/suite.h> @@ -75,6 +76,10 @@ Application::~Application() } +void Application::abort() +{ + FINISH; +} GCFEvent::TResult Application::initial(GCFEvent& e, GCFPortInterface& /*p*/) { @@ -1352,16 +1357,28 @@ void Application::run() } // namespace GCF } // namespace LOFAR -using namespace LOFAR::GCF; +static LOFAR::GCF::Test::Application* pApp = 0; + +void sigintHandler(/*@unused@*/int signum) +{ + LOG_INFO(LOFAR::formatString("SIGINT signal detected (%d)",signum)); + if(0 != pApp) + pApp->abort(); +} int main(int argc, char* argv[]) { - TM::GCFTask::init(argc, argv); + LOFAR::GCF::TM::GCFTask::init(argc, argv); LOG_INFO("MACProcessScope: GCF.TEST.MAC.App1"); Suite s("GCF Test", &cerr); - s.addTest(new LOFAR::GCF::Test::Application); + pApp = new LOFAR::GCF::Test::Application; + s.addTest(pApp); + + /* install ctrl-c signal handler */ + (void)signal(SIGINT,sigintHandler); + s.run(); s.report(); s.free(); diff --git a/MAC/Test/GCF/MAC/src/Application1.h b/MAC/Test/GCF/MAC/src/Application1.h index a80d95a5b47..7d8899d9e05 100644 --- a/MAC/Test/GCF/MAC/src/Application1.h +++ b/MAC/Test/GCF/MAC/src/Application1.h @@ -25,7 +25,8 @@ class Application : public TM::GCFTask, public ::Test Application(); virtual ~Application(); - void run(); + void run(); + void abort(); private: TM::GCFEvent::TResult initial(TM::GCFEvent& e, TM::GCFPortInterface& p); -- GitLab