blob: 995de8c5773d6262927a34300c777bc68ce9a490 [file] [log] [blame]
Xiaochu Liu39911862018-11-20 14:24:16 -08001//
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"
Amin Hassaniec7bc112020-10-29 16:47:58 -070021#include "update_engine/cros/fake_system_state.h"
22#include "update_engine/cros/omaha_request_action.h"
Xiaochu Liu39911862018-11-20 14:24:16 -080023
24class Environment {
25 public:
26 Environment() { logging::SetMinLogLevel(logging::LOG_FATAL); }
27};
28
29extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
30 static Environment env;
31 brillo::FakeMessageLoop loop(nullptr);
32 loop.SetAsCurrent();
33
Amin Hassani538bd592020-11-04 20:46:08 -080034 chromeos_update_engine::FakeSystemState::CreateInstance();
Xiaochu Liu39911862018-11-20 14:24:16 -080035 auto omaha_request_action =
36 std::make_unique<chromeos_update_engine::OmahaRequestAction>(
Xiaochu Liu39911862018-11-20 14:24:16 -080037 nullptr,
38 std::make_unique<chromeos_update_engine::MockHttpFetcher>(
39 data, size, nullptr),
Jae Hoon Kim07874972019-06-26 17:22:34 -070040 false,
41 "" /* session_id */);
Xiaochu Liu39911862018-11-20 14:24:16 -080042 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}