test_proclog: add cmdline check in buildProcLogerMessage (#25891)

old-commit-hash: 2e5b50c2d7
taco
Dean Lee 3 years ago committed by GitHub
parent 33508cd811
commit cf305def06
  1. 12
      system/proclogd/tests/test_proclog.cc

@ -140,6 +140,18 @@ TEST_CASE("buildProcLogerMessage") {
REQUIRE(p.getName() == "test_proclog"); REQUIRE(p.getName() == "test_proclog");
REQUIRE(p.getState() == 'R'); REQUIRE(p.getState() == 'R');
REQUIRE_THAT(p.getExe().cStr(), Catch::Matchers::Contains("test_proclog")); 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());
}
}
} }
} }
} }

Loading…
Cancel
Save