hunting/test/utils/LinuxApiMock/include/LinuxApiMock.h
2024-01-24 08:20:47 -08:00

30 lines
763 B
C++

#ifndef LINUX_API_MOCK_H
#define LINUX_API_MOCK_H
#include <memory>
#ifdef __cplusplus
extern "C" {
#endif
// Modify all the real api.
int __real_fx_open(const char *pathname, int flags);
#ifdef __cplusplus
}
#endif
class LinuxApiMock
{
public:
LinuxApiMock() = default;
virtual ~LinuxApiMock() = default;
static std::shared_ptr<LinuxApiMock> &GetInstance(std::shared_ptr<LinuxApiMock> *impl = nullptr)
{
static auto instance = std::make_shared<LinuxApiMock>();
if (impl) {
// The non-thread-safe changing is only for gtest.
instance = *impl;
}
return instance;
}
virtual void Init() {}
virtual void UnInit() {}
virtual int fx_open(const char *pathname, int flags);
};
#endif