Skip to content

Commit 00f4e75

Browse files
committed
Added support for multiple arguments
This change provides greater flexibility by allowing users to provide specific parameters to individual testcases from run-test.sh Signed-off-by: Vamsee Narapareddi <[email protected]>
1 parent a1ee177 commit 00f4e75

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

Runner/run-test.sh

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ RESULTS_SKIP=""
3838

3939
execute_test_case() {
4040
test_path=$1
41+
shift
42+
4143
test_name=$(basename "$test_path")
4244

4345
if [ -d "$test_path" ]; then
4446
run_script="$test_path/run.sh"
4547
if [ -f "$run_script" ]; then
4648
log "Executing test case: $test_name"
47-
(cd "$test_path" && sh "./run.sh")
49+
(cd "$test_path" && sh "./run.sh" "$@")
4850
res_file="$test_path/$test_name.res"
4951
if [ -f "$res_file" ]; then
5052
if grep -q "SKIP" "$res_file"; then
@@ -88,12 +90,13 @@ execute_test_case() {
8890

8991
run_specific_test_by_name() {
9092
test_name=$1
93+
shift
9194
test_path=$(find_test_case_by_name "$test_name")
9295
if [ -z "$test_path" ]; then
9396
log_error "Test case with name $test_name not found."
9497
RESULTS_FAIL=$(printf "%s\n%s" "$RESULTS_FAIL" "$test_name (not found)")
9598
else
96-
execute_test_case "$test_path"
99+
execute_test_case "$test_path" "$@"
97100
fi
98101
}
99102

@@ -119,15 +122,35 @@ print_summary() {
119122
log_info "=================================="
120123
}
121124

122-
if [ "$#" -eq 0 ]; then
123-
log "Usage: $0 [all | <testcase_name>]"
124-
exit 1
125+
print_usage() {
126+
cat >&2 <<EOF
127+
Usage:
128+
"${0##*/}" all
129+
"${0##*/}" <testcase_name> [arg1 arg2 ...]
130+
131+
Notes:
132+
- Extra args are forwarded only when a single <testcase_name> is specified.
133+
- 'all' runs every test and does not accept additional args.
134+
- Use -h or --help to display this message.
135+
EOF
136+
}
137+
138+
if [ "$#" -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
139+
print_usage
140+
if [ "$#" -eq 0 ]; then
141+
log_error "No arguments provided"
142+
exit 1
143+
else
144+
exit 0
145+
fi
125146
fi
126147

127148
if [ "$1" = "all" ]; then
128149
run_all_tests
129150
else
130-
run_specific_test_by_name "$1"
151+
test_case_name="$1"
152+
shift
153+
run_specific_test_by_name "$test_case_name" "$@"
131154
fi
132155

133156
print_summary

0 commit comments

Comments
 (0)