Covert to GTEST

pull/19275/head
Yash Tibrewal 6 years ago
parent 7994ea53fc
commit 597a67a2b5
  1. 4
      test/core/bad_client/generate_tests.bzl
  2. 21
      test/core/bad_client/tests/unknown_frame.cc

@ -42,6 +42,10 @@ def grpc_bad_client_tests():
name = 'bad_client_test',
srcs = ['bad_client.cc'],
hdrs = ['bad_client.h'],
external_deps = [
"gtest",
],
language = "C++",
deps = ['//test/core/util:grpc_test_util', '//:grpc', '//:gpr', '//test/core/end2end:cq_verifier']
)
for t, topt in BAD_CLIENT_TESTS.items():

@ -18,6 +18,8 @@
#include <string>
#include <gtest/gtest.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/surface/server.h"
#include "test/core/bad_client/bad_client.h"
@ -31,17 +33,15 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq,
}
}
int main(int argc, char** argv) {
grpc_init();
grpc::testing::TestEnvironment env(argc, argv);
namespace {
TEST(UnknownFrameType, Test) {
/* test that all invalid/unknown frame types are handled */
for (int i = 10; i <= 255; i++) {
std::string unknown_frame_string;
unknown_frame_string.append("\x01\x01\x01", sizeof("\x00\x00\x00") - 1);
unknown_frame_string.append("\x00\x00\x00", sizeof("\x00\x00\x00") - 1);
char frame_type = static_cast<char>(i);
unknown_frame_string.append(&frame_type, 1);
unknown_frame_string.append("\x01\x02\x03\x04\x05",
unknown_frame_string.append("\x00\x00\x00\x00\x01",
sizeof("\x00\x00\x00\x00\x01") - 1);
grpc_bad_client_arg args[2];
args[0] = connection_preface_arg;
@ -50,7 +50,14 @@ int main(int argc, char** argv) {
args[1].client_payload_length = unknown_frame_string.size();
grpc_run_bad_client_test(verifier, args, 2, GRPC_BAD_CLIENT_DISCONNECT);
}
}
} // namespace
int main(int argc, char** argv) {
grpc_init();
grpc::testing::TestEnvironment env(argc, argv);
::testing::InitGoogleTest(&argc, argv);
int retval = RUN_ALL_TESTS();
grpc_shutdown();
return 0;
return retval;
}

Loading…
Cancel
Save