-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fuser.cpp
More file actions
41 lines (34 loc) · 1.03 KB
/
Copy pathtest_fuser.cpp
File metadata and controls
41 lines (34 loc) · 1.03 KB
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
#include <gtest/gtest.h>
#include <cfbox/applet_config.hpp>
#if CFBOX_ENABLE_FUSER
#include <cfbox/applets.hpp>
TEST(FuserTest, HelpAndVersion) {
char a0[] = "fuser";
char a1[] = "--help";
char* argv[] = {a0, a1, nullptr};
testing::internal::CaptureStdout();
int rc = fuser_main(2, argv);
std::string out = testing::internal::GetCapturedStdout();
EXPECT_EQ(rc, 0);
EXPECT_NE(out.find("fuser"), std::string::npos);
}
TEST(FuserTest, NoArgs) {
char a0[] = "fuser";
char* argv[] = {a0, nullptr};
testing::internal::CaptureStdout();
testing::internal::CaptureStderr();
int rc = fuser_main(1, argv);
testing::internal::GetCapturedStdout();
testing::internal::GetCapturedStderr();
EXPECT_EQ(rc, 1);
}
TEST(FuserTest, NonExistentFile) {
char a0[] = "fuser";
char a1[] = "/nonexistent_file_xyz";
char* argv[] = {a0, a1, nullptr};
testing::internal::CaptureStdout();
int rc = fuser_main(2, argv);
// Should fail to stat or find no processes
EXPECT_NE(rc, 0);
}
#endif