blob: 58f0129a1f925f170c14b8f20df920781b2d2ab0 [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
Keun Soo Yimc5d092a2016-04-28 16:51:56 +000046bool FuzzerBase::Fuzz(const vts::InterfaceSpecificationMessage& message,
Keun Soo Yim2ee90792016-04-27 14:53:54 -070047 void** result) {
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080048 cout << "Fuzzing target component: "
49 << "class " << message.component_class()
50 << " type " << message.component_type()
51 << " version " << message.component_type_version() << endl;
52
53 string function_name_prefix = GetFunctionNamePrefix(message);
54 function_name_prefix_ = function_name_prefix.c_str();
55 for (const vts::FunctionSpecificationMessage& func_msg : message.api()) {
Keun Soo Yimc5d092a2016-04-28 16:51:56 +000056 Fuzz(func_msg, result);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080057 }
58 return true;
59}
60
Keun Soo Yim2ee90792016-04-27 14:53:54 -070061
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080062} // namespace vts
63} // namespace android