1 /* 2 * Copyright (C) 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 #ifndef __VTS_SYSFUZZER_COMMON_REPLAYER_VTSHIDLHALREPLAYER_H__ 17 #define __VTS_SYSFUZZER_COMMON_REPLAYER_VTSHIDLHALREPLAYER_H__ 18 19 #include "fuzz_tester/FuzzerWrapper.h" 20 #include "test/vts/proto/VtsProfilingMessage.pb.h" 21 22 namespace android { 23 namespace vts { 24 25 // Class to perform VTS record and replay test. 26 // The class is responsible for: 27 // 1) Load and parse a given trace file. 28 // 2) Replay the API call sequence parsed from the trace file by calling 29 // the HAL drive. 30 // 3) Verify the return results of each API calls. 31 class VtsHidlHalReplayer { 32 public: 33 VtsHidlHalReplayer(const std::string& spec_path, 34 const std::string& callback_socket_name); 35 36 // Loads the given interface specification (.vts file) and parses it to 37 // ComponentSpecificationMessage. 38 bool LoadComponentSpecification(const std::string& package, 39 float version, 40 const std::string& interface_name, 41 ComponentSpecificationMessage* message); 42 43 // Parses the trace file, stores the parsed sequence of API calls in 44 // func_msgs and the corresponding return results in result_msgs. 45 bool ParseTrace(const std::string& trace_file, 46 vector<VtsProfilingRecord>* call_msgs, 47 vector<VtsProfilingRecord>* result_msgs); 48 49 // Replays the API call sequence parsed from the trace file. 50 bool ReplayTrace(const std::string& spec_lib_file_path, 51 const std::string& trace_file, const std::string& hal_service_name); 52 53 private: 54 // A FuzzerWrapper instance. 55 FuzzerWrapper wrapper_; 56 // The interface specification ASCII proto file. 57 std::string spec_path_; 58 // The server socket port # of the agent. 59 std::string callback_socket_name_; 60 }; 61 62 } // namespace vts 63 } // namespace android 64 65 #endif // __VTS_SYSFUZZER_COMMON_REPLAYER_VTSHIDLHALREPLAYER_H__ 66