blob: 48eb71503e2ded380fd85bf59d39f7e7777b63e0 [file] [log] [blame]
Keun Soo Yim6f25faa2016-03-03 13:28:22 -08001/*
2 * Copyright 2016 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 "fuzz_tester/FuzzerBase.h"
18
19#include <string>
20#include <iostream>
21
22#include "test/vts/sysfuzzer/common/proto/InterfaceSpecificationMessage.pb.h"
23
24#include "component_loader/DllLoader.h"
25#include "utils/InterfaceSpecUtil.h"
26
27using namespace std;
28using namespace android;
29
30namespace android {
31namespace vts {
32
33FuzzerBase::FuzzerBase() {}
34
35
36FuzzerBase::~FuzzerBase() {}
37
38
39bool FuzzerBase::LoadTargetComponent(const char* target_dll_path) {
40 target_dll_path_ = target_dll_path;
41 if (!target_loader_.Load(target_dll_path_)) return false;
42 return (device_ = target_loader_.GetHWDevice()) != NULL;
43}
44
45
Brian Carlstrom5ebde2a2016-04-28 04:48:31 +000046bool FuzzerBase::Fuzz(const vts::InterfaceSpecificationMessage& message) {
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080047 cout << "Fuzzing target component: "
48 << "class " << message.component_class()
49 << " type " << message.component_type()
50 << " version " << message.component_type_version() << endl;
51
52 string function_name_prefix = GetFunctionNamePrefix(message);
53 function_name_prefix_ = function_name_prefix.c_str();
54 for (const vts::FunctionSpecificationMessage& func_msg : message.api()) {
Brian Carlstrom5ebde2a2016-04-28 04:48:31 +000055 Fuzz(func_msg);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080056 }
57 return true;
58}
59
60} // namespace vts
61} // namespace android