1 // Copyright (C) 2020 The Android Open Source Project 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 15 #include "fuzz_utils.h" 16 17 #include <android-base/logging.h> 18 19 namespace android::fuzz { 20 CheckInternal(bool value,std::string_view msg)21void CheckInternal(bool value, std::string_view msg) { 22 CHECK(value) << msg; 23 } 24 GetProtoValueDescriptor(const google::protobuf::Descriptor * action_desc)25const google::protobuf::OneofDescriptor* GetProtoValueDescriptor( 26 const google::protobuf::Descriptor* action_desc) { 27 CHECK(action_desc); 28 CHECK(action_desc->oneof_decl_count() == 1) 29 << action_desc->oneof_decl_count() << " oneof fields found in " << action_desc->name() 30 << "; only one is expected."; 31 auto* oneof_value_desc = action_desc->oneof_decl(0); 32 CHECK(oneof_value_desc); 33 CHECK(oneof_value_desc->name() == "value") 34 << "oneof field has name " << oneof_value_desc->name(); 35 return oneof_value_desc; 36 } 37 38 } // namespace android::fuzz 39