From 2444c9e248805af8ba38a74fbe6cc6817baa05e9 Mon Sep 17 00:00:00 2001 From: zhujiaxin Date: Wed, 29 Jun 2022 10:59:19 +0800 Subject: [PATCH 01/12] kernel common patch Signed-off-by: zhujiaxin --- README.md | 21 +++++++++++++-------- README_zh.md | 21 +++++++++++++-------- kernel.mk | 3 +-- 3 files changed, 27 insertions(+), 18 deletions(-) mode change 100755 => 100644 kernel.mk diff --git a/README.md b/README.md index 5a75941..9e500a3 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,19 @@ The vendor provides the driver code of the chip architecture. ``` kernel/linux/patches -├── linux-4.19 # linux-4.19 patches -│ └── hi3516dv300_patch -│ ├── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches -│ └── hdf.patch # linux-4.19 Hi3516D V300 HDF patches +├── linux-4.19 # linux-4.19 patches +│   ├── common_patch +│   │ └── hdf.patch # linux-4.19 HDF patches +│   └── hi3516dv300_patch +│   └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches └── linux-5.10 - └── hi3516dv300_patch - ├── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches - └── hdf.patch # linux-5.10 Hi3516D V300 HDF patches + ├── common_patch + │ └── hdf.patch # linux-5.10 HDF patches + └── hi3516dv300_patch + │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches + └── rkrk3568_patch + ├── kernel.patch # linux-5.10 rk3568 SOC patches + └── hdf.patch # linux-5.10 rk3568 customized HDF patches ``` ## Usage @@ -44,7 +49,7 @@ kernel/linux/patches Apply the HDF kernel patches matching your kernel version. For details, see the method in **kernel.mk** in the **kernel/linux/build** repository. ``` - $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE) + $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) ``` 2. Apply the chip driver patches. diff --git a/README_zh.md b/README_zh.md index 2f3b328..c54c399 100644 --- a/README_zh.md +++ b/README_zh.md @@ -27,14 +27,19 @@ hi3516dv300_small.patch: 在Hi3516DV300芯片上支持arm架构的内核启动 ``` kernel/linux/patches -├── linux-4.19 # linux-4.19 相关patch -│ └── hi3516dv300_patch -│ ├── hi3516dv300.patch # linux-4.19 hi3516dv300 SOC patch -│ └── hdf.patch # linux-4.19 hi3516dv300 hdf patch +├── linux-4.19 # linux-4.19 相关patch +│   ├── common_patch +│   │ └── hdf.patch # linux-4.19 HDF patches +│   └── hi3516dv300_patch +│   └── hi3516dv300.patch # linux-4.19 Hi3516D V300 SOC patches └── linux-5.10 - └── hi3516dv300_patch - ├── hi3516dv300.patch # linux-5.10 hi3516dv300 SOC patch - └── hdf.patch # linux-5.10 hi3516dv300 hdf patch + ├── common_patch + │ └── hdf.patch # linux-5.10 HDF patches + └── hi3516dv300_patch + │ └── hi3516dv300.patch # linux-5.10 Hi3516D V300 SOC patches + └── rkrk3568_patch + ├── kernel.patch # linux-5.10 rk3568 SOC patches + └── hdf.patch # linux-5.10 rk3568 定制 HDF patches ``` ## 使用说明 @@ -44,7 +49,7 @@ kernel/linux/patches 在kernel/linux/build仓中,按照kernel.mk中HDF的补丁合入方法,合入不同内核版本对应的HDF内核补丁: ``` - $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE) + $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) ``` 2. 合入芯片平台驱动补丁 diff --git a/kernel.mk b/kernel.mk old mode 100755 new mode 100644 index a4bfb82..5de5dc9 --- a/kernel.mk +++ b/kernel.mk @@ -64,7 +64,6 @@ ifneq ($(findstring $(BUILD_TYPE), small standard),) DEVICE_PATCH_DIR := $(OHOS_BUILD_HOME)/kernel/linux/patches/${KERNEL_VERSION}/$(DEVICE_NAME)_patch DEVICE_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME).patch PRODUCT_PATCH_FILE := $(OHOS_BUILD_HOME)/vendor/hisilicon/watchos/patchs/$(DEVICE_NAME).patch -HDF_PATCH_FILE := $(DEVICE_PATCH_DIR)/hdf.patch SMALL_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME)_$(BUILD_TYPE).patch KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/$(KERNEL_IMAGE) DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig @@ -80,7 +79,7 @@ ifeq ($(DEVICE_NAME), hispark_phoenix) else $(hide) rm -rf $(KERNEL_SRC_TMP_PATH);mkdir -p $(KERNEL_SRC_TMP_PATH);cp -arfL $(KERNEL_SRC_PATH)/* $(KERNEL_SRC_TMP_PATH)/ endif - $(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(HDF_PATCH_FILE) + $(hide) $(OHOS_BUILD_HOME)/drivers/hdf_core/adapter/khdf/linux/patch_hdf.sh $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(KERNEL_PATCH_PATH) $(DEVICE_NAME) ifeq ($(PRODUCT_PATH), vendor/hisilicon/watchos) $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(PRODUCT_PATCH_FILE) -- Gitee From 7cdbb67dc5e9f2278035d19b78204865e7d6392f Mon Sep 17 00:00:00 2001 From: liudanning Date: Tue, 12 Jul 2022 09:45:17 +0800 Subject: [PATCH 02/12] kernel_linux_build:Modify testcases to adapt to app AbilityName changes Signed-off-by: liudanning --- test/moduletest/runtest/bin/enhancedswap_t_init.sh | 7 ++++++- .../runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh | 2 +- test/moduletest/runtest/bin/mem_debug_t_init.sh | 2 +- .../runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh | 6 +++--- .../runtest/bin/sched_rtg_t/testcases/bin/sched_rtg02.sh | 2 +- .../runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh | 2 +- .../runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh | 2 +- .../runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh | 6 +++--- 8 files changed, 17 insertions(+), 12 deletions(-) diff --git a/test/moduletest/runtest/bin/enhancedswap_t_init.sh b/test/moduletest/runtest/bin/enhancedswap_t_init.sh index 4dcadcf..a51937e 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t_init.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t_init.sh @@ -58,14 +58,19 @@ zram_enable() swapon /dev/block/zram0 aa start -b com.ohos.settings -a com.ohos.settings.MainAbility aa start -b ohos.samples.airquality -a ohos.samples.airquality.default - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default aa start -b ohos.samples.clock -a ohos.samples.clock.default + aa start -b com.ohos.camera -a com.ohos.camera.MainAbility + aa start -b com.ohos.permissionmanager -a com.ohos.permissionmanager.MainAbility + aa start -b ohos.sample.shopping -a com.example.entry.MainAbility + aa start -b ohos.samples.distributedcalc -a ohos.samples.distributedcalc.MainAbility } echo "***************************ESWAP INIT START***************************" free -m +uninit_platform pre_condition hp_init hp_enable diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh index cdfcb09..fabc90e 100644 --- a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug04.sh @@ -56,7 +56,7 @@ do_test() sh ../../../mem_debug_t_init.sh aa start -b com.ohos.settings -a com.ohos.settings.MainAbility aa start -b ohos.samples.airquality -a ohos.samples.airquality.default - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default aa start -b ohos.samples.clock -a ohos.samples.clock.default diff --git a/test/moduletest/runtest/bin/mem_debug_t_init.sh b/test/moduletest/runtest/bin/mem_debug_t_init.sh index 91474c8..1455628 100644 --- a/test/moduletest/runtest/bin/mem_debug_t_init.sh +++ b/test/moduletest/runtest/bin/mem_debug_t_init.sh @@ -58,7 +58,7 @@ zram_enable() swapon /dev/block/zram0 aa start -b com.ohos.settings -a com.ohos.settings.MainAbility aa start -b ohos.samples.airquality -a ohos.samples.airquality.default - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility aa start -b ohos.samples.flashlight -a ohos.samples.flashlight.default aa start -b ohos.samples.clock -a ohos.samples.clock.default } diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh index 429b78b..6f273c1 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg01.sh @@ -29,7 +29,7 @@ source tst_oh.sh do_setup() { - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility sleep 1 PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') } @@ -65,7 +65,7 @@ do_test() fi local rtgid3=$(cat $sched_group_id) if [ $rtgid3 -eq 3 ]; then - tst_res TFAIL "process $PID switch rtgid 2 to 3 success unexpected!" + tst_res TFAIL "process $PID switch rtgid 2 to 3 sucess unexpected!" res=$(($res + 1)) fi @@ -96,4 +96,4 @@ do_clean() do_setup do_test do_clean -tst_exit +tst_exit \ No newline at end of file diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg02.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg02.sh index 8ab1532..631283d 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg02.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg02.sh @@ -31,7 +31,7 @@ source tst_oh.sh do_setup() { - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility sleep 1 PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') } diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh index 6c53aeb..d9f1a6a 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg03.sh @@ -29,7 +29,7 @@ source tst_oh.sh do_setup() { - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility sleep 1 PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') } diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh index 56996f4..0f77902 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg04.sh @@ -31,7 +31,7 @@ do_setup() { cpu_value=$(cat /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable) - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility sleep 1 PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') echo 1 > /sys/kernel/debug/tracing/events/rtg/find_rtg_cpu/enable diff --git a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh index e69d871..91a3014 100644 --- a/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh +++ b/test/moduletest/runtest/bin/sched_rtg_t/testcases/bin/sched_rtg06.sh @@ -65,8 +65,8 @@ stability_test() tst_res TINFO "kill 40 task processes...." ps -ef | grep "create_process" | grep -v "grep" | grep -v ${PPID} | cut -c 9-18 | xargs kill -9 sleep 5 - tst_res TINFO "kill process succeeded." - aa start -b ohos.samples.ecg -a ohos.samples.ecg.default && + tst_res TINFO "kill process successed." + aa start -b ohos.samples.ecg -a ohos.samples.ecg.MainAbility && sleep 1 && PID=$(ps -ef | grep ohos.samples.ecg | grep -v grep | awk '{print $2}') if [ $? -eq 0 ]; then @@ -147,4 +147,4 @@ do_clean() do_setup do_test do_clean -tst_exit +tst_exit \ No newline at end of file -- Gitee From 8fcea5edb0f61956b41df34048fb74d495a28f2c Mon Sep 17 00:00:00 2001 From: liudanning Date: Tue, 12 Jul 2022 09:47:28 +0800 Subject: [PATCH 03/12] kernel_linux_build:modify enhancedswap_t_init.sh to clean environment Signed-off-by: liudanning --- .../runtest/bin/enhancedswap_t_init.sh | 16 ++++++++++++++-- .../runtest/bin/enhancedswap_t_uninit.sh | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/test/moduletest/runtest/bin/enhancedswap_t_init.sh b/test/moduletest/runtest/bin/enhancedswap_t_init.sh index a51937e..404136d 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t_init.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t_init.sh @@ -30,12 +30,24 @@ pre_condition() } +uninit_platform() +{ + losetup -d /dev/block/loop7 + echo ${hyperhold_device} > /proc/sys/kernel/hyperhold/device + echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable + echo ${zram0_group} > /sys/block/zram0/group + echo ${zram0_disksize} > /sys/block/zram0/disksize + rm -rf hpdisk + swapoff /dev/block/zram0 + echo 1 > /sys/block/zram0/reset +} + hp_init() { dd if=/dev/random of=hpdisk bs=4096 count=131072 - losetup /dev/block/loop6 hpdisk + losetup /dev/block/loop7 hpdisk hyperhold_device=$(cat /proc/sys/kernel/hyperhold/device) - echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device + echo /dev/block/loop7 > /proc/sys/kernel/hyperhold/device } hp_enable() diff --git a/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh b/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh index e7a5e60..6236024 100644 --- a/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh +++ b/test/moduletest/runtest/bin/enhancedswap_t_uninit.sh @@ -27,7 +27,7 @@ uninit_platform() { - losetup -d /dev/block/loop6 + losetup -d /dev/block/loop7 echo ${hyperhold_device} > /proc/sys/kernel/hyperhold/device echo ${hyperhold_enable} > /proc/sys/kernel/hyperhold/enable echo ${zram0_group} > /sys/block/zram0/group -- Gitee From fe4bcfc3123b4f965587a492b143f4a13ec6ffa5 Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Tue, 12 Jul 2022 19:42:54 +0800 Subject: [PATCH 04/12] fix include file by IWYU Signed-off-by: @wu_fan520 --- .../accessftokenidgrptest_fuzzer.cpp | 3 +++ .../accessftokenidgrptestother_fuzzer.cpp | 3 +++ .../accessftokenidthreadtest_fuzzer.cpp | 3 +++ .../accesstokenidgrptest_fuzzer.cpp | 3 +++ .../accesstokenidgrptestother_fuzzer.cpp | 3 +++ .../accesstokenidthreadtest_fuzzer.cpp | 3 +++ .../getftokenidcmdcorrect_fuzzer.cpp | 3 +++ .../getftokenidnullptr_fuzzer.cpp | 3 +++ .../gettokenidcmdcorrect_fuzzer.cpp | 3 +++ .../gettokenidcmderror_fuzzer.cpp | 3 +++ .../gettokenidnullptr_fuzzer.cpp | 3 +++ .../accesstokenid/include/accessftokenidcommon.h | 1 + .../accesstokenid/include/accesstokenidcommon.h | 1 + .../setftokenidcmdcorrect_fuzzer.cpp | 3 +++ .../setftokenidcmderror_fuzzer.cpp | 3 +++ .../settokenidcmdcorrect_fuzzer.cpp | 3 +++ .../settokenidnullptr_fuzzer.cpp | 3 +++ .../accesstokenid/src/accessftokenidcommon.cpp | 13 +++++-------- .../accesstokenid/src/accesstokenidcommon.cpp | 13 +++++-------- .../hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp | 7 +++---- .../hchotdatalowerlimit_fuzzer.cpp | 7 +++---- .../hchotdatawaterline_fuzzer.cpp | 7 +++---- .../hchotnodelowerlimit_fuzzer.cpp | 7 +++---- .../hchotnodewaterline_fuzzer.cpp | 7 +++---- .../hcwarmdatalowerlimit_fuzzer.cpp | 7 +++---- .../hcwarmdatawaterline_fuzzer.cpp | 7 +++---- .../hcwarmnodelowerlimit_fuzzer.cpp | 7 +++---- 27 files changed, 81 insertions(+), 48 deletions(-) diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp index c535b27..aa78808 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp index 399d77f..5f5c841 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp index 4212980..9e8fbd6 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp index af5b636..872a7bd 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp index a4e57da..d0437f9 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp index 5215747..0aadbf7 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp index 1173bb9..0425ea0 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp index c098598..8dbfbf3 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp @@ -16,6 +16,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp index 40762c2..4f2e592 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp @@ -16,6 +16,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp index 46d305e..e594226 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #define CMDERROR #include "accesstokenidcommon.h" diff --git a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp index 5be434e..a6a862f 100644 --- a/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidnullptr_fuzzer/gettokenidnullptr_fuzzer.cpp @@ -16,6 +16,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h index e0c3903..fe074a4 100644 --- a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h @@ -15,6 +15,7 @@ #ifndef ACCESSFTOKENIDCOMMON_H #define ACCESSFTOKENIDCOMMON_H +#include #define FUZZ_PROJECT_NAME "accessftokenidcommon" diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index febe475..7b1cd98 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -15,6 +15,7 @@ #ifndef ACCESSTOKENIDCOMMON_H #define ACCESSTOKENIDCOMMON_H +#include #define FUZZ_PROJECT_NAME "accesstokenidcommon" diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp index 000316c..595cabd 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "accessftokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp index 9a2f085..d3b9184 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #define CMDERROR #include "accessftokenidcommon.h" diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp index 7183f67..0bd4263 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp @@ -16,6 +16,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp index 715454c..b8fa5ea 100644 --- a/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidnullptr_fuzzer/settokenidnullptr_fuzzer.cpp @@ -16,6 +16,9 @@ */ #include +#include +#include +#include "__config" #include "accesstokenidcommon.h" using namespace std; diff --git a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp index 6fa504f..7f6b538 100644 --- a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp @@ -13,16 +13,13 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include #include -#include -#include +#include +#include +#include +#include +#include #include "accessftokenidcommon.h" namespace OHOS { diff --git a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp index 1be96bd..69d3471 100644 --- a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp @@ -13,16 +13,13 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include #include #include -#include -#include +#include +#include +#include +#include +#include #include "accesstokenidcommon.h" namespace OHOS { diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp index 7c7c9f0..93eac67 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable"; diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp index 8a1af0c..5918d1e 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit"; diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp index 189b67b..e037e72 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline"; diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp index 5799c61..8f5b0bf 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit"; diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp index 2ef9b15..2910e8b 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline"; diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp index 9691fba..849fefa 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit"; diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp index 040152f..02eedd3 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline"; diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp index e5d3b23..075d978 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit"; -- Gitee From 3461e24b8aa0d7b839e94d5b297c82193fb919aa Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Fri, 15 Jul 2022 11:18:46 +0800 Subject: [PATCH 05/12] fix retract and variable name Signed-off-by: @wu_fan520 --- .../accesstokenid/include/accessftokenidcommon.h | 12 ++++++------ .../accesstokenid/include/accesstokenidcommon.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h index fe074a4..0067162 100644 --- a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h @@ -25,17 +25,17 @@ namespace AccessToken { #define ACCESS_TOKEN_ID_IOCTL_BASE 'A' #ifdef CMDERROR -constexpr unsigned int GET_FTOKEN_ID = 0; -constexpr unsigned int SET_FTOKEN_ID = 0; +constexpr unsigned int get_ftoken_id = 0; +constexpr unsigned int set_ftoken_id = 0; #else -constexpr unsigned int GET_FTOKEN_ID = 3; -constexpr unsigned int SET_FTOKEN_ID = 4; +constexpr unsigned int get_ftoken_id = 3; +constexpr unsigned int set_ftoken_id = 4; #endif #define ACCESS_TOKENID_GET_FTOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_ftoken_id, unsigned long long) #define ACCESS_TOKENID_SET_FTOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_ftoken_id, unsigned long long) #define LIST_NUM_1 1 #define LIST_NUM_2 2 diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index 7b1cd98..298412b 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -25,17 +25,17 @@ namespace AccessToken { #define ACCESS_TOKEN_ID_IOCTL_BASE 'A' #ifdef CMDERROR -constexpr unsigned int GET_TOKEN_ID = 0; -constexpr unsigned int SET_TOKEN_ID = 0; +constexpr unsigned int get_token_id = 0; +constexpr unsigned int set_token_id = 0; #else -constexpr unsigned int GET_TOKEN_ID = 1; -constexpr unsigned int SET_TOKEN_ID = 2; +constexpr unsigned int get_token_id = 1; +constexpr unsigned int set_token_id = 2; #endif #define ACCESS_TOKENID_GET_TOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_token_id, unsigned long long) #define ACCESS_TOKENID_SET_TOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_token_id, unsigned long long) #define LIST_NUM_1 1 #define LIST_NUM_2 2 -- Gitee From 81714dab001e7ced58356cb100c2eaed6fd038b6 Mon Sep 17 00:00:00 2001 From: liudanning Date: Fri, 15 Jul 2022 16:16:14 +0800 Subject: [PATCH 06/12] kernel_linux_build:modify mem_debug05 to become precise when cat log Signed-off-by: liudanning --- .../mem_debug_t/testcases/bin/mem_debug05.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh index c900e9a..6287ab0 100644 --- a/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh +++ b/test/moduletest/runtest/bin/mem_debug_t/testcases/bin/mem_debug05.sh @@ -65,11 +65,12 @@ check_reclaim_efficiency() { local mem_type=$1 - local total_process_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep total_process | awk '{print $2}') - local drain_pages_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep drain_pages | awk '{print $2}') - local shrink_file_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_file | awk '{print $2}') - local shrink_anon_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_anon | awk '{print $2}') - local shrink_slab_time=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_slab | awk '{print $2}') + cat /proc/reclaim_efficiency > log.txt + local total_process_time=$(cat log.txt | grep -A5 $mem_type | grep total_process | awk '{print $2}') + local drain_pages_time=$(cat log.txt | grep -A5 $mem_type | grep drain_pages | awk '{print $2}') + local shrink_file_time=$(cat log.txt | grep -A5 $mem_type | grep shrink_file | awk '{print $2}') + local shrink_anon_time=$(cat log.txt | grep -A5 $mem_type | grep shrink_anon | awk '{print $2}') + local shrink_slab_time=$(cat log.txt | grep -A5 $mem_type | grep shrink_slab | awk '{print $2}') local sum_time_a=$(($drain_pages_time + $shrink_file_time)) local sum_time_b=$(($shrink_anon_time + $shrink_slab_time)) local sum_time=$(($sum_time_a + $sum_time_b)) @@ -80,9 +81,9 @@ check_reclaim_efficiency() tst_res TFAIL "total_process_time in $mem_type is less than sum of subprocess." fi - local total_process_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep total_process | awk '{print $3}') - local shrink_file_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_file | awk '{print $3}') - local shrink_anon_freed=$(cat /proc/reclaim_efficiency | grep -A5 $mem_type | grep shrink_anon | awk '{print $3}') + local total_process_freed=$(cat log.txt | grep -A5 $mem_type | grep total_process | awk '{print $3}') + local shrink_file_freed=$(cat log.txt | grep -A5 $mem_type | grep shrink_file | awk '{print $3}') + local shrink_anon_freed=$(cat log.txt | grep -A5 $mem_type | grep shrink_anon | awk '{print $3}') local sum_freed=$(($shrink_file_freed + $shrink_anon_freed)) if [ $sum_freed -eq $total_process_freed ]; then @@ -98,6 +99,7 @@ do_clean() kill -9 $pid echo $reclaim_acct_disable_def > $reclaim_acct_disable echo $avail_buffers_def $min_avail_buffers_def $high_avail_buffers_def $free_swap_threshold_def > $avail_buffers + rm -rf log.txt } do_setup -- Gitee From 969a2f98e27c8e9d637a1f751d5961b64f2202bf Mon Sep 17 00:00:00 2001 From: duxbbo Date: Fri, 15 Jul 2022 11:49:11 +0000 Subject: [PATCH 07/12] support newip Signed-off-by: duxbbo Change-Id: I6b38f5c6047a8fff42931cd957fe5c031ac34529 --- kernel.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel.mk b/kernel.mk index 31ffd7f..04ebff0 100644 --- a/kernel.mk +++ b/kernel.mk @@ -67,6 +67,7 @@ PRODUCT_PATCH_FILE := $(OHOS_BUILD_HOME)/vendor/hisilicon/watchos/patches/$(DEVI SMALL_PATCH_FILE := $(DEVICE_PATCH_DIR)/$(DEVICE_NAME)_$(BUILD_TYPE).patch KERNEL_IMAGE_FILE := $(KERNEL_SRC_TMP_PATH)/arch/$(KERNEL_ARCH)/boot/$(KERNEL_IMAGE) DEFCONFIG_FILE := $(DEVICE_NAME)_$(BUILD_TYPE)_defconfig +NEWIP_PATCH_FILE := $(OHOS_BUILD_HOME)/foundation/communication/sfc/newip/apply_newip.sh export KBUILD_OUTPUT=$(KERNEL_OBJ_TMP_PATH) @@ -90,6 +91,10 @@ endif ifneq ($(findstring $(BUILD_TYPE), small),) $(hide) cd $(KERNEL_SRC_TMP_PATH) && patch -p1 < $(SMALL_PATCH_FILE) endif + +ifeq ($(NEWIP_PATCH_FILE), $(wildcard $(NEWIP_PATCH_FILE))) + $(hide) $(NEWIP_PATCH_FILE) $(OHOS_BUILD_HOME) $(KERNEL_SRC_TMP_PATH) $(DEVICE_NAME) ${KERNEL_VERSION} +endif $(hide) cp -rf $(KERNEL_CONFIG_PATH)/. $(KERNEL_SRC_TMP_PATH)/ $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) distclean $(hide) $(KERNEL_MAKE) -C $(KERNEL_SRC_TMP_PATH) ARCH=$(KERNEL_ARCH) $(KERNEL_CROSS_COMPILE) $(DEFCONFIG_FILE) -- Gitee From 8dc6bf63f91bb406db20e736d31ad3fd194b2497 Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Mon, 18 Jul 2022 10:10:49 +0800 Subject: [PATCH 08/12] fix code duplication and memory&&sched include file Signed-off-by: @wu_fan520 --- .../accessftokenidgrptest_fuzzer/BUILD.gn | 2 +- .../accessftokenidgrptest_fuzzer.cpp | 2 +- .../BUILD.gn | 2 +- .../accessftokenidgrptestother_fuzzer.cpp | 2 +- .../accessftokenidthreadtest_fuzzer/BUILD.gn | 2 +- .../accessftokenidthreadtest_fuzzer.cpp | 2 +- .../getftokenidcmdcorrect_fuzzer/BUILD.gn | 2 +- .../getftokenidcmdcorrect_fuzzer.cpp | 10 +- .../getftokenidcmderror_fuzzer/BUILD.gn | 2 +- .../getftokenidcmderror_fuzzer.cpp | 13 +- .../getftokenidnullptr_fuzzer/BUILD.gn | 2 +- .../getftokenidnullptr_fuzzer.cpp | 2 +- .../gettokenidcmdcorrect_fuzzer.cpp | 8 +- .../gettokenidcmdcorrect_fuzzer.h | 21 -- .../gettokenidcmderror_fuzzer.cpp | 8 +- .../include/accessftokenidcommon.h | 71 ------- .../include/accesstokenidcommon.h | 22 ++ .../setftokenidcmdcorrect_fuzzer/BUILD.gn | 2 +- .../setftokenidcmdcorrect_fuzzer.cpp | 10 +- .../setftokenidcmdcorrect_fuzzer.h | 21 -- .../setftokenidcmderror_fuzzer/BUILD.gn | 2 +- .../setftokenidcmderror_fuzzer.cpp | 10 +- .../setftokenidcmderror_fuzzer.h | 21 -- .../setftokenidnullptr_fuzzer/BUILD.gn | 2 +- .../setftokenidnullptr_fuzzer.cpp | 5 +- .../settokenidcmdcorrect_fuzzer.cpp | 8 +- .../settokenidcmdcorrect_fuzzer.h | 21 -- .../settokenidcmderror_fuzzer.cpp | 11 +- .../src/accessftokenidcommon.cpp | 192 ------------------ .../accesstokenid/src/accesstokenidcommon.cpp | 142 +++++++++++++ .../fuzztest/hc_node/hcenable_fuzzer/BUILD.gn | 7 +- .../hcenable_fuzzer/hcenable_fuzzer.cpp | 32 +-- .../hchotdatalowerlimit_fuzzer/BUILD.gn | 7 +- .../hchotdatalowerlimit_fuzzer.cpp | 32 +-- .../hchotdatawaterline_fuzzer/BUILD.gn | 7 +- .../hchotdatawaterline_fuzzer.cpp | 32 +-- .../hchotnodelowerlimit_fuzzer/BUILD.gn | 7 +- .../hchotnodelowerlimit_fuzzer.cpp | 32 +-- .../hchotnodewaterline_fuzzer/BUILD.gn | 7 +- .../hchotnodewaterline_fuzzer.cpp | 32 +-- .../hcwarmdatalowerlimit_fuzzer/BUILD.gn | 7 +- .../hcwarmdatalowerlimit_fuzzer.cpp | 32 +-- .../hcwarmdatawaterline_fuzzer/BUILD.gn | 7 +- .../hcwarmdatawaterline_fuzzer.cpp | 32 +-- .../hcwarmnodelowerlimit_fuzzer/BUILD.gn | 7 +- .../hcwarmnodelowerlimit_fuzzer.cpp | 32 +-- .../hcwarmnodewaterline_fuzzer/BUILD.gn | 7 +- .../hcwarmnodewaterline_fuzzer.cpp | 39 +--- .../include/hccommon.h} | 10 +- .../src/hccommon.cpp} | 43 +++- .../BUILD.gn | 7 +- .../anonrefaultsnapshotmininterval_fuzzer.cpp | 31 +-- test/fuzztest/memory/appscore_fuzzer/BUILD.gn | 7 +- .../appscore_fuzzer/appscore_fuzzer.cpp | 31 +-- .../areaanonrefaultthreshold_fuzzer/BUILD.gn | 7 +- .../areaanonrefaultthreshold_fuzzer.cpp | 31 +-- .../memory/availbuffers_fuzzer/BUILD.gn | 7 +- .../availbuffers_fuzzer.cpp | 31 +-- .../memory/bufferratioparams_fuzzer/BUILD.gn | 7 +- .../bufferratioparams_fuzzer.cpp | 31 +-- .../memory/compressratio_fuzzer/BUILD.gn | 7 +- .../compressratio_fuzzer.cpp | 31 +-- .../emptyroundcheckthreshold_fuzzer/BUILD.gn | 7 +- .../emptyroundcheckthreshold_fuzzer.cpp | 31 +-- .../emptyroundskipinterval_fuzzer/BUILD.gn | 7 +- .../emptyroundskipinterval_fuzzer.cpp | 31 +-- .../memory/forceshrinkanon_fuzzer/BUILD.gn | 7 +- .../forceshrinkanon_fuzzer.cpp | 7 +- .../include/memorycommon.h} | 10 +- .../memory/maxskipinterval_fuzzer/BUILD.gn | 7 +- .../maxskipinterval_fuzzer.cpp | 31 +-- test/fuzztest/memory/name_fuzzer/BUILD.gn | 7 +- .../memory/name_fuzzer/name_fuzzer.cpp | 31 +-- .../src/memorycommon.cpp} | 35 +++- .../memory/ubufs2zramratio_fuzzer/BUILD.gn | 7 +- .../ubufs2zramratio_fuzzer.cpp | 31 +-- .../zramcriticalthreshold_fuzzer/BUILD.gn | 7 +- .../zramcriticalthreshold_fuzzer.cpp | 31 +-- .../memory/zramwmratio_fuzzer/BUILD.gn | 7 +- .../zramwmratio_fuzzer/zramwmratio_fuzzer.cpp | 31 +-- .../zswapdmaxreclaimsize_fuzzer/BUILD.gn | 7 +- .../zswapdmaxreclaimsize_fuzzer.cpp | 31 +-- .../memory/zswapdmemcgsparam_fuzzer/BUILD.gn | 7 +- .../zswapdmemcgsparam_fuzzer.cpp | 31 +-- .../memory/zswapdpressureshow_fuzzer/BUILD.gn | 7 +- .../zswapdpressureshow_fuzzer.cpp | 31 +-- .../zswapdsinglememcgparam_fuzzer/BUILD.gn | 7 +- .../zswapdsinglememcgparam_fuzzer.cpp | 31 +-- .../addthreadtortg_fuzzer.cpp | 3 + .../beginframefreq_fuzzer.cpp | 3 + .../endframefreq_fuzzer.cpp | 3 + .../sched/endscene_fuzzer/endscene_fuzzer.cpp | 3 + .../searchrtgfortid_fuzzer.cpp | 3 + .../setmargin_fuzzer/setmargin_fuzzer.cpp | 3 + 94 files changed, 579 insertions(+), 1175 deletions(-) delete mode 100644 test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h delete mode 100644 test/fuzztest/accesstokenid/include/accessftokenidcommon.h delete mode 100644 test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h delete mode 100644 test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h delete mode 100644 test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h delete mode 100644 test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp rename test/fuzztest/{accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h => hc_node/include/hccommon.h} (74%) rename test/fuzztest/{accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h => hc_node/src/hccommon.cpp} (38%) rename test/fuzztest/{accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h => memory/include/memorycommon.h} (74%) rename test/fuzztest/{accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h => memory/src/memorycommon.cpp} (51%) diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn index 25f6b34..6ed9dc3 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/BUILD.gn @@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidGrpTestFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "accessftokenidgrptest_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp index aa78808..2dc2296 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp @@ -17,7 +17,7 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn index d902d27..6e4cbfc 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/BUILD.gn @@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidGrpTestOtherFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "accessftokenidgrptestother_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp index 5f5c841..6a58dfe 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp @@ -17,7 +17,7 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn index 3bdbd2b..b842dac 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/BUILD.gn @@ -31,7 +31,7 @@ ohos_fuzztest("AccessfTokenidThreadTestFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "accessftokenidthreadtest_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp index 9e8fbd6..ad8101a 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp @@ -17,7 +17,7 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn index dd833e2..da9537e 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdCorrectFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "getftokenidcmdcorrect_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp index 0425ea0..f59e1c7 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.cpp @@ -17,20 +17,14 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetfTokenid(&tokenId); - } + bool ret = GetfTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn index 66b1aab..1464b6f 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidCmdErrorFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "getftokenidcmderror_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp index 0ffb6a9..e5c2ef7 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.cpp @@ -14,21 +14,18 @@ */ #include +#include +#include +#include "__config" #define CMDERROR -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool GetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetfTokenid(&tokenId); - } + bool ret = GetfTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn index a7aa727..8b092e6 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("GetfTokenidNullptrFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "getftokenidnullptr_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp index 8dbfbf3..0882bb7 100644 --- a/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/getftokenidnullptr_fuzzer/getftokenidnullptr_fuzzer.cpp @@ -19,7 +19,7 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp index 4f2e592..310c2a9 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.cpp @@ -26,13 +26,7 @@ using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool GetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetTokenid(&tokenId); - } + bool ret = GetTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h deleted file mode 100644 index 2ac8751..0000000 --- a/test/fuzztest/accesstokenid/gettokenidcmdcorrect_fuzzer/gettokenidcmdcorrect_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "gettokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_GETTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp index e594226..28255d6 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.cpp @@ -25,13 +25,7 @@ using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool GetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = GetTokenid(&tokenId); - } + bool ret = GetTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h b/test/fuzztest/accesstokenid/include/accessftokenidcommon.h deleted file mode 100644 index 0067162..0000000 --- a/test/fuzztest/accesstokenid/include/accessftokenidcommon.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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. - */ - -#ifndef ACCESSFTOKENIDCOMMON_H -#define ACCESSFTOKENIDCOMMON_H -#include - -#define FUZZ_PROJECT_NAME "accessftokenidcommon" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' - -#ifdef CMDERROR -constexpr unsigned int get_ftoken_id = 0; -constexpr unsigned int set_ftoken_id = 0; -#else -constexpr unsigned int get_ftoken_id = 3; -constexpr unsigned int set_ftoken_id = 4; -#endif - -#define ACCESS_TOKENID_GET_FTOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_ftoken_id, unsigned long long) -#define ACCESS_TOKENID_SET_FTOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_ftoken_id, unsigned long long) - -#define LIST_NUM_1 1 -#define LIST_NUM_2 2 -#define TEST_VALUE 123 -#define CHILDREN_NUM 3 -#define WAIT_FOR_SHELL_OP_TIME 1 -#define FATHER_WAIT_TIME (WAIT_FOR_SHELL_OP_TIME * (CHILDREN_NUM + 1)) - -#define ACCESS_TOKEN_UID 3020 -#define ACCESS_TOKEN_GRPID 3020 - -#define ACCESS_TOKEN_OTHER_UID 1234 -#define ACCESS_TOKEN_OTHER_GRPID 1234 - -#define INVAL_TOKEN 0xffffffffffffffff - -int GetfTokenid(unsigned long long *ftoken); -int SetfTokenid(unsigned long long *ftoken); - -void SetUidAndGrp(); -void SetUidAndGrpOther(); -void GetCurfToken(unsigned long long *ftoken); -void SetRandfTokenAndCheck(unsigned long long *data_ftoken); -void fTokenTest(unsigned long long *data_ftoken); -void ThreadTest(unsigned long long *data_ftoken); -int AccessfTokenidThreadTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken); -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS - -#endif // ACCESSTOKENIDCOMMON_H diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index 298412b..856b61f 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -27,15 +27,23 @@ namespace AccessToken { #ifdef CMDERROR constexpr unsigned int get_token_id = 0; constexpr unsigned int set_token_id = 0; +constexpr unsigned int get_ftoken_id = 0; +constexpr unsigned int set_ftoken_id = 0; #else constexpr unsigned int get_token_id = 1; constexpr unsigned int set_token_id = 2; +constexpr unsigned int get_ftoken_id = 3; +constexpr unsigned int set_ftoken_id = 4; #endif #define ACCESS_TOKENID_GET_TOKENID \ _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_token_id, unsigned long long) #define ACCESS_TOKENID_SET_TOKENID \ _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_token_id, unsigned long long) +#define ACCESS_TOKENID_GET_FTOKENID \ + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_ftoken_id, unsigned long long) +#define ACCESS_TOKENID_SET_FTOKENID \ + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_ftoken_id, unsigned long long) #define LIST_NUM_1 1 #define LIST_NUM_2 2 @@ -54,6 +62,8 @@ constexpr unsigned int set_token_id = 2; int GetTokenid(unsigned long long *token); int SetTokenid(unsigned long long *token); +int GetfTokenid(unsigned long long *ftoken); +int SetfTokenid(unsigned long long *ftoken); void SetUidAndGrp(); void SetUidAndGrpOther(); @@ -64,6 +74,18 @@ void ThreadTest(unsigned long long *data_token); int AccessTokenidThreadTest(uint8_t *data_token); int AccessTokenidGrpTest(uint8_t *data_token); int AccessTokenidGrpTestOther(uint8_t *data_token); + +void GetCurfToken(unsigned long long *ftoken); +void SetRandfTokenAndCheck(unsigned long long *data_ftoken); +void fTokenTest(unsigned long long *data_ftoken); +void ThreadTest(unsigned long long *data_ftoken); +int AccessfTokenidThreadTest(uint8_t *data_ftoken); +int AccessfTokenidGrpTest(uint8_t *data_ftoken); +int AccessfTokenidGrpTestOther(uint8_t *data_ftoken); +bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size); +bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size); +bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size); +bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size); } // namespace AccessToken } // namespace Kernel } // namespace OHOS diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn index bdabf6f..bf9b79c 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdCorrectFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "setftokenidcmdcorrect_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp index 595cabd..35b1d10 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.cpp @@ -17,20 +17,14 @@ #include #include #include "__config" -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool SetfTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetfTokenid(&tokenId); - } + bool ret = SetfTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h deleted file mode 100644 index 0b440c2..0000000 --- a/test/fuzztest/accesstokenid/setftokenidcmdcorrect_fuzzer/setftokenidcmdcorrect_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "setftokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_SETFTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn index 00fb0ff..3a642c1 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidCmdErrorFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "setftokenidcmderror_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp index d3b9184..7edb5fd 100644 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.cpp @@ -18,20 +18,14 @@ #include #include "__config" #define CMDERROR -#include "accessftokenidcommon.h" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool SetfTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetfTokenid(&tokenId); - } + bool ret = SetfTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h b/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h deleted file mode 100644 index 3ab67c5..0000000 --- a/test/fuzztest/accesstokenid/setftokenidcmderror_fuzzer/setftokenidcmderror_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H - -#define FUZZ_PROJECT_NAME "setftokenidcmderror_fuzzer" - -#endif // TEST_FUZZTEST_SETFTOKENIDCMDERROR_FUZZER_H diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn index 0847e82..6d4ebbc 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/BUILD.gn @@ -30,7 +30,7 @@ ohos_fuzztest("SetfTokenidNullptrFuzzTest") { ] sources = [ - "../src/accessftokenidcommon.cpp", + "../src/accesstokenidcommon.cpp", "setftokenidnullptr_fuzzer.cpp", ] } diff --git a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp index f79706f..7671315 100644 --- a/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/setftokenidnullptr_fuzzer/setftokenidnullptr_fuzzer.cpp @@ -16,7 +16,10 @@ */ #include -#include "accessftokenidcommon.h" +#include +#include +#include "__config" +#include "accesstokenidcommon.h" using namespace std; using namespace OHOS::Kernel::AccessToken; diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp index 0bd4263..212190c 100644 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.cpp @@ -26,13 +26,7 @@ using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool SetTokenidCmdCorrectFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetTokenid(&tokenId); - } + bool ret = SetTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h b/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h deleted file mode 100644 index 4cc82ca..0000000 --- a/test/fuzztest/accesstokenid/settokenidcmdcorrect_fuzzer/settokenidcmdcorrect_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ - -#ifndef TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H - -#define FUZZ_PROJECT_NAME "settokenidcmdcorrect_fuzzer" - -#endif // TEST_FUZZTEST_SETTOKENIDCMDCORRECT_FUZZER_H diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp index 37851e0..9292c1f 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #define CMDERROR #include "accesstokenidcommon.h" @@ -22,13 +25,7 @@ using namespace OHOS::Kernel::AccessToken; namespace OHOS { bool SetTokenidCmdErrorFuzzTest(const uint8_t *data, size_t size) { - bool ret = false; - if ((data == nullptr) || (size < sizeof(unsigned long long))) { - return ret; - } else { - unsigned long long tokenId = *(reinterpret_cast(data)); - ret = SetTokenid(&tokenId); - } + bool ret = SetTokenidCmdFuzzTest(data, size); return ret; } } diff --git a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp deleted file mode 100644 index 7f6b538..0000000 --- a/test/fuzztest/accesstokenid/src/accessftokenidcommon.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include "accessftokenidcommon.h" - -namespace OHOS { -namespace Kernel { -namespace AccessToken { -const char *DEVACCESSTOKENID = "/dev/access_token_id"; - -int GetfTokenid(unsigned long long *ftoken) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - - int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken); - if (ret) { - close(fd); - return -1; - } - - close(fd); - return 0; -} - -int SetfTokenid(unsigned long long *ftoken) -{ - int fd = open(DEVACCESSTOKENID, O_RDWR); - if (fd < 0) { - return -1; - } - - int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken); - if (ret) { - close(fd); - return -1; - } - - close(fd); - return 0; -} - -void SetUidAndGrp() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_2; - gid_t groupList[LIST_NUM_2] = {ACCESS_TOKEN_GRPID, TEST_VALUE}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \n", ret); - } - - return; -} - -void SetUidAndGrpOther() -{ - int ret = 0; - size_t groupListSize = LIST_NUM_1; - gid_t groupList[LIST_NUM_1] = {ACCESS_TOKEN_OTHER_GRPID}; - - ret = setgroups(groupListSize, groupList); - if (ret != 0) { - return; - } - - ret = setuid(ACCESS_TOKEN_OTHER_UID); - if (ret != 0) { - printf("SetUidAndGrp setuid error %d \r\n", ret); - } - - return; -} - -void SetRandfTokenAndCheck(unsigned long long *data_ftoken) -{ - pid_t pid = getpid(); - pid_t tid = syscall(__NR_gettid); - unsigned long long ftoken = INVAL_TOKEN; - unsigned long long ftokenSet = *data_ftoken; - - SetfTokenid(&ftokenSet); - GetfTokenid(&ftoken); - - if (ftoken != ftokenSet) { - printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } else { - printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } - - sleep(WAIT_FOR_SHELL_OP_TIME); - - GetfTokenid(&ftoken); - if (ftoken != ftokenSet) { - printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } else { - printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", - pid, tid, ftoken, ftokenSet); - } - return; -} - -void *fTokenTest(void *data_ftoken) -{ - SetRandfTokenAndCheck(static_cast(data_ftoken)); - return nullptr; -} - -void ThreadTest(void *data_ftoken) -{ - pthread_t id_1; - pthread_t id_2; - pthread_t id_3; - int ret = 0; - - ret = pthread_create(&id_1, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_2, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - ret = pthread_create(&id_3, nullptr, fTokenTest, data_ftoken); - if (ret != 0) { - return; - } - - pthread_join(id_1, nullptr); - pthread_join(id_2, nullptr); - pthread_join(id_3, nullptr); - - return; -} - -int AccessfTokenidThreadTest(uint8_t *data_ftoken) -{ - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} - -int AccessfTokenidGrpTest(uint8_t *data_ftoken) -{ - SetUidAndGrp(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} - -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken) -{ - SetUidAndGrpOther(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); - return 0; -} -} // namespace AccessToken -} // namespace Kernel -} // namespace OHOS diff --git a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp index 69d3471..18a28cd 100644 --- a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp @@ -184,6 +184,148 @@ int AccessTokenidGrpTestOther(uint8_t *data_token) ThreadTest(static_cast(data_token)); return 0; } + +int GetfTokenid(unsigned long long *ftoken) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + + int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken); + if (ret) { + close(fd); + return -1; + } + + close(fd); + return 0; +} + +int SetfTokenid(unsigned long long *ftoken) +{ + int fd = open(DEVACCESSTOKENID, O_RDWR); + if (fd < 0) { + return -1; + } + + int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken); + if (ret) { + close(fd); + return -1; + } + + close(fd); + return 0; +} + +void SetRandfTokenAndCheck(unsigned long long *data_ftoken) +{ + pid_t pid = getpid(); + pid_t tid = syscall(__NR_gettid); + unsigned long long ftoken = INVAL_TOKEN; + unsigned long long ftokenSet = *data_ftoken; + + SetfTokenid(&ftokenSet); + GetfTokenid(&ftoken); + + if (ftoken != ftokenSet) { + printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } else { + printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } + + sleep(WAIT_FOR_SHELL_OP_TIME); + + GetfTokenid(&ftoken); + if (ftoken != ftokenSet) { + printf("pid:%d tid:%d ftoken test failed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } else { + printf("pid:%d tid:%d ftoken test succeed, ftoken:%llu ftokenSet:%llu\n", + pid, tid, ftoken, ftokenSet); + } + return; +} + +void *fTokenTest(void *data_ftoken) +{ + SetRandfTokenAndCheck(static_cast(data_ftoken)); + return nullptr; +} + +int AccessfTokenidThreadTest(uint8_t *data_ftoken) +{ + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} + +int AccessfTokenidGrpTest(uint8_t *data_ftoken) +{ + SetUidAndGrp(); + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} + +int AccessfTokenidGrpTestOther(uint8_t *data_ftoken) +{ + SetUidAndGrpOther(); + fTokenTest(static_cast(data_ftoken)); + ThreadTest(static_cast(data_ftoken)); + return 0; +} + +bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetfTokenid(&tokenId); + } + return ret; +} + +bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetfTokenid(&tokenId); + } + return ret; +} + +bool GetTokenidCmdFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = GetTokenid(&tokenId); + } + return ret; +} + +bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size) +{ + bool ret = false; + if ((data == nullptr) || (size < sizeof(unsigned long long))) { + return ret; + } else { + unsigned long long tokenId = *(reinterpret_cast(data)); + ret = SetTokenid(&tokenId); + } + return ret; +} } // namespace AccessToken } // namespace Kernel } // namespace OHOS diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn index d2edc28..dcc34f4 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcenable_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcEnableFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hcenable_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hcenable_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hcenable_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp index 93eac67..2eb3d64 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable"; namespace OHOS { bool HcEnableFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_ENABLE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_ENABLE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_ENABLE, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn index dc889e8..9351847 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcHotDataLowerLimitFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hchotdatalowerlimit_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hchotdatalowerlimit_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp index 5918d1e..a1beab2 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit"; namespace OHOS { bool HcHotDataLowerLimitFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_DATA_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_DATA_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_HOT_DATA_LOWER_LIMIT, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn index ba64e31..aa7205f 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcHotDataWaterlineFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hchotdatawaterline_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hchotdatawaterline_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hchotdatawaterline_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp index e037e72..88cbc08 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline"; namespace OHOS { bool HcHotDataWaterlineFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_DATA_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_DATA_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_HOT_DATA_WATERLINE, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn index 2ff4a14..a7f3a19 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcHotNodeLowerLimitFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hchotnodelowerlimit_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hchotnodelowerlimit_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp index 8f5b0bf..d8cb261 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit"; namespace OHOS { bool HcHotNodeLowerLimitFuzzTest(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_NODE_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_NODE_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_HOT_NODE_LOWER_LIMIT, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn index f313858..c3df58b 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcHotNodeWaterLineFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hchotnodewaterline_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hchotnodewaterline_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hchotnodewaterline_fuzzer.cpp", + ] } group("fuzztest") { testonly = true diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp index 2910e8b..818a097 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline"; namespace OHOS { bool HcHotNodeWaterlineFuzzTest(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_HOT_NODE_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_HOT_NODE_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_HOT_NODE_WATERLINE, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn index 2a1f7fe..fa0a7a5 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmDataLowerLimitFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hcwarmdatalowerlimit_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hcwarmdatalowerlimit_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp index 849fefa..83005f9 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit"; namespace OHOS { bool HcWarmDataLowerLimitFuzzTest(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_DATA_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_DATA_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_WARM_DATA_LOWER_LIMIT, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn index 76517cb..aff7449 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmDataWaterLineFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hcwarmdatawaterline_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hcwarmdatawaterline_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp index 02eedd3..2c3203b 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline"; namespace OHOS { bool HcWarmDataWaterLineFuzzTest(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_DATA_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_DATA_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_WARM_DATA_WATERLINE, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn index 11d6cbf..23ca923 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("HcWarmNodeLowerLimitFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hcwarmnodelowerlimit_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hcwarmnodelowerlimit_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp index 075d978..a6e07f4 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp @@ -19,41 +19,15 @@ #include #include #include +#include "hccommon.h" const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit"; namespace OHOS { bool HcWarmNodeLowerLimit(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_NODE_LOWER_LIMIT, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_NODE_LOWER_LIMIT); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_WARM_NODE_LOWER_LIMIT, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn index 82873d4..ad8bf35 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("HcWarmNodeWaterLineFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "hcwarmnodewaterline_fuzzer.cpp" ] + sources = [ + "../src/hccommon.cpp", + "hcwarmnodewaterline_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp index 4c19bc2..2c34974 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp @@ -14,47 +14,20 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include +#include "hccommon.h" const char *HC_WARM_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_node_waterline"; namespace OHOS { bool HcWarmNodeLowerWaterLine(const uint8_t *data, size_t size) { - uint32_t value = 0; - uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; - int ret = access("/mnt/f2fs_mount/", F_OK); - if (ret < 0) { - system("mkdir -p /mnt/f2fs_mount/"); - system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); - system("losetup /dev/block/loop1 /data/image_f2fs"); - system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); - } - - int fd = open(HC_WARM_NODE_WATERLINE, O_RDWR); - if (fd < 0) { - return false; - } - - ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", HC_WARM_NODE_WATERLINE); - close(fd); - return false; - } - - ret = write(fd, data, length); - if (ret < 0) { - close(fd); - return false; - } - close(fd); - return true; + bool ret = HcFuzzTest(data, HC_WARM_NODE_WATERLINE, size); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h b/test/fuzztest/hc_node/include/hccommon.h similarity index 74% rename from test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h rename to test/fuzztest/hc_node/include/hccommon.h index 78627a8..31f790c 100644 --- a/test/fuzztest/accesstokenid/settokenidcmderror_fuzzer/settokenidcmderror_fuzzer.h +++ b/test/fuzztest/hc_node/include/hccommon.h @@ -13,9 +13,11 @@ * limitations under the License. */ -#ifndef TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H +#ifndef HCCOMMON_H +#define HCCOMMON_H -#define FUZZ_PROJECT_NAME "settokenidcmderror_fuzzer" +namespace OHOS { +bool HcFuzzTest(const uint8_t *data, const char *pathname, size_t size); +} -#endif // TEST_FUZZTEST_SETTOKENIDCMDERROR_FUZZER_H +#endif \ No newline at end of file diff --git a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h b/test/fuzztest/hc_node/src/hccommon.cpp similarity index 38% rename from test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h rename to test/fuzztest/hc_node/src/hccommon.cpp index 60a4804..07e4575 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmderror_fuzzer/getftokenidcmderror_fuzzer.h +++ b/test/fuzztest/hc_node/src/hccommon.cpp @@ -13,9 +13,44 @@ * limitations under the License. */ -#ifndef TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H +#include +#include +#include +#include +#include +#include +#include "hccommon.h" -#define FUZZ_PROJECT_NAME "getftokenidcmderror_fuzzer" +namespace OHOS { +bool HcFuzzTest(const uint8_t *data, const char *pathname, size_t size) +{ + uint32_t value = 0; + uint32_t length = size > sizeof(uint32_t) ? sizeof(uint32_t) : size; + int ret = access("/mnt/f2fs_mount/", F_OK); + if (ret < 0) { + system("mkdir -p /mnt/f2fs_mount/"); + system("mkfs.f2fs -d1 -t1 -O quota /data/image_f2fs"); + system("losetup /dev/block/loop1 /data/image_f2fs"); + system("mount -t f2fs /dev/block/loop1 /mnt/f2fs_mount/"); + } -#endif // TEST_FUZZTEST_GETFTOKENIDCMDERROR_FUZZER_H + int fd = open(pathname, O_RDWR); + if (fd < 0) { + return false; + } + + ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + close(fd); + return false; + } + + ret = write(fd, data, length); + if (ret < 0) { + close(fd); + return false; + } + close(fd); + return true; +} +} \ No newline at end of file diff --git a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/BUILD.gn b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/BUILD.gn index 1728b29..b27b7f6 100644 --- a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("AnonRefaultSnapshotMinIntervalFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "anonrefaultsnapshotmininterval_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "anonrefaultsnapshotmininterval_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp index 3d35b90..d43d1d0 100644 --- a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp +++ b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ANON_REFAULT_SNAPSHOT_MIN_INTERVAL = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; namespace OHOS { bool AnonRefaultSnapshotMinIntervalFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ANON_REFAULT_SNAPSHOT_MIN_INTERVAL, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ANON_REFAULT_SNAPSHOT_MIN_INTERVAL); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ANON_REFAULT_SNAPSHOT_MIN_INTERVAL); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/appscore_fuzzer/BUILD.gn b/test/fuzztest/memory/appscore_fuzzer/BUILD.gn index 33b823b..4cb2e35 100644 --- a/test/fuzztest/memory/appscore_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/appscore_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("AppScoreFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/appscore_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "appscore_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "appscore_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp index 1896d1b..410b9a3 100644 --- a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp +++ b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *APP_SCORE = "/dev/memcg/memory.app_score"; namespace OHOS { bool AppScoreFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(APP_SCORE, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", APP_SCORE); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, APP_SCORE); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/BUILD.gn b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/BUILD.gn index c7fc1a3..6c16381 100644 --- a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("AreaAnonRefaultThresholdFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "areaanonrefaultthreshold_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "areaanonrefaultthreshold_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp index fbe1e3c..f6ef410 100644 --- a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *AREA_ANON_REFAULT_THRESHOLD = "/dev/memcg/memory.area_anon_refault_threshold"; namespace OHOS { bool AreaAnonRefaultThresholdFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(AREA_ANON_REFAULT_THRESHOLD, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", AREA_ANON_REFAULT_THRESHOLD); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, AREA_ANON_REFAULT_THRESHOLD); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/availbuffers_fuzzer/BUILD.gn b/test/fuzztest/memory/availbuffers_fuzzer/BUILD.gn index 23dc1c7..9d3e783 100644 --- a/test/fuzztest/memory/availbuffers_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/availbuffers_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("AvailBuffersFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/availbuffers_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "availbuffers_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "availbuffers_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp index 54ceadd..b706790 100644 --- a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp +++ b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *AVAIL_BUFFERS = "/dev/memcg/memory.avail_buffers"; namespace OHOS { bool AvailBuffersFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(AVAIL_BUFFERS, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", AVAIL_BUFFERS); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, AVAIL_BUFFERS); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/bufferratioparams_fuzzer/BUILD.gn b/test/fuzztest/memory/bufferratioparams_fuzzer/BUILD.gn index 323a77e..81f37a9 100644 --- a/test/fuzztest/memory/bufferratioparams_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/bufferratioparams_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("BufferRatioParamsFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/bufferratioparams_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "bufferratioparams_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "bufferratioparams_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp index e05a1b6..71f0376 100644 --- a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp +++ b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *BUFFER_RATIO_PARAMS = "/dev/memcg/memory.buffer_ratio_params"; namespace OHOS { bool BufferRatioParamsFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(BUFFER_RATIO_PARAMS, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", BUFFER_RATIO_PARAMS); - close(fd); - return false; - } - - ret = write(fd, data, sizeof(uint8_t)); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, BUFFER_RATIO_PARAMS); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/compressratio_fuzzer/BUILD.gn b/test/fuzztest/memory/compressratio_fuzzer/BUILD.gn index 019dd38..a040fa1 100644 --- a/test/fuzztest/memory/compressratio_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/compressratio_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("CompressRatioFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/compressratio_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "compressratio_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "compressratio_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp index 44a5437..52ed22d 100644 --- a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp +++ b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *COMPRESS_RATIO = "/dev/memcg/memory.compress_ratio"; namespace OHOS { bool CompressRatioFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(COMPRESS_RATIO, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", COMPRESS_RATIO); - close(fd); - return false; - } - - ret = write(fd, data, sizeof(uint8_t)); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, COMPRESS_RATIO); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/BUILD.gn b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/BUILD.gn index 7afade9..96661e8 100644 --- a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("EmptyRoundCheckThresholdFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "emptyroundcheckthreshold_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "emptyroundcheckthreshold_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp index a57895a..e1c86c5 100644 --- a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *EMPTY_ROUND_CHECK_THRESHOLD = "/dev/memcg/memory.empty_round_check_threshold"; namespace OHOS { bool EmptyRoundCheckThresholdFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(EMPTY_ROUND_CHECK_THRESHOLD, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", EMPTY_ROUND_CHECK_THRESHOLD); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, EMPTY_ROUND_CHECK_THRESHOLD); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/BUILD.gn b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/BUILD.gn index 4d456e8..6c5b642 100644 --- a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("EmptyRoundSkipIntervalFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/emptyroundskipinterval_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "emptyroundskipinterval_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "emptyroundskipinterval_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp index 787aa5f..6187492 100644 --- a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *EMPTY_ROUND_SKIP_INTERVAL = "/dev/memcg/memory.empty_round_skip_interval"; namespace OHOS { bool EmptyRoundSkipIntervalFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(EMPTY_ROUND_SKIP_INTERVAL, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", EMPTY_ROUND_SKIP_INTERVAL); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, EMPTY_ROUND_SKIP_INTERVAL); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/forceshrinkanon_fuzzer/BUILD.gn b/test/fuzztest/memory/forceshrinkanon_fuzzer/BUILD.gn index 08e9c7a..83ca3a9 100644 --- a/test/fuzztest/memory/forceshrinkanon_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/forceshrinkanon_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ForceShrinkAnonFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/forceshrinkanon_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "forceshrinkanon_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "forceshrinkanon_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp index 6725fe7..f0b4fb5 100644 --- a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp +++ b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp @@ -14,12 +14,11 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *FORCE_SHRINK_ANON = "/dev/memcg/memory.force_shrink_anon"; diff --git a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h b/test/fuzztest/memory/include/memorycommon.h similarity index 74% rename from test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h rename to test/fuzztest/memory/include/memorycommon.h index 0545956..7e90286 100644 --- a/test/fuzztest/accesstokenid/gettokenidcmderror_fuzzer/gettokenidcmderror_fuzzer.h +++ b/test/fuzztest/memory/include/memorycommon.h @@ -13,9 +13,11 @@ * limitations under the License. */ -#ifndef TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H -#define TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H +#ifndef MEMORYCOMMON_H +#define MEMORYCOMMON_H -#define FUZZ_PROJECT_NAME "gettokenidcmderror_fuzzer" +namespace OHOS { +bool MemoryFuzzTest(const uint8_t *data, size_t size, const char *pathname); +} -#endif // TEST_FUZZTEST_GETTOKENIDCMDERROR_FUZZER_H +#endif \ No newline at end of file diff --git a/test/fuzztest/memory/maxskipinterval_fuzzer/BUILD.gn b/test/fuzztest/memory/maxskipinterval_fuzzer/BUILD.gn index f5273cd..dd186d5 100644 --- a/test/fuzztest/memory/maxskipinterval_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/maxskipinterval_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("MaxSkipIntervalFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/maxskipinterval_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "maxskipinterval_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "maxskipinterval_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp index f87096b..5fa9646 100644 --- a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *MAX_SKIP_INTERVAL = "/dev/memcg/memory.max_skip_interval"; namespace OHOS { bool MaxSkipIntervalFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(MAX_SKIP_INTERVAL, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", MAX_SKIP_INTERVAL); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, MAX_SKIP_INTERVAL); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/name_fuzzer/BUILD.gn b/test/fuzztest/memory/name_fuzzer/BUILD.gn index b49cc4e..f73cf5c 100644 --- a/test/fuzztest/memory/name_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/name_fuzzer/BUILD.gn @@ -20,13 +20,18 @@ ohos_fuzztest("NameFuzzTest") { module_out_path = module_output_path fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/name_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "name_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "name_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp index d8fe0e5..5da7d00 100644 --- a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp +++ b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *NAME = "/dev/memcg/memory.name"; namespace OHOS { bool NameFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(NAME, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", NAME); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, NAME); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h b/test/fuzztest/memory/src/memorycommon.cpp similarity index 51% rename from test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h rename to test/fuzztest/memory/src/memorycommon.cpp index 314fb9d..491f9b0 100644 --- a/test/fuzztest/accesstokenid/getftokenidcmdcorrect_fuzzer/getftokenidcmdcorrect_fuzzer.h +++ b/test/fuzztest/memory/src/memorycommon.cpp @@ -13,9 +13,36 @@ * limitations under the License. */ -#ifndef TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H -#define TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H +#include +#include +#include +#include +#include +#include "memorycommon.h" -#define FUZZ_PROJECT_NAME "getftokenidcmdcorrect_fuzzer" +namespace OHOS { +bool MemoryFuzzTest(const uint8_t *data, size_t size, const char *pathname) +{ + uint32_t value = 0; -#endif // TEST_FUZZTEST_GETFTOKENIDCMDCORRECT_FUZZER_H + int fd = open(pathname, O_RDWR); + if (fd < 0) { + return false; + } + + int ret = read(fd, &value, sizeof(value)); + if (ret < 0) { + close(fd); + return false; + } + + ret = write(fd, data, size); + if (ret < 0) { + close(fd); + return false; + } + + close(fd); + return true; +} +} \ No newline at end of file diff --git a/test/fuzztest/memory/ubufs2zramratio_fuzzer/BUILD.gn b/test/fuzztest/memory/ubufs2zramratio_fuzzer/BUILD.gn index 88cd1ae..dcd7589 100644 --- a/test/fuzztest/memory/ubufs2zramratio_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/ubufs2zramratio_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("UbUfs2zramRatioFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/ubufs2zramratio_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "ubufs2zramratio_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "ubufs2zramratio_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp index a8ab055..3526479 100644 --- a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp +++ b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *UB_UFS2ZRAM_RATIO = "/dev/memcg/memory.ub_ufs2zram_ratio"; namespace OHOS { bool UbUfs2zramRatioFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(UB_UFS2ZRAM_RATIO, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", UB_UFS2ZRAM_RATIO); - close(fd); - return false; - } - - ret = write(fd, data, sizeof(uint8_t)); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, UB_UFS2ZRAM_RATIO); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/BUILD.gn b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/BUILD.gn index 6c3c462..f41f4bd 100644 --- a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZramCriticalThresholdFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zramcriticalthreshold_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zramcriticalthreshold_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zramcriticalthreshold_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp index 5fc1675..73da10f 100644 --- a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZRAM_CRITICAL_THRESHOLD = "/dev/memcg/memory.zram_critical_threshold"; namespace OHOS { bool ZramCriticalThresholdFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZRAM_CRITICAL_THRESHOLD, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZRAM_CRITICAL_THRESHOLD); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZRAM_CRITICAL_THRESHOLD); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramwmratio_fuzzer/BUILD.gn b/test/fuzztest/memory/zramwmratio_fuzzer/BUILD.gn index 981da10..57d902f 100644 --- a/test/fuzztest/memory/zramwmratio_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zramwmratio_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZramWmRatioFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zramwmratio_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zramwmratio_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zramwmratio_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp index 3560005..07125d5 100644 --- a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp +++ b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZRAM_WR_RATIO = "/dev/memcg/memory.zram_wm_ratio"; namespace OHOS { bool ZramWmRatioFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZRAM_WR_RATIO, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZRAM_WR_RATIO); - close(fd); - return false; - } - - ret = write(fd, data, sizeof(uint8_t)); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZRAM_WR_RATIO); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/BUILD.gn b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/BUILD.gn index 93a7875..3b24272 100644 --- a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdMaxReclaimSizeFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zswapdmaxreclaimsize_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zswapdmaxreclaimsize_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp index 6697c5c..59b15e4 100644 --- a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZSWAPD_MAX_RECLAIM_SIZE = "/dev/memcg/memory.zswapd_max_reclaim_size"; namespace OHOS { bool ZswapdMaxReclaimSizeFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZSWAPD_MAX_RECLAIM_SIZE, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZSWAPD_MAX_RECLAIM_SIZE); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZSWAPD_MAX_RECLAIM_SIZE); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/BUILD.gn b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/BUILD.gn index 64fd1c4..4416b1a 100644 --- a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdMemcgsparamFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zswapdmemcgsparam_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zswapdmemcgsparam_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zswapdmemcgsparam_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp index 7b35774..4071fa6 100644 --- a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZSWAPD_MEMCGS_PARAM = "/dev/memcg/memory.zswapd_memcgs_param"; namespace OHOS { bool ZswapdMemcgsParamFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZSWAPD_MEMCGS_PARAM, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZSWAPD_MEMCGS_PARAM); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZSWAPD_MEMCGS_PARAM); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdpressureshow_fuzzer/BUILD.gn b/test/fuzztest/memory/zswapdpressureshow_fuzzer/BUILD.gn index c12a1bb..6628521 100644 --- a/test/fuzztest/memory/zswapdpressureshow_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zswapdpressureshow_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdPressureShowFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zswapdpressureshow_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zswapdpressureshow_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zswapdpressureshow_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp index 8dfcd24..67a5af9 100644 --- a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZSWAPD_PRESSURE_SHOW = "/dev/memcg/memory.zswapd_pressure_show"; namespace OHOS { bool ZswapdPressureShowFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZSWAPD_PRESSURE_SHOW, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZSWAPD_PRESSURE_SHOW); - close(fd); - return false; - } - - ret = write(fd, data, sizeof(uint8_t)); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZSWAPD_PRESSURE_SHOW); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/BUILD.gn b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/BUILD.gn index 6a8459e..9dd6656 100644 --- a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/BUILD.gn +++ b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/BUILD.gn @@ -21,13 +21,18 @@ ohos_fuzztest("ZswapdSingleMemcgParamFuzzTest") { fuzz_config_file = "//kernel/linux/build/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer" + include_dirs = [ "../include" ] + cflags = [ "-g", "-O0", "-Wno-unused-variable", "-fno-omit-frame-pointer", ] - sources = [ "zswapdsinglememcgparam_fuzzer.cpp" ] + sources = [ + "../src/memorycommon.cpp", + "zswapdsinglememcgparam_fuzzer.cpp", + ] } group("fuzztest") { diff --git a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp index 8e7c735..4646540 100644 --- a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp @@ -14,40 +14,19 @@ */ #include -#include -#include -#include -#include #include #include +#include +#include +#include "memorycommon.h" const char *ZSWAPD_SINGLE_MEMCG_PARAM = "/dev/memcg/memory.zswapd_single_memcg_param"; namespace OHOS { bool ZswapdSingleMemcgParamFuzzer(const uint8_t *data, size_t size) { - uint32_t value = 0; - - int fd = open(ZSWAPD_SINGLE_MEMCG_PARAM, O_RDWR); - if (fd < 0) { - return false; - } - - int ret = read(fd, &value, sizeof(value)); - if (ret < 0) { - printf("%s read fail\n", ZSWAPD_SINGLE_MEMCG_PARAM); - close(fd); - return false; - } - - ret = write(fd, data, size); - if (ret < 0) { - close(fd); - return false; - } - - close(fd); - return true; + bool ret = MemoryFuzzTest(data, size, ZSWAPD_SINGLE_MEMCG_PARAM); + return ret; } } // namespace OHOS diff --git a/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp b/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp index 221d1d9..edefad3 100644 --- a/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp +++ b/test/fuzztest/sched/addthreadtortg_fuzzer/addthreadtortg_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp index 0c617e5..023a325 100644 --- a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp +++ b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; diff --git a/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp b/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp index 70fcd22..d7cd044 100644 --- a/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp +++ b/test/fuzztest/sched/endframefreq_fuzzer/endframefreq_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; diff --git a/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp b/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp index bda65ae..cb309a5 100644 --- a/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp +++ b/test/fuzztest/sched/endscene_fuzzer/endscene_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; diff --git a/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp b/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp index d5bba73..8d77343 100644 --- a/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp +++ b/test/fuzztest/sched/searchrtgfortid_fuzzer/searchrtgfortid_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; diff --git a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp index 92209c9..4b92d3f 100644 --- a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp +++ b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp @@ -14,6 +14,9 @@ */ #include +#include +#include +#include "__config" #include "rtg_interface.h" using namespace std; -- Gitee From 2416a5febdfc6348492af623cec9543e1df81bbf Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Wed, 20 Jul 2022 09:48:06 +0800 Subject: [PATCH 09/12] fix new include file by IWYU Signed-off-by: @wu_fan520 --- test/fuzztest/accesstokenid/include/accesstokenidcommon.h | 1 + test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp | 4 ---- .../hchotdatalowerlimit_fuzzer.cpp | 4 ---- .../hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp | 4 ---- .../hchotnodelowerlimit_fuzzer.cpp | 4 ---- .../hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp | 4 ---- .../hcwarmdatalowerlimit_fuzzer.cpp | 4 ---- .../hcwarmdatawaterline_fuzzer.cpp | 4 ---- .../hcwarmnodelowerlimit_fuzzer.cpp | 4 ---- .../hcwarmnodewaterline_fuzzer.cpp | 4 ---- test/fuzztest/hc_node/src/hccommon.cpp | 1 - .../anonrefaultsnapshotmininterval_fuzzer.cpp | 3 --- test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp | 3 --- .../areaanonrefaultthreshold_fuzzer.cpp | 3 --- .../memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp | 3 --- .../bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp | 3 --- .../memory/compressratio_fuzzer/compressratio_fuzzer.cpp | 3 --- .../emptyroundcheckthreshold_fuzzer.cpp | 3 --- .../emptyroundskipinterval_fuzzer.cpp | 3 --- .../forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp | 6 +++--- .../maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp | 3 --- test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp | 3 --- test/fuzztest/memory/src/memorycommon.cpp | 1 - .../ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp | 3 --- .../zramcriticalthreshold_fuzzer.cpp | 3 --- .../memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp | 3 --- .../zswapdmaxreclaimsize_fuzzer.cpp | 3 --- .../zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp | 3 --- .../zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp | 3 --- .../zswapdsinglememcgparam_fuzzer.cpp | 3 --- 30 files changed, 4 insertions(+), 92 deletions(-) diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index 856b61f..ba3bde7 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -15,6 +15,7 @@ #ifndef ACCESSTOKENIDCOMMON_H #define ACCESSTOKENIDCOMMON_H +#include #include #define FUZZ_PROJECT_NAME "accesstokenidcommon" diff --git a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp index 2eb3d64..c1bb408 100644 --- a/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcenable_fuzzer/hcenable_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_ENABLE = "/sys/fs/f2fs/loop1/hc_enable"; diff --git a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp index a1beab2..12960c3 100644 --- a/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatalowerlimit_fuzzer/hchotdatalowerlimit_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_HOT_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_data_lower_limit"; diff --git a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp index 88cbc08..6630f76 100644 --- a/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotdatawaterline_fuzzer/hchotdatawaterline_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_HOT_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_data_waterline"; diff --git a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp index d8cb261..9e38b73 100644 --- a/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodelowerlimit_fuzzer/hchotnodelowerlimit_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_HOT_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_hot_node_lower_limit"; diff --git a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp index 818a097..b009933 100644 --- a/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hchotnodewaterline_fuzzer/hchotnodewaterline_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_HOT_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_hot_node_waterline"; diff --git a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp index 83005f9..0c51cf9 100644 --- a/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatalowerlimit_fuzzer/hcwarmdatalowerlimit_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_WARM_DATA_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_data_lower_limit"; diff --git a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp index 2c3203b..ff0684b 100644 --- a/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmdatawaterline_fuzzer/hcwarmdatawaterline_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_WARM_DATA_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_data_waterline"; diff --git a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp index a6e07f4..ebb10de 100644 --- a/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodelowerlimit_fuzzer/hcwarmnodelowerlimit_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_WARM_NODE_LOWER_LIMIT = "/sys/fs/f2fs/loop1/hc_warm_node_lower_limit"; diff --git a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp index 2c34974..a9603a7 100644 --- a/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp +++ b/test/fuzztest/hc_node/hcwarmnodewaterline_fuzzer/hcwarmnodewaterline_fuzzer.cpp @@ -14,11 +14,7 @@ */ #include -#include -#include #include -#include -#include #include "hccommon.h" const char *HC_WARM_NODE_WATERLINE = "/sys/fs/f2fs/loop1/hc_warm_node_waterline"; diff --git a/test/fuzztest/hc_node/src/hccommon.cpp b/test/fuzztest/hc_node/src/hccommon.cpp index 07e4575..fa866bf 100644 --- a/test/fuzztest/hc_node/src/hccommon.cpp +++ b/test/fuzztest/hc_node/src/hccommon.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "hccommon.h" diff --git a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp index d43d1d0..fe4f842 100644 --- a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp +++ b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ANON_REFAULT_SNAPSHOT_MIN_INTERVAL = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; diff --git a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp index 410b9a3..e480ac3 100644 --- a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp +++ b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *APP_SCORE = "/dev/memcg/memory.app_score"; diff --git a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp index f6ef410..8fb0d18 100644 --- a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *AREA_ANON_REFAULT_THRESHOLD = "/dev/memcg/memory.area_anon_refault_threshold"; diff --git a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp index b706790..03bc523 100644 --- a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp +++ b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *AVAIL_BUFFERS = "/dev/memcg/memory.avail_buffers"; diff --git a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp index 71f0376..daca18e 100644 --- a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp +++ b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *BUFFER_RATIO_PARAMS = "/dev/memcg/memory.buffer_ratio_params"; diff --git a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp index 52ed22d..5f629c7 100644 --- a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp +++ b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *COMPRESS_RATIO = "/dev/memcg/memory.compress_ratio"; diff --git a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp index e1c86c5..7f58665 100644 --- a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *EMPTY_ROUND_CHECK_THRESHOLD = "/dev/memcg/memory.empty_round_check_threshold"; diff --git a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp index 6187492..4cc1b48 100644 --- a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *EMPTY_ROUND_SKIP_INTERVAL = "/dev/memcg/memory.empty_round_skip_interval"; diff --git a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp index f0b4fb5..d5c532c 100644 --- a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp +++ b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp @@ -13,11 +13,11 @@ * limitations under the License. */ +#include #include -#include -#include #include -#include +#include +#include #include "memorycommon.h" const char *FORCE_SHRINK_ANON = "/dev/memcg/memory.force_shrink_anon"; diff --git a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp index 5fa9646..a185c33 100644 --- a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *MAX_SKIP_INTERVAL = "/dev/memcg/memory.max_skip_interval"; diff --git a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp index 5da7d00..272a44f 100644 --- a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp +++ b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *NAME = "/dev/memcg/memory.name"; diff --git a/test/fuzztest/memory/src/memorycommon.cpp b/test/fuzztest/memory/src/memorycommon.cpp index 491f9b0..82e2dfb 100644 --- a/test/fuzztest/memory/src/memorycommon.cpp +++ b/test/fuzztest/memory/src/memorycommon.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include "memorycommon.h" namespace OHOS { diff --git a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp index 3526479..0a8b80a 100644 --- a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp +++ b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *UB_UFS2ZRAM_RATIO = "/dev/memcg/memory.ub_ufs2zram_ratio"; diff --git a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp index 73da10f..226a5f3 100644 --- a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZRAM_CRITICAL_THRESHOLD = "/dev/memcg/memory.zram_critical_threshold"; diff --git a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp index 07125d5..4e78fd5 100644 --- a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp +++ b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZRAM_WR_RATIO = "/dev/memcg/memory.zram_wm_ratio"; diff --git a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp index 59b15e4..0d8ca27 100644 --- a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZSWAPD_MAX_RECLAIM_SIZE = "/dev/memcg/memory.zswapd_max_reclaim_size"; diff --git a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp index 4071fa6..e43e324 100644 --- a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZSWAPD_MEMCGS_PARAM = "/dev/memcg/memory.zswapd_memcgs_param"; diff --git a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp index 67a5af9..81b8e7c 100644 --- a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZSWAPD_PRESSURE_SHOW = "/dev/memcg/memory.zswapd_pressure_show"; diff --git a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp index 4646540..954f44a 100644 --- a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp @@ -14,10 +14,7 @@ */ #include -#include -#include #include -#include #include "memorycommon.h" const char *ZSWAPD_SINGLE_MEMCG_PARAM = "/dev/memcg/memory.zswapd_single_memcg_param"; -- Gitee From bc25db78fe1bbac61d0457e6cfdfb204f9a61ba9 Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Thu, 21 Jul 2022 09:46:28 +0800 Subject: [PATCH 10/12] fix variables case Signed-off-by: @wu_fan520 --- .../anonrefaultsnapshotmininterval_fuzzer.cpp | 5 ++--- test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp | 5 ++--- .../areaanonrefaultthreshold_fuzzer.cpp | 5 ++--- .../memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp | 5 ++--- .../bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp | 5 ++--- .../memory/compressratio_fuzzer/compressratio_fuzzer.cpp | 5 ++--- .../emptyroundcheckthreshold_fuzzer.cpp | 5 ++--- .../emptyroundskipinterval_fuzzer.cpp | 5 ++--- .../forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp | 7 +++---- .../maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp | 5 ++--- test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp | 5 ++--- .../ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp | 5 ++--- .../zramcriticalthreshold_fuzzer.cpp | 5 ++--- .../memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp | 5 ++--- .../zswapdmaxreclaimsize_fuzzer.cpp | 5 ++--- .../zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp | 5 ++--- .../zswapdpressureshow_fuzzer.cpp | 5 ++--- .../zswapdsinglememcgparam_fuzzer.cpp | 5 ++--- .../sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp | 6 +++--- test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp | 6 +++--- 20 files changed, 43 insertions(+), 61 deletions(-) diff --git a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp index fe4f842..b01933f 100644 --- a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp +++ b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ANON_REFAULT_SNAPSHOT_MIN_INTERVAL = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; - namespace OHOS { bool AnonRefaultSnapshotMinIntervalFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ANON_REFAULT_SNAPSHOT_MIN_INTERVAL); + const char *anon_refault_snapshot_min_interval = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; + bool ret = MemoryFuzzTest(data, size, anon_refault_snapshot_min_interval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp index e480ac3..1776020 100644 --- a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp +++ b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *APP_SCORE = "/dev/memcg/memory.app_score"; - namespace OHOS { bool AppScoreFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, APP_SCORE); + const char *app_score = "/dev/memcg/memory.app_score"; + bool ret = MemoryFuzzTest(data, size, app_score); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp index 8fb0d18..9d34c76 100644 --- a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *AREA_ANON_REFAULT_THRESHOLD = "/dev/memcg/memory.area_anon_refault_threshold"; - namespace OHOS { bool AreaAnonRefaultThresholdFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, AREA_ANON_REFAULT_THRESHOLD); + const char *area_anon_refault_threshold = "/dev/memcg/memory.area_anon_refault_threshold"; + bool ret = MemoryFuzzTest(data, size, area_anon_refault_threshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp index 03bc523..7baf485 100644 --- a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp +++ b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *AVAIL_BUFFERS = "/dev/memcg/memory.avail_buffers"; - namespace OHOS { bool AvailBuffersFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, AVAIL_BUFFERS); + const char *avail_buffers = "/dev/memcg/memory.avail_buffers"; + bool ret = MemoryFuzzTest(data, size, avail_buffers); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp index daca18e..e74be40 100644 --- a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp +++ b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *BUFFER_RATIO_PARAMS = "/dev/memcg/memory.buffer_ratio_params"; - namespace OHOS { bool BufferRatioParamsFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, BUFFER_RATIO_PARAMS); + const char *buffer_ratio_params = "/dev/memcg/memory.buffer_ratio_params"; + bool ret = MemoryFuzzTest(data, size, buffer_ratio_params); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp index 5f629c7..0eea7b1 100644 --- a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp +++ b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *COMPRESS_RATIO = "/dev/memcg/memory.compress_ratio"; - namespace OHOS { bool CompressRatioFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, COMPRESS_RATIO); + const char *compress_ratio = "/dev/memcg/memory.compress_ratio"; + bool ret = MemoryFuzzTest(data, size, compress_ratio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp index 7f58665..268aaf2 100644 --- a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *EMPTY_ROUND_CHECK_THRESHOLD = "/dev/memcg/memory.empty_round_check_threshold"; - namespace OHOS { bool EmptyRoundCheckThresholdFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, EMPTY_ROUND_CHECK_THRESHOLD); + const char *empty_round_check_threshold = "/dev/memcg/memory.empty_round_check_threshold"; + bool ret = MemoryFuzzTest(data, size, empty_round_check_threshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp index 4cc1b48..d053ace 100644 --- a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *EMPTY_ROUND_SKIP_INTERVAL = "/dev/memcg/memory.empty_round_skip_interval"; - namespace OHOS { bool EmptyRoundSkipIntervalFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, EMPTY_ROUND_SKIP_INTERVAL); + const char *empty_round_skip_interval = "/dev/memcg/memory.empty_round_skip_interval"; + bool ret = MemoryFuzzTest(data, size, empty_round_skip_interval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp index d5c532c..9dcaa00 100644 --- a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp +++ b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp @@ -20,19 +20,18 @@ #include #include "memorycommon.h" -const char *FORCE_SHRINK_ANON = "/dev/memcg/memory.force_shrink_anon"; - namespace OHOS { bool ForceShrinkAnonFuzzer(const uint8_t *data, size_t size) { - int fd = open(FORCE_SHRINK_ANON, O_RDWR); + const char *force_shrink_anon = "/dev/memcg/memory.force_shrink_anon"; + int fd = open(force_shrink_anon, O_RDWR); if (fd < 0) { return false; } int ret = write(fd, data, size); if (ret < 0) { - printf("%s write fail\n", FORCE_SHRINK_ANON); + printf("%s write fail\n", force_shrink_anon); close(fd); return false; } diff --git a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp index a185c33..d5e8c15 100644 --- a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *MAX_SKIP_INTERVAL = "/dev/memcg/memory.max_skip_interval"; - namespace OHOS { bool MaxSkipIntervalFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, MAX_SKIP_INTERVAL); + const char *max_skip_interval = "/dev/memcg/memory.max_skip_interval"; + bool ret = MemoryFuzzTest(data, size, max_skip_interval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp index 272a44f..9311f4d 100644 --- a/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp +++ b/test/fuzztest/memory/name_fuzzer/name_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *NAME = "/dev/memcg/memory.name"; - namespace OHOS { bool NameFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, NAME); + const char *name = "/dev/memcg/memory.name"; + bool ret = MemoryFuzzTest(data, size, name); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp index 0a8b80a..505e8d0 100644 --- a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp +++ b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *UB_UFS2ZRAM_RATIO = "/dev/memcg/memory.ub_ufs2zram_ratio"; - namespace OHOS { bool UbUfs2zramRatioFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, UB_UFS2ZRAM_RATIO); + const char *ub_ufs2zram_ratio = "/dev/memcg/memory.ub_ufs2zram_ratio"; + bool ret = MemoryFuzzTest(data, size, ub_ufs2zram_ratio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp index 226a5f3..32c4692 100644 --- a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZRAM_CRITICAL_THRESHOLD = "/dev/memcg/memory.zram_critical_threshold"; - namespace OHOS { bool ZramCriticalThresholdFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZRAM_CRITICAL_THRESHOLD); + const char *zram_critical_threshold = "/dev/memcg/memory.zram_critical_threshold"; + bool ret = MemoryFuzzTest(data, size, zram_critical_threshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp index 4e78fd5..8bd4d17 100644 --- a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp +++ b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZRAM_WR_RATIO = "/dev/memcg/memory.zram_wm_ratio"; - namespace OHOS { bool ZramWmRatioFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZRAM_WR_RATIO); + const char *zram_wr_ratio = "/dev/memcg/memory.zram_wm_ratio"; + bool ret = MemoryFuzzTest(data, size, zram_wr_ratio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp index 0d8ca27..2c43294 100644 --- a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZSWAPD_MAX_RECLAIM_SIZE = "/dev/memcg/memory.zswapd_max_reclaim_size"; - namespace OHOS { bool ZswapdMaxReclaimSizeFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZSWAPD_MAX_RECLAIM_SIZE); + const char *zswapd_max_reclaim_size = "/dev/memcg/memory.zswapd_max_reclaim_size"; + bool ret = MemoryFuzzTest(data, size, zswapd_max_reclaim_size); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp index e43e324..b6820c0 100644 --- a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZSWAPD_MEMCGS_PARAM = "/dev/memcg/memory.zswapd_memcgs_param"; - namespace OHOS { bool ZswapdMemcgsParamFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZSWAPD_MEMCGS_PARAM); + const char *zswapd_memcgs_param = "/dev/memcg/memory.zswapd_memcgs_param"; + bool ret = MemoryFuzzTest(data, size, zswapd_memcgs_param); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp index 81b8e7c..c6d423e 100644 --- a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZSWAPD_PRESSURE_SHOW = "/dev/memcg/memory.zswapd_pressure_show"; - namespace OHOS { bool ZswapdPressureShowFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZSWAPD_PRESSURE_SHOW); + const char *zswapd_pressure_show = "/dev/memcg/memory.zswapd_pressure_show"; + bool ret = MemoryFuzzTest(data, size, zswapd_pressure_show); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp index 954f44a..4966fa1 100644 --- a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp @@ -17,12 +17,11 @@ #include #include "memorycommon.h" -const char *ZSWAPD_SINGLE_MEMCG_PARAM = "/dev/memcg/memory.zswapd_single_memcg_param"; - namespace OHOS { bool ZswapdSingleMemcgParamFuzzer(const uint8_t *data, size_t size) { - bool ret = MemoryFuzzTest(data, size, ZSWAPD_SINGLE_MEMCG_PARAM); + const char *zswapd_single_memcg_param = "/dev/memcg/memory.zswapd_single_memcg_param"; + bool ret = MemoryFuzzTest(data, size, zswapd_single_memcg_param); return ret; } } // namespace OHOS diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp index 023a325..bf0f9d6 100644 --- a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp +++ b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp @@ -25,14 +25,14 @@ 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; + 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) { + if (margin < margin_lower_limit_time || margin > margin_upper_limit_time) { return ret; } int grpId = 2; diff --git a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp index 4b92d3f..ceddac4 100644 --- a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp +++ b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp @@ -25,14 +25,14 @@ 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; + 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) { + if (margin < margin_lower_limit_time || margin > margin_upper_limit_time) { return ret; } int grpId = 2; -- Gitee From 09f9e4b00595373999024ccf39ac9ceacc5959cd Mon Sep 17 00:00:00 2001 From: "@wu_fan520" Date: Fri, 22 Jul 2022 11:08:48 +0800 Subject: [PATCH 11/12] fix variables case and include file Signed-off-by: @wu_fan520 --- .../accessftokenidgrptest_fuzzer.cpp | 4 +- .../accessftokenidgrptestother_fuzzer.cpp | 4 +- .../accessftokenidthreadtest_fuzzer.cpp | 4 +- .../accesstokenidgrptest_fuzzer.cpp | 4 +- .../accesstokenidgrptestother_fuzzer.cpp | 4 +- .../accesstokenidthreadtest_fuzzer.cpp | 4 +- .../include/accesstokenidcommon.h | 48 +++++------ .../accesstokenid/src/accesstokenidcommon.cpp | 81 +++++++++---------- .../anonrefaultsnapshotmininterval_fuzzer.cpp | 4 +- .../appscore_fuzzer/appscore_fuzzer.cpp | 4 +- .../areaanonrefaultthreshold_fuzzer.cpp | 4 +- .../availbuffers_fuzzer.cpp | 4 +- .../bufferratioparams_fuzzer.cpp | 4 +- .../compressratio_fuzzer.cpp | 4 +- .../emptyroundcheckthreshold_fuzzer.cpp | 4 +- .../emptyroundskipinterval_fuzzer.cpp | 4 +- .../forceshrinkanon_fuzzer.cpp | 8 +- .../maxskipinterval_fuzzer.cpp | 4 +- .../ubufs2zramratio_fuzzer.cpp | 4 +- .../zramcriticalthreshold_fuzzer.cpp | 4 +- .../zramwmratio_fuzzer/zramwmratio_fuzzer.cpp | 4 +- .../zswapdmaxreclaimsize_fuzzer.cpp | 4 +- .../zswapdmemcgsparam_fuzzer.cpp | 4 +- .../zswapdpressureshow_fuzzer.cpp | 4 +- .../zswapdsinglememcgparam_fuzzer.cpp | 4 +- .../beginframefreq_fuzzer.cpp | 6 +- .../setmargin_fuzzer/setmargin_fuzzer.cpp | 6 +- 27 files changed, 117 insertions(+), 120 deletions(-) diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp index 2dc2296..08e9ddb 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptest_fuzzer/accessftokenidgrptest_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessfTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidGrpTest(data_ftoken); + uint8_t *dataFtoken = const_cast(data); + ret = AccessfTokenidGrpTest(dataFtoken); } return ret; } diff --git a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp index 6a58dfe..126264c 100644 --- a/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidgrptestother_fuzzer/accessftokenidgrptestother_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessfTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidGrpTestOther(data_ftoken); + uint8_t *dataFtoken = const_cast(data); + ret = AccessfTokenidGrpTestOther(dataFtoken); } return ret; } diff --git a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp index ad8101a..95b1130 100644 --- a/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accessftokenidthreadtest_fuzzer/accessftokenidthreadtest_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessfTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_ftoken = const_cast(data); - ret = AccessfTokenidThreadTest(data_ftoken); + uint8_t *dataFtoken = const_cast(data); + ret = AccessfTokenidThreadTest(dataFtoken); } return ret; } diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp index 872a7bd..a9a8c04 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptest_fuzzer/accesstokenidgrptest_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessTokenidGrpTestFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidGrpTest(data_token); + uint8_t *dataToken = const_cast(data); + ret = AccessTokenidGrpTest(dataToken); } return ret; } diff --git a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp index d0437f9..111c3d5 100644 --- a/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidgrptestother_fuzzer/accesstokenidgrptestother_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessTokenidGrpTestOtherFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidGrpTestOther(data_token); + uint8_t *dataToken = const_cast(data); + ret = AccessTokenidGrpTestOther(dataToken); } return ret; } diff --git a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp index 0aadbf7..72f6f1d 100644 --- a/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp +++ b/test/fuzztest/accesstokenid/accesstokenidthreadtest_fuzzer/accesstokenidthreadtest_fuzzer.cpp @@ -28,8 +28,8 @@ bool AccessTokenidThreadTestFuzzTest(const uint8_t *data, size_t size) if ((data == nullptr) || (size < sizeof(unsigned long long))) { return ret; } else { - uint8_t *data_token = const_cast(data); - ret = AccessTokenidThreadTest(data_token); + uint8_t *dataToken = const_cast(data); + ret = AccessTokenidThreadTest(dataToken); } return ret; } diff --git a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h index ba3bde7..ce1059a 100644 --- a/test/fuzztest/accesstokenid/include/accesstokenidcommon.h +++ b/test/fuzztest/accesstokenid/include/accesstokenidcommon.h @@ -26,25 +26,25 @@ namespace AccessToken { #define ACCESS_TOKEN_ID_IOCTL_BASE 'A' #ifdef CMDERROR -constexpr unsigned int get_token_id = 0; -constexpr unsigned int set_token_id = 0; -constexpr unsigned int get_ftoken_id = 0; -constexpr unsigned int set_ftoken_id = 0; +#define GET_TOKEN_ID 0 +#define SET_TOKEN_ID 0 +#define GET_GTOKEN_ID 0 +#define SET_GTOKEN_ID 0 #else -constexpr unsigned int get_token_id = 1; -constexpr unsigned int set_token_id = 2; -constexpr unsigned int get_ftoken_id = 3; -constexpr unsigned int set_ftoken_id = 4; +#define GET_TOKEN_ID 1 +#define SET_TOKEN_ID 2 +#define GET_GTOKEN_ID 3 +#define SET_GTOKEN_ID 4 #endif #define ACCESS_TOKENID_GET_TOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_token_id, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) #define ACCESS_TOKENID_SET_TOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_token_id, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) #define ACCESS_TOKENID_GET_FTOKENID \ - _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, get_ftoken_id, unsigned long long) + _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_GTOKEN_ID, unsigned long long) #define ACCESS_TOKENID_SET_FTOKENID \ - _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, set_ftoken_id, unsigned long long) + _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_GTOKEN_ID, unsigned long long) #define LIST_NUM_1 1 #define LIST_NUM_2 2 @@ -69,20 +69,20 @@ int SetfTokenid(unsigned long long *ftoken); void SetUidAndGrp(); void SetUidAndGrpOther(); void GetCurToken(unsigned long long *token); -void SetRandTokenAndCheck(unsigned long long *data_token); -void TokenTest(unsigned long long *data_token); -void ThreadTest(unsigned long long *data_token); -int AccessTokenidThreadTest(uint8_t *data_token); -int AccessTokenidGrpTest(uint8_t *data_token); -int AccessTokenidGrpTestOther(uint8_t *data_token); +void SetRandTokenAndCheck(unsigned long long *dataToken); +void TokenTest(unsigned long long *dataToken); +void ThreadTest(unsigned long long *dataToken); +int AccessTokenidThreadTest(uint8_t *dataToken); +int AccessTokenidGrpTest(uint8_t *dataToken); +int AccessTokenidGrpTestOther(uint8_t *dataToken); void GetCurfToken(unsigned long long *ftoken); -void SetRandfTokenAndCheck(unsigned long long *data_ftoken); -void fTokenTest(unsigned long long *data_ftoken); -void ThreadTest(unsigned long long *data_ftoken); -int AccessfTokenidThreadTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTest(uint8_t *data_ftoken); -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken); +void SetRandfTokenAndCheck(unsigned long long *dataFtoken); +void FTokenTest(unsigned long long *dataFtoken); +void ThreadTest(unsigned long long *dataFtoken); +int AccessfTokenidThreadTest(uint8_t *dataFtoken); +int AccessfTokenidGrpTest(uint8_t *dataFtoken); +int AccessfTokenidGrpTestOther(uint8_t *dataFtoken); bool SetfTokenidCmdFuzzTest(const uint8_t *data, size_t size); bool GetfTokenidCmdFuzzTest(const uint8_t *data, size_t size); bool SetTokenidCmdFuzzTest(const uint8_t *data, size_t size); diff --git a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp index 18a28cd..3b7fa7f 100644 --- a/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp +++ b/test/fuzztest/accesstokenid/src/accesstokenidcommon.cpp @@ -34,7 +34,7 @@ int GetTokenid(unsigned long long *token) return -1; } int ret = ioctl(fd, ACCESS_TOKENID_GET_TOKENID, token); - if (ret) { + if (ret != 0) { close(fd); return -1; } @@ -49,7 +49,7 @@ int SetTokenid(unsigned long long *token) return -1; } int ret = ioctl(fd, ACCESS_TOKENID_SET_TOKENID, token); - if (ret) { + if (ret != 0) { close(fd); return -1; } @@ -95,12 +95,12 @@ void SetUidAndGrpOther() return; } -void SetRandTokenAndCheck(unsigned long long *data_token) +void SetRandTokenAndCheck(unsigned long long *dataToken) { pid_t pid = getpid(); pid_t tid = syscall(__NR_gettid); unsigned long long token = INVAL_TOKEN; - unsigned long long tokenSet = *data_token; + unsigned long long tokenSet = *dataToken; SetTokenid(&tokenSet); GetTokenid(&token); @@ -126,62 +126,61 @@ void SetRandTokenAndCheck(unsigned long long *data_token) return; } -void *TokenTest(void *data_token) +void *TokenTest(void *dataToken) { - SetRandTokenAndCheck(static_cast(data_token)); - + SetRandTokenAndCheck(static_cast(dataToken)); return nullptr; } -void ThreadTest(void *data_token) +void ThreadTest(void *dataToken) { - pthread_t id_1; - pthread_t id_2; - pthread_t id_3; + pthread_t tid1; + pthread_t tid2; + pthread_t tid3; int ret = 0; - ret = pthread_create(&id_1, nullptr, TokenTest, data_token); + ret = pthread_create(&tid1, nullptr, TokenTest, dataToken); if (ret != 0) { return; } - ret = pthread_create(&id_2, nullptr, TokenTest, data_token); + ret = pthread_create(&tid2, nullptr, TokenTest, dataToken); if (ret != 0) { return; } - ret = pthread_create(&id_3, nullptr, TokenTest, data_token); + ret = pthread_create(&tid3, nullptr, TokenTest, dataToken); if (ret != 0) { return; } - pthread_join(id_1, nullptr); - pthread_join(id_2, nullptr); - pthread_join(id_3, nullptr); + pthread_join(tid1, nullptr); + pthread_join(tid2, nullptr); + pthread_join(tid3, nullptr); return; } -int AccessTokenidThreadTest(uint8_t *data_token) +int AccessTokenidThreadTest(uint8_t *dataToken) { - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); + TokenTest(static_cast(dataToken)); + ThreadTest(static_cast(dataToken)); return 0; } -int AccessTokenidGrpTest(uint8_t *data_token) +int AccessTokenidGrpTest(uint8_t *dataToken) { SetUidAndGrp(); - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); + TokenTest(static_cast(dataToken)); + ThreadTest(static_cast(dataToken)); return 0; } -int AccessTokenidGrpTestOther(uint8_t *data_token) +int AccessTokenidGrpTestOther(uint8_t *dataToken) { SetUidAndGrpOther(); - TokenTest(static_cast(data_token)); - ThreadTest(static_cast(data_token)); + TokenTest(static_cast(dataToken)); + ThreadTest(static_cast(dataToken)); return 0; } @@ -193,7 +192,7 @@ int GetfTokenid(unsigned long long *ftoken) } int ret = ioctl(fd, ACCESS_TOKENID_GET_FTOKENID, ftoken); - if (ret) { + if (ret != 0) { close(fd); return -1; } @@ -210,7 +209,7 @@ int SetfTokenid(unsigned long long *ftoken) } int ret = ioctl(fd, ACCESS_TOKENID_SET_FTOKENID, ftoken); - if (ret) { + if (ret != 0) { close(fd); return -1; } @@ -219,12 +218,12 @@ int SetfTokenid(unsigned long long *ftoken) return 0; } -void SetRandfTokenAndCheck(unsigned long long *data_ftoken) +void SetRandfTokenAndCheck(unsigned long long *dataFtoken) { pid_t pid = getpid(); pid_t tid = syscall(__NR_gettid); unsigned long long ftoken = INVAL_TOKEN; - unsigned long long ftokenSet = *data_ftoken; + unsigned long long ftokenSet = *dataFtoken; SetfTokenid(&ftokenSet); GetfTokenid(&ftoken); @@ -250,32 +249,32 @@ void SetRandfTokenAndCheck(unsigned long long *data_ftoken) return; } -void *fTokenTest(void *data_ftoken) +void *FTokenTest(void *dataFtoken) { - SetRandfTokenAndCheck(static_cast(data_ftoken)); + SetRandfTokenAndCheck(static_cast(dataFtoken)); return nullptr; } -int AccessfTokenidThreadTest(uint8_t *data_ftoken) +int AccessfTokenidThreadTest(uint8_t *dataFtoken) { - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); + FTokenTest(static_cast(dataFtoken)); + ThreadTest(static_cast(dataFtoken)); return 0; } -int AccessfTokenidGrpTest(uint8_t *data_ftoken) +int AccessfTokenidGrpTest(uint8_t *dataFtoken) { SetUidAndGrp(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); + FTokenTest(static_cast(dataFtoken)); + ThreadTest(static_cast(dataFtoken)); return 0; } -int AccessfTokenidGrpTestOther(uint8_t *data_ftoken) +int AccessfTokenidGrpTestOther(uint8_t *dataFtoken) { SetUidAndGrpOther(); - fTokenTest(static_cast(data_ftoken)); - ThreadTest(static_cast(data_ftoken)); + FTokenTest(static_cast(dataFtoken)); + ThreadTest(static_cast(dataFtoken)); return 0; } diff --git a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp index b01933f..82b5a38 100644 --- a/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp +++ b/test/fuzztest/memory/anonrefaultsnapshotmininterval_fuzzer/anonrefaultsnapshotmininterval_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool AnonRefaultSnapshotMinIntervalFuzzer(const uint8_t *data, size_t size) { - const char *anon_refault_snapshot_min_interval = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; - bool ret = MemoryFuzzTest(data, size, anon_refault_snapshot_min_interval); + const char *anonRefaultSnapshotMinInterval = "/dev/memcg/memory.anon_refault_snapshot_min_interval"; + bool ret = MemoryFuzzTest(data, size, anonRefaultSnapshotMinInterval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp index 1776020..a8cd8b4 100644 --- a/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp +++ b/test/fuzztest/memory/appscore_fuzzer/appscore_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool AppScoreFuzzer(const uint8_t *data, size_t size) { - const char *app_score = "/dev/memcg/memory.app_score"; - bool ret = MemoryFuzzTest(data, size, app_score); + const char *appScore = "/dev/memcg/memory.app_score"; + bool ret = MemoryFuzzTest(data, size, appScore); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp index 9d34c76..0da0acd 100644 --- a/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/areaanonrefaultthreshold_fuzzer/areaanonrefaultthreshold_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool AreaAnonRefaultThresholdFuzzer(const uint8_t *data, size_t size) { - const char *area_anon_refault_threshold = "/dev/memcg/memory.area_anon_refault_threshold"; - bool ret = MemoryFuzzTest(data, size, area_anon_refault_threshold); + const char *areaAnonRefaultThreshold = "/dev/memcg/memory.area_anon_refault_threshold"; + bool ret = MemoryFuzzTest(data, size, areaAnonRefaultThreshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp index 7baf485..bc650ce 100644 --- a/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp +++ b/test/fuzztest/memory/availbuffers_fuzzer/availbuffers_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool AvailBuffersFuzzer(const uint8_t *data, size_t size) { - const char *avail_buffers = "/dev/memcg/memory.avail_buffers"; - bool ret = MemoryFuzzTest(data, size, avail_buffers); + const char *availBuffers = "/dev/memcg/memory.avail_buffers"; + bool ret = MemoryFuzzTest(data, size, availBuffers); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp index e74be40..644d1d3 100644 --- a/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp +++ b/test/fuzztest/memory/bufferratioparams_fuzzer/bufferratioparams_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool BufferRatioParamsFuzzer(const uint8_t *data, size_t size) { - const char *buffer_ratio_params = "/dev/memcg/memory.buffer_ratio_params"; - bool ret = MemoryFuzzTest(data, size, buffer_ratio_params); + const char *bufferRatioParams = "/dev/memcg/memory.buffer_ratio_params"; + bool ret = MemoryFuzzTest(data, size, bufferRatioParams); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp index 0eea7b1..487a958 100644 --- a/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp +++ b/test/fuzztest/memory/compressratio_fuzzer/compressratio_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool CompressRatioFuzzer(const uint8_t *data, size_t size) { - const char *compress_ratio = "/dev/memcg/memory.compress_ratio"; - bool ret = MemoryFuzzTest(data, size, compress_ratio); + const char *compressRatio = "/dev/memcg/memory.compress_ratio"; + bool ret = MemoryFuzzTest(data, size, compressRatio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp index 268aaf2..7984e6e 100644 --- a/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundcheckthreshold_fuzzer/emptyroundcheckthreshold_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool EmptyRoundCheckThresholdFuzzer(const uint8_t *data, size_t size) { - const char *empty_round_check_threshold = "/dev/memcg/memory.empty_round_check_threshold"; - bool ret = MemoryFuzzTest(data, size, empty_round_check_threshold); + const char *emptyRoundCheckThreshold = "/dev/memcg/memory.empty_round_check_threshold"; + bool ret = MemoryFuzzTest(data, size, emptyRoundCheckThreshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp index d053ace..96a05f3 100644 --- a/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/emptyroundskipinterval_fuzzer/emptyroundskipinterval_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool EmptyRoundSkipIntervalFuzzer(const uint8_t *data, size_t size) { - const char *empty_round_skip_interval = "/dev/memcg/memory.empty_round_skip_interval"; - bool ret = MemoryFuzzTest(data, size, empty_round_skip_interval); + const char *emptyRoundSkipInterval = "/dev/memcg/memory.empty_round_skip_interval"; + bool ret = MemoryFuzzTest(data, size, emptyRoundSkipInterval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp index 9dcaa00..358aff4 100644 --- a/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp +++ b/test/fuzztest/memory/forceshrinkanon_fuzzer/forceshrinkanon_fuzzer.cpp @@ -14,24 +14,22 @@ */ #include -#include #include #include #include -#include "memorycommon.h" namespace OHOS { bool ForceShrinkAnonFuzzer(const uint8_t *data, size_t size) { - const char *force_shrink_anon = "/dev/memcg/memory.force_shrink_anon"; - int fd = open(force_shrink_anon, O_RDWR); + const char *forceShrinkAnon = "/dev/memcg/memory.force_shrink_anon"; + int fd = open(forceShrinkAnon, O_RDWR); if (fd < 0) { return false; } int ret = write(fd, data, size); if (ret < 0) { - printf("%s write fail\n", force_shrink_anon); + printf("%s write fail\n", forceShrinkAnon); close(fd); return false; } diff --git a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp index d5e8c15..73ffffd 100644 --- a/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp +++ b/test/fuzztest/memory/maxskipinterval_fuzzer/maxskipinterval_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool MaxSkipIntervalFuzzer(const uint8_t *data, size_t size) { - const char *max_skip_interval = "/dev/memcg/memory.max_skip_interval"; - bool ret = MemoryFuzzTest(data, size, max_skip_interval); + const char *maxSkipInterval = "/dev/memcg/memory.max_skip_interval"; + bool ret = MemoryFuzzTest(data, size, maxSkipInterval); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp index 505e8d0..0dbe7af 100644 --- a/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp +++ b/test/fuzztest/memory/ubufs2zramratio_fuzzer/ubufs2zramratio_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool UbUfs2zramRatioFuzzer(const uint8_t *data, size_t size) { - const char *ub_ufs2zram_ratio = "/dev/memcg/memory.ub_ufs2zram_ratio"; - bool ret = MemoryFuzzTest(data, size, ub_ufs2zram_ratio); + const char *ubUfs2zramRatio = "/dev/memcg/memory.ub_ufs2zram_ratio"; + bool ret = MemoryFuzzTest(data, size, ubUfs2zramRatio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp index 32c4692..dd63253 100644 --- a/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp +++ b/test/fuzztest/memory/zramcriticalthreshold_fuzzer/zramcriticalthreshold_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZramCriticalThresholdFuzzer(const uint8_t *data, size_t size) { - const char *zram_critical_threshold = "/dev/memcg/memory.zram_critical_threshold"; - bool ret = MemoryFuzzTest(data, size, zram_critical_threshold); + const char *zramCriticalThreshold = "/dev/memcg/memory.zram_critical_threshold"; + bool ret = MemoryFuzzTest(data, size, zramCriticalThreshold); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp index 8bd4d17..ac871ce 100644 --- a/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp +++ b/test/fuzztest/memory/zramwmratio_fuzzer/zramwmratio_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZramWmRatioFuzzer(const uint8_t *data, size_t size) { - const char *zram_wr_ratio = "/dev/memcg/memory.zram_wm_ratio"; - bool ret = MemoryFuzzTest(data, size, zram_wr_ratio); + const char *zramWrRatio = "/dev/memcg/memory.zram_wm_ratio"; + bool ret = MemoryFuzzTest(data, size, zramWrRatio); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp index 2c43294..dd39fdb 100644 --- a/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmaxreclaimsize_fuzzer/zswapdmaxreclaimsize_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZswapdMaxReclaimSizeFuzzer(const uint8_t *data, size_t size) { - const char *zswapd_max_reclaim_size = "/dev/memcg/memory.zswapd_max_reclaim_size"; - bool ret = MemoryFuzzTest(data, size, zswapd_max_reclaim_size); + const char *zswapdMaxReclaimSize = "/dev/memcg/memory.zswapd_max_reclaim_size"; + bool ret = MemoryFuzzTest(data, size, zswapdMaxReclaimSize); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp index b6820c0..7afeee9 100644 --- a/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdmemcgsparam_fuzzer/zswapdmemcgsparam_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZswapdMemcgsParamFuzzer(const uint8_t *data, size_t size) { - const char *zswapd_memcgs_param = "/dev/memcg/memory.zswapd_memcgs_param"; - bool ret = MemoryFuzzTest(data, size, zswapd_memcgs_param); + const char *zswapdMemcgsParam = "/dev/memcg/memory.zswapd_memcgs_param"; + bool ret = MemoryFuzzTest(data, size, zswapdMemcgsParam); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp index c6d423e..df71beb 100644 --- a/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdpressureshow_fuzzer/zswapdpressureshow_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZswapdPressureShowFuzzer(const uint8_t *data, size_t size) { - const char *zswapd_pressure_show = "/dev/memcg/memory.zswapd_pressure_show"; - bool ret = MemoryFuzzTest(data, size, zswapd_pressure_show); + const char *zswapdPressureShow = "/dev/memcg/memory.zswapd_pressure_show"; + bool ret = MemoryFuzzTest(data, size, zswapdPressureShow); return ret; } } // namespace OHOS diff --git a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp index 4966fa1..1dc2ba9 100644 --- a/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp +++ b/test/fuzztest/memory/zswapdsinglememcgparam_fuzzer/zswapdsinglememcgparam_fuzzer.cpp @@ -20,8 +20,8 @@ namespace OHOS { bool ZswapdSingleMemcgParamFuzzer(const uint8_t *data, size_t size) { - const char *zswapd_single_memcg_param = "/dev/memcg/memory.zswapd_single_memcg_param"; - bool ret = MemoryFuzzTest(data, size, zswapd_single_memcg_param); + const char *zswapdSingleMemcgParam = "/dev/memcg/memory.zswapd_single_memcg_param"; + bool ret = MemoryFuzzTest(data, size, zswapdSingleMemcgParam); return ret; } } // namespace OHOS diff --git a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp index bf0f9d6..942ba8f 100644 --- a/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp +++ b/test/fuzztest/sched/beginframefreq_fuzzer/beginframefreq_fuzzer.cpp @@ -25,14 +25,14 @@ 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; + constexpr int marginUpperLimitTime = 32000; + constexpr int marginLowerLimitTime = -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) { + if (margin < marginLowerLimitTime || margin > marginUpperLimitTime) { return ret; } int grpId = 2; diff --git a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp index ceddac4..02aed9a 100644 --- a/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp +++ b/test/fuzztest/sched/setmargin_fuzzer/setmargin_fuzzer.cpp @@ -25,14 +25,14 @@ 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; + constexpr int marginUpperLimitTime = 32000; + constexpr int marginLowerLimitTime = -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) { + if (margin < marginLowerLimitTime || margin > marginUpperLimitTime) { return ret; } int grpId = 2; -- Gitee From 32f38f10c7e20d22ee0e221adffbc926d77b6b3d Mon Sep 17 00:00:00 2001 From: Ma Feng Date: Tue, 26 Jul 2022 11:13:37 +0800 Subject: [PATCH 12/12] test: Change shell scripts out diretory Change shell test scripts from moduletest to kernel_shelltest Signed-off-by: Ma Feng --- test/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/BUILD.gn b/test/BUILD.gn index 747fc28..89103af 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -32,10 +32,10 @@ if (is_standard_system) { script_dir = "kernel/linux/build/test/moduletest/runtest" action("init_runtest") { script = "init_runtest.sh" - outputs = [ "$root_build_dir/tests/moduletest/runtest.timestamp" ] + outputs = [ "$root_build_dir/tests/kernel_shelltest/runtest.timestamp" ] args = [ rebase_path("$root_build_dir/../../$script_dir"), - rebase_path("$root_build_dir/tests/moduletest"), + rebase_path("$root_build_dir/tests/kernel_shelltest"), ] } } -- Gitee