Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
threshold_fixture Struct Reference
Collaboration diagram for threshold_fixture:

Classes

struct  mock_space_provider
 

Public Types

using file_space_handler_t = file_space_handler<mock_space_provider>
 

Public Member Functions

 threshold_fixture ()
 
void add_file_system (const bfs::path &path_name)
 
void set_threshold (uint32_t threshold, uint32_t warning_threshold)
 
bool is_threshold_exceeded ()
 
void set_shutdown_on_exceeded (bool shutdown_on_exceeded)
 
bool test_threshold_common (std::map< bfs::path, uintmax_t > &available, std::map< bfs::path, int > &dev, uint32_t warning_threshold=75)
 

Public Attributes

boost::asio::io_context ctx
 
std::function< bfs::space_info(const bfs::path &p, boost::system::error_code &ec)> mock_get_space
 
std::function< int(const char *path, struct stat *buf)> mock_get_stat
 
file_space_handler_t space_handler
 

Detailed Description

Definition at line 12 of file test_threshold.cpp.

Member Typedef Documentation

◆ file_space_handler_t

Constructor & Destructor Documentation

◆ threshold_fixture()

threshold_fixture::threshold_fixture ( )
inline

Definition at line 32 of file test_threshold.cpp.

33 : space_handler(mock_space_provider(*this), ctx)
34 {
35 }
file_space_handler_t space_handler
boost::asio::io_context ctx

Member Function Documentation

◆ add_file_system()

void threshold_fixture::add_file_system ( const bfs::path & path_name)
inline

Definition at line 37 of file test_threshold.cpp.

37 {
39 }
void add_file_system(const bfs::path &path_name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_threshold_exceeded()

bool threshold_fixture::is_threshold_exceeded ( )
inline

Definition at line 45 of file test_threshold.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_shutdown_on_exceeded()

void threshold_fixture::set_shutdown_on_exceeded ( bool shutdown_on_exceeded)
inline

Definition at line 49 of file test_threshold.cpp.

49 {
50 space_handler.set_shutdown_on_exceeded(shutdown_on_exceeded);
51 }
void set_shutdown_on_exceeded(bool new_shutdown_on_exceeded)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_threshold()

void threshold_fixture::set_threshold ( uint32_t threshold,
uint32_t warning_threshold )
inline

Definition at line 41 of file test_threshold.cpp.

41 {
42 space_handler.set_threshold(threshold, warning_threshold);
43 }
void set_threshold(uint32_t new_threshold, uint32_t new_warning_threshold)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_threshold_common()

bool threshold_fixture::test_threshold_common ( std::map< bfs::path, uintmax_t > & available,
std::map< bfs::path, int > & dev,
uint32_t warning_threshold = 75 )
inline

Definition at line 53 of file test_threshold.cpp.

54 {
55 mock_get_space = [available]( const bfs::path& p, boost::system::error_code& ec) mutable -> bfs::space_info {
56 ec = boost::system::errc::make_error_code(errc::success);
57
58 bfs::space_info rc;
59 rc.capacity = 1000000;
60 rc.available = available[p];
61
62 return rc;
63 };
64
65 mock_get_stat = [dev]( const char *path, struct stat *buf ) mutable -> int {
66 bfs::path name = path;
67 buf->st_dev = dev[name];
68
69 return 0;
70 };
71
72 set_threshold(80, warning_threshold);
74
75 for (auto i = 0; i < available.size(); i++) {
76 add_file_system("/test" + std::to_string(i));
77 }
78
79 return is_threshold_exceeded();
80 }
const mie::Vuint & p
Definition bn.cpp:27
std::string name
wraps boost::filesystem::path to provide platform independent path manipulation.
Immutable except for fc::from_variant.
Definition name.hpp:43
void set_shutdown_on_exceeded(bool shutdown_on_exceeded)
void set_threshold(uint32_t threshold, uint32_t warning_threshold)
void add_file_system(const bfs::path &path_name)
std::function< int(const char *path, struct stat *buf)> mock_get_stat
std::function< bfs::space_info(const bfs::path &p, boost::system::error_code &ec)> mock_get_space
uint8_t buf[2048]
yh_rc rc
Here is the call graph for this function:

Member Data Documentation

◆ ctx

boost::asio::io_context threshold_fixture::ctx

Definition at line 29 of file test_threshold.cpp.

◆ mock_get_space

std::function<bfs::space_info(const bfs::path& p, boost::system::error_code& ec)> threshold_fixture::mock_get_space

Definition at line 83 of file test_threshold.cpp.

◆ mock_get_stat

std::function<int(const char *path, struct stat *buf)> threshold_fixture::mock_get_stat

Definition at line 84 of file test_threshold.cpp.

◆ space_handler

file_space_handler_t threshold_fixture::space_handler

Definition at line 86 of file test_threshold.cpp.


The documentation for this struct was generated from the following file: