From 12c67f59a6256efbda580012a82023b51517edf5 Mon Sep 17 00:00:00 2001 From: zhtianyu Date: Fri, 19 Dec 2025 18:33:41 +0800 Subject: [PATCH] fix os-basic testcases --- .../os-basic/oe_test_c_stat/oe_test_c_stat.sh | 15 ++++++------- .../oe_test_disk_tuned_set.sh | 12 ++++++++--- .../oe_test_get_module/oe_test_get_module.sh | 5 +++++ .../oe_test_kernel_kdump.sh | 15 +++++++++++-- .../os-basic/oe_test_libffi/libffi_test.c | 4 ++-- .../oe_test_logsave/oe_test_logsave.sh | 2 +- .../oe_test_net_mtr/oe_test_net_mtr.sh | 13 ++++++------ .../oe_test_power_measurement_internal.sh | 12 +++++------ .../oe_test_power_powertop_powerup.sh | 8 +++---- .../oe_test_system_log_recorded.sh | 21 ++++++++++++------- .../oe_test_timedatectl.sh | 8 +++---- 11 files changed, 72 insertions(+), 43 deletions(-) diff --git a/testcases/system-test/system-integration/os-basic/oe_test_c_stat/oe_test_c_stat.sh b/testcases/system-test/system-integration/os-basic/oe_test_c_stat/oe_test_c_stat.sh index d9821b255..26d0b9996 100644 --- a/testcases/system-test/system-integration/os-basic/oe_test_c_stat/oe_test_c_stat.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_c_stat/oe_test_c_stat.sh @@ -16,14 +16,14 @@ # @License : Mulan PSL v2 # @Desc : Use c_stat case # ############################################ - -source ${OET_PATH}/libs/locallibs/common_lib.sh +# shellcheck disable=SC2119 +source "${OET_PATH}/libs/locallibs/common_lib.sh" function pre_test() { LOG_INFO "Start to prepare the test environment." - pwd=`pwd` + pwd=$(pwd) DNF_INSTALL gcc - mkdir c_stat_test && cd c_stat_test + mkdir c_stat_test && cd c_stat_test || exit LOG_INFO "End to prepare the test environment." } @@ -43,6 +43,7 @@ EOF cat > teststat.c << EOF #include #include +void haha(struct stat *fileinfo); int main() { struct stat fileinfo; @@ -58,16 +59,16 @@ EOF CHECK_RESULT $? 0 0 "Error,fail to create teststat" gcc -D_FILE_OFFSET_BITS=64 -o teststat64 teststat.c ./haha.so CHECK_RESULT $? 0 0 "Error,fail to create teststat64" - result=`./teststat` + result=$(./teststat) CHECK_RESULT $? 0 0 "Error,check the file teststat" - ./teststat64 | grep $result + ./teststat64 | grep "$result" CHECK_RESULT $? 0 0 "Error,check the file teststat64" LOG_INFO "End to run test." } function post_test() { LOG_INFO "Start to restore the test environment." - cd $pwd && rm -rf c_stat_test/ + cd "$pwd" && rm -rf c_stat_test/ DNF_REMOVE LOG_INFO "End to restore the test environment." } diff --git a/testcases/system-test/system-integration/os-basic/oe_test_disk_tuned_set/oe_test_disk_tuned_set.sh b/testcases/system-test/system-integration/os-basic/oe_test_disk_tuned_set/oe_test_disk_tuned_set.sh index e406b6562..b29f1a24a 100755 --- a/testcases/system-test/system-integration/os-basic/oe_test_disk_tuned_set/oe_test_disk_tuned_set.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_disk_tuned_set/oe_test_disk_tuned_set.sh @@ -16,10 +16,11 @@ # @License : Mulan PSL v2 # @Desc : Setting up the disk scheduler using Tuned(For physical machines only) # ############################################# - -source ../common/disk_lib.sh +# shellcheck disable=SC2119 +source "${OET_PATH}/testcases/system-test/system-integration/os-basic/common/disk_lib.sh" function config_params() { LOG_INFO "Start to config the test environment." + local_disk="" check_free_disk LOG_INFO "Start to config the test environment." } @@ -49,6 +50,11 @@ include=my-profile_new [disk] devices_udev_regex=$ID_WWN elevator=mq-deadline" >/etc/tuned/my-profile/tuned.conf + if rpm -qa tuned | grep 2.24.1; then + test -d /etc/tuned/profiles || mkdir /etc/tuned/profiles + mv -f /etc/tuned/my-profile_new /etc/tuned/profiles + mv -f /etc/tuned/my-profile /etc/tuned/profiles + fi LOG_INFO "End to prepare the test environment." } @@ -74,4 +80,4 @@ function post_test() { LOG_INFO "End to restore the test environment." } -main $@ +main "$@" diff --git a/testcases/system-test/system-integration/os-basic/oe_test_get_module/oe_test_get_module.sh b/testcases/system-test/system-integration/os-basic/oe_test_get_module/oe_test_get_module.sh index c3dec15e3..69242b1dc 100644 --- a/testcases/system-test/system-integration/os-basic/oe_test_get_module/oe_test_get_module.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_get_module/oe_test_get_module.sh @@ -29,6 +29,11 @@ function run_test() { modinfo drm | grep sig CHECK_RESULT $? 0 1 "modinfo function error" fi + elif [[ "${NODE1_FRAME}" == "riscv64" ]]; then + modinfo kvm | grep file + CHECK_RESULT $? 0 0 "modinfo function error" + modinfo drm | grep file + CHECK_RESULT $? 0 0 "modinfo function error" else modinfo kvm | grep sig CHECK_RESULT $? 0 0 "modinfo function error" diff --git a/testcases/system-test/system-integration/os-basic/oe_test_kernel_kdump/oe_test_kernel_kdump.sh b/testcases/system-test/system-integration/os-basic/oe_test_kernel_kdump/oe_test_kernel_kdump.sh index 76fda0e2f..8fddc8067 100755 --- a/testcases/system-test/system-integration/os-basic/oe_test_kernel_kdump/oe_test_kernel_kdump.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_kernel_kdump/oe_test_kernel_kdump.sh @@ -17,7 +17,18 @@ # @Desc : KDUMP configuration # ############################################ -source ${OET_PATH}/libs/locallibs/common_lib.sh +source "${OET_PATH}/libs/locallibs/common_lib.sh" + +function pre_test() { + LOG_INFO "Start to prepare the test environment." + DNF_INSTALL kexec-tools + if ! grep -q "crashkernel=" /proc/cmdline; then + LOG_WARN "Skip this testcase: crashkernel parameter is not configured in kernel cmdline" + exit 255 + fi + LOG_INFO "End to prepare the test environment." +} + function run_test() { LOG_INFO "Start executing testcase." rpm -q kexec-tools @@ -42,4 +53,4 @@ function post_test() { LOG_INFO "Finish environment cleanup." } -main $@ +main "$@" diff --git a/testcases/system-test/system-integration/os-basic/oe_test_libffi/libffi_test.c b/testcases/system-test/system-integration/os-basic/oe_test_libffi/libffi_test.c index 104b8a71e..c3797a077 100644 --- a/testcases/system-test/system-integration/os-basic/oe_test_libffi/libffi_test.c +++ b/testcases/system-test/system-integration/os-basic/oe_test_libffi/libffi_test.c @@ -15,9 +15,9 @@ int main() &ffi_type_sint, args) == FFI_OK) { s = "Hello World!"; - ffi_call(&cif, puts, &rc, values); + ffi_call(&cif, (void (*)(void))puts, &rc, values); s = "This is cool!"; - ffi_call(&cif, puts, &rc, values); + ffi_call(&cif, (void (*)(void))puts, &rc, values); } return 0; } diff --git a/testcases/system-test/system-integration/os-basic/oe_test_logsave/oe_test_logsave.sh b/testcases/system-test/system-integration/os-basic/oe_test_logsave/oe_test_logsave.sh index 8752eddee..e973eeec1 100644 --- a/testcases/system-test/system-integration/os-basic/oe_test_logsave/oe_test_logsave.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_logsave/oe_test_logsave.sh @@ -26,7 +26,7 @@ function run_test() { grep Log log.txt CHECK_RESULT $? 0 0 "File view failed" logsave -a log.txt df -h - grep 文件系统 log.txt + grep -E 'Filesystem|文件系统' log.txt CHECK_RESULT $? 0 0 "File view failed" logsave -c log.txt ps aux grep usr log.txt diff --git a/testcases/system-test/system-integration/os-basic/oe_test_net_mtr/oe_test_net_mtr.sh b/testcases/system-test/system-integration/os-basic/oe_test_net_mtr/oe_test_net_mtr.sh index a2f1397b8..feb3f7512 100755 --- a/testcases/system-test/system-integration/os-basic/oe_test_net_mtr/oe_test_net_mtr.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_net_mtr/oe_test_net_mtr.sh @@ -16,7 +16,7 @@ # @License : Mulan PSL v2 # @Desc : Command test mtr # ############################################ - +# shellcheck disable=SC2119 source "${OET_PATH}"/libs/locallibs/common_lib.sh function pre_test() { LOG_INFO "Start environmental preparation." @@ -30,21 +30,20 @@ function run_test() { CHECK_RESULT $? 0 0 "check mtr version error" mtr -h CHECK_RESULT $? 0 0 "check mtr help error" - gateway=$(ip route | grep default | awk '{print $3}') mtr -n -r dns.google -c 15 > mtr.tmp1 2>&1 CHECK_RESULT $? 0 0 "execute -n -r -c cmd error" - s_value=$(grep "$gateway" mtr.tmp1 | awk '{print $4}') + s_value=$(awk 'NR>2 {print $4}' mtr.tmp1 | head -n1) CHECK_RESULT "${s_value}" 15 0 "check log error after execute -n -r -c" mtr -n -r -s 50 dns.google CHECK_RESULT $? 0 0 "execute -n -r -s cmd error" mtr -n --xml dns.google > mtr.tmp2 2>&1 CHECK_RESULT $? 0 0 "execute -n --xml cmd error" - grep "$gateway" mtr.tmp2 | grep '' + grep -q " mtr.tmp3 2>&1 CHECK_RESULT $? 0 0 "execute -n --csv cmd error" - target_value=$(grep "$gateway" mtr.tmp3 | awk -F ',' '{print $6}') - CHECK_RESULT "${target_value}" "$gateway" 0 "check log error after execute --csv" + grep -q "Host," mtr.tmp3 + CHECK_RESULT $? 0 0 "check log error after execute --csv" mtr -T -r dns.google CHECK_RESULT $? 0 0 "execute -T -r cmd error" mtr -u -r dns.google @@ -55,7 +54,7 @@ function run_test() { function post_test() { LOG_INFO "start environment cleanup." rm -rf mtr.tmp* - DNF_REMOVE "$@" + DNF_REMOVE LOG_INFO "Finish environment cleanup!" } main "$@" diff --git a/testcases/system-test/system-integration/os-basic/oe_test_power_measurement_internal/oe_test_power_measurement_internal.sh b/testcases/system-test/system-integration/os-basic/oe_test_power_measurement_internal/oe_test_power_measurement_internal.sh index 27b3bc0aa..fe30aa63f 100755 --- a/testcases/system-test/system-integration/os-basic/oe_test_power_measurement_internal/oe_test_power_measurement_internal.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_power_measurement_internal/oe_test_power_measurement_internal.sh @@ -16,8 +16,8 @@ # @License : Mulan PSL v2 # @Desc : Set the measurement interval # ############################################# - -source ${OET_PATH}/libs/locallibs/common_lib.sh +# shellcheck disable=SC2119 +source "${OET_PATH}/libs/locallibs/common_lib.sh" function pre_test() { LOG_INFO "Start to prepare the test environment." DNF_INSTALL powertop @@ -26,10 +26,10 @@ function pre_test() { function run_test() { LOG_INFO "Start to run test." - nohup powertop --time=time in seconds >nohup.out 2>&1 & - SLEEP_WAIT 2 + nohup powertop --time=5 in seconds >nohup.out 2>&1 & + SLEEP_WAIT 5 nopid=$(pgrep -f "powertop --time") - kill -9 $nopid + kill -9 "$nopid" grep "wakeups/second" nohup.out CHECK_RESULT $? LOG_INFO "End to run test." @@ -42,4 +42,4 @@ function post_test() { LOG_INFO "End to restore the test environment." } -main $@ +main "$@" diff --git a/testcases/system-test/system-integration/os-basic/oe_test_power_powertop_powerup/oe_test_power_powertop_powerup.sh b/testcases/system-test/system-integration/os-basic/oe_test_power_powertop_powerup/oe_test_power_powertop_powerup.sh index 1693179a8..4685a91a1 100755 --- a/testcases/system-test/system-integration/os-basic/oe_test_power_powertop_powerup/oe_test_power_powertop_powerup.sh +++ b/testcases/system-test/system-integration/os-basic/oe_test_power_powertop_powerup/oe_test_power_powertop_powerup.sh @@ -16,8 +16,8 @@ # @License : Mulan PSL v2 # @Desc : Power up the POWERTOP # ############################################# - -source ${OET_PATH}/libs/locallibs/common_lib.sh +# shellcheck disable=SC2119 +source "${OET_PATH}/libs/locallibs/common_lib.sh" function pre_test() { LOG_INFO "Start to prepare the test environment." DNF_INSTALL powertop @@ -28,7 +28,7 @@ function run_test() { LOG_INFO "Start to run test." nohup powertop >nohup.out 2>&1 & nopid=$! - SLEEP_WAIT 2 + SLEEP_WAIT 5 kill -9 $nopid grep "wakeups/second"