ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
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/keywordFormatterMock.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)
 
 TEST_F (TestState, StopAsyncDoesNotThrowWithTolerantPolicy)
 
 TEST_F (TestState, AbortAsyncIsOkIfNotStarted)
 It should be possible to abort a data acquisition even if it's not started.
 
 TEST_F (TestState, StopAsyncThrowsIfStarting)
 It's possible to abort but not stop (and keep) if data acquisition is starting.
 
 TEST_F (TestState, AbortingIsOkWhenStarting)
 Test sequence:
 
 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.
 
 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 (TestNotStarted, UpdateKeywordFailureDoesNotUpdateKeywords)
 
 TEST_F (TestStopped, CannotUpdateKeywordsInStopped)
 
 TEST_F (TestAwaitWithPrimSource, StartWillAwait)
 
 TEST_F (TestAwaitWithPrimSource, AutomaticStop)
 Tests that DaqController automatically stops DAQ when the await-op completes.
 

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 85 of file testOcmDaqController.cpp.

◆ SetSourceState()

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

Definition at line 78 of file testOcmDaqController.cpp.

◆ TEST()

TEST ( TestBoost  ,
Unwrap   
)

Definition at line 299 of file testOcmDaqController.cpp.

◆ TEST_F() [1/33]

TEST_F ( TestAwait  ,
AwaitNonExistantSourceFails   
)

Definition at line 795 of file testOcmDaqController.cpp.

◆ TEST_F() [2/33]

TEST_F ( TestAwait  ,
AwaitStopSingleSourceWhenConditionIsFulfilled   
)

Definition at line 857 of file testOcmDaqController.cpp.

◆ TEST_F() [3/33]

TEST_F ( TestAwait  ,
AwaitTimeout   
)

Definition at line 802 of file testOcmDaqController.cpp.

◆ TEST_F() [4/33]

TEST_F ( TestAwaitWithPrimSource  ,
AutomaticStop   
)

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

Definition at line 924 of file testOcmDaqController.cpp.

◆ TEST_F() [5/33]

TEST_F ( TestAwaitWithPrimSource  ,
AwaitAbortAllSources   
)

Definition at line 834 of file testOcmDaqController.cpp.

◆ TEST_F() [6/33]

TEST_F ( TestAwaitWithPrimSource  ,
AwaitStopSingleSourceIsOk   
)

Definition at line 811 of file testOcmDaqController.cpp.

◆ TEST_F() [7/33]

TEST_F ( TestAwaitWithPrimSource  ,
StartWillAwait   
)

Definition at line 914 of file testOcmDaqController.cpp.

◆ TEST_F() [8/33]

TEST_F ( TestNotStarted  ,
CanUpdateKeywords   
)

Definition at line 871 of file testOcmDaqController.cpp.

◆ TEST_F() [9/33]

TEST_F ( TestNotStarted  ,
UpdateKeywordFailureDoesNotUpdateKeywords   
)

Definition at line 887 of file testOcmDaqController.cpp.

◆ TEST_F() [10/33]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfAsyncOperationIsInvalid   
)

Definition at line 330 of file testOcmDaqController.cpp.

◆ TEST_F() [11/33]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsIfNoSourcesAreProvided   
)

Definition at line 313 of file testOcmDaqController.cpp.

◆ TEST_F() [12/33]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorFailsObservableStatusIdDoesNotMatchDaqContextId   
)

Definition at line 320 of file testOcmDaqController.cpp.

◆ TEST_F() [13/33]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
ConstructorSucceedsIfSingleMetadataSourceIsUsed   
)

Definition at line 367 of file testOcmDaqController.cpp.

◆ TEST_F() [14/33]

TEST_F ( TestOcmDaqControllerLifeCycle  ,
DestructionAbortsAsyncWait   
)

Definition at line 375 of file testOcmDaqController.cpp.

◆ TEST_F() [15/33]

TEST_F ( TestState  ,
AbortAsyncIsOkIfNotStarted   
)

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

Definition at line 525 of file testOcmDaqController.cpp.

◆ TEST_F() [16/33]

TEST_F ( TestState  ,
AbortAsyncReturnsWithErrorInsteadOfExceptionForTolerantPolicy   
)

Definition at line 662 of file testOcmDaqController.cpp.

◆ TEST_F() [17/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 576 of file testOcmDaqController.cpp.

◆ TEST_F() [18/33]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateAborting   
)

Definition at line 635 of file testOcmDaqController.cpp.

◆ TEST_F() [19/33]

TEST_F ( TestState  ,
AbortOcmDaqControllerInStateStarting   
)

Definition at line 651 of file testOcmDaqController.cpp.

◆ TEST_F() [20/33]

TEST_F ( TestState  ,
CannotAbortStoppedOcmDaqController   
)

Definition at line 415 of file testOcmDaqController.cpp.

◆ TEST_F() [21/33]

TEST_F ( TestState  ,
CannotStopStoppedOcmDaqController   
)

Definition at line 402 of file testOcmDaqController.cpp.

◆ TEST_F() [22/33]

TEST_F ( TestState  ,
GetStatusReturnsSameStatusObject   
)

Definition at line 397 of file testOcmDaqController.cpp.

◆ TEST_F() [23/33]

TEST_F ( TestState  ,
NewAbortSupersedesFailedAbortWithStrictPolicy   
)

Definition at line 740 of file testOcmDaqController.cpp.

◆ TEST_F() [24/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 696 of file testOcmDaqController.cpp.

◆ TEST_F() [25/33]

TEST_F ( TestState  ,
NotStarted   
)

Definition at line 393 of file testOcmDaqController.cpp.

◆ TEST_F() [26/33]

TEST_F ( TestState  ,
StartAsyncCompletesSuccessfully   
)

Definition at line 629 of file testOcmDaqController.cpp.

◆ TEST_F() [27/33]

TEST_F ( TestState  ,
StartAsyncReturnsExceptionalFutureInStateStarting   
)

Definition at line 449 of file testOcmDaqController.cpp.

◆ TEST_F() [28/33]

TEST_F ( TestState  ,
StartingFailsToSendStartDaqWillAbortAndSetErrorFlagAndStayInStarting   
)

Definition at line 428 of file testOcmDaqController.cpp.

◆ TEST_F() [29/33]

TEST_F ( TestState  ,
StopAsyncDoesNotThrowWithTolerantPolicy   
)

Definition at line 483 of file testOcmDaqController.cpp.

◆ TEST_F() [30/33]

TEST_F ( TestState  ,
StopAsyncThrowsIfNotStarted   
)

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

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

◆ TEST_F() [32/33]

TEST_F ( TestState  ,
StopOcmDaqControllerSuccessfully   
)

Definition at line 785 of file testOcmDaqController.cpp.

◆ TEST_F() [33/33]

TEST_F ( TestStopped  ,
CannotUpdateKeywordsInStopped   
)

Definition at line 907 of file testOcmDaqController.cpp.