1 // 2 // Copyright (C) 2018 The Android Open Source Project 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #include <brillo/message_loops/fake_message_loop.h> 18 19 #include "update_engine/common/mock_http_fetcher.h" 20 #include "update_engine/common/test_utils.h" 21 #include "update_engine/fake_system_state.h" 22 #include "update_engine/omaha_request_action.h" 23 24 class Environment { 25 public: 26 Environment() { logging::SetMinLogLevel(logging::LOG_FATAL); } 27 }; 28 29 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 30 static Environment env; 31 brillo::FakeMessageLoop loop(nullptr); 32 loop.SetAsCurrent(); 33 34 chromeos_update_engine::FakeSystemState fake_system_state; 35 auto omaha_request_action = 36 std::make_unique<chromeos_update_engine::OmahaRequestAction>( 37 &fake_system_state, 38 nullptr, 39 std::make_unique<chromeos_update_engine::MockHttpFetcher>( 40 data, size, nullptr), 41 false); 42 auto collector_action = 43 std::make_unique<chromeos_update_engine::ObjectCollectorAction< 44 chromeos_update_engine::OmahaResponse>>(); 45 BondActions(omaha_request_action.get(), collector_action.get()); 46 chromeos_update_engine::ActionProcessor action_processor; 47 action_processor.EnqueueAction(std::move(omaha_request_action)); 48 action_processor.EnqueueAction(std::move(collector_action)); 49 action_processor.StartProcessing(); 50 51 loop.Run(); 52 return 0; 53 } 54