summaryrefslogtreecommitdiff
path: root/mk/xe-linux-distribution-test
blob: 6bc26b86640d377485435073086e9f80e1617a9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/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} ${NAME} 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"
do_test "testcases/sle-15"               "sles 15 0"
do_test "testcases/sle-15sp1"            "sles 15 1"
exit 0