ifw-daq  2.1.0-pre1
IFW Data Acquisition modules
mockAsyncProcess.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * @ingroup daq_common_libdpm
4  * @copyright (c) Copyright ESO 2022
5  * All Rights Reserved
6  * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7  *
8  * @brief Mocks for daq::RsyncAsyncProcessIf
9  */
10 #ifndef DAQ_DPM_MOCK_MOCKASYNCPROCESS_HPP
11 #define DAQ_DPM_MOCK_MOCKASYNCPROCESS_HPP
12 
13 #include <gmock/gmock.h>
14 
16 
17 namespace daq {
18 /**
19  * Combined fake/mock
20  */
21 struct MockAsyncProcess : virtual AsyncProcessIf {
22  virtual boost::future<int> Initiate() override {
23  return promise.get_future();
24  }
25  MOCK_METHOD(std::optional<pid_t>, GetPid, (), (const, noexcept, override));
26 
27  MOCK_METHOD(std::error_code, Abort, (), (noexcept, override));
28  MOCK_METHOD(std::error_code, Signal, (int), (override, noexcept));
29  MOCK_METHOD(std::vector<std::string> const&, GetArguments, (), (const, override, noexcept));
30  MOCK_METHOD(bool, IsRunning, (), (const, noexcept, override));
31 
33  boost::signals2::connection ConnectStdout(SigOutStream::slot_type const& slot) override {
34  return stdout.connect(slot);
35  }
36  boost::signals2::connection ConnectStderr(SigOutStream::slot_type const& slot) override {
37  return stderr.connect(slot);
38  }
39 
42  boost::promise<int> promise;
43 };
44 
47  boost::signals2::connection ConnectProgress(SigProgress::slot_type const& slot) override {
48  return progress.connect(slot);
49  }
51 };
52 } // namespace daq
53 #endif // #ifndef DAQ_DPM_MOCK_MOCKASYNCPROCESS_HPP
daq::MockAsyncProcess::stdout
SigOutStream stdout
Definition: mockAsyncProcess.hpp:40
daq::MockAsyncProcess::MOCK_METHOD
MOCK_METHOD(std::error_code, Signal,(int),(override, noexcept))
daq::MockRsyncAsyncProcess::ConnectProgress
boost::signals2::connection ConnectProgress(SigProgress::slot_type const &slot) override
Connect to progress signal.
Definition: mockAsyncProcess.hpp:47
daq::AsyncProcessIf::GetArguments
virtual std::vector< std::string > const & GetArguments() const noexcept=0
daq::MockAsyncProcess::MOCK_METHOD
MOCK_METHOD(std::optional< pid_t >, GetPid,(),(const, noexcept, override))
daq::MockAsyncProcess::ConnectStderr
boost::signals2::connection ConnectStderr(SigOutStream::slot_type const &slot) override
Connect slot to line-buffered stderr signal.
Definition: mockAsyncProcess.hpp:36
daq::MockAsyncProcess::Initiate
virtual boost::future< int > Initiate() override
Initiates async operation by executing the specified process.
Definition: mockAsyncProcess.hpp:22
daq::MockAsyncProcess::promise
boost::promise< int > promise
Definition: mockAsyncProcess.hpp:42
daq::MockRsyncAsyncProcess
Definition: mockAsyncProcess.hpp:45
daq::AsyncProcessIf::Signal
virtual std::error_code Signal(int sig) noexcept=0
Send signal to process.
daq
Definition: asyncProcess.cpp:15
daq::AsyncProcessIf::Abort
virtual std::error_code Abort() noexcept=0
Aborts the operation by terminating process which completes the operation.
daq::MockAsyncProcess::MOCK_METHOD
MOCK_METHOD(std::error_code, Abort,(),(noexcept, override))
daq::MockRsyncAsyncProcess::progress
SigProgress progress
Definition: mockAsyncProcess.hpp:50
daq::MockAsyncProcess
Combined fake/mock.
Definition: mockAsyncProcess.hpp:21
daq::MockRsyncAsyncProcess::SigProgress
boost::signals2::signal< void(pid_t, RsyncProgress const &)> SigProgress
Progress update signal.
Definition: rsyncAsyncProcess.hpp:86
daq::MockAsyncProcess::ConnectStdout
boost::signals2::connection ConnectStdout(SigOutStream::slot_type const &slot) override
Connect slot to line-buffered stdout signal.
Definition: mockAsyncProcess.hpp:33
daq::AsyncProcessIf::IsRunning
virtual bool IsRunning() const noexcept=0
rsyncAsyncProcess.hpp
daq::RsyncAsyncProcess and related class declarations.
daq::AsyncProcessIf::SigOutStream
boost::signals2::signal< void(pid_t, std::string const &)> SigOutStream
Signal type for stdout/stderr signals.
Definition: asyncProcess.hpp:82
daq::MockAsyncProcess::MOCK_METHOD
MOCK_METHOD(std::vector< std::string > const &, GetArguments,(),(const, override, noexcept))
daq::RsyncAsyncProcessIf::SigProgress
boost::signals2::signal< void(pid_t, RsyncProgress const &)> SigProgress
Progress update signal.
Definition: rsyncAsyncProcess.hpp:86
daq::MockAsyncProcess::stderr
SigOutStream stderr
Definition: mockAsyncProcess.hpp:41
daq::AsyncProcessIf::GetPid
virtual std::optional< pid_t > GetPid() const noexcept=0
Get PID.
daq::RsyncAsyncProcessIf
More specialized version for rsync which also monitors transfer progress.
Definition: rsyncAsyncProcess.hpp:77
daq::AsyncProcessIf
Interface to asynchronous process.
Definition: asyncProcess.hpp:27
daq::MockAsyncProcess::MOCK_METHOD
MOCK_METHOD(bool, IsRunning,(),(const, noexcept, override))