diff --git a/tests/function/cpu/cpu.yaml b/tests/function/cpu/cpu.yaml index 8350f2b458efddef81dd549f9cd14ed2fee60f0b..c6ae39f3108e5bca34b63f50f9e3e4d52d91d5e7 100644 --- a/tests/function/cpu/cpu.yaml +++ b/tests/function/cpu/cpu.yaml @@ -13,6 +13,8 @@ testgroup: - ras_platform_correctable - ras_platform_uncorrectable_non_fatal - ras_platform_uncorrectable_fatal + group2: + - cpu_pcie cases: - name: ras_core_correctable feature: ['ras'] @@ -85,4 +87,9 @@ cases: description: test ras_platform_uncorrectable_fatal filepath: ras_platform_uncorrectable_fatal.sh filetype: shell - runtime: 60 \ No newline at end of file + runtime: 60 + - name: cpu_pcie + feature: ['pcie'] + description: test cpu pcie features + filepath: cpu_pcie.sh + filetype: shell diff --git a/tests/function/cpu/cpu_pcie.sh b/tests/function/cpu/cpu_pcie.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f1d271ea15da1eec0163be23370da4cf1b1eec8 --- /dev/null +++ b/tests/function/cpu/cpu_pcie.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +source ../../lib/shell/env.sh +source ../../lib/shell/common.sh + +declare options="CPU_PCIE_ACS CPU_PCIE_ACS CPU_PCIE_AER CPU_PCIE_ASPM CPU_PCIE_ATOMIC CPU_PCIE_BAR CPU_PCIE_FLR CPU_PCIE_HOTPLUG + CPU_PCIE_INTX CPU_PCIE_MPS CPU_PCIE_MRRS CPU_PCIE_MSIX CPU_PCIE_PME CPU_PCIE_SRIOV" + +function clean_log() { + echo -e "\n==============[cleanup log]================" + for op in $options;do + if test -f "${op,,}.log";then + echo "cleanup ${op,,}.log`rm -rf ${op,,}.log`" + fi + done +} + +function cpu_pcie_features_test() { + local failed_msg="" + + echo "Start cpu pcie features test..." + for op in $options;do + #check env + if test -n "${!op}";then + test -f "${op,,}.log" && rm -rf "${op,,}.log" + else + echo "Error: Environment variables ${op} have not taken effect!" && test_fail + fi + + #run features test + echo -e "\n[features--->${op,,}]" + echo "sudo lspci -vv | grep \"${!op}\"" + sudo lspci -vv | grep "${!op}" >> ${op,,}.log & + done + wait + echo "Complete cpu pcie features test." + + echo -e "\nCheck cpu pcie features test result." + for op in $options;do + if test -f "${op,,}.log";then + if grep "${!op}" "${op,,}.log" >/dev/null 2>&1;then + #The file exists and the contents are not empty + echo -e "\n==============[${!op}]================" + while read line; do echo $line; done < ${op,,}.log + else + failed_msg="${failed_msg}Failed to detect \"${!op}\" for ${op,,} test.\n" + fi + else + failed_msg="${failed_msg}Failed to detect \"${!op}\" for ${op,,} test.\n" + fi + done + [ -n "$failed_msg" ] && { echo -e "\n==============================\n$failed_msg";test_fail; } +} + +trap "clean_log" EXIT +# # # # # # # # # # # # # # main # # # # # # # # # # # # # # +func_cpu_env +cpu_pcie_features_test +test_pass diff --git a/tests/lib/shell/env.sh b/tests/lib/shell/env.sh index ad8d597a9f6f9c921d1dc228f56c03e66dd5ddbb..91c8863925eb2631b952485929b3618cd40c638b 100644 --- a/tests/lib/shell/env.sh +++ b/tests/lib/shell/env.sh @@ -1,3 +1,21 @@ +#!/bin/bash + + +function func_cpu_env() { + CPU_PCIE_ACS="Access Control Services" + CPU_PCIE_AER="Advanced Error Reporting" + CPU_PCIE_ASPM="ASPM not supported" + CPU_PCIE_ATOMIC="Atomic" + CPU_PCIE_BAR="BAR" + CPU_PCIE_FLR="FLReset+" + CPU_PCIE_HOTPLUG=" HotPlug+" + CPU_PCIE_INTX=" INTx" + CPU_PCIE_MPS="MaxPayload" + CPU_PCIE_MRRS="MaxReadReq" + CPU_PCIE_MSIX="MSI-X: Enable+" + CPU_PCIE_PME="PME" + CPU_PCIE_SRIOV="SR-IOV" +} #!/usr/bin/env bash