Commit fae306f0 authored by Zhangyi Chen's avatar Zhangyi Chen

Fix UT on ubuntu

parent cb054071
...@@ -3,11 +3,10 @@ ...@@ -3,11 +3,10 @@
// Author: Zhangyi Chen (chenzhangyi01@baidu.com) // Author: Zhangyi Chen (chenzhangyi01@baidu.com)
// Date: 2017/11/06 10:57:08 // Date: 2017/11/06 10:57:08
#include <gtest/gtest.h>
#include <sstream>
#include "butil/popen.h" #include "butil/popen.h"
#include "butil/errno.h" #include "butil/errno.h"
#include "butil/strings/string_piece.h" #include "butil/strings/string_piece.h"
#include <gtest/gtest.h>
namespace { namespace {
...@@ -23,7 +22,7 @@ TEST(PopenTest, sanity) { ...@@ -23,7 +22,7 @@ TEST(PopenTest, sanity) {
oss.str(""); oss.str("");
rc = butil::read_command_output(oss, "exit 1"); rc = butil::read_command_output(oss, "exit 1");
ASSERT_EQ(1, rc) << berror(errno); ASSERT_EQ(1, rc) << berror(errno);
ASSERT_TRUE(oss.str().empty()) << oss; ASSERT_TRUE(oss.str().empty()) << oss.str();
oss.str(""); oss.str("");
rc = butil::read_command_output(oss, "kill -9 $$"); rc = butil::read_command_output(oss, "kill -9 $$");
ASSERT_EQ(-1, rc); ASSERT_EQ(-1, rc);
...@@ -36,8 +35,8 @@ TEST(PopenTest, sanity) { ...@@ -36,8 +35,8 @@ TEST(PopenTest, sanity) {
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("");
ASSERT_EQ(0, butil::read_command_output(oss, "printf '=%.0s' {1..100000}")); ASSERT_EQ(0, butil::read_command_output(oss, "for i in `seq 1 100000`; do echo -n '=' ; done"));
ASSERT_EQ(100000u, oss.str().length()); ASSERT_EQ(100000u, oss.str().length()) << oss.str();
std::string expected; std::string expected;
expected.resize(100000, '='); expected.resize(100000, '=');
ASSERT_EQ(expected, oss.str()); ASSERT_EQ(expected, oss.str());
......
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