diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index e95c3307f024e86b4d38c3d69a2ba3c7da2b21a7..267f1edcdfae2e6d8b8df966de2df9d9e0b11d11 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -18,5 +18,6 @@ group("fuzztest") { deps += [ "accesstokenid:fuzztest", "hc_node:fuzztest", + "sched:fuzztest", ] } diff --git a/test/fuzztest/sched/BUILD.gn b/test/fuzztest/sched/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a1dc18aaf6a4c14628dbafb1efa067098006a845 --- /dev/null +++ b/test/fuzztest/sched/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2022 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. + +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + "addthreadtortg_fuzzer:AddThreadToRtgFuzzTest", + "beginframefreq_fuzzer:BeginFrameFreqFuzzTest", + "endframefreq_fuzzer:EndFrameFreqFuzzTest", + "endscene_fuzzer:EndSceneFuzzTest", + "searchrtgfortid_fuzzer:SearchRtgForTidFuzzTest", + "setmargin_fuzzer:SetMarginFuzzTest", + ] +} diff --git a/test/fuzztest/sched/addthreadtortg_fuzzer/BUILD.gn b/test/fuzztest/sched/addthreadtortg_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..12a8ea96817a1f82634c36f64d5cc2441ca310d8 --- /dev/null +++ b/test/fuzztest/sched/addthreadtortg_fuzzer/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("AddThreadToRtgFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/sched/addthreadtortg_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "addthreadtortg_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":AddThreadToRtgFuzzTest" ] +} diff --git a/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp b/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..221d1d9d82f683b42f1fadc16e04565b4d5ab87b --- /dev/null +++ b/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool AddThreadToRtgFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + return ret; + } else { + uint8_t *countData = const_cast(data); + int tid = *(reinterpret_cast(countData)); + if (tid <= 0) { + return ret; + } + int grpId = 2; + ret = AddThreadToRtg(tid, grpId); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::AddThreadToRtgFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/sched/addthreadtortg_fuzzer/corpus/init b/test/fuzztest/sched/addthreadtortg_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/addthreadtortg_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/addthreadtortg_fuzzer/project.xml b/test/fuzztest/sched/addthreadtortg_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/addthreadtortg_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/BUILD.gn b/test/fuzztest/sched/beginframefreq_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..636c061b0150d48307986fb2603da2ecde3888b4 --- /dev/null +++ b/test/fuzztest/sched/beginframefreq_fuzzer/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("BeginFrameFreqFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/sched/beginframefreq_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "beginframefreq_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":BeginFrameFreqFuzzTest" ] +} diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0c617e5fc6469865716ba7ee85c18b82ec64e4a4 --- /dev/null +++ b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool BeginFrameFreqFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + constexpr int MARGIN_UPPER_LIMIT_TIME = 32000; + constexpr int MARGIN_LOWER_LIMIT_TIME = -32000; + if (data == nullptr) { + return ret; + } else { + uint8_t *countData = const_cast(data); + int margin = *(reinterpret_cast(countData)); + if (margin < MARGIN_LOWER_LIMIT_TIME || margin > MARGIN_UPPER_LIMIT_TIME) { + return ret; + } + int grpId = 2; + ret = BeginFrameFreq(grpId, margin); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::BeginFrameFreqFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/corpus/init b/test/fuzztest/sched/beginframefreq_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/beginframefreq_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/project.xml b/test/fuzztest/sched/beginframefreq_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/beginframefreq_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/endframefreq_fuzzer/BUILD.gn b/test/fuzztest/sched/endframefreq_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..05a80ce01b855783d2551512a00628e9ff7ddcdb --- /dev/null +++ b/test/fuzztest/sched/endframefreq_fuzzer/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("EndFrameFreqFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/sched/endframefreq_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "endframefreq_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":EndFrameFreqFuzzTest" ] +} diff --git a/test/fuzztest/sched/endframefreq_fuzzer/corpus/init b/test/fuzztest/sched/endframefreq_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/endframefreq_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp b/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70fcd22731d75afcb1ccc02ff1f2095795ec5f78 --- /dev/null +++ b/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool EndFrameFreqFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + return ret; + } + int grpId = 2; + ret = EndFrameFreq(grpId); + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::EndFrameFreqFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/sched/endframefreq_fuzzer/project.xml b/test/fuzztest/sched/endframefreq_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/endframefreq_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/endscene_fuzzer/BUILD.gn b/test/fuzztest/sched/endscene_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..50ba263ca1f1e085e5f0fad8d8232387ba9cd369 --- /dev/null +++ b/test/fuzztest/sched/endscene_fuzzer/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("EndSceneFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/sched/endscene_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "endscene_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":EndSceneFuzzTest" ] +} diff --git a/test/fuzztest/sched/endscene_fuzzer/corpus/init b/test/fuzztest/sched/endscene_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/endscene_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp b/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bda65aeb7db3a324ca869804aac3954e31dc4f8f --- /dev/null +++ b/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool EndSceneFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + return ret; + } + int grpId = 2; + ret = EndScene(grpId); + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::EndSceneFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/sched/endscene_fuzzer/project.xml b/test/fuzztest/sched/endscene_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/endscene_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/searchrtgfortid_fuzzer/BUILD.gn b/test/fuzztest/sched/searchrtgfortid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3c72d832d7234b5851367867e9ca6cf330912c82 --- /dev/null +++ b/test/fuzztest/sched/searchrtgfortid_fuzzer/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("SearchRtgForTidFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "//kernel/linux/build/test/fuzztest/sched/searchrtgfortid_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "searchrtgfortid_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SearchRtgForTidFuzzTest" ] +} diff --git a/test/fuzztest/sched/searchrtgfortid_fuzzer/corpus/init b/test/fuzztest/sched/searchrtgfortid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/searchrtgfortid_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/searchrtgfortid_fuzzer/project.xml b/test/fuzztest/sched/searchrtgfortid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/searchrtgfortid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp b/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5bba73a19d8a1d6f039f7e0e7710429d0e9a406 --- /dev/null +++ b/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool SearchRtgForTidFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if (data == nullptr) { + return ret; + } else { + uint8_t *countData = const_cast(data); + int tid = *(reinterpret_cast(countData)); + if (tid <= 0) { + return ret; + } + ret = SearchRtgForTid(tid); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SearchRtgForTidFuzzTest(data, size); + return 0; +} diff --git a/test/fuzztest/sched/setmargin_fuzzer/BUILD.gn b/test/fuzztest/sched/setmargin_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0605210b97fcf58843fd97e42676933e5094eb92 --- /dev/null +++ b/test/fuzztest/sched/setmargin_fuzzer/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (c) 2022 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. + +import("//build/config/features.gni") +import("//build/test.gni") + +module_output_path = "linuxkerneltest/sched" + +ohos_fuzztest("SetMarginFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "//kernel/linux/build/test/fuzztest/sched/setmargin_fuzzer" + + include_dirs = [ + "//foundation/multimedia/image_standard/mock/native/include", + "//foundation/resourceschedule/frame_aware_sched/common/include", + "//third_party/bounds_checking_function/include", + ] + deps = [ "//third_party/bounds_checking_function:libsec_static" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-pthread", + ] + + sources = [ + "//foundation/multimedia/image_standard/mock/native/src/HiLog.cpp", + "//foundation/resourceschedule/frame_aware_sched/interfaces/innerkits/frameintf/rtg_interface.cpp", + "setmargin_fuzzer.cpp", + ] +} + +group("fuzztest") { + testonly = true + deps = [] + deps += [ ":SetMarginFuzzTest" ] +} diff --git a/test/fuzztest/sched/setmargin_fuzzer/corpus/init b/test/fuzztest/sched/setmargin_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..58ee85e5da3dcf11bcb8e41f5bd5312014a16989 --- /dev/null +++ b/test/fuzztest/sched/setmargin_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2020-2022 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. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/sched/setmargin_fuzzer/project.xml b/test/fuzztest/sched/setmargin_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/sched/setmargin_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..92209c911c3658a5426993727e09614572f5b10b --- /dev/null +++ b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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. + */ + +#include +#include "rtg_interface.h" + +using namespace std; +using namespace OHOS::RME; +namespace OHOS { +bool SetMarginFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + constexpr int MARGIN_UPPER_LIMIT_TIME = 32000; + constexpr int MARGIN_LOWER_LIMIT_TIME = -32000; + if (data == nullptr) { + return ret; + } else { + uint8_t *countData = const_cast(data); + int margin = *(reinterpret_cast(countData)); + if (margin < MARGIN_LOWER_LIMIT_TIME || margin > MARGIN_UPPER_LIMIT_TIME) { + return ret; + } + int grpId = 2; + ret = SetMargin(grpId, margin); + } + return ret; +} +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + OHOS::SetMarginFuzzTest(data, size); + return 0; +}