ifw-daq  3.0.1
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  TestAwaitWithPrimSource
 Fixture for. More...
 

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 (TestAwaitWithPrimSource, AwaitStopSingleSourceIsOk)
 
 TEST_F (TestAwaitWithPrimSource, AwaitAbortAllSources)
 
 TEST_F (TestAwait, AwaitStopSingleSourceWhenConditionIsFulfilled)
 
 TEST_F (TestNotStarted, CanUpdateKeywords)
 
 TEST_F (TestStopped, CannotUpdateKeywordsInStopped)
 
 TEST_F (TestAwaitWithPrimSource, StartWillAwait)
 
 TEST_F (TestAwaitWithPrimSource, 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 288 of file testOcmDaqController.cpp.

◆ TEST_F() [1/32]

TEST_F ( TestAwait  ,
AwaitNonExistantSourceFails   
)

Definition at line 775 of file testOcmDaqController.cpp.

◆ TEST_F() [2/32]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceWhenConditionIsFulfilled   
)

Definition at line 837 of file testOcmDaqController.cpp.

◆ TEST_F() [3/32]

TEST_F ( TestAwait  ,
AwaitTimeout   
)

Definition at line 782 of file testOcmDaqController.cpp.

◆ TEST_F() [4/32]

TEST_F ( TestAwaitWithPrimSource  ,
AutomaticStop   
)

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

Definition at line 877 of file testOcmDaqController.cpp.

◆ TEST_F() [5/32]

TEST_F ( TestAwaitWithPrimSource  ,
AwaitAbortAllSources   
)

Definition at line 814 of file testOcmDaqController.cpp.

◆ TEST_F() [6/32]

TEST_F ( TestAwaitWithPrimSource  ,
AwaitStopSingleSourceIsOk   
)

Definition at line 791 of file testOcmDaqController.cpp.

◆ TEST_F() [7/32]

TEST_F ( TestAwaitWithPrimSource  ,
StartWillAwait   
)

Definition at line 867 of file testOcmDaqController.cpp.

◆ TEST_F() [8/32]

TEST_F ( TestNotStarted  ,
CanUpdateKeywords   
)

Definition at line 851 of file testOcmDaqController.cpp.

◆ TEST_F() [9/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfAsyncOperationIsInvalid   
)

Definition at line 317 of file testOcmDaqController.cpp.

◆ TEST_F() [10/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfNoSourcesAreProvided   
)

Definition at line 302 of file testOcmDaqController.cpp.

◆ TEST_F() [11/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsObservableStatusIdDoesNotMatchDaqContextId   
)

Definition at line 308 of file testOcmDaqController.cpp.

◆ TEST_F() [12/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorSucceedsIfSingleMetadataSourceIsUsed   
)

Definition at line 350 of file testOcmDaqController.cpp.

◆ TEST_F() [13/32]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
DestructionAbortsAsyncWait   
)

Definition at line 356 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 505 of file testOcmDaqController.cpp.

◆ TEST_F() [15/32]

TEST_F ( TestState  ,
AbortAsyncReturnsWithErrorInsteadOfExceptionForTolerantPolicy   
)

Definition at line 642 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 556 of file testOcmDaqController.cpp.

◆ TEST_F() [17/32]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateAborting   
)

Definition at line 615 of file testOcmDaqController.cpp.

◆ TEST_F() [18/32]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateStarting   
)

Definition at line 631 of file testOcmDaqController.cpp.

◆ TEST_F() [19/32]

TEST_F ( TestState  ,
CannotAbortStoppedOcmDaqController   
)

Definition at line 396 of file testOcmDaqController.cpp.

◆ TEST_F() [20/32]

TEST_F ( TestState  ,
CannotStopStoppedOcmDaqController   
)

Definition at line 383 of file testOcmDaqController.cpp.

◆ TEST_F() [21/32]

TEST_F ( TestState  ,
GetStatusReturnsSameStatusObject   
)

Definition at line 378 of file testOcmDaqController.cpp.

◆ TEST_F() [22/32]

TEST_F ( TestState  ,
NewAbortSupersedesFailedAbortWithStrictPolicy   
)

Definition at line 720 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 676 of file testOcmDaqController.cpp.

◆ TEST_F() [24/32]

TEST_F ( TestState  ,
NotStarted   
)

Definition at line 374 of file testOcmDaqController.cpp.

◆ TEST_F() [25/32]

TEST_F ( TestState  ,
StartAsyncCompletesSuccessfully   
)

Definition at line 609 of file testOcmDaqController.cpp.

◆ TEST_F() [26/32]

TEST_F ( TestState  ,
StartAsyncReturnsExceptionalFutureInStateStarting   
)

Definition at line 430 of file testOcmDaqController.cpp.

◆ TEST_F() [27/32]

TEST_F ( TestState  ,
StartingFailsToSendStartDaqWillAbortAndSetErrorFlagAndStayInStarting   
)

Definition at line 409 of file testOcmDaqController.cpp.

◆ TEST_F() [28/32]

TEST_F ( TestState  ,
StopAsyncDoesNotThrowWithTolerantPolicy   
)

Definition at line 464 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 458 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 520 of file testOcmDaqController.cpp.

◆ TEST_F() [31/32]

TEST_F ( TestState  ,
StopOcmDaqControllerSuccessfully   
)

Definition at line 765 of file testOcmDaqController.cpp.

◆ TEST_F() [32/32]

TEST_F ( TestStopped  ,
CannotUpdateKeywordsInStopped   
)

Definition at line 860 of file testOcmDaqController.cpp.