blob: 9855546fb963f59fdc31039d66a9eb9d095bdf66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include <gtest/gtest.h>
#include <thread>
#include "process.h"
#include <unistd.h>
class ProcessTest: public ::testing::Test
{
protected:
ProcessTest(){
}
~ProcessTest() override{
}
void SetUp() override
{
}
void TearDown() override
{
}
};
TEST_F(ProcessTest, is_running) {
auto pid{::getpid()};
EXPECT_NE(pid, -1);
EXPECT_EQ(Reichwein::Process::is_running(pid), true);
EXPECT_EQ(Reichwein::Process::is_running(999999999), false);
}
TEST_F(ProcessTest, number_of_threads) {
EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 1);
std::thread t1{[](){std::this_thread::sleep_for(std::chrono::milliseconds(50));}};
EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 2);
t1.join();
EXPECT_EQ(Reichwein::Process::number_of_threads(::getpid()), 1);
}
|