summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2016-09-08 16:44:25 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-09-13 11:52:04 +0000
commitbcc9162e170a68fc13a7efec6c9724a2470291d6 (patch)
tree68480bf7517f7dfe6258ff423833f7f2c475310c
parente913f2d65af88622b25d8a1a9ed518c51424252e (diff)
v2: linux: add openjdk smoke test
Change-Id: I1abb98d67746529197b5f262311e2b06a582edf8 Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/lib/sh-test-lib14
-rwxr-xr-xautomated/linux/openjdk/openjdk-smoke.sh65
-rw-r--r--automated/linux/openjdk/openjdk-smoke.yaml33
3 files changed, 108 insertions, 4 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index 3edecb8..0b81fc8 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -7,7 +7,7 @@ error_msg() {
local msg="$1"
[ -z "${msg}" ] && msg="Unknown error"
printf "ERROR: %s\n" "${msg}" >&2
- exit 1
+ exit 0
}
warn_msg() {
@@ -37,7 +37,12 @@ exit_on_fail() {
if [ "${exit_code}" -ne 0 ]; then
echo "${test} fail" | tee -a "${RESULT_FILE}"
- exit 1
+ # Exit normally to continue to run the following steps defined in test
+ # definition file.
+ exit 0
+ else
+ echo "${test} pass" | tee -a "${RESULT_FILE}"
+ return 0
fi
}
@@ -99,8 +104,9 @@ install_deps() {
dist_name
case "${dist}" in
Debian|Ubuntu)
- apt-get update
- apt-get install -y -q ${pkgs}
+ # Use the default answers for all questions.
+ DEBIAN_FRONTEND=noninteractive apt-get update -q -y
+ DEBIAN_FRONTEND=noninteractive apt-get install -q -y ${pkgs}
;;
CentOS)
yum -e 0 -y install ${pkgs}
diff --git a/automated/linux/openjdk/openjdk-smoke.sh b/automated/linux/openjdk/openjdk-smoke.sh
new file mode 100755
index 0000000..7202a85
--- /dev/null
+++ b/automated/linux/openjdk/openjdk-smoke.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+VERSION="8"
+
+usage() {
+ echo "Usage: $0 [-v <8|9>] [-s <true|false>]" 1>&2
+ exit 1
+}
+
+while getopts "v:s:" o; do
+ case "$o" in
+ v) VERSION="${OPTARG}" ;;
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+! check_root && error_msg "You need to be root to run this script."
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+
+if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
+ info_msg "JDK package installation skipped"
+else
+ dist_name
+ case "${dist}" in
+ Debian|Ubuntu) pkg="openjdk-${VERSION}-jdk" ;;
+ CentOS|Fedora) pkg="java-1.${VERSION}.0-openjdk-devel" ;;
+ *) error_msg "Unsupported distribution" ;;
+ esac
+ install_deps "${pkg}"
+ exit_on_fail "jdk${VERSION}-installation"
+fi
+
+# Set the specific version as default in case more than one jdk installed.
+for link in java javac; do
+ path="$(update-alternatives --display "${link}" \
+ | egrep "^/usr/lib/jvm/java-(${VERSION}|1.${VERSION}.0)" \
+ | awk '{print $1}')"
+ update-alternatives --set "${link}" "${path}"
+done
+
+java -version 2>&1 | grep "version \"1.${VERSION}"
+exit_on_fail "check-java-version"
+
+javac -version 2>&1 | grep "javac 1.${VERSION}"
+exit_on_fail "check-javac-version"
+
+cd "${OUTPUT}"
+cat > "HelloWorld.java" << EOL
+public class HelloWorld {
+ public static void main(String[] args) {
+ System.out.println("Hello, World");
+ }
+}
+EOL
+
+javac HelloWorld.java
+check_return "compile-HelloWorld"
+
+java HelloWorld | grep "Hello, World"
+check_return "execute-HelloWorld"
diff --git a/automated/linux/openjdk/openjdk-smoke.yaml b/automated/linux/openjdk/openjdk-smoke.yaml
new file mode 100644
index 0000000..74799ea
--- /dev/null
+++ b/automated/linux/openjdk/openjdk-smoke.yaml
@@ -0,0 +1,33 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: openjdk-smoke-test
+ description: "Install openjdk, compile and run HelloWorld."
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ - chase.qi@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - centos
+ - fedora
+ scope:
+ - functional
+ devices:
+ - juno
+ - hi6220-hikey
+ - apq8016-sbc
+ - mustang
+ - d02
+ - d03
+ - overdrive
+
+params:
+ # Specify JDK vesion.
+ VERSION: 8
+ SKIP_INSTALL: "False"
+
+run:
+ steps:
+ - cd ./automated/linux/openjdk/
+ - ./openjdk-smoke.sh -v "${VERSION}" -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt