1 // Copyright 2023 The gRPC Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 #include "test/core/util/fuzzing_channel_args.h" 15 16 #include <grpc/support/port_platform.h> 17 18 #include "src/core/lib/channel/channel_args.h" 19 #include "src/core/lib/resource_quota/resource_quota.h" 20 #include "test/core/util/fuzzing_channel_args.pb.h" 21 22 namespace grpc_core { 23 namespace testing { 24 25 namespace { 26 using grpc::testing::FuzzingChannelArg; 27 } // namespace 28 CreateChannelArgsFromFuzzingConfiguration(const grpc::testing::FuzzingChannelArgs & fuzzing_channel_args,const FuzzingEnvironment & fuzzing_environment)29ChannelArgs CreateChannelArgsFromFuzzingConfiguration( 30 const grpc::testing::FuzzingChannelArgs& fuzzing_channel_args, 31 const FuzzingEnvironment& fuzzing_environment) { 32 ChannelArgs channel_args; 33 for (const auto& fuzz_arg : fuzzing_channel_args.args()) { 34 switch (fuzz_arg.value_case()) { 35 case FuzzingChannelArg::kStr: 36 channel_args = channel_args.Set(fuzz_arg.key(), fuzz_arg.str()); 37 break; 38 case FuzzingChannelArg::kI: 39 channel_args = channel_args.Set(fuzz_arg.key(), fuzz_arg.i()); 40 break; 41 case FuzzingChannelArg::kResourceQuota: 42 channel_args = 43 channel_args.SetObject(fuzzing_environment.resource_quota); 44 break; 45 default: 46 // ignore 47 break; 48 } 49 } 50 return channel_args; 51 } 52 53 } // namespace testing 54 } // namespace grpc_core 55