aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-03-24 10:36:08 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-03-24 10:36:08 -0700
commit82dd80abc6fffab0f0bcff406dbd0750a6a45b37 (patch)
tree2015139aa7e4951be748b52d81ffacb7b36a04e5 /test
parent8ba8cfe143d47c8c9b14cd0cb0fbf968112cfc9c (diff)
Elminate range-based fors and work around some other limitations in older compilers
Diffstat (limited to 'test')
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc4
-rw-r--r--test/cpp/qps/client_async.cc11
-rw-r--r--test/cpp/qps/driver.cc44
-rw-r--r--test/cpp/qps/server_async.cc4
-rw-r--r--test/cpp/qps/stats.h4
5 files changed, 34 insertions, 33 deletions
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 711f1b9540..11998a7cb7 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -83,8 +83,8 @@ bool ParseFromByteBuffer(ByteBuffer* buffer, grpc::protobuf::Message* message) {
buffer->Dump(&slices);
grpc::string buf;
buf.reserve(buffer->Length());
- for (const Slice& s : slices) {
- buf.append(reinterpret_cast<const char*>(s.begin()), s.size());
+ for (auto s = slices.begin(); s != slices.end(); s++) {
+ buf.append(reinterpret_cast<const char*>(s->begin()), s->size());
}
return message->ParseFromString(buf);
}
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 526f37a1fd..f995a63f49 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -144,7 +144,8 @@ class AsyncClient GRPC_FINAL : public Client {
int t = 0;
for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) {
- for (auto& channel : channels_) {
+ for (auto channel = channels_.begin(); channel != channels_.end();
+ channel++) {
auto* cq = cli_cqs_[t].get();
t = (t + 1) % cli_cqs_.size();
auto start_req = [cq](TestService::Stub* stub, grpc::ClientContext* ctx,
@@ -152,7 +153,7 @@ class AsyncClient GRPC_FINAL : public Client {
return stub->AsyncUnaryCall(ctx, request, cq, tag);
};
- TestService::Stub* stub = channel.get_stub();
+ TestService::Stub* stub = channel->get_stub();
const SimpleRequest& request = request_;
new ClientRpcContextUnaryImpl<SimpleRequest, SimpleResponse>(
stub, request, start_req, check_done);
@@ -165,11 +166,11 @@ class AsyncClient GRPC_FINAL : public Client {
~AsyncClient() GRPC_OVERRIDE {
EndThreads();
- for (auto& cq : cli_cqs_) {
- cq->Shutdown();
+ for (auto cq = cli_cqs_.begin(); cq != cli_cqs_.end(); cq++) {
+ (*cq)->Shutdown();
void* got_tag;
bool ok;
- while (cq->Next(&got_tag, &ok)) {
+ while ((*cq)->Next(&got_tag, &ok)) {
delete ClientRpcContext::detag(got_tag);
}
}
diff --git a/test/cpp/qps/driver.cc b/test/cpp/qps/driver.cc
index d29ca1de94..64a53496ae 100644
--- a/test/cpp/qps/driver.cc
+++ b/test/cpp/qps/driver.cc
@@ -154,19 +154,19 @@ ScenarioResult RunScenario(const ClientConfig& initial_client_config,
server_mark.mutable_mark();
ClientArgs client_mark;
client_mark.mutable_mark();
- for (auto& server : servers) {
- GPR_ASSERT(server.stream->Write(server_mark));
+ for (auto server = servers.begin(); server != servers.end(); server++) {
+ GPR_ASSERT(server->stream->Write(server_mark));
}
- for (auto& client : clients) {
- GPR_ASSERT(client.stream->Write(client_mark));
+ for (auto client = clients.begin(); client != clients.end(); client++) {
+ GPR_ASSERT(client->stream->Write(client_mark));
}
ServerStatus server_status;
ClientStatus client_status;
- for (auto& server : servers) {
- GPR_ASSERT(server.stream->Read(&server_status));
+ for (auto server = servers.begin(); server != servers.end(); server++) {
+ GPR_ASSERT(server->stream->Read(&server_status));
}
- for (auto& client : clients) {
- GPR_ASSERT(client.stream->Read(&client_status));
+ for (auto client = clients.begin(); client != clients.end(); client++) {
+ GPR_ASSERT(client->stream->Read(&client_status));
}
// Wait some time
@@ -176,33 +176,33 @@ ScenarioResult RunScenario(const ClientConfig& initial_client_config,
// Finish a run
ScenarioResult result;
gpr_log(GPR_INFO, "Finishing");
- for (auto& server : servers) {
- GPR_ASSERT(server.stream->Write(server_mark));
+ for (auto server = servers.begin(); server != servers.end(); server++) {
+ GPR_ASSERT(server->stream->Write(server_mark));
}
- for (auto& client : clients) {
- GPR_ASSERT(client.stream->Write(client_mark));
+ for (auto client = clients.begin(); client != clients.end(); client++) {
+ GPR_ASSERT(client->stream->Write(client_mark));
}
- for (auto& server : servers) {
- GPR_ASSERT(server.stream->Read(&server_status));
+ for (auto server = servers.begin(); server != servers.end(); server++) {
+ GPR_ASSERT(server->stream->Read(&server_status));
const auto& stats = server_status.stats();
result.server_resources.push_back(ResourceUsage{
stats.time_elapsed(), stats.time_user(), stats.time_system()});
}
- for (auto& client : clients) {
- GPR_ASSERT(client.stream->Read(&client_status));
+ for (auto client = clients.begin(); client != clients.end(); client++) {
+ GPR_ASSERT(client->stream->Read(&client_status));
const auto& stats = client_status.stats();
result.latencies.MergeProto(stats.latencies());
result.client_resources.push_back(ResourceUsage{
stats.time_elapsed(), stats.time_user(), stats.time_system()});
}
- for (auto& client : clients) {
- GPR_ASSERT(client.stream->WritesDone());
- GPR_ASSERT(client.stream->Finish().IsOk());
+ for (auto client = clients.begin(); client != clients.end(); client++) {
+ GPR_ASSERT(client->stream->WritesDone());
+ GPR_ASSERT(client->stream->Finish().IsOk());
}
- for (auto& server : servers) {
- GPR_ASSERT(server.stream->WritesDone());
- GPR_ASSERT(server.stream->Finish().IsOk());
+ for (auto server = servers.begin(); server != servers.end(); server++) {
+ GPR_ASSERT(server->stream->WritesDone());
+ GPR_ASSERT(server->stream->Finish().IsOk());
}
return result;
}
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index 586b6e7abe..7b81bd35a2 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -105,8 +105,8 @@ class AsyncQpsServerTest : public Server {
~AsyncQpsServerTest() {
server_->Shutdown();
srv_cq_.Shutdown();
- for (auto& thr : threads_) {
- thr.join();
+ for (auto thr = threads_.begin(); thr != threads_.end(); thr++) {
+ thr->join();
}
while (!contexts_.empty()) {
delete contexts_.front();
diff --git a/test/cpp/qps/stats.h b/test/cpp/qps/stats.h
index ca59390ad7..82dc03e3da 100644
--- a/test/cpp/qps/stats.h
+++ b/test/cpp/qps/stats.h
@@ -43,8 +43,8 @@ namespace testing {
template <class T, class F>
double sum(const T& container, F functor) {
double r = 0;
- for (auto v : container) {
- r += functor(v);
+ for (auto v = container.begin(); v != container.end(); v++) {
+ r += functor(*v);
}
return r;
}