diff --git a/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/BUILD.gn index d68c1c067fef664958c47b459dd214dd134d1434..daad5a6b333fb285d6c5c5c9bd364f0a1e30f028 100644 --- a/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServiceDumpStateFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/dumpstate_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/dumpstate_fuzzer.cpp index e8883423af7f17b3cf55a789a5f3385263b3da00..33d85b6e290c976001f01cf27dd4db5da1ab4820 100644 --- a/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/dumpstate_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicedumpstate_fuzzer/dumpstate_fuzzer.cpp @@ -14,8 +14,10 @@ */ #include "dumpstate_fuzzer.h" +#define private public #include "common_event_manager_service.h" #include "common_event_data.h" +#include "common_utils.h" #include "fuzz_common_base.h" #include "refbase.h" #include @@ -55,6 +57,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) service->DumpState(dumpType, fdp->ConsumeRandomLengthString(), fdp->ConsumeIntegralInRange(-3, 1000), state, funcResult1); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/BUILD.gn index 17283798b1bee1f5a887db10d3ed6fadeacf5f04..f7bd70f9c9e95fee47167f44d415a4d4ed4dc787 100644 --- a/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServiceFinishReceiverFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/finishreceiver_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/finishreceiver_fuzzer.cpp index 198890128bda5ef95ed8e4adb1688f470d715b56..4ac73f1085cb231912369f1002bb4a3a587724b4 100644 --- a/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/finishreceiver_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicefinishreceiver_fuzzer/finishreceiver_fuzzer.cpp @@ -14,10 +14,12 @@ */ #include "finishreceiver_fuzzer.h" +#define private public #include "common_event_data.h" #include "common_event_listener.h" #include "common_event_manager_service.h" #include "common_event_subscriber.h" +#include "common_utils.h" #include "fuzz_common_base.h" #include "refbase.h" #include @@ -59,6 +61,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) service->FinishReceiver(commonEventListener, fdp->ConsumeIntegral(), fdp->ConsumeRandomLengthString(), fdp->ConsumeBool(), funcResult1); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/BUILD.gn index e83b46b8f9c14f60c2bb5f3f687c79ccb0a36418..7cdef433e8601200459e03d30fdba0e38abd7b5f 100644 --- a/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServiceFreezeAndUnfreezeFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/freezeandunfreeze_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/freezeandunfreeze_fuzzer.cpp index e9766beaafe10d701d0c8e450db5865127906383..1527ee0f85cbdcc0a8576c704548de1473141291 100644 --- a/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/freezeandunfreeze_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicefreezeandunfreeze_fuzzer/freezeandunfreeze_fuzzer.cpp @@ -14,8 +14,10 @@ */ #include "freezeandunfreeze_fuzzer.h" +#define private public #include "common_event_manager_service.h" #include "common_event_data.h" +#include "common_utils.h" #include "fuzz_common_base.h" #include "refbase.h" #include @@ -39,6 +41,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) } service->SetFreezeStatus(pidList, fdp->ConsumeBool(), funcResult1); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/BUILD.gn index 5d7671df0c54fcf11135fcecaf4c862c16e65d48..9a24b82759f129e4d0e6fa84792f1238c0a5db87 100644 --- a/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServicePublishCommonEventFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/publishcommonevent_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/publishcommonevent_fuzzer.cpp index ace4d39deb88d49f74e7144f8961197e4a2ee86a..df97314fbf12ac920cf6b81e0007ec4527d0379a 100644 --- a/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/publishcommonevent_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicepublishcommonevent_fuzzer/publishcommonevent_fuzzer.cpp @@ -15,7 +15,9 @@ #include "publishcommonevent_fuzzer.h" #include "common_event_data.h" +#define private public #include "common_event_manager_service.h" +#include "common_utils.h" #include "refbase.h" #include "fuzz_common_base.h" #include @@ -60,6 +62,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) fdp->ConsumeIntegral(), fdp->ConsumeIntegral(), fdp->ConsumeIntegralInRange(-3, 1000), funcResult1); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/BUILD.gn index 8cfa74a0f564ad3e7a2813683a7751ee20bc64a0..11f85f7f083f6cf1f56ce8ce900328f3ece83751 100644 --- a/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServiceSetStaticSubscriberStateFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/setstaticsubscriberstate_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/setstaticsubscriberstate_fuzzer.cpp index 762571f5e794a717a6b790b21ae3c76686442b5d..26807bac2e03bfeb5f28665d6ea3b0bd780af937 100644 --- a/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/setstaticsubscriberstate_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicesetstaticsubscriberstate_fuzzer/setstaticsubscriberstate_fuzzer.cpp @@ -14,7 +14,9 @@ */ #include "setstaticsubscriberstate_fuzzer.h" +#define private public #include "common_event_manager_service.h" +#include "common_utils.h" #include "fuzz_common_base.h" #include "refbase.h" #include @@ -36,6 +38,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) int32_t funcResult1 = -1; service->SetStaticSubscriberStateByEvents(events, fdp->ConsumeBool(), funcResult1); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/BUILD.gn index cc1c348a95df37e05273d37b3ee224a8a08823d5..a4458fb2f92ddcfde5193e8d07a0ac18ccc0c4be 100644 --- a/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/BUILD.gn @@ -22,7 +22,7 @@ ohos_fuzztest("ServiceStickyCommonEventFuzzTest") { fuzz_config_file = "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/stickycommonevent_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/stickycommonevent_fuzzer.cpp index 999711ca558fc7e88f377e449d929943b3177b53..40935ccf28dfabf17fa60d883ce8b7a4ef1d3f15 100644 --- a/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/stickycommonevent_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicestickycommonevent_fuzzer/stickycommonevent_fuzzer.cpp @@ -14,8 +14,10 @@ */ #include "stickycommonevent_fuzzer.h" +#define private public #include "common_event_manager_service.h" #include "common_event_data.h" +#include "common_utils.h" #include "fuzz_common_base.h" #include "refbase.h" #include @@ -48,6 +50,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) service->RemoveStickyCommonEvent(event, funcResult); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/BUILD.gn index a0f27854f615c72401ce17c9affcea54d1f596be..452b406074bfb86abf8ec7e32a88358ffbc0fe15 100644 --- a/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/BUILD.gn @@ -23,7 +23,7 @@ ohos_fuzztest("ServiceSubscribeCommonEventFuzzTest") { "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/unsubscribecommonevent_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/unsubscribecommonevent_fuzzer.cpp index a62914293682930cdfd1a87bd9b66e20904e9022..16e38be9930a0218af04961b95f8eacfe897f164 100644 --- a/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/unsubscribecommonevent_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/servicesubscribecommonevent_fuzzer/unsubscribecommonevent_fuzzer.cpp @@ -14,10 +14,12 @@ */ #include "unsubscribecommonevent_fuzzer.h" +#define private public #include "common_event_data.h" #include "common_event_listener.h" #include "common_event_manager_service.h" #include "common_event_subscriber.h" +#include "common_utils.h" #include "refbase.h" #include "fuzz_common_base.h" @@ -60,6 +62,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) service->UnsubscribeCommonEvent(commonEventListener, funcResult); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/BUILD.gn b/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/BUILD.gn index 4c5b763370be77292b7a58df80c955e02022ad93..891cb19c5df17b06bb2c640091cc601fce8dbdb9 100644 --- a/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/BUILD.gn +++ b/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/BUILD.gn @@ -23,7 +23,7 @@ ohos_fuzztest("ServiceUnsubscribeCommonEventFuzzTest") { "${common_event_service_path}/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer" include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + [ "${common_event_service_path}/test/fuzztest/commonutils" ] cflags = [ "-g", "-O0", diff --git a/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/subscribecommonevent_fuzzer.cpp b/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/subscribecommonevent_fuzzer.cpp index 82eabaa3449a668212d9abb6cc1050206c37c8cc..02fb9106af27d01eaea8f59896f79537a671e349 100644 --- a/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/subscribecommonevent_fuzzer.cpp +++ b/test/fuzztest/commoneventmanagerservice/serviceunsubscribecommonevent_fuzzer/subscribecommonevent_fuzzer.cpp @@ -14,10 +14,12 @@ */ #include "subscribecommonevent_fuzzer.h" +#define private public #include "common_event_data.h" #include "common_event_listener.h" #include "common_event_manager_service.h" #include "common_event_subscriber.h" +#include "common_utils.h" #include "refbase.h" #include "fuzz_common_base.h" @@ -60,6 +62,7 @@ bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fdp) service->UnsubscribeCommonEventSync(commonEventListener, funcResult); usleep(10000); + CleanFfrt(service); return true; } } diff --git a/test/fuzztest/commonutils/common_utils.h b/test/fuzztest/commonutils/common_utils.h new file mode 100644 index 0000000000000000000000000000000000000000..758458748d07f50898c0edf6e2284553ea7a0fb9 --- /dev/null +++ b/test/fuzztest/commonutils/common_utils.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef TEST_FUZZTEST_COMMON_UTILS_H +#define TEST_FUZZTEST_COMMON_UTILS_H + +#include "common_event_manager_service.h" + +inline void CleanFfrt(OHOS::sptr &service) +{ + service->commonEventSrvQueue_.reset(); + service->innerCommonEventManager_->controlPtr_->orderedQueue_.reset(); + service->innerCommonEventManager_->controlPtr_->unorderedQueue_.reset(); + service->innerCommonEventManager_->controlPtr_->unorderedImmediateQueue_.reset(); +} + +#endif \ No newline at end of file diff --git a/test/fuzztest/fuzz_common_base/BUILD.gn b/test/fuzztest/fuzz_common_base/BUILD.gn index 35181bbb687eca9028fcfd91778ad7d6d254759d..86040a0bb6e479212b9406cb70cc9209e2d94e62 100644 --- a/test/fuzztest/fuzz_common_base/BUILD.gn +++ b/test/fuzztest/fuzz_common_base/BUILD.gn @@ -13,6 +13,13 @@ import("//base/notification/common_event_service/event.gni") +config("fuzz_common_base_public_config") { + visibility = [ ":*" ] + + include_dirs = + [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] +} + static_library("fuzz_common_base") { sources = [ "fuzz_common_base.cpp" ] cflags = [ @@ -21,9 +28,7 @@ static_library("fuzz_common_base") { "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - - include_dirs = - [ "${common_event_service_path}/test/fuzztest/fuzz_common_base" ] + public_configs = [ ":fuzz_common_base_public_config" ] external_deps = [ "access_token:libaccesstoken_sdk",