[server-fuzzer] Fix behavior on failed transport creation (#34827)

pull/34862/head
Craig Tiller 1 year ago committed by GitHub
parent 248ce57f30
commit b7b75fca3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      test/core/end2end/fuzzers/server_fuzzer.cc
  2. 268
      test/core/end2end/fuzzers/server_fuzzer_corpus/5367317597847552

@ -28,7 +28,6 @@
#include "src/core/lib/experiments/config.h" #include "src/core/lib/experiments/config.h"
#include "src/core/lib/gprpp/env.h" #include "src/core/lib/gprpp/env.h"
#include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/server.h" #include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/transport.h" #include "src/core/lib/transport/transport.h"
@ -72,14 +71,21 @@ class ServerFuzzer final : public BasicFuzzer {
.get()); .get());
Transport* transport = Transport* transport =
grpc_create_chttp2_transport(channel_args, mock_endpoint_, false); grpc_create_chttp2_transport(channel_args, mock_endpoint_, false);
GPR_ASSERT(GRPC_LOG_IF_ERROR( transport_setup_ok_ =
"SetupTransport", Server::FromC(server_)->SetupTransport( Server::FromC(server_)
transport, nullptr, channel_args, nullptr))); ->SetupTransport(transport, nullptr, channel_args, nullptr)
.ok();
if (transport_setup_ok_) {
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);
} else {
DestroyServer();
}
} }
~ServerFuzzer() { GPR_ASSERT(server_ == nullptr); } ~ServerFuzzer() { GPR_ASSERT(server_ == nullptr); }
bool transport_setup_ok() const { return transport_setup_ok_; }
private: private:
Result CreateChannel( Result CreateChannel(
const api_fuzzer::CreateChannel& /* create_channel */) override { const api_fuzzer::CreateChannel& /* create_channel */) override {
@ -100,6 +106,7 @@ class ServerFuzzer final : public BasicFuzzer {
grpc_endpoint* mock_endpoint_ = grpc_mock_endpoint_create(discard_write); grpc_endpoint* mock_endpoint_ = grpc_mock_endpoint_create(discard_write);
grpc_server* server_ = grpc_server_create(nullptr, nullptr); grpc_server* server_ = grpc_server_create(nullptr, nullptr);
bool transport_setup_ok_ = false;
}; };
} // namespace testing } // namespace testing
@ -111,5 +118,7 @@ DEFINE_PROTO_FUZZER(const fuzzer_input::Msg& msg) {
} }
grpc_core::ApplyFuzzConfigVars(msg.config_vars()); grpc_core::ApplyFuzzConfigVars(msg.config_vars());
grpc_core::TestOnlyReloadExperimentsFromConfigVariables(); grpc_core::TestOnlyReloadExperimentsFromConfigVariables();
grpc_core::testing::ServerFuzzer(msg).Run(msg.api_actions()); grpc_core::testing::ServerFuzzer server_fuzzer(msg);
if (!server_fuzzer.transport_setup_ok()) return;
server_fuzzer.Run(msg.api_actions());
} }

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save