Xiaochu Liu | 3991186 | 2018-11-20 14:24:16 -0800 | [diff] [blame] | 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), |
Jae Hoon Kim | 0787497 | 2019-06-26 17:22:34 -0700 | [diff] [blame] | 41 | false, |
| 42 | "" /* session_id */); |
Xiaochu Liu | 3991186 | 2018-11-20 14:24:16 -0800 | [diff] [blame] | 43 | auto collector_action = |
| 44 | std::make_unique<chromeos_update_engine::ObjectCollectorAction< |
| 45 | chromeos_update_engine::OmahaResponse>>(); |
| 46 | BondActions(omaha_request_action.get(), collector_action.get()); |
| 47 | chromeos_update_engine::ActionProcessor action_processor; |
| 48 | action_processor.EnqueueAction(std::move(omaha_request_action)); |
| 49 | action_processor.EnqueueAction(std::move(collector_action)); |
| 50 | action_processor.StartProcessing(); |
| 51 | |
| 52 | loop.Run(); |
| 53 | return 0; |
| 54 | } |