GCC Code Coverage Report


Directory: ./
File: Os/Stub/Cpu.hpp
Date: 2026-09-03 21:13:48
Exec Total Coverage
Lines: 2 2 100.0%
Functions: 2 2 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Stub/Cpu.hpp
3 // \brief stub implementation for Os::Cpu, header and test definitions
4 // ======================================================================
5 #include <Os/Cpu.hpp>
6 #include <cstdio>
7 #ifndef OS_Stub_Cpu_HPP
8 #define OS_Stub_Cpu_HPP
9
10 namespace Os {
11 namespace Stub {
12 namespace Cpu {
13
14 //! CpuHandle class definition for stub implementations.
15 //!
16 struct StubCpuHandle : public CpuHandle {};
17
18 //! \brief stub implementation of Os::CpuInterface
19 //!
20 //! Stub implementation of `CpuInterface` for use as a delegate class handling stub console operations.
21 //!
22 class StubCpu : public CpuInterface {
23 public:
24 //! \brief constructor
25 //!
26 1 StubCpu() = default;
27
28 //! \brief copy constructor
29 StubCpu(const StubCpu& other) = delete;
30
31 //! \brief default copy assignment
32 CpuInterface& operator=(const CpuInterface& other) override = delete;
33
34 //! \brief destructor
35 //!
36 2 ~StubCpu() override = default;
37
38 // ------------------------------------
39 // Functions overrides
40 // ------------------------------------
41 public:
42 //! \brief Request the count of the CPUs detected by the system
43 //!
44 //! This method wraps delegates to the underlying implementation.
45 //!
46 //! \param cpu_count: (output) filled with CPU count on system
47 //! \return: OP_OK with valid CPU count, ERROR when error occurs
48 //!
49 Status _getCount(FwSizeType& cpu_count) override;
50
51 //! \brief Get the CPU tick information for a given CPU
52 //!
53 //! CPU ticks represent a small time slice of processor time. This will retrieve the used CPU ticks and total
54 //! ticks for a given CPU. This information in a running accumulation and thus a sample-to-sample
55 //! differencing is needed to see the 'realtime' changing load. This shall be done by the caller. This method wraps
56 //! delegates to the underlying implementation.
57 //!
58 //! \param ticks: (output) filled with the tick information for the given CPU
59 //! \param cpu_index: index for CPU to read. Default: 0
60 //! \return: ERROR when error occurs, OK otherwise.
61 //!
62 Status _getTicks(Ticks& ticks, FwSizeType cpu_index) override;
63
64 //! \brief returns the raw console handle
65 //!
66 //! Gets the raw console handle from the implementation. Note: users must include the implementation specific
67 //! header to make any real use of this handle. Otherwise it will be as an opaque type.
68 //!
69 //! \return raw console handle
70 //!
71 CpuHandle* getHandle() override;
72
73 private:
74 //! File handle for PosixFile
75 StubCpuHandle m_handle;
76 };
77 } // namespace Cpu
78 } // namespace Stub
79 } // namespace Os
80
81 #endif // OS_Stub_Cpu_HPP
82