ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
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
17namespace daq {
18/**
19 * Combined fake/mock
20 */
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
Interface to asynchronous process.
virtual std::error_code Abort() noexcept=0
Aborts the operation by terminating process which completes the operation.
boost::signals2::signal< void(pid_t, std::string const &)> SigOutStream
Signal type for stdout/stderr signals.
virtual std::error_code Signal(int sig) noexcept=0
Send signal to process.
virtual std::optional< pid_t > GetPid() const noexcept=0
Get PID.
virtual bool IsRunning() const noexcept=0
virtual std::vector< std::string > const & GetArguments() const noexcept=0
More specialized version for rsync which also monitors transfer progress.
boost::signals2::signal< void(pid_t, RsyncProgress const &)> SigProgress
Progress update signal.
daq::RsyncAsyncProcess and related class declarations.
Combined fake/mock.
boost::signals2::connection ConnectStderr(SigOutStream::slot_type const &slot) override
Connect slot to line-buffered stderr signal.
MOCK_METHOD(std::optional< pid_t >, GetPid,(),(const, noexcept, override))
virtual boost::future< int > Initiate() override
Initiates async operation by executing the specified process.
MOCK_METHOD(std::error_code, Abort,(),(noexcept, override))
boost::promise< int > promise
boost::signals2::signal< void(pid_t, std::string const &)> SigOutStream
Signal type for stdout/stderr signals.
MOCK_METHOD(std::error_code, Signal,(int),(override, noexcept))
MOCK_METHOD(std::vector< std::string > const &, GetArguments,(),(const, override, noexcept))
boost::signals2::connection ConnectStdout(SigOutStream::slot_type const &slot) override
Connect slot to line-buffered stdout signal.
MOCK_METHOD(bool, IsRunning,(),(const, noexcept, override))
boost::signals2::connection ConnectProgress(SigProgress::slot_type const &slot) override
Connect to progress signal.
boost::signals2::signal< void(pid_t, RsyncProgress const &)> SigProgress
Progress update signal.