Commit a264483a authored by zhujiashun's avatar zhujiashun

re-enable one case in BuiltinServiceTest.pprof

parent 57d69fd1
...@@ -70,8 +70,8 @@ ssize_t ReadCommandLine(char* buf, size_t len, bool with_args) { ...@@ -70,8 +70,8 @@ ssize_t ReadCommandLine(char* buf, size_t len, bool with_args) {
return nr; return nr;
} else { } else {
for (ssize_t i = 0; i < nr; ++i) { for (ssize_t i = 0; i < nr; ++i) {
// The result in macos is ended with '\n' // The command in macos is separated with space and ended with '\n'
if (buf[i] == '\0' || buf[i] == '\n') { if (buf[i] == '\0' || buf[i] == '\n' || buf[i] == ' ') {
return i; return i;
} }
} }
......
...@@ -664,7 +664,6 @@ TEST_F(BuiltinServiceTest, pprof) { ...@@ -664,7 +664,6 @@ TEST_F(BuiltinServiceTest, pprof) {
EXPECT_FALSE(cntl.Failed()); EXPECT_FALSE(cntl.Failed());
CheckContent(cntl, "num_symbols"); CheckContent(cntl, "num_symbols");
} }
#if defined(OS_LINUX)
{ {
ClosureChecker done; ClosureChecker done;
brpc::Controller cntl; brpc::Controller cntl;
...@@ -672,7 +671,6 @@ TEST_F(BuiltinServiceTest, pprof) { ...@@ -672,7 +671,6 @@ TEST_F(BuiltinServiceTest, pprof) {
EXPECT_FALSE(cntl.Failed()); EXPECT_FALSE(cntl.Failed());
CheckContent(cntl, "brpc_builtin_service_unittest"); CheckContent(cntl, "brpc_builtin_service_unittest");
} }
#endif
} }
TEST_F(BuiltinServiceTest, dir) { TEST_F(BuiltinServiceTest, dir) {
......
...@@ -36,11 +36,7 @@ TEST(PopenTest, posix_popen) { ...@@ -36,11 +36,7 @@ TEST(PopenTest, posix_popen) {
ASSERT_EQ(errno, ECHILD); ASSERT_EQ(errno, ECHILD);
ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 9")); ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 9"));
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
rc = butil::read_command_output_through_popen(oss, "kill -15 $$"); rc = butil::read_command_output_through_popen(oss, "kill -15 $$");
#else
rc = butil::read_command_output_through_clone(oss, "kill -15 $$");
#endif
ASSERT_EQ(-1, rc); ASSERT_EQ(-1, rc);
ASSERT_EQ(errno, ECHILD); ASSERT_EQ(errno, ECHILD);
ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 15")); ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 15"));
...@@ -48,11 +44,7 @@ TEST(PopenTest, posix_popen) { ...@@ -48,11 +44,7 @@ TEST(PopenTest, posix_popen) {
// TODO(zhujiashun): Fix this in macos // TODO(zhujiashun): Fix this in macos
/* /*
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
ASSERT_EQ(0, butil::read_command_output_through_popen(oss, "for i in `seq 1 100000`; do echo -n '=' ; done")); ASSERT_EQ(0, butil::read_command_output_through_popen(oss, "for i in `seq 1 100000`; do echo -n '=' ; done"));
#else
ASSERT_EQ(0, butil::read_command_output_through_clone(oss, "for i in `seq 1 100000`; do echo -n '=' ; done"));
#endif
ASSERT_EQ(100000u, oss.str().length()); ASSERT_EQ(100000u, oss.str().length());
std::string expected; std::string expected;
expected.resize(100000, '='); expected.resize(100000, '=');
...@@ -64,54 +56,33 @@ TEST(PopenTest, posix_popen) { ...@@ -64,54 +56,33 @@ TEST(PopenTest, posix_popen) {
TEST(PopenTest, clone) { TEST(PopenTest, clone) {
std::ostringstream oss; std::ostringstream oss;
#if !defined(OS_LINUX)
int rc = butil::read_command_output_through_popen(oss, "echo \"Hello World\"");
#else
int rc = butil::read_command_output_through_clone(oss, "echo \"Hello World\""); int rc = butil::read_command_output_through_clone(oss, "echo \"Hello World\"");
#endif
ASSERT_EQ(0, rc) << berror(errno); ASSERT_EQ(0, rc) << berror(errno);
ASSERT_EQ("Hello World\n", oss.str()); ASSERT_EQ("Hello World\n", oss.str());
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
rc = butil::read_command_output_through_popen(oss, "exit 1");
#else
rc = butil::read_command_output_through_clone(oss, "exit 1"); rc = butil::read_command_output_through_clone(oss, "exit 1");
#endif
ASSERT_EQ(1, rc) << berror(errno); ASSERT_EQ(1, rc) << berror(errno);
ASSERT_TRUE(oss.str().empty()) << oss.str(); ASSERT_TRUE(oss.str().empty()) << oss.str();
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
rc = butil::read_command_output_through_popen(oss, "kill -9 $$");
#else
rc = butil::read_command_output_through_clone(oss, "kill -9 $$"); rc = butil::read_command_output_through_clone(oss, "kill -9 $$");
#endif
ASSERT_EQ(-1, rc); ASSERT_EQ(-1, rc);
ASSERT_EQ(errno, ECHILD); ASSERT_EQ(errno, ECHILD);
ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 9")); ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 9"));
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
rc = butil::read_command_output_through_popen(oss, "kill -15 $$");
#else
rc = butil::read_command_output_through_clone(oss, "kill -15 $$"); rc = butil::read_command_output_through_clone(oss, "kill -15 $$");
#endif
ASSERT_EQ(-1, rc); ASSERT_EQ(-1, rc);
ASSERT_EQ(errno, ECHILD); ASSERT_EQ(errno, ECHILD);
ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 15")); ASSERT_TRUE(butil::StringPiece(oss.str()).ends_with("was killed by signal 15"));
oss.str(""); oss.str("");
#if !defined(OS_LINUX)
ASSERT_EQ(0, butil::read_command_output_through_popen(oss, "for i in `seq 1 100000`; do echo -n '=' ; done"));
#else
ASSERT_EQ(0, butil::read_command_output_through_clone(oss, "for i in `seq 1 100000`; do echo -n '=' ; done")); ASSERT_EQ(0, butil::read_command_output_through_clone(oss, "for i in `seq 1 100000`; do echo -n '=' ; done"));
#endif
ASSERT_EQ(100000u, oss.str().length()); ASSERT_EQ(100000u, oss.str().length());
std::string expected; std::string expected;
expected.resize(100000, '='); expected.resize(100000, '=');
ASSERT_EQ(expected, oss.str()); ASSERT_EQ(expected, oss.str());
} }
struct CounterArg { struct CounterArg {
volatile int64_t counter; volatile int64_t counter;
volatile bool stop; volatile bool stop;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment