test_proclog: add cmdline check in buildProcLogerMessage (#25891)

old-commit-hash: 2e5b50c2d7c09accaa51e954790a478b125af591
This commit is contained in:
Dean Lee
2022-09-29 08:35:55 +08:00
committed by GitHub
parent 33508cd811
commit cf305def06
+12
View File
@@ -140,6 +140,18 @@ TEST_CASE("buildProcLogerMessage") {
REQUIRE(p.getName() == "test_proclog");
REQUIRE(p.getState() == 'R');
REQUIRE_THAT(p.getExe().cStr(), Catch::Matchers::Contains("test_proclog"));
REQUIRE(p.getCmdline().size() == 1);
REQUIRE_THAT(p.getCmdline()[0], Catch::Matchers::Contains("test_proclog"));
} else {
std::string cmd_path = "/proc/" + std::to_string(p.getPid()) + "/cmdline";
if (util::file_exists(cmd_path)) {
std::ifstream stream(cmd_path);
auto cmdline = Parser::cmdline(stream);
REQUIRE(cmdline.size() == p.getCmdline().size());
for (int i = 0; i < p.getCmdline().size(); ++i) {
REQUIRE(cmdline[i] == p.getCmdline()[i].cStr());
}
}
}
}
}