#!/bin/sh LANG="C" export LANG TEST=yes . xe-linux-distribution test_identify() { export TESTCASE=$1 identify_lsb testcases/lsb || \ identify_debian "${1}" || \ identify_redhat "${1}" || \ identify_sles "${1}" || \ return 1 } do_test() { TC=$1 ; shift TEST_RESULT=$@ if test_identify ${TC} ; then if [ X"${TEST_RESULT}" = X"FAIL" ] ; then echo "FAILED: ${TC}: should fail to parse" 1>&2 else set ${TEST_RESULT} if [ "$1" != "${DISTRO}" ] ; then echo "FAILED: ${TC}: $1 $2.$3: distro ${DISTRO} != $1" 1>&2 exit 1 fi if [ "$2" != "${MAJOR}" ] ; then echo "FAILED: ${TC}: $1 $2.$3: major ${MAJOR} != $2" 1>&2 exit 1 fi if [ "$3" != "${MINOR}" ] ; then echo "FAILED: ${TC} $1 $2.$3: minor ${MINOR} != $3" 1>&2 exit 1 fi echo "PASSED: ${TC}: ${DISTRO} ${MAJOR} ${MINOR} correctly detected" 1>&2 fi else if [ X"${TEST_RESULT}" = X"FAIL" ] ; then echo "PASSED: ${TC}: correctly failed to parse" 1>&2 else echo "FAILED: ${TC}: unable to parse" 1>&2 fi fi } do_test "testcases/debian-sid" "debian" do_test "testcases/rhel-3u6" "rhel 3 6" do_test "testcases/rhel-3u8" "rhel 3 8" do_test "testcases/rhel-4" "rhel 4 0" do_test "testcases/rhel-4u1" "rhel 4 1" do_test "testcases/rhel-4u2" "rhel 4 2" do_test "testcases/rhel-4u3" "rhel 4 3" do_test "testcases/rhel-4u4" "rhel 4 4" do_test "testcases/rhel-4u5" "rhel 4 5" do_test "testcases/rhel-4u6" "rhel 4 6" do_test "testcases/rhel-5beta" "rhel 5 0beta" do_test "testcases/rhel-5" "rhel 5 0" do_test "testcases/rhel-5u1beta" "rhel 5 1beta" do_test "testcases/rhel-5u1" "rhel 5 1" do_test "testcases/fc3" "fedora 3 0" do_test "testcases/sles-9" "sles 9 0" do_test "testcases/sles-9sp3" "sles 9 3" do_test "testcases/sles-10sp2" "sles 10 2" do_test "testcases/sles-11" "sles 11 0" do_test "testcases/ddk-0.5.6-2991c" "xe-ddk 0.5.6 2991c" do_test "testcases/sdk-0.5.6-2991c" "xe-sdk 0.5.6 2991c" do_test "testcases/centos4" "centos 4 0" do_test "testcases/centos5" "centos 5 0" do_test "testcases/lsb-ubuntu-6.10" "ubuntu 6 10" do_test "testcases/lsb-ubuntu-7.04" "ubuntu 7 04" do_test "testcases/oracle-5" "oracle 5 0" do_test "testcases/oracle-5u1" "oracle 5 1" do_test "testcases/lsb-coreos-367.1.0" "coreos 367 1.0" exit 0