|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|