1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /* This files contains faultlog config modules. */ 17 18 #ifndef THERMAL_FUZZER_TEST_H 19 #define THERMAL_FUZZER_TEST_H 20 21 #include <cstddef> 22 #include <cstdint> 23 #include <cstdio> 24 #include <cstdlib> 25 #include <ctime> 26 #include <fcntl.h> 27 #include <iostream> 28 #include <random> 29 #include <securec.h> 30 #include <string> 31 #include <thread> 32 33 #include "ithermal_action_callback.h" 34 #include "ithermal_level_callback.h" 35 #include "ithermal_temp_callback.h" 36 #include "securec.h" 37 #include "thermal_action_callback_stub.h" 38 #include "thermal_level_callback_stub.h" 39 #include "thermal_mgr_client.h" 40 #include "thermal_temp_callback_stub.h" 41 42 #define FUZZ_PROJECT_NAME "fault_fuzzer" 43 44 namespace OHOS { 45 namespace PowerMgr { 46 enum class ApiNumber : int32_t { NUM_ZERO = 0, NUM_ONE, NUM_TWO, NUM_THREE, NUM_FOUR, NUM_FIVE, NUM_END }; 47 48 class ThermalFuzzerTest { 49 public: 50 static bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size); 51 static void TestSubscribeTemp(const uint8_t* data); 52 static void TestUnSubscribeTemp(); 53 static void TestSubscribeLevel(const uint8_t* data); 54 static void TestUnSubscribeLevel(); 55 static void TestSubscribeAction(const uint8_t* data); 56 static void TestUnSubscribeAction(); 57 static void TestGetLevel(); 58 static void TestSetScene(const uint8_t* data); 59 static void TestGetSensorTemp(const uint8_t* data); 60 61 class ThermalTempTestCallback : public ThermalTempCallbackStub { 62 public: ThermalTempTestCallback()63 ThermalTempTestCallback() {}; ~ThermalTempTestCallback()64 virtual ~ThermalTempTestCallback() {}; 65 virtual bool OnThermalTempChanged(TempCallbackMap& tempCbMap) override; 66 }; 67 class ThermalLevelTestCallback : public ThermalLevelCallbackStub { 68 public: ThermalLevelTestCallback()69 ThermalLevelTestCallback() {}; ~ThermalLevelTestCallback()70 virtual ~ThermalLevelTestCallback() {}; 71 virtual bool GetThermalLevel(ThermalLevel level) override; 72 }; 73 class ThermalActionTestCallback : public ThermalActionCallbackStub { 74 public: ThermalActionTestCallback()75 ThermalActionTestCallback() {}; ~ThermalActionTestCallback()76 virtual ~ThermalActionTestCallback() {}; 77 virtual bool OnThermalActionChanged(ActionCallbackMap& actionCbMap) override; 78 }; 79 }; 80 } // namespace PowerMgr 81 } // namespace OHOS 82 #endif // THERMAL_FUZZER_TEST_H