27 #include <gtest/gtest.h> 31 TEST(LinuxProcess, accessing_proc_stats_works)
38 EXPECT_NO_THROW(child >> stat);
42 TEST(LinuxProcess, accessing_proc_oom_score_works)
48 TEST(LinuxProcess, accessing_proc_oom_score_adj_works)
60 ::testing::AssertionResult is_approximately_equal(
int a,
int b)
62 static const int error_margin = 10;
65 return ::testing::AssertionSuccess() << ::abs(a-b) <<
" <= " << error_margin;
67 return ::testing::AssertionFailure() << ::abs(a-b) <<
" > " << error_margin;
71 TEST(LinuxProcess, adjusting_proc_oom_score_adj_works)
88 TEST(LinuxProcess, adjusting_proc_oom_score_adj_to_privileged_values_only_works_if_root)
104 TEST(LinuxProcess, trying_to_write_an_invalid_oom_score_adj_throws)
114 TEST(LinuxProcess, adjusting_proc_oom_adj_works)
134 TEST(LinuxProcess, adjusting_proc_oom_adj_to_privileged_values_does_not_work)
150 TEST(LinuxProcess, trying_to_write_an_invalid_oom_adj_throws)
static int max_value()
Returns the maximum valid value.
static int min_value()
Returns the minimum valid value.
The Stat struct encapsulates status information about a process.
EXPECT_ANY_THROW(auto death_observer=core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap))
CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function< posix::exit::Status()> &main, const StandardStream &flags)
fork forks a new process and executes the provided main function in the newly forked process...
int value
Current OomScore as calculated by the kernel.
static int min_value()
Returns the minimum valid value.
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true)
Returns a Process instance corresponding to this process.
static int max_value()
Returns the maximum valid value.
TEST(LinuxProcess, accessing_proc_stats_works)