Skip to content

Commit

Permalink
[guest-test] Test Enhance: update based on test_executor refactoring
Browse files Browse the repository at this point in the history
update previous osv_sanity implementation reference based on
test_executor refactoring

[Test Components] tdx
[Test Types] func
[Supported Devices] spr,emr,gnr,srf

Signed-off-by: Hongyu Ning <[email protected]>
  • Loading branch information
hongyuni committed Dec 8, 2023
1 parent 7c434a0 commit a360f20
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 7 deletions.
4 changes: 2 additions & 2 deletions guest-test/guest.test_executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
###################### Variables ######################
# exec only if script being executed
if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
SCRIPT_DIR=$( cd $( dirname "$0" ) && pwd )
echo "$SCRIPT_DIR"
else # bypass above execution in case of being sourced
ehco "guest.test_executor.sh being sourced"
echo "guest.test_executor.sh being sourced"
fi
GUEST_TEST_DIR="/root/guest_test/"

Expand Down
4 changes: 0 additions & 4 deletions guest-test/osv_sanity/test_2.1.1.4

This file was deleted.

2 changes: 1 addition & 1 deletion guest-test/tdx/tdx.test_executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

###################### Variables ######################
## common variables example ##
SCRIPT_DIR_LOCAL="$( cd "$( dirname "$0" )" && pwd )"
SCRIPT_DIR_LOCAL=$( cd $( dirname "$0" ) && pwd )
echo "$SCRIPT_DIR_LOCAL"
# get test scenario config for $FEATURE tdx test_executor
source "$SCRIPT_DIR_LOCAL"/../test_params.py
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
82 changes: 82 additions & 0 deletions guest-test/tdx_osv_sanity/tdx_osv_sanity.test_executor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2023 Intel Corporation

# Author: Hongyu Ning <[email protected]>
#
# History: 5, Dec., 2023 - Hongyu Ning - creation


# @desc This script prepare and run $TESTCASE in for $FEATURE tdx_osv_sanity
# in tdx VM; please note, $FEATURE name and subfolder name under guest-test
# must be the exactly same, here FEATURE=tdx_osv_sanity

###################### Variables ######################
## common variables example ##
SCRIPT_DIR_LOCAL=$( cd $( dirname "$0" ) && pwd )
echo "$SCRIPT_DIR_LOCAL"
# get test scenario config for $FEATURE tdx test_executor
source "$SCRIPT_DIR_LOCAL"/../test_params.py
## end of common variables example ##

###################### Functions ######################
## $FEATURE specific Functions ##

###################### Do Works ######################
## common works example ##
cd $(dirname "$0") 2>/dev/null || exit 1
source ../../.env

# get test_executor common functions:
# function based on sshpass to scp common.sh and $1 test_script.sh to Guest VM
## guest_test_prepare
# function based on sshpass to scp $1 source_code_dir and compile $2 test_binary in Guest VM
## guest_test_source_code
# function based on sshpass to execute $1 test_script.sh and potential $2 script params in Guest VM
## guest_test_entry
# function based on sshpass to close VM
## guest_test_close
source "$SCRIPT_DIR"/guest.test_executor.sh

cd "$SCRIPT_DIR_LOCAL" || die "fail to switch to $SCRIPT_DIR_LOCAL"
## end of common works example ##

## $FEATURE specific code path ##
# select test_functions by $TESTCASE
case "$TESTCASE" in
GUEST_TESTCASE_EXAMPLE)
guest_test_prepare guest_test.sh
guest_test_source_code test_source_code_dir_example test_binary_example
guest_test_entry guest_test.sh "-t $TESTCASE" || \
die "Failed on $TESTCASE guest_test.sh -t $TESTCASE"
if [[ $GCOV == "off" ]]; then
guest_test_close
fi
;;
TD_TSC_DEFAULT)
guest_test_prepare tdx_guest_tsc_check.sh
source tdx_host_tsc_check.sh
guest_test_entry tdx_guest_tsc_check.sh "-c $HOST_TSC" || \
{ die "Failed on TD_TSC_DEFAULT tdx_guest_tsc_check.sh -c $HOST_TSC"; return 1; }
if [[ $GCOV == "off" ]]; then
guest_test_close
fi
;;
TD_TSC_CONFIG)
guest_test_prepare tdx_guest_tsc_check.sh
CONFIG_TSC=3000000000
guest_test_entry tdx_guest_tsc_check.sh "-c $CONFIG_TSC" || \
{ die "Failed on TD_TSC_CONFIG tdx_guest_tsc_check.sh -c $CONFIG_TSC"; return 1; }
if [[ $GCOV == "off" ]]; then
guest_test_close
fi
;;
:)
test_print_err "Must specify the test scenario option by [-t]"
usage && exit 1
;;
\?)
test_print_err "Input test case option $TESTCASE is not supported"
usage && exit 1
;;
esac
4 changes: 4 additions & 0 deletions guest-test/tdx_osv_sanity/test_2.1.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Create TDX guest with default qemu config and check TSC value on guest
guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -f tdx_osv_sanity -x TD_TSC_DEFAULT -p off -i "tdx_osv_sanity/common.json" -j "tdx_osv_sanity/qemu.config.default.json"
# Create TDX guest with tsc-freq specified qemu config and check TSC value on guest
guest.test_launcher.sh -v 1 -s 1 -m 4 -d on -t tdx -f tdx_osv_sanity -x TD_TSC_CONFIG -p off -i "tdx_osv_sanity/common.json" -j "tdx_osv_sanity/qemu.config.tsc.json"

0 comments on commit a360f20

Please sign in to comment.