aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Abraham <thomas.abraham@arm.com>2019-02-28 17:12:28 +0530
committerThomas Abraham <thomas.abraham@arm.com>2019-03-04 17:03:17 +0530
commitfb9f9b8ce7e810e4778046fe231869f22f58a05e (patch)
tree616dedfb4180aeede775352457f81e8f30908513
parent7561fa751c1e58bef01223e70894ceb80c0bf86e (diff)
sgi/sgi_common_util.sh: add a helper script for common code in sgi tests
Add a helper script with functions that can be reused by all the sgi test scripts. Change-Id: I0fff024fba62a536d72d65a9213d6fe32d43bc9d Signed-off-by: Thomas Abraham <thomas.abraham@arm.com>
-rw-r--r--sgi/sgi_common_util.sh91
1 files changed, 91 insertions, 0 deletions
diff --git a/sgi/sgi_common_util.sh b/sgi/sgi_common_util.sh
new file mode 100644
index 0000000..de5362d
--- /dev/null
+++ b/sgi/sgi_common_util.sh
@@ -0,0 +1,91 @@
+#!/usr/bin/env bash
+
+# Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# Neither the name of ARM nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific
+# prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+if [ -z "$refinfra" ] ; then
+ refinfra="sgi"
+fi
+
+__print_supported_platforms_sgi()
+{
+ echo "Supported platforms are -"
+ for plat in "${!platforms_sgi[@]}" ;
+ do
+ printf "\t $plat\n"
+ done
+ echo
+}
+
+__print_supported_platforms_rdinfra()
+{
+ echo "Supported platforms are -"
+ for plat in "${!platforms_rdinfra[@]}" ;
+ do
+ printf "\t $plat\n"
+ done
+ echo
+}
+
+__print_examples_sgi()
+{
+ __print_examples "sgi575"
+}
+
+__print_examples_rdinfra()
+{
+ __print_examples "rdn1edge"
+}
+
+__parse_params_validate()
+{
+ #Ensure that the platform is supported
+ if [ -z "$SGI_PLATFORM" ] ; then
+ __print_usage
+ fi
+ if [ -z "${platforms_sgi[$SGI_PLATFORM]}" -a \
+ -z "${platforms_rdinfra[$SGI_PLATFORM]}" ]; then
+ echo "[ERROR] Could not deduce which platform to build."
+ __print_supported_platforms_$refinfra
+ exit
+ fi
+
+ #Ensure a build command is specified
+ if [ -z "$BUILD_CMD" ] ; then
+ __print_usage
+ fi
+
+ #Ensure that the build command is supported
+ if [ "$BUILD_CMD" != "all" -a \
+ "$BUILD_CMD" != "build" -a \
+ "$BUILD_CMD" != "package" -a \
+ "$BUILD_CMD" != "clean" ] ; then
+ echo "[ERROR] unsupported build command \"$BUILD_CMD\"."
+ __print_usage
+ fi
+}