MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / popen_test

Function popen_test

thread/test/test-lib-data.cpp:24–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include <stdlib.h>
23
24bool popen_test(const std::string& cmd, int expect = 0) {
25 puts(cmd.c_str());
26 auto p = popen(cmd.c_str(), "r");
27 char buffer[4096];
28 while (fgets(buffer, sizeof(buffer), p) != NULL)
29 ;
30 auto r = pclose(p);
31 if (WIFEXITED(r)) return WEXITSTATUS(r) == expect;
32 puts("Not exit");
33 return false;
34}
35
36std::string popen_read(const std::string& cmd, int expect = 0) {
37 std::string ret;

Callers 1

TESTFunction · 0.85

Calls 1

c_strMethod · 0.45

Tested by

no test coverage detected