Skip to content

Commit 510091c

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 510091c

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Runner/run-test.sh

Lines changed: 24 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,30 @@ 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+
# Show help if no arguments or help flag is passed
139+
if [ "$#" -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
140+
print_usage
125141
fi
126142

127143
if [ "$1" = "all" ]; then
128144
run_all_tests
129145
else
130-
run_specific_test_by_name "$1"
146+
test_case_name="$1"
147+
shift
148+
run_specific_test_by_name "$test_case_name" "$@"
131149
fi
132150

133151
print_summary

0 commit comments

Comments
 (0)