From c6d33c6488423913ea2432713601cc55d64a255c Mon Sep 17 00:00:00 2001 From: Tony Zhu Date: Tue, 21 Nov 2023 16:43:18 +0800 Subject: [PATCH] SPLITLOCK test: add split lock test items into tests This test includes two test items, the first one will check cpuinfo, the second one will call split lock test to trigger an execption. Signed-off-by: Tony Zhu --- splitlock/split_lock.sh | 70 +++++++++++++++++++++++++++++++++++++++++ splitlock/tests | 5 +++ 2 files changed, 75 insertions(+) create mode 100755 splitlock/split_lock.sh create mode 100755 splitlock/tests diff --git a/splitlock/split_lock.sh b/splitlock/split_lock.sh new file mode 100755 index 00000000..77b925d9 --- /dev/null +++ b/splitlock/split_lock.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2023 Intel Corporation +# Description: Test script for split lock of CPU + +cd "$(dirname "$0")" 2>/dev/null && source ../.env + +: "${CASE_NAME:="check_cpu_info"}" + +usage() { + cat <<__EOF + usage: ./${0##*/} [-t TESTCASE_ID] [-H] + -t TEST CASE ID + -H show this +__EOF +} + +# Check this feature is enabled/supported +# Return: 0 for true, otherwise false +check_cpu_info() { + local cpu_func="split_lock_detect" + grep -q "$cpu_func" /proc/cpuinfo || block_test "CPU not support:$cpu_func" + test_print_trc "/proc/cpuinfo contain '$cpu_func'" +} + +# Call split lock test and check dmesg if #AC is triggered +split_lock_ac() { + local ac_dmesg_start=$(dmesg | grep "x86/split lock detection: #" | wc -l) + sl_test + local ac_dmesg_end=$(dmesg | grep "x86/split lock detection: #" | wc -l) + grep -q "split_lock_detect=fatal" /proc/cmdline && block_test "If set is fatal won't trigger #AC" + if [[ $ac_dmesg_end -gt $ac_dmesg_start ]];then + test_print_trc "split_lock_dect: [PASS]" + else + die "split_lock_dect: [FAIL]" + fi +} + +split_lock_test() { + case $TEST_SCENARIO in + sl_on_default) + check_cpu_info + ;; + check_ac_dmesg) + split_lock_ac + ;; + esac + return 0 +} + +while getopts :t:H arg; do + case $arg in + t) + TEST_SCENARIO=$OPTARG + ;; + H) + usage && exit 0 + ;; + \?) + usage + die "Invalid Option -$OPTARG" + ;; + :) + usage + die "Option -$OPTARG requires an argument." + ;; + esac +done + +split_lock_test diff --git a/splitlock/tests b/splitlock/tests new file mode 100755 index 00000000..168d8ba5 --- /dev/null +++ b/splitlock/tests @@ -0,0 +1,5 @@ +# This file collects the split lock feature tests on +# IntelĀ® Architecture-based platforms. + +split_lock.sh -t sl_on_default +split_lock.sh -t check_ac_dmesg