diff --git a/testcases/cli-test/fakechroot/oe_test_fakechroot_chroot.sh b/testcases/cli-test/fakechroot/oe_test_fakechroot_chroot.sh index 7e1ebbfe2965cda97312cd404226e64f234aea59..254818ad459109cc297d4d562e4dd68061b179ac 100644 --- a/testcases/cli-test/fakechroot/oe_test_fakechroot_chroot.sh +++ b/testcases/cli-test/fakechroot/oe_test_fakechroot_chroot.sh @@ -16,12 +16,12 @@ # @License : Mulan PSL v2 # @Desc : verify the uasge of fakechroot command # ############################################ +# shellcheck disable=SC1091 -source ${OET_PATH}/libs/locallibs/common_lib.sh +source "${OET_PATH}"/libs/locallibs/common_lib.sh function pre_test() { LOG_INFO "Start environmental preparation." - DNF_INSTALL fakechroot cp ./common/hello.sh ./ chmod 777 hello.sh LOG_INFO "End of environmental preparation!" @@ -36,7 +36,7 @@ function run_test() { chroot --userspec=root:root --skip-chdir / ./hello.sh | grep "hello world!" CHECK_RESULT $? 0 0 "Check chroot --userspec --skip-chdir failed" - chroot --help | fgrep "Usage: chroot [OPTION]" + chroot --help | grep -F "Usage: chroot [OPTION]" CHECK_RESULT $? 0 0 "Check chroot --help failed" chroot --version | grep "chroot (GNU coreutils) [[:digit:]]" @@ -47,7 +47,6 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - DNF_REMOVE rm -rf hello.sh test LOG_INFO "Finish restore the test environment." } diff --git a/testcases/cli-test/fakechroot/oe_test_fakechroot_env_01.sh b/testcases/cli-test/fakechroot/oe_test_fakechroot_env_01.sh index bb59d183b48951e85337c01b9a3c3bee2dd99d25..8091645e64b13044e41cec21e2156e1ac3bcc626 100644 --- a/testcases/cli-test/fakechroot/oe_test_fakechroot_env_01.sh +++ b/testcases/cli-test/fakechroot/oe_test_fakechroot_env_01.sh @@ -16,12 +16,12 @@ # @License : Mulan PSL v2 # @Desc : verify the uasge of fakechroot command # ############################################ +# shellcheck disable=SC1091 -source ${OET_PATH}/libs/locallibs/common_lib.sh +source "${OET_PATH}"/libs/locallibs/common_lib.sh function pre_test() { LOG_INFO "Start environmental preparation." - DNF_INSTALL fakechroot cp ./common/hello.sh ./ chmod 777 hello.sh mkdir test @@ -68,7 +68,6 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - DNF_REMOVE rm -rf hello.sh test LOG_INFO "Finish restore the test environment." } diff --git a/testcases/cli-test/fakechroot/oe_test_fakechroot_env_02.sh b/testcases/cli-test/fakechroot/oe_test_fakechroot_env_02.sh index fc2cee94cec55c7f0fab4621e37ce905c0bd6adc..968d7772f11b3e8548f0c65ffafae7a806b1ad94 100644 --- a/testcases/cli-test/fakechroot/oe_test_fakechroot_env_02.sh +++ b/testcases/cli-test/fakechroot/oe_test_fakechroot_env_02.sh @@ -16,12 +16,12 @@ # @License : Mulan PSL v2 # @Desc : verify the uasge of fakechroot command # ############################################ +# shellcheck disable=SC1091 -source ${OET_PATH}/libs/locallibs/common_lib.sh +source "${OET_PATH}"/libs/locallibs/common_lib.sh function pre_test() { LOG_INFO "Start environmental preparation." - DNF_INSTALL fakechroot cp ./common/hello.sh ./ chmod 777 hello.sh LOG_INFO "End of environmental preparation!" @@ -48,7 +48,7 @@ function run_test() { env --debug | grep "USER=" CHECK_RESULT $? 0 0 "Check env --debug failed" - env --help | fgrep "Usage: env [OPTION]" + env --help | grep -F "Usage: env [OPTION]" CHECK_RESULT $? 0 0 "Check env --help failed" env --version | grep "env (GNU coreutils) [[:digit:]]" @@ -59,7 +59,6 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - DNF_REMOVE rm -rf hello.sh LOG_INFO "Finish restore the test environment." } diff --git a/testcases/cli-test/libosinfo/oe_test_osinfo-db-import/oe_test_osinfo-db-import.sh b/testcases/cli-test/libosinfo/oe_test_osinfo-db-import/oe_test_osinfo-db-import.sh index 900c7986f666bd038a96844f2b2d52917703ea5c..67b4ac9eddfea197689f760a30df8437ccb9ab20 100644 --- a/testcases/cli-test/libosinfo/oe_test_osinfo-db-import/oe_test_osinfo-db-import.sh +++ b/testcases/cli-test/libosinfo/oe_test_osinfo-db-import/oe_test_osinfo-db-import.sh @@ -22,7 +22,7 @@ source "$OET_PATH/libs/locallibs/common_lib.sh" function pre_test() { LOG_INFO "Start to prepare the test environment." DNF_INSTALL "osinfo-db-tools" - pwd=`pwd` + pwd=$(pwd) LOG_INFO "Finish preparing the test environment." } @@ -32,19 +32,19 @@ function run_test() { osinfo-db-import --local osinfo-db-20230308.tar.xz CHECK_RESULT $? 0 0 "Failed to import data" mkdir testdir - cd testdir + cd testdir || exit osinfo-db-export CHECK_RESULT $? 0 0 "Failed to export data" - test -e osinfo-db-20230331.tar.xz + test -e osinfo-db-20230308.tar.xz CHECK_RESULT $? 0 0 "Export file does not exist" LOG_INFO "End of the test." } function post_test() { LOG_INFO "Start to restore the test environment." - cd $pwd + cd "$pwd" || exit rm -rf testdir osinfo-db-20230308.tar.xz - DNF_REMOVE + DNF_REMOVE "$@" LOG_INFO "Finish restoring the test environment." } diff --git a/testcases/cli-test/nototools/oe_test_nototools_0.2.17_notodiff/oe_test_nototools_0.2.17_notodiff.sh b/testcases/cli-test/nototools/oe_test_nototools_0.2.17_notodiff/oe_test_nototools_0.2.17_notodiff.sh index 2b8665d8a1cc7b9425f73d167cabcef6a77ac1f0..5c99e9bbd6c2ebbb3c5c0cf2c9aa9ccdd91c2da4 100644 --- a/testcases/cli-test/nototools/oe_test_nototools_0.2.17_notodiff/oe_test_nototools_0.2.17_notodiff.sh +++ b/testcases/cli-test/nototools/oe_test_nototools_0.2.17_notodiff/oe_test_nototools_0.2.17_notodiff.sh @@ -17,8 +17,10 @@ # @License : Mulan PSL v2 # @Desc : TEST notodiff in nototools options # ############################################# +# shellcheck disable=SC1091 -source ${OET_PATH}/libs/locallibs/common_lib.sh +source "${OET_PATH}"/libs/locallibs/common_lib.sh +source ../common/common.sh # Preloaded data, parameter configuration function config_params() { @@ -53,60 +55,60 @@ function run_test() { CHECK_RESULT $? 0 0 "option: --help error" #Test the --before,--after parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --before,--after error" #Test the -t parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -t area | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -t area | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: -t area error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --diff-type shape | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --diff-type shape | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --diff-type shape error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -t area-shape-product | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -t area-shape-product | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: -t area-shape-product error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --diff-type rendered | grep -q "3 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --diff-type rendered | grep -q "3 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --diff-type rendered error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -t gsub | grep -q "9 differences in GSUB rules" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -t gsub | grep -q "9 differences in GSUB rules" CHECK_RESULT $? 0 0 "option: -t gsub error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --diff-type gpos | grep -qE "115 differences in mark-to-mark positioning rule coverage|0 differences in mark-to-mark positioning rule values" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --diff-type gpos | grep -qE "115 differences in mark-to-mark positioning rule coverage|0 differences in mark-to-mark positioning rule values" CHECK_RESULT $? 0 0 "option: --diff-type gpos error" #Test the -m parameter - notodiff --before test_input/test_input_1 --after test_input/test_input_2 -m *.ttf | grep -q "17 differences in glyph shape" + notodiff -- *glob* test_input/test_input_1 test_input/test_input_2 -m *.ttf | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: -m error" - notodiff --before test_input/test_input_1 --after test_input/test_input_2 --match *.ttf | grep -q "17 differences in glyph shape" + notodiff -- *glob* test_input/test_input_1 test_input/test_input_2 --match *.ttf | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --match error" #Test the -l parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -l 10 | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -l 10 | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: -l error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --out-lines 10 | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --out-lines 10 | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --out-lines error" #Test the -w parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -w ${MISS_LIST} | grep -q "15 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -w "${MISS_LIST}" | grep -q "15 differences in glyph shape" CHECK_RESULT $? 0 0 "option: -w error" - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --allowlist ${MISS_LIST} | grep -q "15 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --allowlist "${MISS_LIST}" | grep -q "15 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --allowlist error" #Test the --font-size parameter for i in "64" "128" do - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -t rendered --font-size ${i} | grep -q "3 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -t rendered --font-size ${i} | grep -q "3 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --font-size ${i} error" done #Test the --render-path parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} -t rendered --render-path ${TMP_DIR} | grep -q "3 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" -t rendered --render-path "${TMP_DIR}" | grep -q "3 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --render-path error" #Test the --diff-threshold parameter - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --diff-threshold 1 | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --diff-threshold 1 | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --diff-threshold error" #Test the --verbose parameter for i in "debug" "info" "warning" "critical" "error" do - notodiff --before test_input/test_input_1/${TEST_FILE_1} --after test_input/test_input_1/${TEST_FILE_2} --verbose ${i} | grep -q "17 differences in glyph shape" + notodiff --before test_input/test_input_1/"${TEST_FILE_1}" --after test_input/test_input_1/"${TEST_FILE_2}" --verbose ${i} | grep -q "17 differences in glyph shape" CHECK_RESULT $? 0 0 "option: --verbose ${i} error" done @@ -117,7 +119,7 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - rm -rf ${TMP_DIR} + rm -rf "${TMP_DIR}" common_post LOG_INFO "End to restore the test environment." diff --git a/testcases/cli-test/pyyaml/oe_test_pyyaml.sh b/testcases/cli-test/pyyaml/oe_test_pyyaml.sh index 823d802626481474fdc17d8d1993c78cb6a58bdd..00ffbd46c0e4b25ba23062c95200031edcc5de45 100644 --- a/testcases/cli-test/pyyaml/oe_test_pyyaml.sh +++ b/testcases/cli-test/pyyaml/oe_test_pyyaml.sh @@ -17,7 +17,7 @@ # @Desc : pyyaml function verification # ############################################ -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 "python3-pyyaml" @@ -39,7 +39,7 @@ function run_test() { function post_test() { LOG_INFO "Start to restore the test environment." - DNF_REMOVE + DNF_REMOVE "$@" rm -f generate.yaml LOG_INFO "End to restore the test environment." } diff --git a/testcases/embedded-test/version_basic_tests/oe_test_version_posix_suite_test_001/oe_test_version_posix_suite_test_001.sh b/testcases/embedded-test/version_basic_tests/oe_test_version_posix_suite_test_001/oe_test_version_posix_suite_test_001.sh index 2b10f7d018cd2e28cfce7dea9629466e4f57858c..20d8ce563b54f300b2c1925a2197af051a9dfffb 100644 --- a/testcases/embedded-test/version_basic_tests/oe_test_version_posix_suite_test_001/oe_test_version_posix_suite_test_001.sh +++ b/testcases/embedded-test/version_basic_tests/oe_test_version_posix_suite_test_001/oe_test_version_posix_suite_test_001.sh @@ -15,23 +15,24 @@ #@License : Mulan PSL v2 #@Desc : run posix test suite ##################################### +# shellcheck disable=SC1091 -source ../comm_lib.sh +source ../../common_libs/comm_lib.sh -CUR_DATE=`date +'%Y-%m-%d %H:%M:%S'` +CUR_DATE=$(date +'%Y-%m-%d %H:%M:%S') # 测试对象、测试需要的工具等安装准备 function pre_test() { LOG_INFO "Start to prepare the test environment." - EXECUTE_T="180m" + # EXECUTE_T="180m" MAKEDIR=$(cd .. && pwd) - chmod 777 ${MAKEDIR}/make + chmod 777 "${MAKEDIR}"/make MAKE=${MAKEDIR}/make - timestap=`stat -c %Y tmp_test/build.log` - formart_date=`date '+%Y-%m-%d %H:%M:%S' -d @$timestap` + timestap=$(stat -c %Y tmp_test/build.log) + formart_date=$(date '+%Y-%m-%d %H:%M:%S' -d @"$timestap") date -s "$formart_date" LOG_INFO "End to prepare the test environment." @@ -41,26 +42,26 @@ function pre_test() { function run_test() { LOG_INFO "Start to run test." - pushd tmp_test/ - pushd posixtestsuite/ + pushd tmp_test/ || exit + pushd posixtestsuite/ || exit POSIX_TARGET=./ ${MAKE} run-tests > ../run.log 2>&1 - popd + popd || exit awk -F': ' '{if(($2=="build" && $3!="PASS") || ($2=="link" && $3!="PASS") || (($2=="execution" && $3=="PASS"))) print $1}' build.log > skip.name cat ../ignore.out >> skip.name awk -F': ' '{if($2=="execution" && $3!="PASS") print $1}' run.log > fail.name - while read line || [[ -n $line ]]; do - grep -q $line skip.name - if [ $? -eq 0 ]; then + while read -r line || [[ -n $line ]]; do + grep -q "$line" skip.name + if mycmd; then continue fi # 单独再执行一次 - ./posixtestsuite/$line.test + ./posixtestsuite/"$line".test CHECK_RESULT $? 0 0 "run posix testcase fail case name: $line" done < fail.name - popd + popd || exit LOG_INFO "End to run test." }