Skip to content

Commit 74d4144

Browse files
committed
contrib: add run_ci script
To control blktests test run conditions, introduced a script named "run_ci". It refers to condition files at the specified URL, generate the conifg file and run blktests. Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent b4f3078 commit 74d4144

2 files changed

Lines changed: 104 additions & 2 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ NPROCS := $(shell nproc)
2020

2121
check:
2222
shellcheck -x -e $(SHELLCHECK_EXCLUDE) -f gcc check common/* \
23-
tests/*/rc tests/*/[0-9]*[0-9] src/*.sh
23+
tests/*/rc tests/*/[0-9]*[0-9] src/*.sh contrib/run_ci
2424
shellcheck --exclude=$(SHELLCHECK_EXCLUDE),SC2154 --format=gcc new
2525
! grep TODO tests/*/rc tests/*/[0-9]*[0-9]
2626
! find -L -name '*.out' -perm /u=x+g=x+o=x -printf '%p is executable\n' | grep .
@@ -30,7 +30,7 @@ check-parallel:
3030
@ret=0; \
3131
find tests -type f -name '[0-9]*[0-9]' | \
3232
xargs -P $(NPROCS) -n 1 shellcheck -x -e $(SHELLCHECK_EXCLUDE) -f gcc || ret=1; \
33-
shellcheck -x -e $(SHELLCHECK_EXCLUDE) -f gcc check common/* tests/*/rc src/*.sh || ret=1; \
33+
shellcheck -x -e $(SHELLCHECK_EXCLUDE) -f gcc check common/* tests/*/rc src/*.sh contrib/run_ci || ret=1; \
3434
shellcheck --exclude=$(SHELLCHECK_EXCLUDE),SC2154 --format=gcc new || ret=1; \
3535
grep TODO tests/*/rc tests/*/[0-9]*[0-9] && ret=1; \
3636
find -L -name '*.out' -perm /u=x+g=x+o=x -printf '%p is executable\n' | grep . && ret=1; \

contrib/run_ci

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2026 Western Digital Corporation or its affiliates.
4+
#
5+
# Helper script to run blktests for blktests CI
6+
7+
usage () {
8+
echo "$0" "[OPTIONS] CONDITION_BASE_URL"
9+
echo -e "\tGet blktests run conditions from CONDITION_BASE_URL."
10+
echo -e "\tGenerate config file for each condition and run tests."
11+
echo -e "\tOPTIONS: -d\t Debug mode."
12+
exit 1
13+
}
14+
15+
DEBUG_MODE=0
16+
17+
if [[ $1 == -d ]]; then
18+
shift
19+
DEBUG_MODE=1
20+
fi
21+
22+
(($# != 1)) && usage
23+
24+
COND_URL_BASE=$1
25+
26+
cat_url() {
27+
local url=$1
28+
29+
if [[ $url =~ http ]]; then
30+
curl --fail --location --silent "$url"
31+
else
32+
cat "$url"
33+
fi
34+
}
35+
36+
get_conditions() {
37+
local url_base=$1
38+
local line
39+
local -a conds
40+
41+
while read -r line; do
42+
conds+=("$line")
43+
done < <(cat_url "${url_base}/list")
44+
echo "${conds[@]}"
45+
}
46+
47+
dequote() {
48+
local str="$1"
49+
50+
str=${str//\"/}
51+
str=${str//\'/}
52+
echo "$str"
53+
}
54+
55+
gen_config() {
56+
local url=$1
57+
local line check_args
58+
local devs
59+
local -a test_devs
60+
local -a check_args_arr
61+
62+
check_args=${url##*/}
63+
64+
rm -f config
65+
66+
while read -r line; do
67+
if [[ $line =~ BLKTESTS_CI_CHECK_ARGS ]]; then
68+
check_args=${line##*=}
69+
check_args=$(dequote "$check_args")
70+
elif [[ $line =~ BLKTESTS_CI_TEST_DEVS ]]; then
71+
devs=${line##*=}
72+
devs=$(dequote "$devs")
73+
for dev in $devs; do
74+
test_devs+=("${!dev}")
75+
done
76+
echo "TEST_DEVS=(" "${test_devs[@]}" ")" >> config
77+
else
78+
echo "$line" >> config
79+
fi
80+
done < <(cat_url "$url")
81+
82+
check_args_arr=(${check_args})
83+
84+
echo "run_ci: ${url}"
85+
if [[ -f ./config ]]; then
86+
cat ./config
87+
fi
88+
if ((DEBUG_MODE)); then
89+
echo -e "sudo ./check ${check_args_arr[@]}\n"
90+
else
91+
sudo ./check "${check_args_arr[@]}"
92+
if [[ -f results/failures ]]; then
93+
cat results/failures >> all_failures
94+
fi
95+
fi
96+
}
97+
98+
rm -f all_failures
99+
100+
for condition in $(get_conditions "$COND_URL_BASE"); do
101+
gen_config "$COND_URL_BASE"/"$condition"
102+
done

0 commit comments

Comments
 (0)