1/* 2 * Copyright (c) 2022-2023 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#ifndef DEVICESTATUSAGENT_FUZZER_H 17#define DEVICESTATUSAGENT_FUZZER_H 18 19#include <cstdio> 20#include <fcntl.h> 21#include <cstdint> 22#include <ctime> 23#include <iostream> 24#include <string> 25#include <thread> 26#include "securec.h" 27 28#include "devicestatus_agent.h" 29#include "stationary_data.h" 30 31#define FUZZ_PROJECT_NAME "fault_fuzzer" 32 33namespace OHOS { 34namespace Msdp { 35namespace DeviceStatus { 36enum class ApiNumber { 37 NUM_ZERO = 0, 38 NUM_ONE, 39 NUM_TWO, 40 NUM_THREE 41}; 42class DevicestatusAgentFuzzer { 43public: 44 static bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size); 45 static void TestSubscribeAgentEvent(const uint8_t* data); 46 static void TestUnSubscribeAgentEvent(Type type); 47 static void TestSubscribeAgentEventIsNullptr(const uint8_t* data); 48 static void TestSubscribeAgentEventTypeIsNullptr(const uint8_t* data); 49 static void TestUnSubscribeAgentEventTypeIsNullptr(Type type); 50 class DeviceStatusAgentClient : public DeviceStatusAgent::DeviceStatusAgentEvent { 51 public: 52 virtual ~DeviceStatusAgentClient() {}; 53 bool OnEventResult(const Data& devicestatusData) override; 54 }; 55}; 56} // namespace DeviceStatus 57} // namespace Msdp 58} // namespace OHOS 59#endif // DEVICESTATUSAGENT_FUZZER_H 60