1 /* 2 * 3 * Copyright 2016 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #include <stdbool.h> 20 21 #include <grpc/grpc.h> 22 23 #include <grpc/support/log.h> 24 #include "src/core/lib/iomgr/exec_ctx.h" 25 #include "src/core/lib/iomgr/load_file.h" 26 27 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); 28 29 extern bool squelch; 30 extern bool leak_check; 31 32 int main(int argc, char** argv) { 33 grpc_slice buffer; 34 squelch = false; 35 leak_check = false; 36 /* TODO(yashkt) Calling grpc_init breaks tests. Fix the tests and replace 37 * grpc_core::ExecCtx::GlobalInit with grpc_init and GlobalShutdown with 38 * grpc_shutdown */ 39 GPR_ASSERT( 40 GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); 41 LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), 42 GRPC_SLICE_LENGTH(buffer)); 43 grpc_core::ExecCtx::GlobalInit(); 44 grpc_slice_unref(buffer); 45 grpc_core::ExecCtx::GlobalShutdown(); 46 return 0; 47 } 48