From 2252d7078cd634ae13fff4cb6cc11e1a3887ee62 Mon Sep 17 00:00:00 2001 From: ChenKang256 Date: Wed, 1 May 2024 22:34:39 +0800 Subject: [PATCH] struts shell check shell check dnf install set date language --- testcases/cli-test/struts/oe_test_struts_001.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/testcases/cli-test/struts/oe_test_struts_001.sh b/testcases/cli-test/struts/oe_test_struts_001.sh index f9c53841e..ce0e4c0ff 100644 --- a/testcases/cli-test/struts/oe_test_struts_001.sh +++ b/testcases/cli-test/struts/oe_test_struts_001.sh @@ -16,14 +16,16 @@ # @License : Mulan PSL v2 # @Desc : Test strust function # ############################################# - +# shellcheck disable=SC2002,SC2035 source "$OET_PATH/libs/locallibs/common_lib.sh" function pre_test() { LOG_INFO "Start to prepare the test environment." - DNF_INSTALL "struts" + DNF_INSTALL "struts tar binutils" mkdir /tmp/test - cd /tmp/test + cd /tmp/test || exit + old_lc_time=$(locale | grep LC_TIME | awk -F= '{print $2}' | tr -d '"') + export LC_TIME=en_US.UTF-8 LOG_INFO "End to prepare the test environment." } @@ -34,10 +36,10 @@ function run_test() { test -e checkSo CHECK_RESULT $? 0 0 "Decompression failure" yum download struts - cd checkSo/;chmod 755 * - ./main.sh /tmp/test/struts*.rpm | grep 'unpack file /checkSo/tmp_unzip/struts';testtime=$(date) + cd checkSo/ || exit;chmod 755 * + ./main.sh /tmp/test/struts*.rpm | grep 'unpack file /checkSo/tmp_unzip/struts';testtime=$(date '+%a %b') CHECK_RESULT $? 0 0 "Execution failure" - [[ `cat JarResult.log |wc -l` -eq 0 ]] + [[ $(cat JarResult.log |wc -l) -eq 0 ]] CHECK_RESULT $? 0 0 "Execution failure2" cat NonJarResult.log | grep "$testtime" CHECK_RESULT $? 0 0 "Execution failure3" @@ -46,9 +48,10 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - DNF_REMOVE + DNF_REMOVE "$@" rm -rf /tmp/test unset testtime + export LC_TIME=${old_lc_time} LOG_INFO "End to restore the test environment." } -- Gitee