blob: 77a33b18975b3bca4f759a2736f58da05b0aec6a [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:
Keun Soo Yimd4559882016-05-13 20:03:12 -070032 FuzzerBase(int target_class);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080033 virtual ~FuzzerBase();
34
35 // Loads a target component where the argument is the file path.
36 // Returns true iff successful.
Keun Soo Yim34067de2016-05-17 09:46:37 -070037 bool LoadTargetComponent(const char* target_dll_path,
38 const char* module_name = NULL);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080039
40 // Fuzz tests the loaded component using the provided interface specification.
41 // Returns true iff the testing is conducted completely.
Keun Soo Yim2ee90792016-04-27 14:53:54 -070042 bool Fuzz(const vts::InterfaceSpecificationMessage& message, void** result);
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080043
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080044 // Actual implementation of routines to test a specific function using the
45 // provided function interface specification message.
46 // Returns true iff the testing is conducted completely.
Keun Soo Yimc5d092a2016-04-28 16:51:56 +000047 virtual bool Fuzz(const vts::FunctionSpecificationMessage& func_msg,
Keun Soo Yim2ee90792016-04-27 14:53:54 -070048 void** result) {
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080049 return false;
50 };
51
Keun Soo Yim2ee90792016-04-27 14:53:54 -070052 protected:
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080053 // a pointer to a HAL data structure of the loaded component.
54 struct hw_device_t* device_;
55
Keun Soo Yimd4559882016-05-13 20:03:12 -070056 // DLL Loader class.
57 DllLoader target_loader_;
58
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080059 private:
60 // a pointer to the string which contains the loaded component.
61 const char* target_dll_path_;
62
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080063 // function name prefix.
64 const char* function_name_prefix_;
Keun Soo Yimd4559882016-05-13 20:03:12 -070065
66 // target class
67 const int target_class_;
Keun Soo Yim6f25faa2016-03-03 13:28:22 -080068};
69
70} // namespace vts
71} // namespace android
72
73#endif // __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__