summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-09 11:29:22 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-09 11:29:22 +0100
commit24b3afa684e57176f5068fd5896679ae0fa047ad (patch)
treec9f6d03fadcb762ae0163f14f52462338249e62a /tests
parente7dd0b98770ee0c88c1ea976d9e9a6d3979782f7 (diff)
Add process.h: is_running()
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile5
-rw-r--r--tests/test-process.cpp34
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 6ae6f12..b95c91a 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -16,6 +16,7 @@ UNITS=\
file.cpp \
mime.cpp \
os.cpp \
+ process.cpp \
stringhelper.cpp \
tempfile.cpp \
url.cpp
@@ -26,6 +27,7 @@ UNITTESTS=\
test-file.cpp \
test-mime.cpp \
test-os.cpp \
+ test-process.cpp \
test-stringhelper.cpp \
test-tempfile.cpp \
test-url.cpp
@@ -69,6 +71,9 @@ mime.o: ../mime.cpp
os.o: ../os.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
+process.o: ../process.cpp
+ $(CXX) $(CXXFLAGS) -o $@ -c $<
+
stringhelper.o: ../stringhelper.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
diff --git a/tests/test-process.cpp b/tests/test-process.cpp
new file mode 100644
index 0000000..dfee83f
--- /dev/null
+++ b/tests/test-process.cpp
@@ -0,0 +1,34 @@
+#include <gtest/gtest.h>
+
+#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);
+}