From bb5c8af09a0e03cc1658a4a9b05d0b1c8080a108 Mon Sep 17 00:00:00 2001 From: Pengfei Xu Date: Tue, 23 Apr 2024 17:15:40 +0800 Subject: [PATCH] cet: add the kconfig check for kernel dependence check Signed-off-by: Pengfei Xu --- cet/tests | 2 +- common/common.sh | 2 +- common/general_test.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 2 deletions(-) create mode 100755 common/general_test.sh diff --git a/cet/tests b/cet/tests index 3d2752fe..658826a0 100755 --- a/cet/tests +++ b/cet/tests @@ -1,7 +1,7 @@ # This file collects the CET(Control-flow Enforcement Technology) tests on # IntelĀ® Architecture-based platforms. # @hw_dep: cpuid_check 7 0 0 0 c 7 @ HW cpuid could not support CET SHSTK -# @other_dep: +# @other_dep: general_test.sh -t kconfig -k "CONFIG_X86_USER_SHADOW_STACK=y" # @other_warn: quick_test @ Glibc could not support CET # User space SHSTK tests without SHSTK Glibc supported diff --git a/common/common.sh b/common/common.sh index b66b1db7..80b9d587 100755 --- a/common/common.sh +++ b/common/common.sh @@ -236,7 +236,7 @@ test_kconfig() { local name="$2" if [[ ! "$value" =~ [ymn] ]]; then - test_print_err "Invalid koption value!" + test_print_err "Invalid koption value:$value" return 1 fi diff --git a/common/general_test.sh b/common/general_test.sh new file mode 100755 index 00000000..422f0a31 --- /dev/null +++ b/common/general_test.sh @@ -0,0 +1,61 @@ +#!/bin/bash +############################################################################### +# SPDX-License-Identifier: GPL-2.0-only # +# Copyright (c) 2024 Intel Corporation. # +# For general check like KCONFIG, CPU family model stepping # +############################################################################### + +# shellcheck source=/dev/null +cd "$(dirname "$0")" 2>/dev/null && source ../.env + +usage() { + cat <<__EOF + usage: ./${0##*/} [-t TEST_TYPE][-k KCONFIG or keywrod][-p parm][-h] + -t Test type like KCONFIG, FMS + -k KCONFIG name like CONFIG_XXX or keyword + -p PARM like y, null + -h show This +__EOF +} + +general_test() { + case $TYPE in + kconfig) + config_name=$(echo "$KEYWORD" | cut -d '=' -f1) + config_val=$(echo "$KEYWORD" | cut -d '=' -f2) + test_any_kconfig_match "$config_name" "$config_val" + ;; + # family model stepping check + fms) + #TODO, will add the fms check function + ;; + *) + die "Invalid TYPE:$TYPE" + ;; + esac +} + +while getopts :t:p:k:h arg; do + case $arg in + t) + TYPE=$OPTARG + ;; + p) + # TODO, will add more function to use PARM + # PARM=$OPTARG + ;; + k) + KEYWORD=$OPTARG + ;; + h) + usage + exit 0 + ;; + *) + usage + die "Option -$OPTARG requires an argument." + ;; + esac +done + +general_test