Skip to contentSkip to conversation

vsp-lib: Provide command line argument parsing

PATCH New Kieran Bingham 1 participant 1 message Aug 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vsp-lib: Provide command line argument parsing

Extend the vsp-lib to support command line parsing for all tests. The arguments parsed here should be common to all tests, and initially provide shell level verbose debug output, and the option to easily keep frames output by the VSP1.

---
 scripts/vsp-lib.sh | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
scripts/vsp-lib.sh +34 -0
index 0f3992a7827e..6a0f4af5eaf5 100755
@@ -1094,3 +1094,37 @@ test_complete() {
 test_run() {
 	test_main | ./logger.sh error >> $logfile
 }
+
+# ------------------------------------------------------------------------------
+# Common argument parsing
+#
+# non-recognised arguements are restored, to allow tests
+# to implement their own parsing if necessary.
+
+POSITIONAL=()
+while [[ $# -gt 0 ]]
+do
+case $1 in
+	-x|--debug)
+		set -x;
+		shift
+		;;
+	-k|--keep-frames)
+		export VSP_KEEP_FRAMES=1
+		shift
+		;;
+	-h|--help)
+		echo "$(basename $0): VSP Test library"
+		echo "  -x|--debug          enable shell debug"
+		echo "  -k|--keep-frames    keep generated and captured frames"
+		echo "  -h|--help           this help"
+		exit
+		shift
+		;;
+	*)    # unknown option
+		POSITIONAL+=("$1") # save it in an array for later
+		shift # past argument
+		;;
+esac
+done
+set -- "${POSITIONAL[@]}" # restore positional parameters
Signature · 1 line
2.17.1