Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependence #211

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cet/tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 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: 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
cet_tests.sh -t cp_test -n shstk_cp -k "control protection"
Expand Down
50 changes: 48 additions & 2 deletions common/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ 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

# For each expression between '|' separators
if [[ $(get_kconfig "$name") != "$value" ]]; then
test_print_err "$name does not match $value!"
test_print_trc "$name does not match $value!"
return 1
else
test_print_trc "$name matches with expect $value"
Expand Down Expand Up @@ -359,6 +359,52 @@ dmesg_pattern_check() {
return 1
}

# Check whole dmesg, which should contain key words
# Input $1: key word
# Output: 0 for true, otherwise false or die
full_dmesg_check() {
local type=$1
local keyword1=$2
local keyword2=$3
local keyword3=$4
local null="null"
local contain="contain"
local dmesg_head=""
local check_log=""

dmesg_head=$(dmesg | grep "\[ 0.000000\]" | head -n 1)
[[ -n $dmesg_head ]] \
|| test_print_wrg "Dmesg is not started from 0.000000!"
check_log=$(dmesg | grep -v "dmesg" | grep -i "$keyword1" \
| grep -i "$keyword2" \
| grep -i "$keyword3")

case $type in
"$contain")
if [[ -n "$check_log" ]]; then
test_print_trc "Dmesg contains $keyword1 $keyword2:$check_log, pass"
else
test_print_wrg "Dmesg doesn't contain $keyword1 $keyword2:$check_log, fail"
return 1
fi
;;
"$null")
if [[ -z "$check_log" ]]; then
test_print_trc "Dmesg doesn't contain $keyword1 $keyword2:$check_log, pass"
else
test_print_wrg "Dmesg contains $keyword1 $keyword2:$check_log, fail"
return 1
fi
;;
*)
test_print_wrg "Invalid type:$type"
return 2
;;
esac

return 0
}

# Record last timestamp in dmesg and store the value in variable
# LAST_DMESG_TIMESTAMP. The value is refered in function extract_case_dmesg.
last_dmesg_timestamp() {
Expand Down
66 changes: 66 additions & 0 deletions common/general_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/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
;;
dmesg)
key1=$(echo "$KEYWORD" | awk -F '&' '{print $1}')
key2=$(echo "$KEYWORD" | awk -F '&' '{print $2}')\
key3=$(echo "$KEYWORD" | awk -F '&' '{print $3}')
full_dmesg_check "$PARM" "$key1" "$key2" "$key3" || return $?
;;
*)
die "Invalid TYPE:$TYPE"
;;
esac
}

while getopts :t:p:k:h arg; do
case $arg in
t)
TYPE=$OPTARG
;;
p)
PARM=$OPTARG
;;
k)
KEYWORD=$OPTARG
;;
h)
usage
exit 0
;;
*)
usage
die "Option -$OPTARG requires an argument."
;;
esac
done

general_test
6 changes: 3 additions & 3 deletions ifs/ifs_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# Description: Test script to verify Intel IFS(In Field SCAN) functionality

cd "$(dirname "$0")" 2>/dev/null || exit 1
# shellcheck source=/dev/null
source ../.env

# shellcheck source=/dev/null
source "ifs_common.sh"

basic_usage() {
Expand Down Expand Up @@ -56,7 +57,6 @@ run_ifs_tests() {
check_file_content "${IFS_PATH}/${BATCH}" "none" "$CONTAIN"
check_file_content "${IFS_PATH}/${VERSION}" "none" "$CONTAIN"
init_log "$NAME"
dump_ifs_test "$NAME"
;;
ifs_batch)
modprobe -r "$IFS_NAME"
Expand All @@ -70,9 +70,9 @@ run_ifs_tests() {
check_file_content "${IFS_PATH}/${VERSION}" "none" "$NE"
else
test_print_wrg "No ${IFS_PATH}/${BATCH} file, is it 5.15 or old ifs kernel?"
return 2
fi
init_log "$NAME"
dump_ifs_test "$NAME"
;;
"$IMG_VERSION")
modprobe -r "$IFS_NAME"
Expand Down
4 changes: 3 additions & 1 deletion ifs/tests
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file collects Intel IFS(In Field SCAN) tests on
# Intel® Architecture-based platforms.

# @hw_dep:
# @other_dep: general_test.sh -t kconfig -k "CONFIG_INTEL_IFS=m"
# @other_warn: ifs_tests.sh -m 0 -p all -b 1 -n ifs_batch @ check if SGX init ok and DIMM proper set as IFS relies on enabled SGX
# ifs_0 scan test cases, it works on SPR(Sapphire Rapids) platform and future server
ifs_tests.sh -m 0 -p all -n load_ifs
ifs_tests.sh -m 0 -p all -b 1 -n ifs_batch
Expand Down
Loading
Loading