#!/bin/bash
# Copyright © 2019 Collabora Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# (See debian/copyright)

set -e
set -u
set -x

# Assert that Java 8 is the default Java

echo "1..2"

if version="$(java -version 2>&1)"; then
    echo "ok 1 - can run java -version"
else
    echo "not ok 1 - java -version exited $?"
    echo "# $version"
    exit 1
fi

if grep -q '^VARIANT="\?SDK"\?$' /usr/lib/os-release; then
    case "$version" in
        (*version\ \"1.8.*)
            echo "ok 2 - Java 8 is the default"
            ;;

        (*version\ \"1.7.*)
            echo "not ok 2 - Unsupported Java version"
            java -version
            exit 1
            ;;

        (*)
            echo "not ok 2 - Could not parse Java version"
            java -version
            exit 1
            ;;
    esac
else
    echo "ok 2 # SKIP this does not appear to be a SDK image"
fi

# vim:set sw=4 sts=4 et ft=sh:
