Skip to content

Commit

Permalink
Merge branch 'kselftest-env-vars' of https://github.com/crazoes/test-…
Browse files Browse the repository at this point in the history
…definitions into HEAD
  • Loading branch information
staging-kernelci-org committed Jun 11, 2024
2 parents 3a72a6c + 09fc67e commit 8559e4e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 17 additions & 2 deletions automated/linux/kselftest/kselftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ usage() {
[-S kselftest-skipfile]
[-b board]
[-g branch]
[-e environment]" 1>&2
[-e environment]
[-E ENV_NAME=ENV_VAL]" 1>&2
exit 1
}

while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:h" opt; do
while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:E:h" opt; do
case "${opt}" in
i) SHARD_INDEX="${OPTARG}" ;;
n) SHARD_NUMBER="${OPTARG}" ;;
Expand Down Expand Up @@ -107,6 +108,20 @@ while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:h" opt; do
e)
export ENVIRONMENT="${OPTARG}"
;;
E)
if [ -n "$OPTARG" ]; then
IFS='=' read -r env_name env_val << EOF
$OPTARG
EOF
if [ -z "$env_name" ] || [ -z "$env_val" ]; then
echo "Option -E requires an argument of format ENV_NAME=ENV_VAL"
exit 1
fi
# Use eval to set an environment variable dynamically
eval "export ${env_name}=${env_val}"
eval "echo \"${env_name}='\$${env_name}'\""
fi
;;
h|*) usage ;;
esac
done
Expand Down
4 changes: 3 additions & 1 deletion automated/linux/kselftest/kselftest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ params:
BOARD: ""
BRANCH: ""
ENVIRONMENT: ""
# Set arbitrary environment variable
ENV: ""

# Number of shards that will be done, default 1 which is the same as no sharding.
SHARD_NUMBER: 1
Expand All @@ -60,5 +62,5 @@ params:
run:
steps:
- cd ./automated/linux/kselftest/
- ./kselftest.sh -c "${TST_CMDFILES}" -T "${TST_CASENAME}" -t "${TESTPROG}" -s "${SKIP_INSTALL}" -u "${TESTPROG_URL}" -L "${SKIPLIST}" -S "${SKIPFILE}" -b "${BOARD}" -g "${BRANCH}" -e "${ENVIRONMENT}" -p "${KSELFTEST_PATH}" -n "${SHARD_NUMBER}" -i "${SHARD_INDEX}"
- ./kselftest.sh -c "${TST_CMDFILES}" -T "${TST_CASENAME}" -t "${TESTPROG}" -s "${SKIP_INSTALL}" -u "${TESTPROG_URL}" -L "${SKIPLIST}" -S "${SKIPFILE}" -b "${BOARD}" -g "${BRANCH}" -e "${ENVIRONMENT}" -p "${KSELFTEST_PATH}" -n "${SHARD_NUMBER}" -i "${SHARD_INDEX}" -E "${ENV}"
- ../../utils/send-to-lava.sh ./output/result.txt

0 comments on commit 8559e4e

Please sign in to comment.