Skip to content

Commit

Permalink
Fix scripts to check command line switches properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mikir committed Oct 13, 2023
1 parent 2b594ba commit 1d9a777
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 101 deletions.
50 changes: 26 additions & 24 deletions scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,63 +316,65 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${SWITCH_OUT_DIR_OUT}="$2"
shift 2
;;

"-c" | "--test-config")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Test configuration is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing test configuration!"
echo
return 1
fi
eval ${SWITCH_TEST_CONFIG_OUT}="${ARG}"
shift
eval ${SWITCH_TEST_CONFIG_OUT}="$2"
shift 2
;;

"-d" | "--datasets-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing dataset directory!"
echo
return 1
fi
eval ${SWITCH_DATASETS_DIR_OUT}="$2"
shift 2
;;

"-n" | "--num-iterations")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Number of iterations is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing number of iterations!"
echo
return 1
fi
eval ${SWITCH_NUM_ITERATIONS_OUT}="${ARG}"
shift
eval ${SWITCH_NUM_ITERATIONS_OUT}="$2"
shift 2
;;

"-i" | "--include")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Include pattern is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing include pattern!"
echo
return 1
fi
eval ${SWITCH_BENCHMARKS_PATTERN_ARRAY_OUT}[${NUM_PATTERNS}]="i:${ARG}"
eval ${SWITCH_BENCHMARKS_PATTERN_ARRAY_OUT}[${NUM_PATTERNS}]="i:$2"
NUM_PATTERNS=$((NUM_PATTERNS + 1))
shift
shift 2
;;

"-x" | "--exclude")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Exclude pattern is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing exclude pattern!"
echo
return 1
fi
eval ${SWITCH_BENCHMARKS_PATTERN_ARRAY_OUT}[${NUM_PATTERNS}]="x:${ARG}"
eval ${SWITCH_BENCHMARKS_PATTERN_ARRAY_OUT}[${NUM_PATTERNS}]="x:$2"
NUM_PATTERNS=$((NUM_PATTERNS + 1))
shift
shift 2
;;

"-"*)
Expand Down
5 changes: 5 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;
Expand Down
5 changes: 5 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;
Expand Down
10 changes: 10 additions & 0 deletions scripts/show_parser_tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,21 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;

"-r" | "--parser-rule")
if [ $# -eq 1 ] ; then
stderr_echo "Missing parser rule!"
echo
return 1
fi
eval ${PARAM_PARSER_RULE_OUT}="$2"
shift 2
;;
Expand Down
25 changes: 13 additions & 12 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -650,34 +650,35 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;

"-i" | "--include")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Test include pattern is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing test include pattern!"
echo
return 1
fi
eval ${SWITCH_TEST_SUITES_ARRAY_OUT}[${NUM_PATTERNS}]="i:${ARG}"
eval ${SWITCH_TEST_SUITES_ARRAY_OUT}[${NUM_PATTERNS}]="i:$2"
NUM_PATTERNS=$((NUM_PATTERNS + 1))
shift
shift 2
;;

"-x" | "--exclude")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Test exclude pattern is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing test exclude pattern!"
echo
return 1
fi
eval ${SWITCH_TEST_SUITES_ARRAY_OUT}[${NUM_PATTERNS}]="x:${ARG}"
eval ${SWITCH_TEST_SUITES_ARRAY_OUT}[${NUM_PATTERNS}]="x:$2"
NUM_PATTERNS=$((NUM_PATTERNS + 1))
shift
shift 2
;;

"-"*)
Expand Down
10 changes: 10 additions & 0 deletions scripts/test_compat_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,21 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;

"-b" | "--old-version-branch")
if [ $# -eq 1 ] ; then
stderr_echo "Missing old version branch!"
echo
return 1
fi
eval ${PARAM_OLD_VERSION_BRANCH_OUT}="$2"
shift 2
;;
Expand Down
5 changes: 5 additions & 0 deletions scripts/test_gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,11 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${PARAM_OUT_DIR_OUT}="$2"
shift 2
;;
Expand Down
84 changes: 37 additions & 47 deletions scripts/test_perf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1151,104 +1151,94 @@ parse_arguments()
;;

"-o" | "--output-directory")
if [ $# -eq 1 ] ; then
stderr_echo "Missing output directory!"
echo
return 1
fi
eval ${SWITCH_OUT_DIR_OUT}="$2"
shift 2
;;

"-d" | "--source-dir")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Directory with zserio sources is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing directory with zserio sources!"
echo
return 1
fi
eval ${SWITCH_DIRECTORY_OUT}="${ARG}"
shift
eval ${SWITCH_DIRECTORY_OUT}="$2"
shift 2
;;

"-s" | "--source")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Main zserio source is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing main zserio source!"
echo
return 1
fi
eval ${SWITCH_SOURCE_OUT}="${ARG}"
shift
eval ${SWITCH_SOURCE_OUT}="$2"
shift 2
;;

"-t" | "--test-name")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Test name is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing test name!"
echo
return 1
fi
eval ${SWITCH_TEST_NAME_OUT}="${ARG}"
shift
eval ${SWITCH_TEST_NAME_OUT}="$2"
shift 2
;;

"-b" | "--blob-name")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "BLOB name is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing blob name!"
echo
return 1
fi
eval ${SWITCH_BLOB_NAME_OUT}="${ARG}"
shift
eval ${SWITCH_BLOB_NAME_OUT}="$2"
shift 2
;;

"-j" | "--json-file")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "JSON filename is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing JSON file name!"
echo
return 1
fi
eval ${SWITCH_JSON_FILE_OUT}="${ARG}"
shift
eval ${SWITCH_JSON_FILE_OUT}="$2"
shift 2
;;

"-f" | "--blob-file")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "BLOB filename is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing BLOB file name!"
echo
return 1
fi
eval ${SWITCH_BLOB_FILE_OUT}="${ARG}"
shift
eval ${SWITCH_BLOB_FILE_OUT}="$2"
shift 2
;;

"-n" | "--num-iterations")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Number of iterations is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing number of iterations!"
echo
return 1
fi
eval ${SWITCH_NUM_ITERATIONS_OUT}="${ARG}"
shift
eval ${SWITCH_NUM_ITERATIONS_OUT}="$2"
shift 2
;;

"-c" | "--test-config")
shift
local ARG="$1"
if [ -z "${ARG}" ] ; then
stderr_echo "Test configuration is not set!"
if [ $# -eq 1 ] ; then
stderr_echo "Missing test configuration!"
echo
return 1
fi
eval ${SWITCH_TEST_CONFIG_OUT}="${ARG}"
shift
eval ${SWITCH_TEST_CONFIG_OUT}="$2"
shift 2
;;

"-r" | "--run-only")
Expand Down
Loading

0 comments on commit 1d9a777

Please sign in to comment.