已开启
新增vpe fuzz用例 #71
已开启
dengwanlin1创建于 14 天前
6 个文件变更+181-0
@@ -34,6 +34,7 @@ declare_args() {
34 aihdr_enhancer_unit_test = true34 aihdr_enhancer_unit_test = true
35 contrast_enhancer_unit_test = true35 contrast_enhancer_unit_test = true
36 services_fuzzer_test = true36 services_fuzzer_test = true
37+ autoeffect_fuzzer_test = true
37 } else {38 } else {
38 vpe_support_demo_test = false39 vpe_support_demo_test = false
39 vpe_support_unit_test = false40 vpe_support_unit_test = false
@@ -53,6 +54,7 @@ declare_args() {
53 service_unit_test = false54 service_unit_test = false
54 contrast_enhancer_unit_test = false55 contrast_enhancer_unit_test = false
55 services_fuzzer_test = false56 services_fuzzer_test = false
57+ autoeffect_fuzzer_test = false
56 }58 }
57 vpe_support_ndk_module_test = true59 vpe_support_ndk_module_test = true
58}60}
@@ -138,4 +140,9 @@ group("fuzz_test") {
138 "fuzztest/services_fuzzer:ServicesFuzzTest",140 "fuzztest/services_fuzzer:ServicesFuzzTest",
139 ]141 ]
140 }142 }
143+ if (autoeffect_fuzzer_test) {
144+ deps += [
145+ "fuzztest/autoeffect_fuzzer:AutoEffectFuzzTest",
146+ ]
147+ }
141}148}
@@ -0,0 +1,46 @@
1+# Copyright (c) 2026 Huawei Device Co., Ltd.
2+# Licensed under the Apache License, Version 2.0 (the "License");
3+# you may not use this file except in compliance with the License.
4+# You may obtain a copy of the License at
5+#
6+# http://www.apache.org/licenses/LICENSE-2.0
7+#
8+# Unless required by applicable law or agreed to in writing, software
9+# distributed under the License is distributed on an "AS IS" BASIS,
10+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+# See the License for the specific language governing permissions and
12+# limitations under the License.
13+ 
14+#####################hydra-fuzz###################
15+import("//build/config/features.gni")
16+import("//build/test.gni")
17+import("//foundation/multimedia/video_processing_engine/config.gni")
18+module_output_path = "video_processing_engine/video_processing_engine"
19+ 
20+##############################fuzztest##########################################
21+ohos_fuzztest("AutoEffectFuzzTest") {
22+ module_out_path = module_output_path
23+ fuzz_config_file = "$VIDEO_PROCESSING_ENGINE_ROOT_DIR/test/fuzztest/autoeffect_fuzzer"
24+ 
25+ include_dirs = [
26+ "$INTERFACES_CAPI_DIR",
27+ ]
28+ cflags = [
29+ "-g",
30+ "-O0",
31+ "-Wno-unused-variable",
32+ "-fno-omit-frame-pointer",
33+ ]
34+ sources = [
35+ "autoeffect_fuzzer.cpp"
36+ ]
37+ deps = [
38+ "$FRAMEWORK_DIR:video_processing",
39+ ]
40+ 
41+ external_deps = [
42+ "c_utils:utils",
43+ "hilog:libhilog",
44+ "media_foundation:native_media_core",
45+ ]
46+}
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#include <cstdint>
17+#include <string>
18+#include <fuzzer/FuzzedDataProvider.h>
19+ 
20+#include "video_processing.h"
21+#include "video_processing_types.h"
22+#include "native_avformat.h"
23+#include "autoeffect_fuzzer.h"
24+ 
25+namespace {
26+bool IsAutoEffectSupportedFuzzTest(uint32_t type)
27+{
28+ return OH_VideoProcessing_IsAutoEffectSupported(type);
29+}
30+ 
31+VideoProcessing_ErrorCode UseAutoEffectFuzzTest(uint32_t type, bool enable, const char* name)
32+{
33+ return OH_VideoProcessing_UseAutoEffect(type, enable, name);
34+}
35+ 
36+VideoProcessing_ErrorCode SetAutoEffectParamFuzzTest(uint32_t type, const char* name, const OH_AVFormat* param)
37+{
38+ return OH_VideoProcessing_SetAutoEffectParam(type, name, param);
39+}
40+}
41+ 
42+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
43+{
44+ FuzzedDataProvider dataProvider(data, size);
45+ 
46+ uint32_t type = dataProvider.ConsumeBool()
47+ ? static_cast<uint32_t>(VIDEO_PROCESSING_TYPE_AUTOEFFECT_AISR)
48+ : dataProvider.ConsumeIntegral<uint32_t>();
49+ 
50+ bool enable = dataProvider.ConsumeBool();
51+ 
52+ std::string nameStr = dataProvider.ConsumeRandomLengthString(64);
53+ const char* name = dataProvider.ConsumeBool() ? nullptr : nameStr.c_str();
54+ 
55+ OH_AVFormat* param = nullptr;
56+ if (!dataProvider.ConsumeBool()) {
57+ param = OH_AVFormat_Create();
58+ if (param != nullptr) {
59+ int32_t enableVal = dataProvider.ConsumeIntegralInRange<int32_t>(-2, 2);
60+ float strength = dataProvider.ConsumeFloatingPointInRange<float>(-1.0f, 2.0f);
61+ uint8_t paramMode = dataProvider.ConsumeIntegralInRange<uint8_t>(0, 3);
62+ if (paramMode & 0x1) {
63+ OH_AVFormat_SetIntValue(param, VIDEO_AUTOEFFECT_ENABLE, enableVal);
64+ }
65+ if (paramMode & 0x2) {
66+ OH_AVFormat_SetFloatValue(param, VIDEO_AUTOEFFECT_AISR_STRENGTH, strength);
67+ }
68+ }
69+ }
70+ 
71+ (void)IsAutoEffectSupportedFuzzTest(type);
72+ 
73+ (void)UseAutoEffectFuzzTest(type, enable, name);
74+ 
75+ (void)SetAutoEffectParamFuzzTest(type, name, param);
76+ 
77+ if (param != nullptr) {
78+ OH_AVFormat_Destroy(param);
79+ }
80+ return 0;
81+}
@@ -0,0 +1,21 @@
1+/*
2+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+#ifndef TEST_FUZZTEST_AUTOEFFECT_FUZZER_H
17+#define TEST_FUZZTEST_AUTOEFFECT_FUZZER_H
18+ 
19+#define FUZZ_PROJECT_NAME "videoProcessingEngineAutoEffect_fuzzer"
20+ 
21+#endif // TEST_FUZZTEST_AUTOEFFECT_FUZZER_H
@@ -0,0 +1 @@
1+AutoEffectFuzzSeedAISR01
@@ -0,0 +1,25 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<!--
3+ 
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+ 
8+ http://www.apache.org/licenses/LICENSE-2.0
9+ 
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+-->
16+<fuzz_config>
17+ <fuzztest>
18+ <!-- maximum length of a test input -->
19+ <max_len>1000</max_len>
20+ <!-- maximum total time in seconds to run the fuzzer -->
21+ <max_total_time>300</max_total_time>
22+ <!-- memory usage limit in Mb -->
23+ <rss_limit_mb>4096</rss_limit_mb>
24+ </fuzztest>
25+</fuzz_config>