HIRS/.ci/system-tests/container/rim_setup.sh

117 lines
3.3 KiB
Bash
Raw Permalink Normal View History

2022-01-25 15:54:54 +00:00
#!/bin/bash
#########################################################################################
# Setup for PC Client Reference Integrity Manifest (RIM) tests
# usage rim_setup.sh -p <profile> -t <test> [-u] [-n]
2022-01-25 15:54:54 +00:00
#########################################################################################
# Load env variables
. /hirs/.ci/docker/.env
profile=laptop
test=default
ciTestEventLog=$HIRS_CI_TEST_EVENT_LOG_FILE
# By default save the artifacts in EFI and do not upload to the ACA
UPLOAD_ARTIFACTS=NO
PUT_ARTIFACTS_IN_ESP=YES
# Process parameters Argument handling
POSITIONAL_ARGS=()
ORIGINAL_ARGS=("$@")
while [[ $# -gt 0 ]]; do
case $1 in
-p|--profile)
shift # past argument
profile=$1
shift # past parameter
;;
-t|--test)
shift # past argument
test=$1
shift # past parameter
;;
-u|--upload)
UPLOAD_ARTIFACTS=YES
shift # past argument
;;
-n|--no-efi)
PUT_ARTIFACTS_IN_ESP=NO
shift # past argument
;;
-*|--*)
echo "rim_setup.sh: Unknown option $1"
shift # past argument
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
# shift # past argument
break
;;
esac
done
# Profile selections
profileDir="$HIRS_CI_REPO_ROOT/.ci/system-tests/profiles/$profile"
defaultDir="$profileDir/default"
testDir="$profileDir/$test"
2022-01-26 15:24:29 +00:00
eventLog="$testDir"/"$profile"_"$test"_binary_bios_measurements
2022-02-03 20:30:10 +00:00
swidDir="$testDir/swidtags"
rimDir="$testDir/rims"
pcrScript="$testDir/"$profile"_"$test"_setpcrs.sh"
2022-02-03 20:30:10 +00:00
echo "Test is using RIM files from $profile : $test"
2022-01-25 15:54:54 +00:00
# Ensure rim folders under efi are set up and cleared
$HIRS_CI_REPO_ROOT/.ci/system-tests/container/efi_setup.sh -r
2022-01-25 15:54:54 +00:00
# Step 1: Copy binary_bios_measurement file
if [ ! -e "$eventLog" ]; then
eventLog=$HIRS_CI_TEST_DEFAULT_EVENT_LOG
fi
echo "eventLog used was $eventLog"
cp "$eventLog" "$ciTestEventLog"
2022-01-25 15:54:54 +00:00
# Step 2: Copy Base RIM files to the TCG folder
# a: See if test specific swidtag folder exists, if not use the default folder
2022-02-03 20:30:10 +00:00
if [[ ! -d $swidDir ]]; then
swidDir=$defaultDir/swidtags;
fi
pushd $swidDir > /dev/null
2022-01-25 15:54:54 +00:00
if [[ ! -f ".gitignore" ]]; then
for swidtag in * ; do
if [ "$PUT_ARTIFACTS_IN_ESP" = YES ]; then
echo "Saving $swidtag to $HIRS_CI_EFI_PATH_SWIDTAG"
cp $swidtag $HIRS_CI_EFI_PATH_SWIDTAG
fi
if [ "$UPLOAD_ARTIFACTS" = YES ]; then
echo "Uploading $swidtag to $SERVER_RIM_POST"
2024-07-25 18:57:30 +00:00
curl -k -F "file=@$swidtag" $SERVER_RIM_POST > /dev/null 2>&1
fi
2022-01-25 15:54:54 +00:00
done
fi
popd > /dev/null
# Step 3: Copy Support RIM files to the TCG folder in the same manner
2022-02-03 20:30:10 +00:00
if [[ ! -d $rimDir ]]; then
rimDir=$defaultDir/rims;
fi
pushd $rimDir > /dev/null
2022-01-25 15:54:54 +00:00
if [[ ! -f ".gitignore" ]]; then
for rim in * ; do
if [ "$PUT_ARTIFACTS_IN_ESP" = YES ]; then
echo "Saving $rim to $HIRS_CI_EFI_PATH_RIM"
cp $rim $HIRS_CI_EFI_PATH_RIM
fi
if [ "$UPLOAD_ARTIFACTS" = YES ]; then
echo "Uploading $rim to $SERVER_RIM_POST"
2024-07-25 18:57:30 +00:00
curl -k -F "file=@$rim" $SERVER_RIM_POST > /dev/null 2>&1
fi
2022-01-25 15:54:54 +00:00
done
fi
popd > /dev/null
#Step 4, run the setpcr script to make the TPM emulator hold values that correspond the binary_bios_measurement file
2022-02-03 20:30:10 +00:00
if [[ ! -f $pcrScript ]]; then
pcrScript=$HIRS_CI_TEST_DEFAULT_SETPCRS_SH
2022-02-03 20:30:10 +00:00
fi
sh $pcrScript;
2022-01-25 15:54:54 +00:00