ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
Classes | Functions
testOcmDaqController.cpp File Reference

Unit test for daq::OcmDaqController More...

#include <memory>
#include <stdexcept>
#include <thread>
#include <gtest/gtest.h>
#include <daq/daqController.hpp>
#include <daq/error.hpp>
#include <daq/op/abort.hpp>
#include <daq/op/awaitPrim.hpp>
#include <daq/op/initiate.hpp>
#include <daq/op/start.hpp>
#include <daq/op/stop.hpp>
#include "mock/metadaqifMock.hpp"
#include "mock/mockAsyncOperations.hpp"
#include "mock/recifMock.hpp"
#include "statusObserver.hpp"
#include "utils.hpp"

Go to the source code of this file.

Classes

class  TestOcmDaqControllerLifeCycle
 Fixture for daq::DaqController life cycle tests. More...
 
struct  TestState
 Developer notes: OcmDaqController use boost::when_all to compose futures. More...
 
struct  TestAwait
 
struct  TestNotStarted
 
struct  TestAcquiring
 
struct  TestStopped
 
struct  TestDaqControllerAwait
 

Functions

template<class Iterator >
void SetSourceState (Iterator begin, Iterator end, State state)
 
void SetAllSourceState (op::AsyncOpParams &params, State state)
 
 TEST (TestBoost, Unwrap)
 
 TEST_F (TestOcmDaqControllerLifeCycle, ConstructorFailsIfNoSourcesAreProvided)
 
 TEST_F (TestOcmDaqControllerLifeCycle, ConstructorFailsObservableStatusIdDoesNotMatchDaqContextId)
 
 TEST_F (TestOcmDaqControllerLifeCycle, ConstructorFailsIfAsyncOperationIsInvalid)
 
 TEST_F (TestOcmDaqControllerLifeCycle, ConstructorSucceedsIfSingleMetadataSourceIsUsed)
 
 TEST_F (TestOcmDaqControllerLifeCycle, DestructionAbortsAsyncWait)
 
 TEST_F (TestState, NotStarted)
 
 TEST_F (TestState, GetStatusReturnsSameStatusObject)
 
 TEST_F (TestState, CannotStopStoppedOcmDaqController)
 
 TEST_F (TestState, CannotAbortStoppedOcmDaqController)
 
 TEST_F (TestState, StartingFailsToSendStartDaqWillAbortAndSetErrorFlagAndStayInStarting)
 
 TEST_F (TestState, StartAsyncReturnsExceptionalFutureInStateStarting)
 
 TEST_F (TestState, StopAsyncThrowsIfNotStarted)
 It's possible to abort but not stop (and keep) More...
 
 TEST_F (TestState, StopAsyncDoesNotThrowWithTolerantPolicy)
 
 TEST_F (TestState, AbortAsyncIsOkIfNotStarted)
 It should be possible to abort a data acquisition even if it's not started. More...
 
 TEST_F (TestState, StopAsyncThrowsIfStarting)
 It's possible to abort but not stop (and keep) if data acquisition is starting. More...
 
 TEST_F (TestState, AbortingIsOkWhenStarting)
 Test sequence: More...
 
 TEST_F (TestState, StartAsyncCompletesSuccessfully)
 
 TEST_F (TestState, AbortOcmDaqControllerInStateAborting)
 
 TEST_F (TestState, AbortOcmDaqControllerInStateStarting)
 
 TEST_F (TestState, AbortAsyncReturnsWithErrorInsteadOfExceptionForTolerantPolicy)
 
 TEST_F (TestState, NewAbortSupersedesSuccessfulAbort)
 It is possible to abort even though an abort operation has already been started. More...
 
 TEST_F (TestState, NewAbortSupersedesFailedAbortWithStrictPolicy)
 
 TEST_F (TestState, StopOcmDaqControllerSuccessfully)
 
 TEST_F (TestAwait, AwaitNonExistantSourceFails)
 
 TEST_F (TestAwait, AwaitTimeout)
 
 TEST_F (TestAwait, AwaitStopSingleSourceIsOk)
 
 TEST_F (TestAwait, AwaitAbortAllMetadataSources)
 
 TEST_F (TestAwait, AwaitStopSingleSourceWhenConditionIsFulfilled)
 
 TEST_F (TestNotStarted, CanUpdateKeywords)
 
 TEST_F (TestStopped, CannotUpdateKeywordsInStopped)
 
 TEST_F (TestDaqControllerAwait, StartWillAwait)
 
 TEST_F (TestDaqControllerAwait, AutomaticStop)
 Tests that DaqController automatically stops DAQ when the await-op completes. More...
 

Detailed Description

Unit test for daq::OcmDaqController

Definition in file testOcmDaqController.cpp.

Function Documentation

◆ SetAllSourceState()

void SetAllSourceState ( op::AsyncOpParams params,
State  state 
)

Definition at line 78 of file testOcmDaqController.cpp.

◆ SetSourceState()

template<class Iterator >
void SetSourceState ( Iterator  begin,
Iterator  end,
State  state 
)

Definition at line 71 of file testOcmDaqController.cpp.

◆ TEST()

TEST ( TestBoost  ,
Unwrap   
)

Definition at line 284 of file testOcmDaqController.cpp.

◆ TEST_F() [1/32]

TEST_F ( TestAwait  ,
AwaitAbortAllMetadataSources   
)

Definition at line 798 of file testOcmDaqController.cpp.

◆ TEST_F() [2/32]

TEST_F ( TestAwait  ,
AwaitNonExistantSourceFails   
)

Definition at line 761 of file testOcmDaqController.cpp.

◆ TEST_F() [3/32]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceIsOk   
)

Definition at line 777 of file testOcmDaqController.cpp.

◆ TEST_F() [4/32]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceWhenConditionIsFulfilled   
)

Definition at line 819 of file testOcmDaqController.cpp.

◆ TEST_F() [5/32]

TEST_F ( TestAwait  ,
AwaitTimeout   
)

Definition at line 768 of file testOcmDaqController.cpp.

◆ TEST_F() [6/32]

TEST_F ( TestDaqControllerAwait  ,
AutomaticStop   
)

Tests that DaqController automatically stops DAQ when the await-op completes.

Definition at line 859 of file testOcmDaqController.cpp.

◆ TEST_F() [7/32]

TEST_F ( TestDaqControllerAwait  ,
StartWillAwait   
)

Definition at line 849 of file testOcmDaqController.cpp.

◆ TEST_F() [8/32]

TEST_F ( TestNotStarted  ,
CanUpdateKeywords   
)

Definition at line 833 of file testOcmDaqController.cpp.

◆ TEST_F() [9/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfAsyncOperationIsInvalid   
)

Definition at line 313 of file testOcmDaqController.cpp.

◆ TEST_F() [10/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfNoSourcesAreProvided   
)

Definition at line 298 of file testOcmDaqController.cpp.

◆ TEST_F() [11/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsObservableStatusIdDoesNotMatchDaqContextId   
)

Definition at line 304 of file testOcmDaqController.cpp.

◆ TEST_F() [12/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorSucceedsIfSingleMetadataSourceIsUsed   
)

Definition at line 339 of file testOcmDaqController.cpp.

◆ TEST_F() [13/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
DestructionAbortsAsyncWait   
)

Definition at line 345 of file testOcmDaqController.cpp.

◆ TEST_F() [14/32]

TEST_F ( TestState  ,
AbortAsyncIsOkIfNotStarted   
)

It should be possible to abort a data acquisition even if it's not started.

Definition at line 491 of file testOcmDaqController.cpp.

◆ TEST_F() [15/32]

TEST_F ( TestState  ,
AbortAsyncReturnsWithErrorInsteadOfExceptionForTolerantPolicy   
)

Definition at line 628 of file testOcmDaqController.cpp.

◆ TEST_F() [16/32]

TEST_F ( TestState  ,
AbortingIsOkWhenStarting   
)

Test sequence:

  1. Send StartDaq
  2. Send AbortDaq
  3. StartDaq still succeeds in this case (simulates serial handling of client requests at source).
  4. AbortDaq suceeds.

Definition at line 542 of file testOcmDaqController.cpp.

◆ TEST_F() [17/32]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateAborting   
)

Definition at line 601 of file testOcmDaqController.cpp.

◆ TEST_F() [18/32]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateStarting   
)

Definition at line 617 of file testOcmDaqController.cpp.

◆ TEST_F() [19/32]

TEST_F ( TestState  ,
CannotAbortStoppedOcmDaqController   
)

Definition at line 385 of file testOcmDaqController.cpp.

◆ TEST_F() [20/32]

TEST_F ( TestState  ,
CannotStopStoppedOcmDaqController   
)

Definition at line 372 of file testOcmDaqController.cpp.

◆ TEST_F() [21/32]

TEST_F ( TestState  ,
GetStatusReturnsSameStatusObject   
)

Definition at line 367 of file testOcmDaqController.cpp.

◆ TEST_F() [22/32]

TEST_F ( TestState  ,
NewAbortSupersedesFailedAbortWithStrictPolicy   
)

Definition at line 706 of file testOcmDaqController.cpp.

◆ TEST_F() [23/32]

TEST_F ( TestState  ,
NewAbortSupersedesSuccessfulAbort   
)

It is possible to abort even though an abort operation has already been started.

Nothing special happens in this case though.

Todo:
The command bein superseeded should probably fail.

Definition at line 662 of file testOcmDaqController.cpp.

◆ TEST_F() [24/32]

TEST_F ( TestState  ,
NotStarted   
)

Definition at line 363 of file testOcmDaqController.cpp.

◆ TEST_F() [25/32]

TEST_F ( TestState  ,
StartAsyncCompletesSuccessfully   
)

Definition at line 595 of file testOcmDaqController.cpp.

◆ TEST_F() [26/32]

TEST_F ( TestState  ,
StartAsyncReturnsExceptionalFutureInStateStarting   
)

Definition at line 419 of file testOcmDaqController.cpp.

◆ TEST_F() [27/32]

TEST_F ( TestState  ,
StartingFailsToSendStartDaqWillAbortAndSetErrorFlagAndStayInStarting   
)

Definition at line 398 of file testOcmDaqController.cpp.

◆ TEST_F() [28/32]

TEST_F ( TestState  ,
StopAsyncDoesNotThrowWithTolerantPolicy   
)

Definition at line 453 of file testOcmDaqController.cpp.

◆ TEST_F() [29/32]

TEST_F ( TestState  ,
StopAsyncThrowsIfNotStarted   
)

It's possible to abort but not stop (and keep)

Definition at line 447 of file testOcmDaqController.cpp.

◆ TEST_F() [30/32]

TEST_F ( TestState  ,
StopAsyncThrowsIfStarting   
)

It's possible to abort but not stop (and keep) if data acquisition is starting.

Definition at line 506 of file testOcmDaqController.cpp.

◆ TEST_F() [31/32]

TEST_F ( TestState  ,
StopOcmDaqControllerSuccessfully   
)

Definition at line 751 of file testOcmDaqController.cpp.

◆ TEST_F() [32/32]

TEST_F ( TestStopped  ,
CannotUpdateKeywordsInStopped   
)

Definition at line 842 of file testOcmDaqController.cpp.