Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:43

0001 
0002 // Copyright 2021, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 
0006 #include "TimeoutTests.h"
0007 #include "catch.hpp"
0008 
0009 #include <JANA/JApplication.h>
0010 
0011 TEST_CASE("TimeoutTests", "[.][performance]") {
0012 
0013     std::cout << "Running timeout tests..." << std::endl;
0014     JApplication app;
0015     app.SetTimeoutEnabled(true);
0016     app.SetTicker(true);
0017     app.SetParameterValue("jana:timeout", 1);
0018     app.SetParameterValue("jana:warmup_timeout", 3);
0019 
0020 
0021     SECTION("Timeout in the event source on the first event") {
0022         app.Add(new SourceWithTimeout(1));
0023         app.Add(new ProcessorWithTimeout(-1));
0024         app.Run(true);
0025         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Timeout);
0026     }
0027 
0028     SECTION("Timeout in the event source on the 5th event") {
0029         app.Add(new SourceWithTimeout(5));
0030         app.Add(new ProcessorWithTimeout(-1));
0031         app.Run(true);
0032         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Timeout);
0033     }
0034 
0035     SECTION("Timeout in the event processor on the first event") {
0036         app.Add(new SourceWithTimeout(-1));
0037         app.Add(new ProcessorWithTimeout(1));
0038         app.Run(true);
0039         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Timeout);
0040     }
0041 
0042     SECTION("Timeout in the event processor on the 5th event") {
0043         app.Add(new SourceWithTimeout(-1));
0044         app.Add(new ProcessorWithTimeout(5));
0045         app.Run(true);
0046         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Timeout);
0047     }
0048 
0049     SECTION("A slow event source for the first event is fine") {
0050 
0051         int first_event_ms = 2000;
0052         app.Add(new SourceWithTimeout(-1, first_event_ms));
0053         app.Add(new ProcessorWithTimeout(-1, 0));
0054         app.Run(true);
0055         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Success);
0056     }
0057 
0058     SECTION("A slow event processor for the first event is fine") {
0059 
0060         int first_event_ms = 2000;
0061         app.Add(new SourceWithTimeout(-1, 0));
0062         app.Add(new ProcessorWithTimeout(-1, first_event_ms));
0063         app.Run(true);
0064         REQUIRE(app.GetExitCode() == (int) JApplication::ExitCode::Success);
0065     }
0066 
0067 
0068 }
0069