Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 25 | using namespace std; |
| 26 | |
| 27 | namespace android { |
| 28 | namespace vts { |
| 29 | |
| 30 | class FuzzerBase { |
| 31 | public: |
Keun Soo Yim | d455988 | 2016-05-13 20:03:12 -0700 | [diff] [blame] | 32 | FuzzerBase(int target_class); |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 33 | virtual ~FuzzerBase(); |
| 34 | |
| 35 | // Loads a target component where the argument is the file path. |
| 36 | // Returns true iff successful. |
Keun Soo Yim | 34067de | 2016-05-17 09:46:37 -0700 | [diff] [blame] | 37 | bool LoadTargetComponent(const char* target_dll_path, |
| 38 | const char* module_name = NULL); |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 39 | |
| 40 | // Fuzz tests the loaded component using the provided interface specification. |
| 41 | // Returns true iff the testing is conducted completely. |
Keun Soo Yim | 2ee9079 | 2016-04-27 14:53:54 -0700 | [diff] [blame] | 42 | bool Fuzz(const vts::InterfaceSpecificationMessage& message, void** result); |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 43 | |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 44 | // 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 Yim | c5d092a | 2016-04-28 16:51:56 +0000 | [diff] [blame] | 47 | virtual bool Fuzz(const vts::FunctionSpecificationMessage& func_msg, |
Keun Soo Yim | 2ee9079 | 2016-04-27 14:53:54 -0700 | [diff] [blame] | 48 | void** result) { |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 49 | return false; |
| 50 | }; |
| 51 | |
Keun Soo Yim | 2ee9079 | 2016-04-27 14:53:54 -0700 | [diff] [blame] | 52 | protected: |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 53 | // a pointer to a HAL data structure of the loaded component. |
| 54 | struct hw_device_t* device_; |
| 55 | |
Keun Soo Yim | d455988 | 2016-05-13 20:03:12 -0700 | [diff] [blame] | 56 | // DLL Loader class. |
| 57 | DllLoader target_loader_; |
| 58 | |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 59 | private: |
| 60 | // a pointer to the string which contains the loaded component. |
| 61 | const char* target_dll_path_; |
| 62 | |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 63 | // function name prefix. |
| 64 | const char* function_name_prefix_; |
Keun Soo Yim | d455988 | 2016-05-13 20:03:12 -0700 | [diff] [blame] | 65 | |
| 66 | // target class |
| 67 | const int target_class_; |
Keun Soo Yim | 6f25faa | 2016-03-03 13:28:22 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | } // namespace vts |
| 71 | } // namespace android |
| 72 | |
| 73 | #endif // __VTS_SYSFUZZER_COMMON_FUZZER_BASE_H__ |