blob: b14cb14104379079b0b02dc74168c36d9b89c7c4 [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#ifndef __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__
18#define __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__
19
20#include "component_loader/DllLoader.h"
21
22#include "test/vts/sysfuzzer/common/proto/InterfaceSpecificationMessage.pb.h"
23
24
25using namespace std;
26
27namespace android {
28namespace vts {
29
30class FuzzerBase {
31 public:
32 FuzzerBase();
33 virtual ~FuzzerBase();
34
35 // Loads a target component where the argument is the file path.
36 // Returns true iff successful.
37 bool LoadTargetComponent(const char* target_dll_path);
38
39 // Fuzz tests the loaded component using the provided interface specification.
40 // Returns true iff the testing is conducted completely.
Keun Soo Yim2ee90792016-04-27 14:53:54 -070041 bool Fuzz(const vts::InterfaceSpecificationMessage& message, void** result);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080042
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080043 // Actual implementation of routines to test a specific function using the
44 // provided function interface specification message.
45 // Returns true iff the testing is conducted completely.
Keun Soo Yimc5d092a2016-04-28 16:51:56 +000046 virtual bool Fuzz(const vts::FunctionSpecificationMessage& func_msg,
Keun Soo Yim2ee90792016-04-27 14:53:54 -070047 void** result) {
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080048 return false;
49 };
50
Keun Soo Yim2ee90792016-04-27 14:53:54 -070051 protected:
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080052 // a pointer to a HAL data structure of the loaded component.
53 struct hw_device_t* device_;
54
55 private:
56 // a pointer to the string which contains the loaded component.
57 const char* target_dll_path_;
58
59 // DLL Loader class.
60 DllLoader target_loader_;
61
62 // function name prefix.
63 const char* function_name_prefix_;
64};
65
66} // namespace vts
67} // namespace android
68
69#endif // __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__