File indexing completed on 2025-01-18 10:17:42
0001
0002
0003
0004
0005 #include "TerminationTests.h"
0006 #include "catch.hpp"
0007 #include <JANA/JApplication.h>
0008 #include <thread>
0009
0010
0011
0012 TEST_CASE("TerminationTests") {
0013
0014 JApplication app;
0015 app.SetParameterValue("jana:loglevel", "warn");
0016 auto processor = new CountingProcessor();
0017 app.Add(processor);
0018
0019 SECTION("Manual termination") {
0020
0021 auto source = new UnboundedSource();
0022 app.Add(source);
0023 app.Run(false);
0024 std::this_thread::sleep_for(std::chrono::milliseconds(500));
0025 app.Stop(true);
0026 REQUIRE(source->event_count > 0);
0027 REQUIRE(processor->finish_call_count == 1);
0028 REQUIRE(app.GetNEventsProcessed() == source->GetEmittedEventCount());
0029 }
0030
0031 SECTION("Self termination") {
0032
0033 auto source = new BoundedSource();
0034 app.Add(source);
0035 app.Run(true);
0036 REQUIRE(source->event_count == 10);
0037 REQUIRE(processor->processed_count == 10);
0038 REQUIRE(processor->finish_call_count == 1);
0039 REQUIRE(app.GetNEventsProcessed() == source->GetEmittedEventCount());
0040 }
0041
0042 SECTION("Interrupted during JEventSource::Open()") {
0043
0044 auto source = new InterruptedSource();
0045 app.Add(source);
0046 app.Run(true);
0047 REQUIRE(processor->finish_call_count == 1);
0048 REQUIRE(app.GetNEventsProcessed() == source->GetEmittedEventCount());
0049
0050 }
0051
0052 };
0053
0054