ifw-daq  1.0.0
IFW Data Acquisition modules
Classes | Functions
testDaqController.cpp File Reference

Unit test for daq::DaqControllerImpl More...

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

Go to the source code of this file.

Classes

class  TestLifeCycle
 Fixture for daq::DaqController life cycle tests. More...
 
struct  TestState
 Developer notes: DaqControllerImpl 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 (TestLifeCycle, ConstructorFailsIfNoSourcesAreProvided)
 
 TEST_F (TestLifeCycle, ConstructorFailsObservableStatusIdDoesNotMatchDaqPropertiesId)
 
 TEST_F (TestLifeCycle, ConstructorFailsIfAsyncOperationIsInvalid)
 
 TEST_F (TestLifeCycle, ConstructorSucceedsIfSingleMetadataSourceIsUsed)
 
 TEST_F (TestLifeCycle, DestructionAbortsAsyncWait)
 
 TEST_F (TestState, NotStarted)
 
 TEST_F (TestState, GetStatusReturnsSameStatusObject)
 
 TEST_F (TestState, CannotStopStoppedDaqControllerImpl)
 
 TEST_F (TestState, CannotAbortStoppedDaqControllerImpl)
 
 TEST_F (TestState, StartAsyncFailsIfFitsControllerFails)
 
 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, AbortDaqControllerImplInStateAborting)
 
 TEST_F (TestState, AbortDaqControllerImplInStateStarting)
 
 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, StopDaqControllerImplSuccessfully)
 
 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::DaqControllerImpl

Definition in file testDaqController.cpp.

Function Documentation

◆ SetAllSourceState()

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

Definition at line 77 of file testDaqController.cpp.

◆ SetSourceState()

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

Definition at line 70 of file testDaqController.cpp.

◆ TEST()

TEST ( TestBoost  ,
Unwrap   
)

Definition at line 288 of file testDaqController.cpp.

◆ TEST_F() [1/33]

TEST_F ( TestAwait  ,
AwaitAbortAllMetadataSources   
)

Definition at line 856 of file testDaqController.cpp.

◆ TEST_F() [2/33]

TEST_F ( TestAwait  ,
AwaitNonExistantSourceFails   
)

Definition at line 817 of file testDaqController.cpp.

◆ TEST_F() [3/33]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceIsOk   
)

Definition at line 835 of file testDaqController.cpp.

◆ TEST_F() [4/33]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceWhenConditionIsFulfilled   
)

Definition at line 878 of file testDaqController.cpp.

◆ TEST_F() [5/33]

TEST_F ( TestAwait  ,
AwaitTimeout   
)

Definition at line 825 of file testDaqController.cpp.

◆ TEST_F() [6/33]

TEST_F ( TestDaqControllerAwait  ,
AutomaticStop   
)

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

Definition at line 919 of file testDaqController.cpp.

◆ TEST_F() [7/33]

TEST_F ( TestDaqControllerAwait  ,
StartWillAwait   
)

Definition at line 909 of file testDaqController.cpp.

◆ TEST_F() [8/33]

TEST_F ( TestLifeCycle  ,
ConstructorFailsIfAsyncOperationIsInvalid   
)

Definition at line 320 of file testDaqController.cpp.

◆ TEST_F() [9/33]

TEST_F ( TestLifeCycle  ,
ConstructorFailsIfNoSourcesAreProvided   
)

Definition at line 303 of file testDaqController.cpp.

◆ TEST_F() [10/33]

TEST_F ( TestLifeCycle  ,
ConstructorFailsObservableStatusIdDoesNotMatchDaqPropertiesId   
)

Definition at line 310 of file testDaqController.cpp.

◆ TEST_F() [11/33]

TEST_F ( TestLifeCycle  ,
ConstructorSucceedsIfSingleMetadataSourceIsUsed   
)

Definition at line 344 of file testDaqController.cpp.

◆ TEST_F() [12/33]

TEST_F ( TestLifeCycle  ,
DestructionAbortsAsyncWait   
)

Definition at line 352 of file testDaqController.cpp.

◆ TEST_F() [13/33]

TEST_F ( TestNotStarted  ,
CanUpdateKeywords   
)

Definition at line 892 of file testDaqController.cpp.

◆ TEST_F() [14/33]

TEST_F ( TestState  ,
AbortAsyncIsOkIfNotStarted   
)

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

Definition at line 526 of file testDaqController.cpp.

◆ TEST_F() [15/33]

TEST_F ( TestState  ,
AbortAsyncReturnsWithErrorInsteadOfExceptionForTolerantPolicy   
)

Definition at line 671 of file testDaqController.cpp.

◆ TEST_F() [16/33]

TEST_F ( TestState  ,
AbortDaqControllerImplInStateAborting   
)

Definition at line 643 of file testDaqController.cpp.

◆ TEST_F() [17/33]

TEST_F ( TestState  ,
AbortDaqControllerImplInStateStarting   
)

Definition at line 660 of file testDaqController.cpp.

◆ TEST_F() [18/33]

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 580 of file testDaqController.cpp.

◆ TEST_F() [19/33]

TEST_F ( TestState  ,
CannotAbortStoppedDaqControllerImpl   
)

Definition at line 394 of file testDaqController.cpp.

◆ TEST_F() [20/33]

TEST_F ( TestState  ,
CannotStopStoppedDaqControllerImpl   
)

Definition at line 380 of file testDaqController.cpp.

◆ TEST_F() [21/33]

TEST_F ( TestState  ,
GetStatusReturnsSameStatusObject   
)

Definition at line 374 of file testDaqController.cpp.

◆ TEST_F() [22/33]

TEST_F ( TestState  ,
NewAbortSupersedesFailedAbortWithStrictPolicy   
)

Definition at line 756 of file testDaqController.cpp.

◆ TEST_F() [23/33]

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 709 of file testDaqController.cpp.

◆ TEST_F() [24/33]

TEST_F ( TestState  ,
NotStarted   
)

Definition at line 369 of file testDaqController.cpp.

◆ TEST_F() [25/33]

TEST_F ( TestState  ,
StartAsyncCompletesSuccessfully   
)

Definition at line 636 of file testDaqController.cpp.

◆ TEST_F() [26/33]

TEST_F ( TestState  ,
StartAsyncFailsIfFitsControllerFails   
)

Definition at line 407 of file testDaqController.cpp.

◆ TEST_F() [27/33]

TEST_F ( TestState  ,
StartAsyncReturnsExceptionalFutureInStateStarting   
)

Definition at line 448 of file testDaqController.cpp.

◆ TEST_F() [28/33]

TEST_F ( TestState  ,
StartingFailsToSendStartDaqWillAbortAndSetErrorFlagAndStayInStarting   
)

Definition at line 424 of file testDaqController.cpp.

◆ TEST_F() [29/33]

TEST_F ( TestState  ,
StopAsyncDoesNotThrowWithTolerantPolicy   
)

Definition at line 485 of file testDaqController.cpp.

◆ TEST_F() [30/33]

TEST_F ( TestState  ,
StopAsyncThrowsIfNotStarted   
)

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

Definition at line 479 of file testDaqController.cpp.

◆ TEST_F() [31/33]

TEST_F ( TestState  ,
StopAsyncThrowsIfStarting   
)

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

Definition at line 542 of file testDaqController.cpp.

◆ TEST_F() [32/33]

TEST_F ( TestState  ,
StopDaqControllerImplSuccessfully   
)

Definition at line 806 of file testDaqController.cpp.

◆ TEST_F() [33/33]

TEST_F ( TestStopped  ,
CannotUpdateKeywordsInStopped   
)

Definition at line 902 of file testDaqController.cpp.