aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Serov <artem.serov@linaro.org>2021-10-26 19:48:24 +0000
committerLinaro Android Code Review <android-review@review.linaro.org>2021-10-26 19:48:24 +0000
commitfa52f7208c73e4e35c7864b0f92fe81b3d0c7376 (patch)
tree07b4bc42221053669d996a62c3d2b2ddade7bed6
parent17d16653913539174b815808cbd274ac7fca9c2b (diff)
parent91b031361bed631f3264e8721da5e0c0e3aca419 (diff)
downloadart-external-benchmarks-fa52f7208c73e4e35c7864b0f92fe81b3d0c7376.tar.gz
Merge "Extract common code from setup_dacapo.sh before javamatrix benchmark"
-rw-r--r--dacapo/.gitignore2
-rwxr-xr-xdacapo/setup_dacapo.sh54
-rw-r--r--utils/utils.sh87
3 files changed, 93 insertions, 50 deletions
diff --git a/dacapo/.gitignore b/dacapo/.gitignore
new file mode 100644
index 0000000..ec96b72
--- /dev/null
+++ b/dacapo/.gitignore
@@ -0,0 +1,2 @@
+dacapo_src/
+.class \ No newline at end of file
diff --git a/dacapo/setup_dacapo.sh b/dacapo/setup_dacapo.sh
index 8bb8db1..1f200c4 100755
--- a/dacapo/setup_dacapo.sh
+++ b/dacapo/setup_dacapo.sh
@@ -16,45 +16,8 @@
unset DEST_DIR
-readonly CRED="\033[0;31m"
-readonly CORANGE="\033[0;33m"
-readonly CGREEN="\033[0;32m"
-readonly CNC="\033[0m"
-
-# Print error message
-# ${1} - error message
-error() {
- echo -e "${CRED}ERROR: $*${CNC}" >&2
-}
-
-# Print info message
-# ${1} - info message
-info() {
- echo -e "${CORANGE}INFO: $*${CNC}" >&2
-}
-
-# Print error message and exit from the script
-# ${1} - error message.
-exit_with_error() {
- error "$1"
- exit 1
-}
-
-# Check exit code of the previous command; if non-zero, abort.
-# Arguments:
-# ${1} - error message.
-if_error() {
- # shellcheck disable=SC2181
- if [[ $? -ne 0 ]]; then
- exit_with_error "$1"
- fi
-}
-
-# Execute the arguments; if the exit code is non-zero, abort.
-safe() {
- "$@"
- if_error "Failed command: $*"
-}
+readonly local_path="$(dirname "$0")"
+source "${local_path}/../utils/utils.sh"
readonly usage="Usage: $(basename "$0") -d dest_dir
Setup DaCapo binaries and resource files and workloads runners into
@@ -126,18 +89,9 @@ main() {
"to your Linaro tree."
fi
- if [ -z "${JAVA_HOME}" ]; then
- exit_with_error "Please, set JAVA_HOME environment variable to path to Java8 jdk and" \
- "re-run the script."
- else
- JAVA_VERSION=$("${JAVA_HOME}/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
- info "Detected Java version ${JAVA_VERSION:0:3}"
- if [[ ${JAVA_VERSION:0:3} != "1.8" ]]; then
- exit_with_error "Please update JAVA_HOME environment variable with the location of Java 8"
- fi
- fi
+ validate_java
- cd $(dirname "$0")
+ cd "${local_path}"
# uninstall DaCapo if it is already installed
diff --git a/utils/utils.sh b/utils/utils.sh
new file mode 100644
index 0000000..484a47f
--- /dev/null
+++ b/utils/utils.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 Linaro Limited. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+readonly CRED="\033[0;31m"
+readonly CORANGE="\033[0;33m"
+readonly CGREEN="\033[0;32m"
+readonly CNC="\033[0m"
+
+# Print error message.
+# ${1} - error message.
+error() {
+ echo -e "${CRED}ERROR: $*${CNC}" >&2
+}
+
+# Print info message.
+# ${1} - info message.
+info() {
+ echo -e "${CORANGE}INFO: $*${CNC}" >&2
+}
+
+# Print error message and exit from the script.
+# ${1} - error message.
+exit_with_error() {
+ error "$1"
+ exit 1
+}
+
+# Check exit code of the previous command; if non-zero, abort.
+# ${1} - error message.
+if_error() {
+ # shellcheck disable=SC2181
+ if [[ $? -ne 0 ]]; then
+ exit_with_error "$1"
+ fi
+}
+
+# Execute the arguments; if the exit code is non-zero, abort.
+safe() {
+ "$@"
+ if_error "Failed command: $*"
+}
+
+# Delete and remake directory.
+# ${1} - Directory.
+cleandir() {
+ info "Creating clean dir ${1}"
+ if [[ -d "${1}" ]]; then
+ safe rm -rf "${1}"
+ fi
+ safe mkdir -p "${1}"
+}
+
+# Check the version of java being used is Java 8.
+validate_java() {
+ # If JAVA_HOME exists then this will be used.
+ if [[ -n "${JAVA_HOME}" ]] && [[ -x "${JAVA_HOME}/bin/java" ]]; then
+ java_command="${JAVA_HOME}/bin/java"
+ # Otherwise check the default java command.
+ elif [[ ! -z "$(type -p java)" ]]; then
+ java_command="java"
+ else
+ exit_with_error "Could not find Java. Either set Java 8 in JAVA_HOME or add to path."
+ fi
+
+ java_version_text="$("${java_command}" -version 2>&1)"
+ if_error "'${java_command} -version' failed \n${java_version_text}"
+ java_version="$(echo "${java_version_text}" | awk -F '"' '/version/ {print $2}')"
+ if_error "Could not find version number in output of '${java_command} -version'\n${java_version_text}\n${java_version}"
+ info "Detected Java version ${java_version}"
+ if [[ "${java_version:0:3}" != "1.8" ]]; then
+ exit_with_error "Incorrect version of Java. Either set Java 8 to JAVA_HOME or set it as the" \
+ "default Java."
+ fi
+} \ No newline at end of file