Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_add_file_system.cpp File Reference
#include <boost/test/included/unit_test.hpp>
#include <fc/variant_object.hpp>
#include <sysio/resource_monitor_plugin/file_space_handler.hpp>
Include dependency graph for test_add_file_system.cpp:

Go to the source code of this file.

Classes

struct  add_file_system_fixture
 
struct  add_file_system_fixture::mock_space_provider
 

Macros

#define BOOST_TEST_MODULE   add_file_system
 

Functions

 BOOST_FIXTURE_TEST_CASE (get_stat_failure, add_file_system_fixture)
 
 BOOST_FIXTURE_TEST_CASE (get_space_failure, add_file_system_fixture)
 
 BOOST_FIXTURE_TEST_CASE (different_file_systems, add_file_system_fixture)
 
 BOOST_FIXTURE_TEST_CASE (same_file_system, add_file_system_fixture)
 
 BOOST_FIXTURE_TEST_CASE (mixed_file_systems, add_file_system_fixture)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   add_file_system

Definition at line 1 of file test_add_file_system.cpp.

Function Documentation

◆ BOOST_FIXTURE_TEST_CASE() [1/5]

BOOST_FIXTURE_TEST_CASE ( different_file_systems ,
add_file_system_fixture  )

Definition at line 108 of file test_add_file_system.cpp.

109 {
110 std::vector<int> capacity {1000000, 2000000, 3000000, 4000000};
111 std::vector<int> available {500000, 1500000, 2500000, 3500000};
112 std::vector<int> devs {0, 1, 2, 3};
113
114 // As long as no exceptions, it is considered success.
115 BOOST_REQUIRE_NO_THROW(test_add_file_systems_common(capacity, available, devs));
116 }

◆ BOOST_FIXTURE_TEST_CASE() [2/5]

BOOST_FIXTURE_TEST_CASE ( get_space_failure ,
add_file_system_fixture  )

Definition at line 92 of file test_add_file_system.cpp.

93 {
94 mock_get_space = []( const bfs::path& p, boost::system::error_code& ec) -> bfs::space_info {
95 ec = boost::system::errc::make_error_code(errc::no_such_file_or_directory);
96 bfs::space_info rc;
97 return rc;
98 };
99
100 mock_get_stat = []( const char *path, struct stat *buf ) -> int {
101 buf->st_dev = 0;
102 return 0;
103 };
104
105 BOOST_REQUIRE_THROW(add_file_system("/test"), chain::plugin_config_exception);
106 }
const mie::Vuint & p
Definition bn.cpp:27
wraps boost::filesystem::path to provide platform independent path manipulation.
uint8_t buf[2048]
yh_rc rc

◆ BOOST_FIXTURE_TEST_CASE() [3/5]

BOOST_FIXTURE_TEST_CASE ( get_stat_failure ,
add_file_system_fixture  )

Definition at line 83 of file test_add_file_system.cpp.

84 {
85 mock_get_stat = []( const char *path, struct stat *buf ) -> int {
86 return 1; // anything other than 0 is an error in stat
87 };
88
89 BOOST_REQUIRE_THROW(add_file_system("/test"), chain::plugin_config_exception);
90 }

◆ BOOST_FIXTURE_TEST_CASE() [4/5]

BOOST_FIXTURE_TEST_CASE ( mixed_file_systems ,
add_file_system_fixture  )

Definition at line 128 of file test_add_file_system.cpp.

129 {
130 std::vector<int> capacity {1000000, 2000000, 3000000, 4000000, 50000};
131 std::vector<int> available {500000, 1500000, 2500000, 3500000, 20000};
132 std::vector<int> devs {0, 2, 2, 0, 3};
133
134 // As long as no exceptions, it is considered success.
135 BOOST_REQUIRE_NO_THROW(test_add_file_systems_common(capacity, available, devs));
136 }

◆ BOOST_FIXTURE_TEST_CASE() [5/5]

BOOST_FIXTURE_TEST_CASE ( same_file_system ,
add_file_system_fixture  )

Definition at line 118 of file test_add_file_system.cpp.

119 {
120 std::vector<int> capacity {1000000, 2000000, 3000000, 4000000};
121 std::vector<int> available {500000, 1500000, 2500000, 3500000};
122 std::vector<int> devs {0, 0, 0, 0};
123
124 // As long as no exceptions, it is considered success.
125 BOOST_REQUIRE_NO_THROW(test_add_file_systems_common(capacity, available, devs));
126 }