Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
MockSysCalls.hpp
Go to the documentation of this file.
1
20
21#ifndef MOCKSYSCALLS_HPP
22#define MOCKSYSCALLS_HPP
23
24#include <fcntl.h>
25#include <gmock/gmock.h>
26#include <sys/ioctl.h>
27#include <unistd.h>
28
34public:
41 return instance;
42 }
43
45 MOCK_METHOD(int, open, (const char *path, int flags), ());
47 MOCK_METHOD(int, ioctl, (int fd, unsigned long request), ());
49 MOCK_METHOD(int, close, (int fd), ());
50
51private:
53 MockSysCalls() = default;
55 ~MockSysCalls() = default;
57 MockSysCalls(const MockSysCalls &) = delete;
60};
61
69inline int mock_open(const char *path, int flags, ...) {
70 return MockSysCalls::instance().open(path, flags);
71}
72
80inline int mock_ioctl(int fd, unsigned long request, ...) {
81 return MockSysCalls::instance().ioctl(fd, request);
82}
83
90inline int mock_close(int fd) { return MockSysCalls::instance().close(fd); }
91
92#endif // MOCKSYSCALLS_HPP
int mock_ioctl(int fd, unsigned long request,...)
Mocked ioctl function.
int mock_close(int fd)
Mocked close function.
int mock_open(const char *path, int flags,...)
Mocked open function.
MockSysCalls(const MockSysCalls &)=delete
Copy constructor of the class set as delete.
MOCK_METHOD(int, close,(int fd),())
Mocked method to close a file.
~MockSysCalls()=default
Destructor of the class set as default.
MOCK_METHOD(int, ioctl,(int fd, unsigned long request),())
Mocked method to perform an I/O control operation.
MockSysCalls & operator=(const MockSysCalls &)=delete
Operator of the class set as delete.
MOCK_METHOD(int, open,(const char *path, int flags),())
Mocked method to open a file.
static MockSysCalls & instance()
Get the instance object.
MockSysCalls()=default
Constructor of the class set as default.