Allow API fuzzer to send multiple slices (#27993)

* Allow API fuzzer to send multiple slices

* fixes
pull/28018/head
Craig Tiller 3 years ago committed by GitHub
parent 0ea2c37263
commit b690bd011f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/lib/transport/byte_stream.cc
  2. 7
      test/core/end2end/fuzzers/api_fuzzer.cc
  3. 2
      test/core/end2end/fuzzers/api_fuzzer.proto

@ -40,6 +40,10 @@ SliceBufferByteStream::SliceBufferByteStream(grpc_slice_buffer* slice_buffer,
GPR_ASSERT(slice_buffer->length <= UINT32_MAX); GPR_ASSERT(slice_buffer->length <= UINT32_MAX);
grpc_slice_buffer_init(&backing_buffer_); grpc_slice_buffer_init(&backing_buffer_);
grpc_slice_buffer_swap(slice_buffer, &backing_buffer_); grpc_slice_buffer_swap(slice_buffer, &backing_buffer_);
if (backing_buffer_.count == 0) {
grpc_slice_buffer_add_indexed(&backing_buffer_, grpc_empty_slice());
GPR_ASSERT(backing_buffer_.count > 0);
}
} }
SliceBufferByteStream::~SliceBufferByteStream() {} SliceBufferByteStream::~SliceBufferByteStream() {}

@ -379,9 +379,12 @@ class Call : public std::enable_shared_from_this<Call> {
*batch_is_ok = false; *batch_is_ok = false;
} else { } else {
*batch_ops |= 1 << GRPC_OP_SEND_MESSAGE; *batch_ops |= 1 << GRPC_OP_SEND_MESSAGE;
auto send = ReadSlice(batch_op.send_message().message()); std::vector<grpc_slice> slices;
for (const auto& m : batch_op.send_message().message()) {
slices.push_back(ReadSlice(m));
}
send_message_ = op.data.send_message.send_message = send_message_ = op.data.send_message.send_message =
grpc_raw_byte_buffer_create(&send, 1); grpc_raw_byte_buffer_create(slices.data(), slices.size());
unwinders->push_back([this]() { unwinders->push_back([this]() {
grpc_byte_buffer_destroy(send_message_); grpc_byte_buffer_destroy(send_message_);
send_message_ = nullptr; send_message_ = nullptr;

@ -110,7 +110,7 @@ message SendInitialMetadata {
} }
message SendMessage { message SendMessage {
ByteSlice message = 1; repeated ByteSlice message = 1;
} }
message SendCloseFromClient { message SendCloseFromClient {

Loading…
Cancel
Save