From 4f796448a713cfcb9329c3eecceeb8a187e1bf84 Mon Sep 17 00:00:00 2001 From: liudanning Date: Mon, 20 Jun 2022 17:59:03 +0800 Subject: [PATCH 1/2] kernel_linux_build:Correcting code scan errors --- .../testcases/bin/enhancedf2fs08.sh | 31 +++++++++++-------- .../testcases/bin/enhancedf2fs09.sh | 2 +- .../runtest/bin/mem_debug_t_init.sh | 8 ++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh index 78b0636..a94e88c 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh @@ -46,26 +46,30 @@ do_test() init_value3=$(cat $_ssr_path/hc_hot_node_lower_limit) init_value4=$(cat $_ssr_path/hc_warm_node_lower_limit) - confirm_value hc_hot_data_lower_limit - confirm_value hc_warm_data_lower_limit - confirm_value hc_hot_node_lower_limit + confirm_value hc_hot_data_lower_limit && + confirm_value hc_warm_data_lower_limit && + confirm_value hc_hot_node_lower_limit && confirm_value hc_warm_node_lower_limit + [ $? -ne 0 ] && ((ret++)) + echo 6000000 > $_ssr_path/hc_hot_data_lower_limit echo 6000000 > $_ssr_path/hc_warm_data_lower_limit echo 6000000 > $_ssr_path/hc_hot_node_lower_limit echo 6000000 > $_ssr_path/hc_warm_node_lower_limit - confirm_change_value hc_hot_data_lower_limit - confirm_change_value hc_warm_data_lower_limit - confirm_change_value hc_hot_node_lower_limit + confirm_change_value hc_hot_data_lower_limit && + confirm_change_value hc_warm_data_lower_limit && + confirm_change_value hc_hot_node_lower_limit && confirm_change_value hc_warm_node_lower_limit + [ $? -ne 0 ] && ((ret++)) + if [ $ret -eq 0 ];then - tst_res TPASS "hierarchical SSR threshold configuration interface pass." - else - tst_res TFAIL "Hierarchical SSR threshold configuration interface failed!" - fi + tst_res TPASS "hierarchical SSR threshold configuration interface pass." + else + tst_res TFAIL "Hierarchical SSR threshold configuration interface failed!" + fi } confirm_value() @@ -73,9 +77,10 @@ confirm_value() local result_out1=$(cat /sys/fs/f2fs/loop1/$1) if [ "$result_out1" == "5242880" ]; then tst_res TPASS "$1 is 5242880 expected." + return 0 else tst_res TFAIL "$1 is not 5242880 unexpected!" - ret=$(( $ret + 1 )) + return 1 fi } @@ -86,7 +91,7 @@ confirm_change_value() tst_res TPASS "$1 is 6000000 expected." else tst_res TFAIL "$1 is not 6000000 unexpected!" - ret=$(( $ret + 1 )) + return 0 fi } @@ -96,7 +101,7 @@ do_clean() echo $init_value2 > $_ssr_path/hc_warm_data_lower_limit echo $init_value3 > $_ssr_path/hc_hot_node_lower_limit echo $init_value4 > $_ssr_path/hc_warm_node_lower_limit - losetup -d /dev/block/loop1 + losetup -d /dev/block/loop1 umount /mnt/f2fs_mount } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh index 86ecb53..e5d0101 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh @@ -100,7 +100,7 @@ do_clean() echo $init_value2 > $_ssr_path/hc_warm_data_waterline echo $init_value3 > $_ssr_path/hc_hot_node_waterline echo $init_value4 > $_ssr_path/hc_warm_node_waterline - losetup -d /dev/block/loop1 + losetup -d /dev/block/loop1 umount /mnt/f2fs_mount } diff --git a/test/moduletest/runtest/bin/mem_debug_t_init.sh b/test/moduletest/runtest/bin/mem_debug_t_init.sh index 78fbcc5..91474c8 100644 --- a/test/moduletest/runtest/bin/mem_debug_t_init.sh +++ b/test/moduletest/runtest/bin/mem_debug_t_init.sh @@ -34,20 +34,20 @@ hp_init() { dd if=/dev/random of=/data/hpdisk bs=4096 count=131072 losetup /dev/block/loop6 /data/hpdisk - hyperhold_device=`cat /proc/sys/kernel/hyperhold/device` + hyperhold_device=$(cat /proc/sys/kernel/hyperhold/device) echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device } hp_enable() { - hyperhold_enable=`cat /proc/sys/kernel/hyperhold/enable` + hyperhold_enable=$(cat /proc/sys/kernel/hyperhold/enable) echo enable > /proc/sys/kernel/hyperhold/enable } zram_init() { - zram0_group=`cat /sys/block/zram0/group` - zram0_disksize=`cat /sys/block/zram0/disksize` + zram0_group=$(cat /sys/block/zram0/group) + zram0_disksize=$(cat /sys/block/zram0/disksize) echo readwrite > /sys/block/zram0/group echo 512M > /sys/block/zram0/disksize } -- Gitee From eca30308dfe9ac765ecb5a4e4bb0e1aefbe493c2 Mon Sep 17 00:00:00 2001 From: liudanning Date: Tue, 21 Jun 2022 09:59:45 +0800 Subject: [PATCH 2/2] kernel_linux_build:Correcting code scan errors Signed-off-by: liudanning --- .../testcases/bin/enhancedf2fs08.sh | 31 +++++++++++-------- .../testcases/bin/enhancedf2fs09.sh | 2 +- .../runtest/bin/mem_debug_t_init.sh | 8 ++--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh index 78b0636..a94e88c 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs08.sh @@ -46,26 +46,30 @@ do_test() init_value3=$(cat $_ssr_path/hc_hot_node_lower_limit) init_value4=$(cat $_ssr_path/hc_warm_node_lower_limit) - confirm_value hc_hot_data_lower_limit - confirm_value hc_warm_data_lower_limit - confirm_value hc_hot_node_lower_limit + confirm_value hc_hot_data_lower_limit && + confirm_value hc_warm_data_lower_limit && + confirm_value hc_hot_node_lower_limit && confirm_value hc_warm_node_lower_limit + [ $? -ne 0 ] && ((ret++)) + echo 6000000 > $_ssr_path/hc_hot_data_lower_limit echo 6000000 > $_ssr_path/hc_warm_data_lower_limit echo 6000000 > $_ssr_path/hc_hot_node_lower_limit echo 6000000 > $_ssr_path/hc_warm_node_lower_limit - confirm_change_value hc_hot_data_lower_limit - confirm_change_value hc_warm_data_lower_limit - confirm_change_value hc_hot_node_lower_limit + confirm_change_value hc_hot_data_lower_limit && + confirm_change_value hc_warm_data_lower_limit && + confirm_change_value hc_hot_node_lower_limit && confirm_change_value hc_warm_node_lower_limit + [ $? -ne 0 ] && ((ret++)) + if [ $ret -eq 0 ];then - tst_res TPASS "hierarchical SSR threshold configuration interface pass." - else - tst_res TFAIL "Hierarchical SSR threshold configuration interface failed!" - fi + tst_res TPASS "hierarchical SSR threshold configuration interface pass." + else + tst_res TFAIL "Hierarchical SSR threshold configuration interface failed!" + fi } confirm_value() @@ -73,9 +77,10 @@ confirm_value() local result_out1=$(cat /sys/fs/f2fs/loop1/$1) if [ "$result_out1" == "5242880" ]; then tst_res TPASS "$1 is 5242880 expected." + return 0 else tst_res TFAIL "$1 is not 5242880 unexpected!" - ret=$(( $ret + 1 )) + return 1 fi } @@ -86,7 +91,7 @@ confirm_change_value() tst_res TPASS "$1 is 6000000 expected." else tst_res TFAIL "$1 is not 6000000 unexpected!" - ret=$(( $ret + 1 )) + return 0 fi } @@ -96,7 +101,7 @@ do_clean() echo $init_value2 > $_ssr_path/hc_warm_data_lower_limit echo $init_value3 > $_ssr_path/hc_hot_node_lower_limit echo $init_value4 > $_ssr_path/hc_warm_node_lower_limit - losetup -d /dev/block/loop1 + losetup -d /dev/block/loop1 umount /mnt/f2fs_mount } diff --git a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh index 86ecb53..e5d0101 100644 --- a/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh +++ b/test/moduletest/runtest/bin/enhancedf2fs_t/testcases/bin/enhancedf2fs09.sh @@ -100,7 +100,7 @@ do_clean() echo $init_value2 > $_ssr_path/hc_warm_data_waterline echo $init_value3 > $_ssr_path/hc_hot_node_waterline echo $init_value4 > $_ssr_path/hc_warm_node_waterline - losetup -d /dev/block/loop1 + losetup -d /dev/block/loop1 umount /mnt/f2fs_mount } diff --git a/test/moduletest/runtest/bin/mem_debug_t_init.sh b/test/moduletest/runtest/bin/mem_debug_t_init.sh index 78fbcc5..91474c8 100644 --- a/test/moduletest/runtest/bin/mem_debug_t_init.sh +++ b/test/moduletest/runtest/bin/mem_debug_t_init.sh @@ -34,20 +34,20 @@ hp_init() { dd if=/dev/random of=/data/hpdisk bs=4096 count=131072 losetup /dev/block/loop6 /data/hpdisk - hyperhold_device=`cat /proc/sys/kernel/hyperhold/device` + hyperhold_device=$(cat /proc/sys/kernel/hyperhold/device) echo /dev/block/loop6 > /proc/sys/kernel/hyperhold/device } hp_enable() { - hyperhold_enable=`cat /proc/sys/kernel/hyperhold/enable` + hyperhold_enable=$(cat /proc/sys/kernel/hyperhold/enable) echo enable > /proc/sys/kernel/hyperhold/enable } zram_init() { - zram0_group=`cat /sys/block/zram0/group` - zram0_disksize=`cat /sys/block/zram0/disksize` + zram0_group=$(cat /sys/block/zram0/group) + zram0_disksize=$(cat /sys/block/zram0/disksize) echo readwrite > /sys/block/zram0/group echo 512M > /sys/block/zram0/disksize } -- Gitee