HIRS/.ci/tcg-rim-tool/scripts/rim_functions.sh
SuperPotato27 8a3478c19e
Adding RIM tests action (#806)
* Added Rim test workflow

* bug fixes

* added rim tool setup

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* updates to rim_tests.yml

* updates to rim_tests.yml

* updates to rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* Update rim_tests.yml

* added run all script

* added run all script

* updates to rim_tests.yml

* Updates to paths in composite_rim_create_pass.sh

* Added all passing rim tests

* updates to rim_tests.yml

* switched to gradle-build-action@v3

* switched to setup-gradle@v3

* switched to setup-java@v4

* updates to rim_tests.yml

* testing failed script

* fixed failed test

* testing artifacts

* updates to rim_tests.yml

* Update rim_tests.yml

* updates to rim_tests.yml

* changes to rim_tests.yml

* testing log file

* testing log file

* testing log files

* testing log files

* testing log file

* testing log file

* testing log file

* testing log file

* testing log file

* Update rim_tests.yml

* verbose run

* updated paths and references

* updates to README.md

* deleted rim docker testing directory
2024-07-22 06:03:43 -04:00

132 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
#Rim system test support functions.
#exit status functions for rim create and rim verify.
rim_create_status(){
if [ $1 -eq 0 ]; then
echo "********"
echo "RIM create passed, attempting to verify the signature on base rim file..."
echo "********"
else
echo "********"
echo "FAILED: rim creation failed"
echo "********"
((failCount++))
fi
}
rim_verify_status(){
if [ $1 -eq 0 ]; then
echo "********"
echo "RIM Verify passed!"
#echo "********"
else
echo "********"
echo "FAILED: rim verify failed"
#echo "********"
((failCount++))
fi
}
rim_create_fail_test(){
if [ $1 -ne 0 ]; then
echo "********"
echo "PASSED: RIM create FAILED as expected."
#echo "********"
exit 0
else
echo "********"
echo "FAILED: RIM create PASSED expected FAIL."
#echo "********"
exit 1
fi
}
rim_verify_fail_test(){
if [ $1 -ne 0 ]; then
echo "********"
echo "PASSED: RIM verify FAILED as expected."
#echo "********"
exit 0
else
echo "********"
echo "FAILED: RIM verify PASSED expected FAIL."
#echo "********"
exit 1
fi
}
check_req_attributes() {
local element="$1"
shift
local attributes=("$@")
for attribute in "${attributes[@]}"; do
((num_tests++))
if grep -q "$element.*$attribute=" "$BASE_RIM"; then
echo "The $element element HAS the REQUIRED '$attribute' attribute."
((num_tests_pass++))
else
echo -e "\033[31mError: The $element element is MISSING the REQUIRED '$attribute' attribute.\033[0m"
exitStatus=1
fi
done
}
check_opt_attributes() {
local element="$1"
shift
local attributes=("$@")
for attribute in "${attributes[@]}"; do
if grep -q "$element.*$attribute=" "$BASE_RIM"; then
echo "The $element element HAS the OPTIONAL '$attribute' attribute."
else
echo -e "\033[33mThe $element element is MISSING the OPTIONAL '$attribute' attribute.\033[0m"
fi
done
}
check_element() {
local element="$1"
((num_tests++))
if grep -q "$1" "$BASE_RIM"; then
echo "************"
echo "$element element exists checking for REQUIRED attributes... "
((num_tests_pass++))
else
echo -e "\033[31mERROR: $element element is missing\033[0m"
exitStatus=1
fi
}
# checks parent tag for REQUIRED elements/attributes found in child tags.
check_tag_req(){
local element="$1"
local tag_block="$2"
shift 2
local attributes=("$@")
for attribute in "${attributes[@]}"; do
((num_tests++))
if echo "$tag_block" | grep -q "$attribute"; then
echo "The $element element HAS the REQUIRED '$attribute' attribute."
((num_tests_pass++))
else
echo -e "\033[31mError: The $element element is MISSING the REQUIRED '$attribute' attribute.\033[0m"
exitStatus=1
fi
done
}
# checks parent tag for OPTIONAL elements/attributes found in child tags.
check_tag_opt(){
local element="$1"
local tag_block="$2"
shift 2
local attributes=("$@")
for attribute in "${attributes[@]}"; do
if echo "$tag_block" | grep -q "$attribute"; then
echo "The $element element HAS the REQUIRED '$attribute' attribute."
else
echo -e "\033[33mThe $element element is MISSING the OPTIONAL '$attribute' attribute.\033[0m"
fi
done
}