clang-format

pull/1625/head
Craig Tiller 10 years ago
parent f95f048c3e
commit 3cdd9bbdbc
  1. 10
      test/cpp/end2end/crash_test.cc
  2. 1
      test/cpp/end2end/crash_test_server.cc
  3. 25
      test/cpp/util/subprocess.cc
  4. 14
      test/cpp/util/subprocess.h

@ -73,15 +73,17 @@ class CrashTest : public ::testing::Test {
protected: protected:
CrashTest() {} CrashTest() {}
std::unique_ptr<grpc::cpp::test::util::TestService::Stub> CreateServerAndStub() { std::unique_ptr<grpc::cpp::test::util::TestService::Stub>
CreateServerAndStub() {
auto port = grpc_pick_unused_port_or_die(); auto port = grpc_pick_unused_port_or_die();
auto addr = (std::ostringstream() << "localhost:" << port).str(); auto addr = (std::ostringstream() << "localhost:" << port).str();
server_.reset(new SubProcess({ server_.reset(new SubProcess({
(std::ostringstream() << g_root << "/crash_test_server").str(), (std::ostringstream() << g_root << "/crash_test_server").str(),
(std::ostringstream() << "--address=" << addr).str(), (std::ostringstream() << "--address=" << addr).str(),
})); }));
GPR_ASSERT(server_); GPR_ASSERT(server_);
return grpc::cpp::test::util::TestService::NewStub(CreateChannel(addr, InsecureCredentials(), ChannelArguments())); return grpc::cpp::test::util::TestService::NewStub(
CreateChannel(addr, InsecureCredentials(), ChannelArguments()));
} }
void KillServer() { void KillServer() {

@ -83,7 +83,6 @@ void RunServer() {
std::cout << "Server listening on " << FLAGS_address << std::endl; std::cout << "Server listening on " << FLAGS_address << std::endl;
server->Wait(); server->Wait();
} }
} }
} }

@ -40,27 +40,20 @@
namespace grpc { namespace grpc {
static gpr_subprocess *MakeProcess(std::initializer_list<std::string> args) { static gpr_subprocess *MakeProcess(std::initializer_list<std::string> args) {
std::vector<const char *> vargs; std::vector<const char *> vargs;
for (auto it = args.begin(); it != args.end(); ++it) { for (auto it = args.begin(); it != args.end(); ++it) {
vargs.push_back(it->c_str()); vargs.push_back(it->c_str());
} }
return gpr_subprocess_create(vargs.size(), &vargs[0]); return gpr_subprocess_create(vargs.size(), &vargs[0]);
} }
SubProcess::SubProcess(std::initializer_list<std::string> args) SubProcess::SubProcess(std::initializer_list<std::string> args)
: subprocess_(MakeProcess(args)) { : subprocess_(MakeProcess(args)) {}
}
SubProcess::~SubProcess() { SubProcess::~SubProcess() { gpr_subprocess_destroy(subprocess_); }
gpr_subprocess_destroy(subprocess_);
}
int SubProcess::Join() { int SubProcess::Join() { return gpr_subprocess_join(subprocess_); }
return gpr_subprocess_join(subprocess_);
}
void SubProcess::Interrupt() { void SubProcess::Interrupt() { gpr_subprocess_interrupt(subprocess_); }
gpr_subprocess_interrupt(subprocess_);
}
} // namespace grpc } // namespace grpc

@ -43,17 +43,17 @@ namespace grpc {
class SubProcess { class SubProcess {
public: public:
SubProcess(std::initializer_list<std::string> args); SubProcess(std::initializer_list<std::string> args);
~SubProcess(); ~SubProcess();
int Join(); int Join();
void Interrupt(); void Interrupt();
private: private:
SubProcess(const SubProcess& other); SubProcess(const SubProcess& other);
SubProcess& operator=(const SubProcess& other); SubProcess& operator=(const SubProcess& other);
gpr_subprocess *const subprocess_; gpr_subprocess* const subprocess_;
}; };
} // namespace grpc } // namespace grpc

Loading…
Cancel
Save