• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #define private public
16 #define protected public
17 
18 #include "hilog_wrapper.h"
19 
20 // event/commonevent
21 #include "async_common_event_result.h"
22 #include "common_event_manager.h"
23 #include "common_event_data.h"
24 #include "common_event_publish_info.h"
25 #include "common_event_subscribe_info.h"
26 #include "common_event_subscriber.h"
27 #include "common_event_support.h"
28 #include "matching_skills.h"
29 
30 // event/eventhandle
31 #include "event_handler.h"
32 #include "event_queue.h"
33 #include "event_runner.h"
34 #include "inner_event.h"
35 #include "dumper.h"
36 #include "logger.h"
37 
38 // aafwk/ability
39 #include "ability.h"
40 #include "data_ability_helper.h"
41 #include "ability_lifecycle_interface.h"
42 #include "ability_lifecycle.h"
43 #include "data_uri_utils.h"
44 #include "ability_manager.h"
45 
46 // AMS
47 #include "ohos_application.h"
48 #include "ability_context.h"
49 #include "element_name.h"
50 #include "want.h"
51 #include "ability_record_mgr.h"
52 
53 // aafwk/bundle
54 #include "bundle_mgr_proxy.h"
55 #include "short_wrapper.h"
56 #include "../include/getparam.h"
57 #include "../include/fuzzTestManager.h"
58 
59 #include "../include/fuzzConfigParser.h"
60 
61 #include "abs_shared_result_set.h"
62 #include "data_ability_predicates.h"
63 #include "values_bucket.h"
64 
65 #include <unistd.h>
66 #include <csignal>
67 
68 #undef private
69 #undef protected
70 using namespace OHOS::AppExecFwk;
71 namespace OHOS {
72 namespace EventFwk {
73 std::shared_ptr<fuzzTestManager> fuzzTestManager::instance_ = nullptr;
74 
75 // RegisterAsyncCommonEventResult
RegisterAsyncCommonEventResult()76 void fuzzTestManager::RegisterAsyncCommonEventResult()
77 {
78     callFunctionMap_["AsyncCommonEventResultSetCode"] = []() {
79         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
80         temp.get()->SetCode(GetU32Param());
81         std::cout << temp->GetCode();
82     };
83     callFunctionMap_["AsyncCommonEventResultGetCode"] = []() {
84         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
85         temp->GetCode();
86     };
87     callFunctionMap_["AsyncCommonEventResultSetData"] = []() {
88         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
89         temp->SetData(GetStringParam());
90     };
91     callFunctionMap_["AsyncCommonEventResultGetData"] = []() {
92         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
93         temp->GetData();
94     };
95     callFunctionMap_["AsyncCommonEventResultSetCodeAndData"] = []() {
96         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
97         temp->SetCodeAndData(GetIntParam(), GetStringParam());
98     };
99     callFunctionMap_["AsyncCommonEventResultAbortCommonEvent"] = []() {
100         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
101         temp->AbortCommonEvent();
102     };
103     callFunctionMap_["AsyncCommonEventResultClearAbortCommonEvent"] = []() {
104         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
105         temp->ClearAbortCommonEvent();
106     };
107     callFunctionMap_["AsyncCommonEventResultGetAbortCommonEvent"] = []() {
108         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
109         temp->GetAbortCommonEvent();
110     };
111     callFunctionMap_["AsyncCommonEventResultFinishCommonEvent"] = []() {
112         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
113         temp->FinishCommonEvent();
114     };
115     callFunctionMap_["AsyncCommonEventResultIsOrderedCommonEvent"] = []() {
116         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
117         temp->IsOrderedCommonEvent();
118     };
119     callFunctionMap_["AsyncCommonEventResultIsStickyCommonEvent"] = []() {
120         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
121         temp->IsStickyCommonEvent();
122     };
123     callFunctionMap_["AsyncCommonEventResultCheckSynchronous"] = []() {
124         std::shared_ptr<AsyncCommonEventResult> temp = GetParamAsyncCommonEventResult();
125         temp->CheckSynchronous();
126     };
127 }
128 
129 // RegisterCommonEventData
RegisterCommonEventData()130 void fuzzTestManager::RegisterCommonEventData()
131 {
132     callFunctionMap_["CommonEventDataSetWant"] = []() {
133         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
134         temp->SetWant(*(GetParamWant().get()));
135     };
136     callFunctionMap_["CommonEventDataGetWant"] = []() {
137         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
138         temp->GetWant();
139     };
140     callFunctionMap_["CommonEventDataSetCode"] = []() {
141         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
142         temp->SetCode(GetIntParam());
143     };
144     callFunctionMap_["CommonEventDataGetCode"] = []() {
145         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
146         temp->GetCode();
147     };
148     callFunctionMap_["CommonEventDataSetData"] = []() {
149         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
150         temp->SetData(GetStringParam());
151     };
152     callFunctionMap_["CommonEventDataGetData"] = []() {
153         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
154         temp->GetData();
155     };
156     callFunctionMap_["CommonEventDataMarshalling"] = []() {
157         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
158         Parcel p;
159         temp->Marshalling(p);
160     };
161     callFunctionMap_["CommonEventDataUnmarshalling"] = []() {
162         std::shared_ptr<CommonEventData> temp = GetParamCommonEventData();
163         Parcel p;
164         temp->Unmarshalling(p);
165     };
166 }
167 
168 // RegisterCommonEventManager
RegisterCommonEventManager()169 void fuzzTestManager::RegisterCommonEventManager()
170 {
171     callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventData"] = []() {
172         std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
173         temp->PublishCommonEvent(*(GetParamCommonEventData().get()));
174     };
175     callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventDataCommonEventPublishInfo"] = []() {
176         std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
177         temp->PublishCommonEvent(*(GetParamCommonEventData().get()), *(GetParamCommonEventPublishInfo().get()));
178     };
179     callFunctionMap_["CommonEventManagerPublishCommonEventCommonEventDataCommonEventPublishInfoCommonEventSubscriber"] =
180         []() {
181             std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
182             temp->PublishCommonEvent(*(GetParamCommonEventData().get()),
183                 *(GetParamCommonEventPublishInfo().get()),
184                 GetParamCommonEventSubscriber());
185         };
186     callFunctionMap_["CommonEventManagerSubscribeCommonEvent"] = []() {
187         std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
188         temp->SubscribeCommonEvent(GetParamCommonEventSubscriber());
189     };
190     callFunctionMap_["CommonEventManagerUnSubscribeCommonEvent"] = []() {
191         std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
192         temp->UnSubscribeCommonEvent(GetParamCommonEventSubscriber());
193     };
194     callFunctionMap_["CommonEventManagerGetStickyCommonEvent"] = []() {
195         std::shared_ptr<CommonEventManager> temp = GetParamCommonEventManager();
196         temp->GetStickyCommonEvent(GetStringParam(), *(GetParamCommonEventData()));
197     };
198 }
199 
200 // RegisterCommonEventPublishInfo
RegisterCommonEventPublishInfo()201 void fuzzTestManager::RegisterCommonEventPublishInfo()
202 {
203     callFunctionMap_["CommonEventPublishInfoSetSticky"] = []() {
204         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
205         temp->SetSticky(GetBoolParam());
206     };
207     callFunctionMap_["CommonEventPublishInfoIsSticky"] = []() {
208         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
209         temp->IsSticky();
210     };
211     callFunctionMap_["CommonEventPublishInfoSetSubscriberPermissions"] = []() {
212         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
213         temp->SetSubscriberPermissions(GetStringVectorParam());
214     };
215     callFunctionMap_["CommonEventPublishInfoGetSubscriberPermissions"] = []() {
216         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
217         temp->GetSubscriberPermissions();
218     };
219     callFunctionMap_["CommonEventPublishInfoSetOrdered"] = []() {
220         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
221         temp->SetOrdered(GetBoolParam());
222     };
223     callFunctionMap_["CommonEventPublishInfoIsOrdered"] = []() {
224         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
225         temp->IsOrdered();
226     };
227     callFunctionMap_["CommonEventPublishInfoMarshalling"] = []() {
228         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
229         Parcel p;
230         temp->Marshalling(p);
231     };
232 
233     callFunctionMap_["CommonEventPublishInfoUnmarshalling"] = []() {
234         std::shared_ptr<CommonEventPublishInfo> temp = GetParamCommonEventPublishInfo();
235         Parcel p;
236         temp->Unmarshalling(p);
237     };
238 }
239 
240 // RegisterCommonEventSubscribeInfo
RegisterCommonEventSubscribeInfo()241 void fuzzTestManager::RegisterCommonEventSubscribeInfo()
242 {
243     callFunctionMap_["CommonEventSubscribeInfoSetPriority"] = []() {
244         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
245         temp->SetPriority(GetS32Param());
246     };
247     callFunctionMap_["CommonEventSubscribeInfoGetPriority"] = []() {
248         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
249         temp->GetPriority();
250     };
251     callFunctionMap_["CommonEventSubscribeInfoSetPermission"] = []() {
252         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
253         temp->SetPermission(GetStringParam());
254     };
255     callFunctionMap_["CommonEventSubscribeInfoGetPermission"] = []() {
256         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
257         temp->GetPermission();
258     };
259     callFunctionMap_["CommonEventSubscribeInfoSetThreadMode"] = []() {
260         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
261         temp->SetThreadMode(GetParamThreadMode());
262     };
263     callFunctionMap_["CommonEventSubscribeInfoSetDeviceId"] = []() {
264         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
265         temp->SetDeviceId(GetStringParam());
266     };
267     callFunctionMap_["CommonEventSubscribeInfoGetDeviceId"] = []() {
268         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
269         temp->GetDeviceId();
270     };
271     callFunctionMap_["CommonEventSubscribeInfoGetMatchingSkills"] = []() {
272         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
273         temp->GetMatchingSkills();
274     };
275     callFunctionMap_["CommonEventSubscribeInfoMarshalling"] = []() {
276         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
277         Parcel p;
278         temp->Marshalling(p);
279     };
280     callFunctionMap_["CommonEventSubscribeInfoUnmarshalling"] = []() {
281         std::shared_ptr<CommonEventSubscribeInfo> temp = GetParamCommonEventSubscribeInfo();
282         Parcel p;
283         temp->Unmarshalling(p);
284     };
285 }
286 
287 // RegisterCommonEventSubscriber
RegisterCommonEventSubscriber()288 void fuzzTestManager::RegisterCommonEventSubscriber()
289 {
290     callFunctionMap_["CommonEventSubscriberOnReceiveEvent"] = []() {
291         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
292         temp->OnReceiveEvent(*(GetParamCommonEventData().get()));
293     };
294     callFunctionMap_["CommonEventSubscriberGetSubscribeInfo"] = []() {
295         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
296         temp->GetSubscribeInfo();
297     };
298     callFunctionMap_["CommonEventSubscriberSetCode"] = []() {
299         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
300         temp->SetCode(GetIntParam());
301     };
302     callFunctionMap_["CommonEventSubscriberGetCode"] = []() {
303         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
304         temp->GetCode();
305     };
306     callFunctionMap_["CommonEventSubscriberSetData"] = []() {
307         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
308         temp->SetData(GetStringParam());
309     };
310     callFunctionMap_["CommonEventSubscriberGetData"] = []() {
311         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
312         temp->GetData();
313     };
314     callFunctionMap_["CommonEventSubscriberSetCodeAndData"] = []() {
315         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
316         temp->SetCodeAndData(GetIntParam(), GetStringParam());
317     };
318     callFunctionMap_["CommonEventSubscriberAbortCommonEvent"] = []() {
319         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
320         temp->AbortCommonEvent();
321     };
322     callFunctionMap_["CommonEventSubscriberClearAbortCommonEvent"] = []() {
323         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
324         temp->ClearAbortCommonEvent();
325     };
326     callFunctionMap_["CommonEventSubscriberGetAbortCommonEvent"] = []() {
327         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
328         temp->GetAbortCommonEvent();
329     };
330     callFunctionMap_["CommonEventSubscriberGoAsyncCommonEvent"] = []() {
331         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
332         temp->GoAsyncCommonEvent();
333     };
334     callFunctionMap_["CommonEventSubscriberIsOrderedCommonEvent"] = []() {
335         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
336         temp->IsOrderedCommonEvent();
337     };
338     callFunctionMap_["CommonEventSubscriberIsStickyCommonEvent"] = []() {
339         std::shared_ptr<CommonEventSubscriber> temp = GetParamCommonEventSubscriber();
340         temp->IsStickyCommonEvent();
341     };
342 }
343 
344 // RegisterCommonEventSupport
RegisterCommonEventSupport()345 void fuzzTestManager::RegisterCommonEventSupport()
346 {
347     callFunctionMap_["CommonEventSupportIsSystemEvent"] = []() {
348         std::shared_ptr<CommonEventSupport> temp = GetParamCommonEventSupport();
349         std::string s = GetStringParam();
350         temp->IsSystemEvent(s);
351     };
352 }
353 
354 // RegisterMatchingSkills
RegisterMatchingSkills()355 void fuzzTestManager::RegisterMatchingSkills()
356 {
357     callFunctionMap_["MatchingSkillsAddEntity"] = []() {
358         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
359         temp->AddEntity(GetStringParam());
360     };
361     callFunctionMap_["MatchingSkillsHasEntity"] = []() {
362         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
363         temp->HasEntity(GetStringParam());
364     };
365     callFunctionMap_["MatchingSkillsRemoveEntity"] = []() {
366         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
367         temp->RemoveEntity(GetStringParam());
368     };
369     callFunctionMap_["MatchingSkillsCountEntities"] = []() {
370         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
371         temp->CountEntities();
372     };
373     callFunctionMap_["MatchingSkillsAddEvent"] = []() {
374         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
375         temp->AddEvent(GetStringParam());
376     };
377     callFunctionMap_["MatchingSkillsCountEvent"] = []() {
378         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
379         temp->CountEvent();
380     };
381     callFunctionMap_["MatchingSkillsGetEvents"] = []() {
382         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
383         temp->GetEvents();
384     };
385     callFunctionMap_["MatchingSkillsRemoveEvent"] = []() {
386         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
387         temp->RemoveEvent(GetStringParam());
388     };
389     callFunctionMap_["MatchingSkillsHasEvent"] = []() {
390         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
391         temp->HasEvent(GetStringParam());
392     };
393     callFunctionMap_["MatchingSkillsAddScheme"] = []() {
394         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
395         temp->AddScheme(GetStringParam());
396     };
397     callFunctionMap_["MatchingSkillsHasScheme"] = []() {
398         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
399         temp->HasScheme(GetStringParam());
400     };
401     callFunctionMap_["MatchingSkillsRemoveScheme"] = []() {
402         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
403         temp->RemoveScheme(GetStringParam());
404     };
405     callFunctionMap_["MatchingSkillsCountSchemes"] = []() {
406         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
407         temp->CountSchemes();
408     };
409     callFunctionMap_["MatchingSkillsMatch"] = []() {
410         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
411         temp->Match(*(GetParamWant().get()));
412     };
413     callFunctionMap_["MatchingSkillsMarshalling"] = []() {
414         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
415         Parcel p;
416         temp->Marshalling(p);
417     };
418     callFunctionMap_["MatchingSkillsUnmarshalling"] = []() {
419         std::shared_ptr<MatchingSkills> temp = GetParamMatchingSkills();
420         Parcel p;
421         temp->Unmarshalling(p);
422     };
423 }
424 
425 // RegisterDumper
RegisterDumper()426 void fuzzTestManager::RegisterDumper()
427 {
428     callFunctionMap_["DumperDump"] = []() {
429         TestDumper temp;
430         temp.Dump(GetStringParam());
431     };
432     callFunctionMap_["DumperGetTag"] = []() {
433         TestDumper temp;
434         temp.GetTag();
435     };
436 }
437 
438 // RegisterEventHandler
RegisterEventHandler()439 void fuzzTestManager::RegisterEventHandler()
440 {
441     callFunctionMap_["EventHandlerCurrent"] = []() {
442         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
443         temp->Current();
444     };
445     callFunctionMap_["EventHandlerSendEventPointer&int64_tPriority"] = []() {
446         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
447         temp->SendEvent(GetParamInnerEvent(), GetS64Param());
448     };
449 
450     callFunctionMap_["EventHandlerSendTimingEvent"] = []() {
451         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
452         temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param());
453     };
454 
455     callFunctionMap_["EventHandlerSendEventPointerPriority"] = []() {
456         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
457         temp->SendEvent(GetParamInnerEvent());
458     };
459 
460     callFunctionMap_["EventHandlerSendEventPointer&&int64_tPriority"] = []() {
461         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
462         temp->SendEvent(GetParamInnerEvent(), GetS64Param());
463     };
464 
465     callFunctionMap_["EventHandlerSendEventuint32_tint64_tint64_t"] = []() {
466         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
467         temp->SendEvent(GetU32Param(), GetS64Param(), GetS64Param());
468     };
469 
470     callFunctionMap_["EventHandlerSendEventuint32_tint64_tPriority"] = []() {
471         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
472         temp->SendEvent(GetU32Param(), GetS64Param(), GetParamPriority());
473     };
474 
475     callFunctionMap_["EventHandlerSendEventuint32_tPriority"] = []() {
476         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
477         temp->SendEvent(GetU32Param(), GetParamPriority());
478     };
479 
480     callFunctionMap_["EventHandlerSendEventuint32_tshared_ptr<T>int64_t"] = []() {
481         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
482         temp->SendEvent(GetU32Param(), GetParamEventHandler(), GetS64Param());
483     };
484 
485     callFunctionMap_["EventHandlerSendEventuint32_tweak_ptr<T>int64_t"] = []() {
486         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
487         std::weak_ptr<int> wp = std::make_shared<int>(1);
488         temp->SendEvent(GetU32Param(), wp, GetS64Param());
489     };
490 
491     callFunctionMap_["EventHandlerSendEventuint32_tunique_ptr<T, D>&int64_t"] = []() {
492         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
493         std::unique_ptr<int> p(new int, std::default_delete<int>());
494         temp->SendEvent(GetU32Param(), p, GetS64Param());
495     };
496 
497     callFunctionMap_["EventHandlerSendEventuint32_t"] = []() {
498         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
499         temp->SendEvent(GetU32Param());
500     };
501 
502     callFunctionMap_["EventHandlerSendEventunique_ptr<T, D>&&int64_t"] = []() {
503         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
504         temp->SendImmediateEvent(GetParamInnerEvent());
505     };
506 
507     callFunctionMap_["EventHandlerSendImmediateEventPointer"] = []() {
508         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
509         temp->SendImmediateEvent(GetParamInnerEvent());
510     };
511 
512     callFunctionMap_["EventHandlerSendImmediateEventuint32_tint64_t"] = []() {
513         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
514         temp->SendImmediateEvent(GetU32Param(), GetS64Param());
515     };
516 
517     callFunctionMap_["EventHandlerSendImmediateEventuint32_tshared_ptr<T>"] = []() {
518         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
519         temp->SendImmediateEvent(GetU32Param(), GetParamInnerEvent());
520     };
521 
522     callFunctionMap_["EventHandlerSendImmediateEventuint32_t:unique_ptr<T, D>&"] = []() {
523         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
524         temp->SendImmediateEvent(GetU32Param(), GetParamInnerEvent());
525     };
526 
527     callFunctionMap_["EventHandlerSendImmediateEventuint32_t:unique_ptr<T, D>&&"] = []() {
528         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
529         std::unique_ptr<int> p(new int, std::default_delete<int>());
530         temp->SendImmediateEvent(GetU32Param(), p);
531     };
532 
533     callFunctionMap_["EventHandlerSendHighPriorityEventPointer&int64_t"] = []() {
534         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
535         temp->SendImmediateEvent(GetU32Param(), GetS64Param());
536     };
537 
538     callFunctionMap_["EventHandlerSendHighPriorityEventPointer&&int64_t"] = []() {
539         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
540         temp->SendHighPriorityEvent(GetParamInnerEvent(), GetS64Param());
541     };
542 
543     callFunctionMap_["EventHandlerSendHighPriorityEventPointer&int64_t"] = []() {
544         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
545         temp->SendHighPriorityEvent(GetParamInnerEvent(), GetS64Param());
546     };
547 
548     callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tint64_tint64_t"] = []() {
549         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
550         temp->SendHighPriorityEvent(GetU32Param(), GetS64Param(), GetS64Param());
551     };
552 
553     callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tshared_ptr<T>&int64_t"] = []() {
554         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
555         temp->SendHighPriorityEvent(GetU32Param(), GetParamEventHandler(), GetS64Param());
556     };
557 
558     callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tweak_ptr<T>&int64_t"] = []() {
559         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
560         std::weak_ptr<int> wp = std::make_shared<int>(1);
561         temp->SendHighPriorityEvent(GetU32Param(), wp, GetS64Param());
562     };
563 
564     callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tunique_ptr<T, D>&int64_t"] = []() {
565         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
566         std::unique_ptr<int> p(new int, std::default_delete<int>());
567         temp->SendHighPriorityEvent(GetU32Param(), p, GetS64Param());
568     };
569 
570     callFunctionMap_["EventHandlerSendHighPriorityEventuint32_tunique_ptr<T, D>&&int64_t"] = []() {
571         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
572         std::unique_ptr<int> p(new int, std::default_delete<int>());
573         temp->SendHighPriorityEvent(GetU32Param(), p, GetS64Param());
574     };
575 
576     callFunctionMap_["EventHandlerPostTaskCallbackstringint64_tPriority"] = []() {
577         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
578         temp->PostTask(GetParamCallback(), GetStringParam(), GetS64Param());
579     };
580 
581     callFunctionMap_["EventHandlerPostTaskCallbackPriority"] = []() {
582         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
583         temp->PostTask(GetParamCallback(), GetParamPriority());
584     };
585 
586     callFunctionMap_["EventHandlerPostTaskCallbackint64_tPriority"] = []() {
587         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
588         temp->PostTask(GetParamCallback(), GetS64Param(), GetParamPriority());
589     };
590 
591     callFunctionMap_["EventHandlerPostImmediateTaskCallbackstring"] = []() {
592         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
593         temp->PostImmediateTask(GetParamCallback(), GetStringParam());
594     };
595 
596     callFunctionMap_["EventHandlerPostHighPriorityTaskCallbackstringint64_t"] = []() {
597         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
598         temp->PostHighPriorityTask(GetParamCallback(), GetStringParam(), GetS64Param());
599     };
600 
601     callFunctionMap_["EventHandlerPostHighPriorityTaskCallbackint64_t"] = []() {
602         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
603         temp->PostHighPriorityTask(GetParamCallback(), GetS64Param());
604     };
605 
606     callFunctionMap_["EventHandlerPostIdleTaskCallbackstringint64_t"] = []() {
607         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
608         temp->PostIdleTask(GetParamCallback(), GetStringParam(), GetS64Param());
609     };
610 
611     callFunctionMap_["EventHandlerPostIdleTaskCallbackint64_t"] = []() {
612         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
613         temp->PostIdleTask(GetParamCallback(), GetS64Param());
614     };
615 
616     callFunctionMap_["EventHandlerSendSyncEventPointer&Priority"] = []() {
617         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
618         temp->SendSyncEvent(GetParamInnerEvent(), GetParamPriority());
619     };
620 
621     callFunctionMap_["EventHandlerSendSyncEventPointer&&Priority"] = []() {
622         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
623         temp->SendSyncEvent(GetParamInnerEvent(), GetParamPriority());
624     };
625 
626     callFunctionMap_["EventHandlerSendSyncEventuint32_tint64_tPriority"] = []() {
627         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
628         temp->SendSyncEvent(GetU32Param(), GetS64Param(), GetParamPriority());
629     };
630 
631     callFunctionMap_["EventHandlerSendSyncEventuint32_tPriority"] = []() {
632         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
633         temp->SendSyncEvent(GetU32Param(), GetParamPriority());
634     };
635 
636     callFunctionMap_["EventHandlerSendSyncEventuint32_tshared_ptr<T>Priority"] = []() {
637         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
638         temp->SendSyncEvent(GetU32Param(), GetParamEventHandler(), GetParamPriority());
639     };
640 
641     callFunctionMap_["EventHandlerSendSyncEventuint32_tweak_ptr<T>Priority"] = []() {
642         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
643         std::weak_ptr<int> wp = std::make_shared<int>(1);
644         temp->SendSyncEvent(GetU32Param(), wp, GetParamPriority());
645     };
646 
647     callFunctionMap_["EventHandlerSendSyncEventuint32_tunique_ptr<T, D>&Priority"] = []() {
648         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
649         std::unique_ptr<int> p(new int, std::default_delete<int>());
650         temp->SendSyncEvent(GetU32Param(), p, GetParamPriority());
651     };
652 
653     callFunctionMap_["EventHandlerSendSyncEventuint32_tunique_ptr<T, D>&&Priority"] = []() {
654         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
655         std::unique_ptr<int> p(new int, std::default_delete<int>());
656         temp->SendSyncEvent(GetU32Param(), p, GetParamPriority());
657     };
658 
659     callFunctionMap_["EventHandlerPostSyncTaskCallbackstringPriority"] = []() {
660         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
661         temp->PostSyncTask(GetParamCallback(), GetStringParam(), GetParamPriority());
662     };
663 
664     callFunctionMap_["EventHandlerPostSyncTaskCallbackPriority"] = []() {
665         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
666         temp->PostSyncTask(GetParamCallback(), GetParamPriority());
667     };
668 
669     callFunctionMap_["EventHandlerSendTimingEventPointerint64_tPriority"] = []() {
670         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
671         temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param(), GetParamPriority());
672     };
673 
674     callFunctionMap_["EventHandlerSendTimingEventPointerint64_t"] = []() {
675         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
676         temp->SendTimingEvent(GetParamInnerEvent(), GetS64Param());
677     };
678 
679     callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_tint64_t"] = []() {
680         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
681         temp->SendTimingEvent(GetU32Param(), GetS64Param(), GetS64Param());
682     };
683 
684     callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_tPriority"] = []() {
685         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
686         temp->SendTimingEvent(GetU32Param(), GetS64Param(), GetParamPriority());
687     };
688 
689     callFunctionMap_["EventHandlerSendTimingEventuint32_tint64_t"] = []() {
690         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
691         temp->SendTimingEvent(GetU32Param(), GetS64Param());
692     };
693 
694     callFunctionMap_["EventHandlerSendTimingEventuint32_tshared_ptr<T>int64_tPriority"] = []() {
695         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
696         temp->SendTimingEvent(GetU32Param(), GetParamEventHandler(), GetS64Param(), GetParamPriority());
697     };
698 
699     callFunctionMap_["EventHandlerSendTimingEventuint32_tweak_ptr<T>int64_tPriority"] = []() {
700         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
701         std::weak_ptr<int> wp = std::make_shared<int>(1);
702         temp->SendTimingEvent(GetU32Param(), wp, GetS64Param(), GetParamPriority());
703     };
704 
705     callFunctionMap_["EventHandlerSendTimingEventuint32_tunique_ptr<T, D>&int64_tPriority"] = []() {
706         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
707         std::unique_ptr<int> p(new int, std::default_delete<int>());
708         temp->SendTimingEvent(GetU32Param(), p, GetS64Param(), GetParamPriority());
709     };
710 
711     callFunctionMap_["EventHandlerSendTimingEventuint32_tunique_ptr<T, D>&&int64_tPriority"] = []() {
712         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
713         std::unique_ptr<int> p(new int, std::default_delete<int>());
714         temp->SendTimingEvent(GetU32Param(), p, GetS64Param(), GetParamPriority());
715     };
716 
717     callFunctionMap_["EventHandlerPostTimingTaskCallbackint64_tstringPriority"] = []() {
718         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
719         temp->PostTimingTask(GetParamCallback(), GetS64Param(), GetStringParam());
720     };
721 
722     callFunctionMap_["EventHandlerPostTimingTaskCallbackint64_tPriority"] = []() {
723         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
724         temp->PostTimingTask(GetParamCallback(), GetS64Param(), GetParamPriority());
725     };
726 
727     callFunctionMap_["EventHandlerRemoveAllEvents"] = []() {
728         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
729         temp->RemoveAllEvents();
730     };
731 
732     callFunctionMap_["EventHandlerRemoveEvent"] = []() {
733         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
734         temp->RemoveEvent(GetU32Param());
735     };
736 
737     callFunctionMap_["EventHandlerRemoveEventuint32_tint64_t"] = []() {
738         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
739         temp->RemoveEvent(GetU32Param(), GetS64Param());
740     };
741 
742     callFunctionMap_["EventHandlerRemoveTask"] = []() {
743         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
744         temp->RemoveTask(GetStringParam());
745     };
746 
747     callFunctionMap_["EventHandlerAddFileDescriptorListener"] = []() {
748         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
749         temp->AddFileDescriptorListener(GetS32Param(), GetU32Param(), GetParamFileDescriptorListener());
750     };
751 
752     callFunctionMap_["EventHandlerRemoveAllFileDescriptorListeners"] = []() {
753         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
754         temp->RemoveAllFileDescriptorListeners();
755     };
756 
757     callFunctionMap_["EventHandlerRemoveFileDescriptorListener"] = []() {
758         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
759         temp->RemoveFileDescriptorListener(GetS32Param());
760     };
761 
762     callFunctionMap_["EventHandlerSetEventRunner"] = []() {
763         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
764         temp->SetEventRunner(GetParamEventRunner());
765     };
766 
767     callFunctionMap_["EventHandlerGetEventRunner"] = []() {
768         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
769         temp->GetEventRunner();
770     };
771 
772     callFunctionMap_["EventHandlerDistributeEvent"] = []() {
773         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
774         temp->DistributeEvent(GetParamInnerEvent());
775     };
776 
777     callFunctionMap_["EventHandlerDump"] = []() {
778         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
779         TestDumper param;
780         temp->Dump(param);
781     };
782 
783     callFunctionMap_["EventHandlerHasInnerEventuint32_t"] = []() {
784         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
785         temp->HasInnerEvent(GetU32Param());
786     };
787 
788     callFunctionMap_["EventHandlerHasInnerEventint64_t"] = []() {
789         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
790         temp->HasInnerEvent(GetS64Param());
791     };
792 
793     callFunctionMap_["EventHandlerGetEventNamePointer"] = []() {
794         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
795         temp->GetEventName(GetParamInnerEvent());
796     };
797 
798     callFunctionMap_["EventHandlerIsIdle"] = []() {
799         std::shared_ptr<AppExecFwk::EventHandler> temp = GetParamEventHandler();
800         temp->IsIdle();
801     };
802 }
803 
804 // RegisterEventQueue
RegisterEventQueue()805 void fuzzTestManager::RegisterEventQueue()
806 {
807     callFunctionMap_["EventQueueInsert"] = []() {
808         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
809         AppExecFwk::InnerEvent::Pointer param = GetParamInnerEvent();
810         temp->Insert(param, GetParamPriority());
811     };
812 
813     callFunctionMap_["EventQueueRemoveOrphan"] = []() {
814         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
815         temp->RemoveOrphan();
816     };
817     callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>"] = []() {
818         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
819         temp->Remove(GetParamEventHandler());
820     };
821     callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>uint32_t"] = []() {
822         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
823         temp->Remove(GetParamEventHandler(), GetU32Param());
824     };
825     callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>uint32_tint64_t"] = []() {
826         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
827         temp->Remove(GetParamEventHandler(), GetU32Param(), GetS64Param());
828     };
829     callFunctionMap_["EventQueueRemoveshared_ptr<EventHandler>string"] = []() {
830         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
831         temp->Remove(GetParamEventHandler(), GetStringParam());
832     };
833     callFunctionMap_["EventQueueAddFileDescriptor"] = []() {
834         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
835         temp->AddFileDescriptorListener(GetS32Param(), GetU32Param(), GetParamFileDescriptorListener());
836     };
837     callFunctionMap_["EventQueueRemoveFileDescriptorListenershared_ptr<EventHandler>"] = []() {
838         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
839         temp->RemoveFileDescriptorListener(GetParamEventHandler());
840     };
841     callFunctionMap_["EventQueueRemoveFileDescriptorListenerint32_t"] = []() {
842         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
843         temp->RemoveFileDescriptorListener(GetS32Param());
844     };
845     callFunctionMap_["EventQueuePrepare"] = []() {
846         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
847         temp->Prepare();
848     };
849     callFunctionMap_["EventQueueFinish"] = []() {
850         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
851         temp->Finish();
852     };
853     callFunctionMap_["EventQueueGetEvent"] = []() {
854         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
855         temp->GetEvent();
856     };
857     callFunctionMap_["EventQueueGetExpiredEvent"] = []() {
858         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
859         AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
860         temp->GetExpiredEvent(param);
861     };
862     callFunctionMap_["EventQueueDump"] = []() {
863         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
864         TestDumper param;
865         temp->Dump(param);
866     };
867     callFunctionMap_["EventQueueIsIdle"] = []() {
868         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
869         temp->IsIdle();
870     };
871     callFunctionMap_["EventQueueIsQueueEmpty"] = []() {
872         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
873         temp->IsQueueEmpty();
874     };
875     callFunctionMap_["EventQueueHasInnerEventuint32_t"] = []() {
876         std::shared_ptr<AppExecFwk::EventQueue> temp = GetParamEventQueue();
877         temp->HasInnerEvent(GetParamEventHandler(), GetU32Param());
878     };
879 }
880 
881 // RegisterEventRunner
RegisterEventRunner()882 void fuzzTestManager::RegisterEventRunner()
883 {
884     callFunctionMap_["EventRunnerCreatebool"] = []() {
885         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
886         temp->Create(GetBoolParam());
887     };
888     callFunctionMap_["EventRunnerCreatechar*"] = []() {
889         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
890         temp->Create(GetCharArryParam());
891     };
892     callFunctionMap_["EventRunnerCurrent"] = []() {
893         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
894         temp->Current();
895     };
896     callFunctionMap_["EventRunnerRun"] = []() {
897         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
898         temp->Run();
899     };
900     callFunctionMap_["EventRunnerStop"] = []() {
901         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
902         temp->Stop();
903     };
904     callFunctionMap_["EventRunnerGetEventQueue"] = []() {
905         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
906         temp->GetEventQueue();
907     };
908     callFunctionMap_["EventRunnerGetCurrentEventQueue"] = []() {
909         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
910         temp->GetCurrentEventQueue();
911     };
912     callFunctionMap_["EventRunnerDump"] = []() {
913         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
914         TestDumper param;
915         temp->Dump(param);
916     };
917     callFunctionMap_["EventRunnerSetLogger"] = []() {
918         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
919         temp->SetLogger(GetParamLogger());
920     };
921     callFunctionMap_["EventRunnerGetThreadId"] = []() {
922         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
923         temp->GetThreadId();
924     };
925     callFunctionMap_["EventRunnerIsCurrentRunnerThread"] = []() {
926         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
927         temp->IsCurrentRunnerThread();
928     };
929     callFunctionMap_["EventRunnerGetMainEventRunner"] = []() {
930         std::shared_ptr<AppExecFwk::EventRunner> temp = GetParamEventRunner();
931         temp->GetMainEventRunner();
932     };
933 }
934 
935 // RegisterFileDescriptorListener
RegisterFileDescriptorListener()936 void fuzzTestManager::RegisterFileDescriptorListener()
937 {
938     callFunctionMap_["FileDescriptorListenerOnReadable"] = []() {
939         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
940         temp->OnReadable(GetS32Param());
941     };
942     callFunctionMap_["FileDescriptorListenerOnWritable"] = []() {
943         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
944         temp->OnWritable(GetS32Param());
945     };
946     callFunctionMap_["FileDescriptorListenerOnShutdown"] = []() {
947         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
948         temp->OnShutdown(GetS32Param());
949     };
950     callFunctionMap_["FileDescriptorListenerOnException"] = []() {
951         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
952         temp->OnException(GetS32Param());
953     };
954     callFunctionMap_["FileDescriptorListenerGetOwner"] = []() {
955         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
956         temp->GetOwner();
957     };
958     callFunctionMap_["FileDescriptorListenerSetOwner"] = []() {
959         std::shared_ptr<AppExecFwk::FileDescriptorListener> temp = GetParamFileDescriptorListener();
960         temp->SetOwner(GetParamEventHandler());
961     };
962 }
963 
964 // RegisterInnerEvent
RegisterInnerEvent()965 void fuzzTestManager::RegisterInnerEvent()
966 {
967     callFunctionMap_["InnerEventGetuint32_tint64_t"] = []() {
968         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
969         temp->Get(GetU32Param(), GetS64Param());
970     };
971     callFunctionMap_["InnerEventGetuint32_tshared_ptr<T>int64_t"] = []() {
972         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
973         temp->Get<AppExecFwk::EventRunner>(GetU32Param(), GetParamEventRunner(), GetS64Param());
974     };
975     callFunctionMap_["InnerEventGetuint32_tstd::weak_ptr<T>int64_t"] = []() {
976         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
977         std::weak_ptr<int> wp = std::make_shared<int>(1);
978         temp->Get(GetU32Param(), wp, GetS64Param());
979     };
980 
981     callFunctionMap_["InnerEventGetuint32_tunique_ptr<T, D>&&int64_t"] = []() {
982         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
983         std::unique_ptr<int> p(new int, std::default_delete<int>());
984         temp->Get(GetU32Param(), p, GetS64Param());
985     };
986 
987     callFunctionMap_["InnerEventGetuint32_tunique_ptr<T, D>&int64_t"] = []() {
988         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
989         std::unique_ptr<int> p(new int, std::default_delete<int>());
990         temp->Get(GetU32Param(), p, GetS64Param());
991     };
992 
993     callFunctionMap_["InnerEventGetuint32_tint64_tshared_ptr<T>"] = []() {
994         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
995         temp->Get<AppExecFwk::EventRunner>(GetU32Param(), GetS64Param(), GetParamEventRunner());
996     };
997 
998     callFunctionMap_["InnerEventGetuint32_tint64_tweak_ptr<T>"] = []() {
999         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1000         std::weak_ptr<int> wp = std::make_shared<int>(1);
1001         temp->Get(GetU32Param(), GetS64Param(), wp);
1002     };
1003 
1004     callFunctionMap_["InnerEventGetuint32_tint64_tunique_ptr<T, D>&&"] = []() {
1005         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1006         std::unique_ptr<int> p(new int, std::default_delete<int>());
1007         temp->Get(GetU32Param(), GetS64Param(), p);
1008     };
1009     callFunctionMap_["InnerEventGetuint32_tint64_tunique_ptr<T, D>&"] = []() {
1010         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1011         std::unique_ptr<int> p(new int, std::default_delete<int>());
1012         temp->Get(GetU32Param(), GetS64Param(), p);
1013     };
1014     callFunctionMap_["InnerEventGetCallbackstring"] = []() {
1015         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1016         temp->Get(GetParamCallback(), GetStringParam());
1017     };
1018     callFunctionMap_["InnerEventGet"] = []() {
1019         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1020         temp->Get();
1021     };
1022     callFunctionMap_["InnerEventGetOwner"] = []() {
1023         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1024         temp->GetOwner();
1025     };
1026     callFunctionMap_["InnerEventSetOwner"] = []() {
1027         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1028         temp->SetOwner(GetParamEventHandler());
1029     };
1030     callFunctionMap_["InnerEventGetHandleTime"] = []() {
1031         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1032         temp->GetHandleTime();
1033     };
1034     callFunctionMap_["InnerEventSetHandleTime"] = []() {
1035         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1036         AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
1037         temp->SetHandleTime(param);
1038     };
1039     callFunctionMap_["InnerEventGetSendTime"] = []() {
1040         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1041         temp->GetSendTime();
1042     };
1043     callFunctionMap_["InnerEventSetSendTime"] = []() {
1044         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1045         AppExecFwk::InnerEvent::TimePoint param = GetParamTimePoint();
1046         temp->SetSendTime(param);
1047     };
1048     callFunctionMap_["InnerEventGetInnerEventId"] = []() {
1049         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1050         temp->GetInnerEventId();
1051     };
1052     callFunctionMap_["InnerEventGetParam"] = []() {
1053         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1054         temp->GetParam();
1055     };
1056     callFunctionMap_["InnerEventGetSharedObject"] = []() {
1057         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1058         temp->GetSharedObject<int>();
1059     };
1060     callFunctionMap_["InnerEventGetUniqueObject"] = []() {
1061         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1062         temp->GetUniqueObject<int>();
1063     };
1064     callFunctionMap_["InnerEventGetUniqueObject2"] = []() {
1065         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1066         using deleter = void (*)(uint32_t *);
1067         temp->GetUniqueObject<uint32_t, deleter>();
1068     };
1069     callFunctionMap_["InnerEventGetTaskName"] = []() {
1070         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1071         temp->GetTaskName();
1072     };
1073     callFunctionMap_["InnerEventGetTask"] = []() {
1074         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1075         temp->GetTask();
1076     };
1077     callFunctionMap_["InnerEventHasTask"] = []() {
1078         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1079         temp->HasTask();
1080     };
1081     callFunctionMap_["InnerEventDump"] = []() {
1082         std::shared_ptr<AppExecFwk::InnerEvent> temp = GetParamInnerEvent();
1083         temp->Dump();
1084     };
1085 }
1086 
1087 // RegisterEventRunnerNativeImplement
RegisterEventRunnerNativeImplement()1088 void fuzzTestManager::RegisterEventRunnerNativeImplement()
1089 {
1090     callFunctionMap_["EventRunnerNativeImplementGetEventRunnerNativeObj"] = []() {
1091         std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1092         temp->GetEventRunnerNativeObj();
1093     };
1094     callFunctionMap_["EventRunnerNativeImplementCreateEventRunnerNativeObj"] = []() {
1095         std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1096         temp->CreateEventRunnerNativeObj();
1097     };
1098     callFunctionMap_["EventRunnerNativeImplementStopEventRunnerNativeObj"] = []() {
1099         std::shared_ptr<EventRunnerNativeImplement> temp = GetParamEventRunnerNativeImplement();
1100         temp->StopEventRunnerNativeObj();
1101     };
1102 }
1103 
1104 // RegisterWantParams
RegisterWantParams()1105 void fuzzTestManager::RegisterWantParams()
1106 {
1107     callFunctionMap_["WantParamsoperator="] = []() {
1108         AAFwk::WantParams want1;
1109         AAFwk::WantParams want2;
1110         want1 = want2;
1111     };
1112 
1113     callFunctionMap_["WantParamsGetParam"] = []() {
1114         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1115         temp->GetParam(GetStringParam());
1116     };
1117     callFunctionMap_["WantParamsGetParams"] = []() {
1118         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1119         temp->GetParams();
1120     };
1121     callFunctionMap_["WantParamsKeySet"] = []() {
1122         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1123         temp->KeySet();
1124     };
1125     callFunctionMap_["WantParamsRemove"] = []() {
1126         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1127         temp->Remove(GetStringParam());
1128     };
1129     callFunctionMap_["WantParamsHasParam"] = []() {
1130         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1131         temp->HasParam(GetStringParam());
1132     };
1133     callFunctionMap_["WantParamsSize"] = []() {
1134         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1135         temp->Size();
1136     };
1137     callFunctionMap_["WantParamsIsEmpty"] = []() {
1138         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1139         temp->IsEmpty();
1140     };
1141     callFunctionMap_["WantParamsMarshalling"] = []() {
1142         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1143         Parcel p;
1144         temp->Marshalling(p);
1145     };
1146     callFunctionMap_["WantParamsUnmarshalling"] = []() {
1147         std::shared_ptr<AAFwk::WantParams> temp = GetParamWantParams();
1148         Parcel p;
1149         temp->Unmarshalling(p);
1150     };
1151 }
1152 
1153 // bundle
RegisterBundleMgrProxy()1154 void fuzzTestManager::RegisterBundleMgrProxy()
1155 {
1156     callFunctionMap_["BundleMgrProxyGetApplicationInfo"] = []() {
1157         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1158         ApplicationInfo a;
1159         temp->GetApplicationInfo(GetStringParam(), GetParamApplicationFlag(), GetIntParam(), a);
1160     };
1161 
1162     callFunctionMap_["BundleMgrProxyGetApplicationInfos"] = []() {
1163         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1164         std::vector<ApplicationInfo> a;
1165         temp->GetApplicationInfos(GetParamApplicationFlag(), GetIntParam(), a);
1166     };
1167 
1168     callFunctionMap_["BundleMgrProxyGetBundleInfo"] = []() {
1169         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1170         BundleInfo a;
1171         temp->GetBundleInfo(GetStringParam(), GetParamBundleFlag(), a);
1172     };
1173 
1174     callFunctionMap_["BundleMgrProxyGetBundleInfos"] = []() {
1175         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1176         std::vector<BundleInfo> a;
1177         temp->GetBundleInfos(GetParamBundleFlag(), a);
1178     };
1179 
1180     callFunctionMap_["BundleMgrProxyGetUidByBundleName"] = []() {
1181         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1182         temp->GetUidByBundleName(GetStringParam(), GetIntParam());
1183     };
1184 
1185     callFunctionMap_["BundleMgrProxyGetBundleNameForUid"] = []() {
1186         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1187         std::string a;
1188         temp->GetBundleNameForUid(GetIntParam(), a);
1189     };
1190 
1191     callFunctionMap_["BundleMgrProxyGetBundleGids"] = []() {
1192         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1193         std::vector<int> a;
1194         temp->GetBundleGids(GetStringParam(), a);
1195     };
1196 
1197     callFunctionMap_["BundleMgrProxyGetAppType"] = []() {
1198         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1199         temp->GetAppType(GetStringParam());
1200     };
1201 
1202     callFunctionMap_["BundleMgrProxyCheckIsSystemAppByUid"] = []() {
1203         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1204         temp->GetAppType(GetStringParam());
1205     };
1206 
1207     callFunctionMap_["BundleMgrProxyGetBundleInfosByMetaData"] = []() {
1208         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1209         std::vector<BundleInfo> a;
1210         temp->GetBundleInfosByMetaData(GetStringParam(), a);
1211     };
1212 
1213     callFunctionMap_["BundleMgrProxyQueryAbilityInfo"] = []() {
1214         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1215         AbilityInfo a;
1216         Want want;
1217         temp->QueryAbilityInfo(want, a);
1218     };
1219 
1220     callFunctionMap_["BundleMgrProxyQueryAbilityInfoByUri"] = []() {
1221         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1222         AbilityInfo a;
1223         temp->QueryAbilityInfoByUri(GetStringParam(), a);
1224     };
1225 
1226     callFunctionMap_["BundleMgrProxyQueryKeepAliveBundleInfos"] = []() {
1227         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1228         std::vector<BundleInfo> a;
1229         temp->QueryKeepAliveBundleInfos(a);
1230     };
1231 
1232     callFunctionMap_["BundleMgrProxyGetAbilityLabel"] = []() {
1233         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1234         temp->GetAbilityLabel(GetStringParam(), GetStringParam());
1235     };
1236 
1237     callFunctionMap_["BundleMgrProxyGetBundleArchiveInfo"] = []() {
1238         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1239         BundleInfo a;
1240         temp->GetBundleArchiveInfo(GetStringParam(), GetParamBundleFlag(), a);
1241     };
1242 
1243     callFunctionMap_["BundleMgrProxyGetHapModuleInfo"] = []() {
1244         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1245         HapModuleInfo moduleInfo;
1246         AbilityInfo abilityInfo;
1247         temp->GetHapModuleInfo(abilityInfo, moduleInfo);
1248     };
1249 
1250     callFunctionMap_["BundleMgrProxyGetLaunchWantForBundle"] = []() {
1251         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1252         Want want;
1253         temp->GetLaunchWantForBundle(GetStringParam(), want);
1254     };
1255 
1256     callFunctionMap_["BundleMgrProxyCheckPublicKeys"] = []() {
1257         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1258         temp->CheckPublicKeys(GetStringParam(), GetStringParam());
1259     };
1260 
1261     callFunctionMap_["BundleMgrProxyGetPermissionDef"] = []() {
1262         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1263         PermissionDef a;
1264         temp->GetPermissionDef(GetStringParam(), a);
1265     };
1266 
1267     callFunctionMap_["BundleMgrProxyGetSystemAvailableCapabilities"] = []() {
1268         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1269         std::vector<std::string> a;
1270         temp->GetSystemAvailableCapabilities(a);
1271     };
1272 
1273     callFunctionMap_["BundleMgrProxyIsSafeMode"] = []() {
1274         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1275         temp->IsSafeMode();
1276     };
1277 
1278     callFunctionMap_["BundleMgrProxyCleanBundleCacheFiles"] = []() {
1279         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1280         temp->CleanBundleCacheFiles(GetStringParam(), GetParamICleanCacheCallback());
1281     };
1282 
1283     callFunctionMap_["BundleMgrProxyCleanBundleDataFiles"] = []() {
1284         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1285         temp->CleanBundleDataFiles(GetStringParam(), GetIntParam());
1286     };
1287 
1288     callFunctionMap_["BundleMgrProxyRegisterBundleStatusCallback"] = []() {
1289         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1290         temp->RegisterBundleStatusCallback(GetParamIBundleStatusCallback());
1291     };
1292 
1293     callFunctionMap_["BundleMgrProxyClearBundleStatusCallback"] = []() {
1294         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1295         temp->ClearBundleStatusCallback(GetParamIBundleStatusCallback());
1296     };
1297 
1298     callFunctionMap_["BundleMgrProxyUnregisterBundleStatusCallback"] = []() {
1299         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1300         temp->UnregisterBundleStatusCallback();
1301     };
1302 
1303     callFunctionMap_["BundleMgrProxyDumpInfos"] = []() {
1304         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1305         std::string a;
1306         temp->DumpInfos(GetParamDumpFlag(), GetStringParam(), 0, a);
1307     };
1308 
1309     callFunctionMap_["BundleMgrProxyIsApplicationEnabled"] = []() {
1310         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1311         bool isEnable = false;
1312         temp->IsApplicationEnabled(GetStringParam(), isEnable);
1313     };
1314 
1315     callFunctionMap_["BundleMgrProxySetApplicationEnabled"] = []() {
1316         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1317         temp->SetApplicationEnabled(GetStringParam(), GetBoolParam());
1318     };
1319 
1320     callFunctionMap_["BundleMgrProxyGetBundleInstaller"] = []() {
1321         std::shared_ptr<BundleMgrProxy> temp = GetParamBundleMgrProxy();
1322         temp->GetBundleInstaller();
1323     };
1324 }
1325 
1326 // RegisterWant
RegisterWant()1327 void fuzzTestManager::RegisterWant()
1328 {
1329     callFunctionMap_["Wantoperator="] = []() {
1330         Want want1;
1331         Want want2;
1332         want1 = want2;
1333     };
1334     callFunctionMap_["WantSetFlags"] = []() {
1335         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1336         temp->SetFlags(GetUIntParam());
1337     };
1338     callFunctionMap_["WantGetFlags"] = []() {
1339         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1340         temp->GetFlags();
1341     };
1342     callFunctionMap_["WantAddFlags"] = []() {
1343         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1344         temp->AddFlags(GetUIntParam());
1345     };
1346     callFunctionMap_["WantRemoveFlags"] = []() {
1347         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1348         temp->RemoveFlags(GetUIntParam());
1349     };
1350     callFunctionMap_["WantSetElementName"] = []() {
1351         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1352         temp->SetElementName(GetStringParam(), GetStringParam());
1353     };
1354     callFunctionMap_["WantSetElementName2"] = []() {
1355         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1356         temp->SetElementName(GetStringParam(), GetStringParam(), GetStringParam());
1357     };
1358     callFunctionMap_["WantSetElement"] = []() {
1359         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1360         temp->SetElement(*(GetParamElementName()));
1361     };
1362     callFunctionMap_["WantGetElement"] = []() {
1363         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1364         temp->GetElement();
1365     };
1366     callFunctionMap_["WantMakeMainAbility"] = []() {
1367         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1368         temp->MakeMainAbility(*(GetParamElementName()));
1369     };
1370     callFunctionMap_["WantWantParseUri"] = []() {
1371         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1372         temp->WantParseUri(GetCharArryParam());
1373     };
1374     callFunctionMap_["WantParseUri"] = []() {
1375         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1376         temp->ParseUri(GetStringParam());
1377     };
1378     callFunctionMap_["WantGetUri"] = []() {
1379         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1380         temp->GetUri();
1381     };
1382     callFunctionMap_["WantGetUriString"] = []() {
1383         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1384         temp->GetUriString();
1385     };
1386     callFunctionMap_["WantSetUri"] = []() {
1387         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1388         temp->SetUri(GetStringParam());
1389     };
1390     callFunctionMap_["WantSetUri2"] = []() {
1391         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1392         temp->SetUri(GetParamUri());
1393     };
1394     callFunctionMap_["WantSetUriAndType"] = []() {
1395         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1396         temp->SetUriAndType(GetParamUri(), GetStringParam());
1397     };
1398     callFunctionMap_["WantWantToUri"] = []() {
1399         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1400         temp->WantToUri(*(GetParamWant().get()));
1401     };
1402     callFunctionMap_["WantToUri"] = []() {
1403         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1404         temp->ToUri();
1405     };
1406     callFunctionMap_["WantFormatUri"] = []() {
1407         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1408         temp->FormatUri(GetStringParam());
1409     };
1410     callFunctionMap_["WantFormatUri2"] = []() {
1411         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1412         temp->FormatUri(GetParamUri());
1413     };
1414     callFunctionMap_["WantGetAction"] = []() {
1415         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1416         temp->GetAction();
1417     };
1418     callFunctionMap_["WantSetAction"] = []() {
1419         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1420         temp->SetAction(GetStringParam());
1421     };
1422     callFunctionMap_["WantGetBundle"] = []() {
1423         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1424         temp->GetBundle();
1425     };
1426     callFunctionMap_["WantSetBundle"] = []() {
1427         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1428         temp->SetBundle(GetStringParam());
1429     };
1430     callFunctionMap_["WantGetEntities"] = []() {
1431         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1432         temp->GetEntities();
1433     };
1434     callFunctionMap_["WantAddEntity"] = []() {
1435         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1436         temp->AddEntity(GetStringParam());
1437     };
1438     callFunctionMap_["WantRemoveEntity"] = []() {
1439         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1440         temp->RemoveEntity(GetStringParam());
1441     };
1442     callFunctionMap_["WantHasEntity"] = []() {
1443         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1444         temp->HasEntity(GetStringParam());
1445     };
1446     callFunctionMap_["WantCountEntities"] = []() {
1447         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1448         temp->CountEntities();
1449     };
1450     callFunctionMap_["WantGetScheme"] = []() {
1451         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1452         temp->GetScheme();
1453     };
1454     callFunctionMap_["WantGetType"] = []() {
1455         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1456         temp->GetType();
1457     };
1458     callFunctionMap_["WantSetType"] = []() {
1459         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1460         temp->SetType(GetStringParam());
1461     };
1462     callFunctionMap_["WantFormatType"] = []() {
1463         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1464         temp->FormatType(GetStringParam());
1465     };
1466     callFunctionMap_["WantFormatUriAndType"] = []() {
1467         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1468         temp->FormatUriAndType(GetParamUri(), GetStringParam());
1469     };
1470     callFunctionMap_["WantFormatMimeType"] = []() {
1471         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1472         temp->FormatMimeType(GetStringParam());
1473     };
1474     callFunctionMap_["WantClearWant"] = []() {
1475         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1476         temp->ClearWant(GetParamWant().get());
1477     };
1478     callFunctionMap_["WantGetParams"] = []() {
1479         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1480         temp->GetParams();
1481     };
1482     callFunctionMap_["WantSetParams"] = []() {
1483         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1484         temp->SetParams(*(GetParamWantParams()));
1485     };
1486     callFunctionMap_["WantGetBoolParam"] = []() {
1487         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1488         temp->GetBoolParam(GetStringParam(), GetBoolParam());
1489     };
1490     callFunctionMap_["WantGetBoolArrayParam"] = []() {
1491         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1492         temp->GetBoolArrayParam(GetStringParam());
1493     };
1494     callFunctionMap_["WantSetParam"] = []() {
1495         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1496         temp->SetParam(GetStringParam(), GetBoolParam());
1497     };
1498     callFunctionMap_["WantSetParam2"] = []() {
1499         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1500         temp->SetParam(GetStringParam(), GetBoolVectorParam());
1501     };
1502     callFunctionMap_["WantGetByteParam"] = []() {
1503         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1504         temp->GetByteParam(GetStringParam(), GetCharParam());
1505     };
1506     callFunctionMap_["WantGetByteArrayParam"] = []() {
1507         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1508         temp->GetByteArrayParam(GetStringParam());
1509     };
1510     callFunctionMap_["WantSetParam3"] = []() {
1511         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1512         temp->SetParam(GetStringParam(), GetCharParam());
1513     };
1514     callFunctionMap_["WantSetParam4"] = []() {
1515         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1516         temp->SetParam(GetStringParam(), GetCharVectorParam());
1517     };
1518     callFunctionMap_["WantGetCharParam"] = []() {
1519         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1520         temp->GetCharParam(GetStringParam(), GetChar32Param());
1521     };
1522     callFunctionMap_["WantGetCharArrayParam"] = []() {
1523         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1524         temp->GetCharArrayParam(GetStringParam());
1525     };
1526     callFunctionMap_["WantSetParam5"] = []() {
1527         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1528         temp->SetParam(GetStringParam(), GetChar32Param());
1529     };
1530     callFunctionMap_["WantSetParam6"] = []() {
1531         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1532         temp->SetParam(GetStringParam(), GetChar32VectorParam());
1533     };
1534     callFunctionMap_["WantGetIntParam"] = []() {
1535         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1536         temp->GetIntParam(GetStringParam(), GetIntParam());
1537     };
1538     callFunctionMap_["WantGetIntArrayParam"] = []() {
1539         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1540         temp->GetIntArrayParam(GetStringParam());
1541     };
1542     callFunctionMap_["WantSetParam7"] = []() {
1543         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1544         temp->SetParam(GetStringParam(), GetIntParam());
1545     };
1546     callFunctionMap_["WantSetParam8"] = []() {
1547         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1548         temp->SetParam(GetStringParam(), GetIntVectorParam());
1549     };
1550     callFunctionMap_["WantGetDoubleParam"] = []() {
1551         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1552         temp->GetDoubleParam(GetStringParam(), GetDoubleParam());
1553     };
1554     callFunctionMap_["WantGetDoubleArrayParam"] = []() {
1555         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1556         temp->GetDoubleArrayParam(GetStringParam());
1557     };
1558     callFunctionMap_["WantSetParam9"] = []() {
1559         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1560         temp->SetParam(GetStringParam(), GetDoubleParam());
1561     };
1562     callFunctionMap_["WantSetParam10"] = []() {
1563         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1564         temp->SetParam(GetStringParam(), GetDoubleVectorParam());
1565     };
1566     callFunctionMap_["WantGetFloatParam"] = []() {
1567         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1568         temp->GetFloatParam(GetStringParam(), GetFloatParam());
1569     };
1570     callFunctionMap_["WantGetFloatArrayParam"] = []() {
1571         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1572         temp->GetFloatArrayParam(GetStringParam());
1573     };
1574     callFunctionMap_["WantSetParam11"] = []() {
1575         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1576         temp->SetParam(GetStringParam(), GetFloatParam());
1577     };
1578     callFunctionMap_["WantSetParam12"] = []() {
1579         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1580         temp->SetParam(GetStringParam(), GetFloatVectorParam());
1581     };
1582     callFunctionMap_["WantGetLongParam"] = []() {
1583         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1584         temp->GetLongParam(GetStringParam(), GetLongParam());
1585     };
1586     callFunctionMap_["WantGetLongArrayParam"] = []() {
1587         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1588         temp->GetLongArrayParam(GetStringParam());
1589     };
1590     callFunctionMap_["WantSetParam13"] = []() {
1591         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1592         temp->SetParam(GetStringParam(), GetLongParam());
1593     };
1594     callFunctionMap_["WantSetParam14"] = []() {
1595         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1596         temp->SetParam(GetStringParam(), GetLongVectorParam());
1597     };
1598     callFunctionMap_["WantGetShortParam"] = []() {
1599         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1600         temp->GetShortParam(GetStringParam(), GetShortParam());
1601     };
1602     callFunctionMap_["WantGetShortArrayParam"] = []() {
1603         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1604         temp->GetShortArrayParam(GetStringParam());
1605     };
1606     callFunctionMap_["WantSetParam15"] = []() {
1607         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1608         temp->SetParam(GetStringParam(), GetShortParam());
1609     };
1610     callFunctionMap_["WantSetParam16"] = []() {
1611         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1612         temp->SetParam(GetStringParam(), GetShortVectorParam());
1613     };
1614     callFunctionMap_["WantGetStringParam"] = []() {
1615         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1616         temp->GetStringParam(GetStringParam());
1617     };
1618     callFunctionMap_["WantGetStringArrayParam"] = []() {
1619         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1620         temp->GetStringArrayParam(GetStringParam());
1621     };
1622     callFunctionMap_["WantSetParam17"] = []() {
1623         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1624         temp->SetParam(GetStringParam(), GetStringParam());
1625     };
1626     callFunctionMap_["WantSetParam18"] = []() {
1627         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1628         temp->SetParam(GetStringParam(), GetStringVectorParam());
1629     };
1630     callFunctionMap_["WantHasParameter"] = []() {
1631         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1632         temp->HasParameter(GetStringParam());
1633     };
1634     callFunctionMap_["WantReplaceParams"] = []() {
1635         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1636         temp->ReplaceParams(*(GetParamWantParams().get()));
1637     };
1638     callFunctionMap_["WantReplaceParams2"] = []() {
1639         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1640         temp->ReplaceParams(*(GetParamWant().get()));
1641     };
1642     callFunctionMap_["WantRemoveParam"] = []() {
1643         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1644         temp->RemoveParam(GetStringParam());
1645     };
1646     callFunctionMap_["WantGetOperation"] = []() {
1647         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1648         temp->GetOperation();
1649     };
1650     callFunctionMap_["WantSetOperation"] = []() {
1651         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1652         temp->SetOperation(GetParamOperation());
1653     };
1654     callFunctionMap_["WantOperationEquals"] = []() {
1655         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1656         temp->OperationEquals(*(GetParamWant().get()));
1657     };
1658     callFunctionMap_["WantCloneOperation"] = []() {
1659         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1660         temp->CloneOperation();
1661     };
1662     callFunctionMap_["WantMarshalling"] = []() {
1663         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1664         Parcel p;
1665         temp->Marshalling(p);
1666     };
1667     callFunctionMap_["WantUnmarshalling"] = []() {
1668         std::shared_ptr<AAFwk::Want> temp = GetParamWant();
1669         Parcel p;
1670         temp->Unmarshalling(p);
1671     };
1672 }
1673 
1674 // RegisterElementName
RegisterElementName()1675 void fuzzTestManager::RegisterElementName()
1676 {
1677     callFunctionMap_["ElementNameGetURI"] = []() {
1678         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1679         temp->GetURI();
1680     };
1681     callFunctionMap_["ElementNameoperator=="] = []() {
1682         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1683         std::shared_ptr<AppExecFwk::ElementName> temp2 = GetParamElementName();
1684         if (*temp == *temp2) {
1685             return;
1686         };
1687     };
1688     callFunctionMap_["ElementNameSetDeviceID"] = []() {
1689         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1690         temp->SetDeviceID(GetStringParam());
1691     };
1692     callFunctionMap_["ElementNameGetDeviceID"] = []() {
1693         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1694         temp->GetDeviceID();
1695     };
1696     callFunctionMap_["ElementNameSetBundleName"] = []() {
1697         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1698         temp->SetBundleName(GetStringParam());
1699     };
1700     callFunctionMap_["ElementNameGetBundleName"] = []() {
1701         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1702         temp->GetBundleName();
1703     };
1704     callFunctionMap_["ElementNameSetAbilityName"] = []() {
1705         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1706         temp->SetAbilityName(GetStringParam());
1707     };
1708     callFunctionMap_["ElementNameGetAbilityName"] = []() {
1709         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1710         temp->GetAbilityName();
1711     };
1712     callFunctionMap_["ElementNameReadFromParcel"] = []() {
1713         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1714         Parcel p;
1715         temp->ReadFromParcel(p);
1716     };
1717     callFunctionMap_["ElementNameMarshalling"] = []() {
1718         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1719         Parcel p;
1720         temp->Marshalling(p);
1721     };
1722     callFunctionMap_["ElementNameUnmarshalling"] = []() {
1723         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1724         Parcel p;
1725         temp->Unmarshalling(p);
1726     };
1727     callFunctionMap_["ElementNameSetElementDeviceID"] = []() {
1728         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1729         temp->SetElementDeviceID(GetParamElementName().get(), GetCharArryParam());
1730     };
1731     callFunctionMap_["ElementNameSetElementBundleName"] = []() {
1732         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1733         temp->SetElementBundleName(GetParamElementName().get(), GetCharArryParam());
1734     };
1735     callFunctionMap_["ElementNameSetElementAbilityName"] = []() {
1736         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1737         temp->SetElementAbilityName(GetParamElementName().get(), GetCharArryParam());
1738     };
1739     callFunctionMap_["ElementNameClearElement"] = []() {
1740         std::shared_ptr<AppExecFwk::ElementName> temp = GetParamElementName();
1741         temp->ClearElement(GetParamElementName().get());
1742     };
1743 }
1744 
RegisterProcessInfo()1745 void fuzzTestManager::RegisterProcessInfo()
1746 {
1747     callFunctionMap_.emplace("ProcessInfoGetProcessName", []() {
1748         std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
1749         temp->GetProcessName();
1750     });
1751 
1752     callFunctionMap_.emplace("ProcessInfoGetPid", []() {
1753         std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
1754         temp->GetPid();
1755     });
1756 
1757     callFunctionMap_.emplace("ProcessInfoReadFromParcel", []() {
1758         std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
1759         auto p = Parcel();
1760         temp->ReadFromParcel(p);
1761     });
1762 
1763     callFunctionMap_.emplace("ProcessInfoMarshalling", []() {
1764         std::shared_ptr<OHOS::AppExecFwk::ProcessInfo> temp = GetParamProcessInfo();
1765         auto p = Parcel();
1766         temp->Marshalling(p);
1767     });
1768 
1769     callFunctionMap_.emplace("ProcessInfoUnmarshalling", []() {
1770         auto p = Parcel();
1771         OHOS::AppExecFwk::ProcessInfo::Unmarshalling(p);
1772     });
1773 }
1774 
fuzzTestManager()1775 fuzzTestManager::fuzzTestManager()
1776 {
1777     RegisterAsyncCommonEventResult();
1778     RegisterCommonEventData();
1779     RegisterCommonEventManager();
1780     RegisterCommonEventPublishInfo();
1781     RegisterCommonEventSubscribeInfo();
1782     RegisterCommonEventSubscriber();
1783     RegisterCommonEventSupport();
1784     RegisterMatchingSkills();
1785     RegisterDumper();
1786     RegisterEventHandler();
1787     RegisterEventQueue();
1788     RegisterEventRunner();
1789     RegisterFileDescriptorListener();
1790     RegisterInnerEvent();
1791     RegisterEventRunnerNativeImplement();
1792     RegisterWantParams();
1793     RegisterWant();
1794     RegisterElementName();
1795     RegisterBundleMgrProxy();
1796 
1797     RegisterProcessInfo();
1798 }
1799 
SetJsonFunction(std::string functionName)1800 void fuzzTestManager::SetJsonFunction(std::string functionName)
1801 {
1802     remainderMap_.emplace(functionName, cycle_);
1803 }
1804 
SetCycle(uint16_t cycle)1805 void fuzzTestManager::SetCycle(uint16_t cycle)
1806 {
1807     cycle_ = cycle;
1808     for_each(remainderMap_.begin(), remainderMap_.end(), [cycle](std::unordered_map<std::string, int>::reference temp) {
1809         temp.second = cycle;
1810     });
1811 }
1812 
GetRandomInt(int minNum,int maxNum)1813 int GetRandomInt(int minNum, int maxNum)
1814 {
1815     return GetU16Param() % (maxNum - minNum + 1) + minNum;
1816 }
1817 
action(int a)1818 void action(int a)
1819 {
1820     std::cout << "Interrupt signal (" << a << ") received.\n";
1821 }
1822 
StartFuzzTest()1823 void fuzzTestManager::StartFuzzTest()
1824 {
1825     std::cout << __func__ << std::endl;
1826     OHOS::FuzzConfigParser jsonParser;
1827     OHOS::FuzzTestData tempData;
1828 
1829     std::cout << "parseFromFile start" << std::endl;
1830     jsonParser.ParseFromFile4FuzzTest(FUZZ_TEST_CONFIG_FILE_PATH, tempData);
1831     std::cout << "flag :" << tempData.mainLoopFlag << std::endl;
1832     for_each(tempData.methodVec.begin(), tempData.methodVec.end(), [this](std::vector<std::string>::reference s) {
1833         SetJsonFunction(s);
1834     });
1835     SetCycle(tempData.mainLoopFlag);
1836 
1837     std::vector<std::string> index;
1838     std::unordered_map<std::string, int>::iterator it = remainderMap_.begin();
1839     while (it != remainderMap_.end()) {
1840         if (it->second <= 0) {
1841             it = remainderMap_.erase(it);
1842         } else {
1843             index.push_back(it->first);
1844             it++;
1845         }
1846     }
1847 
1848     std::cout << remainderMap_.size() << "--------fuzz test start--------" << callFunctionMap_.size() << std::endl;
1849     for (; remainderMap_.size() > 0;) {
1850         std::string functionName;
1851         int offset = GetRandomInt(0, index.size() - 1);
1852         functionName = index[offset];
1853         if (callFunctionMap_.find(functionName) != callFunctionMap_.end()) {
1854             std::cout << "call function : " << functionName << std::endl;
1855             callFunctionMap_[functionName]();
1856             std::cout << "function end  :" << functionName << std::endl;
1857         } else {
1858             std::cout << "can't find function : " << functionName << std::endl;
1859         }
1860         remainderMap_[functionName]--;
1861         if (remainderMap_[functionName] <= 0) {
1862             remainderMap_.erase(functionName);
1863             index.erase(index.begin() + offset);
1864         };
1865     }
1866     std::cout << remainderMap_.size() << "--------fuzz test end--------" << std::endl;
1867 }
1868 }  // namespace EventFwk
1869 }  // namespace OHOS
1870