Skip to content

Commit 6d6923b

Browse files
crazoesroxell
authored andcommitted
kselftest: Add new option -E for specifying environment variables
Currently we are not able to run the subtests of a kselftest due to lack of support for passing the parameters to the test case. Hence, solve this problem by adding support for passing environment variables in KernelCI kselftest. Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
1 parent 07c9f70 commit 6d6923b

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

automated/linux/kselftest/kselftest.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ usage() {
4444
[-S kselftest-skipfile]
4545
[-b board]
4646
[-g branch]
47-
[-e environment]" 1>&2
47+
[-e environment]
48+
[-E ENV_NAME=ENV_VAL]" 1>&2
4849
exit 1
4950
}
5051

51-
while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:h" opt; do
52+
while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:E:h" opt; do
5253
case "${opt}" in
5354
i) SHARD_INDEX="${OPTARG}" ;;
5455
n) SHARD_NUMBER="${OPTARG}" ;;
@@ -107,6 +108,13 @@ while getopts "i:n:c:T:t:s:u:p:L:S:b:g:e:h" opt; do
107108
e)
108109
export ENVIRONMENT="${OPTARG}"
109110
;;
111+
E)
112+
if [ -n "${OPTARG}" ]; then
113+
set -x
114+
eval "export ${OPTARG}"
115+
set +x
116+
fi
117+
;;
110118
h|*) usage ;;
111119
esac
112120
done

automated/linux/kselftest/kselftest.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ params:
5050
BOARD: ""
5151
BRANCH: ""
5252
ENVIRONMENT: ""
53+
# Set arbitrary environment variables. The value set here is directly evaluated
54+
# as `eval "export ${ENV}"`.
55+
ENV: ""
5356

5457
# Number of shards that will be done, default 1 which is the same as no sharding.
5558
SHARD_NUMBER: 1
@@ -60,5 +63,5 @@ params:
6063
run:
6164
steps:
6265
- cd ./automated/linux/kselftest/
63-
- ./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}"
66+
- ./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}"
6467
- ../../utils/send-to-lava.sh ./output/result.txt

0 commit comments

Comments
 (0)