| 1 | #! /bin/sh |
| 2 | set -e |
| 3 | |
| 4 | if [ "$TEST_VERBOSE" -ge 3 ]; then |
| 5 | set -x |
| 6 | fi |
| 7 | |
| 8 | . "$(dirname "$0")/../$ARCH.sh" |
| 9 | |
| 10 | ok () { |
| 11 | echo "PASS $testname" |
| 12 | } |
| 13 | |
| 14 | notok () { |
| 15 | echo "FAIL $testname" |
| 16 | } |
| 17 | |
| 18 | log () { |
| 19 | echo "$*" >&2 |
| 20 | } |
| 21 | |
| 22 | warning () { |
| 23 | echo "warning: $*" >&2 |
| 24 | } |
| 25 | |
| 26 | for KERNEL_MAJOR in $MAJORS; do |
| 27 | WANT_FLAVOUR="$FLAVOUR" |
| 28 | KERNEL_LIST_NAME="KERNEL_$(echo "$KERNEL_MAJOR" | tr '.-' '__')" |
| 29 | WANT_KERNELS="$(eval echo "\$$KERNEL_LIST_NAME" | tr '\n' ' ' | tr -s ' ' | sed 's/ *$//')" |
| 30 | WANT_KERNEL_STEM="${WANT_KERNELS%% *}" |
| 31 | WANT_KERNEL_STEM="${WANT_KERNEL_STEM#kernel-image-}" |
| 32 | WANT_KERNEL_STEM="${WANT_KERNEL_STEM#linux-image-}" |
| 33 | export KERNEL_MAJOR |
| 34 | export KERNEL_VERSION="$(echo "$WANT_KERNEL_STEM" | cut -d - -f 1)" |
| 35 | |
| 36 | # Is the correct kernel flavour selected? |
| 37 | |
| 38 | testname="arch_get_kernel_flavour $KERNEL_MAJOR exit code" |
| 39 | if GOT_FLAVOUR="$(arch_get_kernel_flavour)" && [ "$GOT_FLAVOUR" ] ; then |
| 40 | ok |
| 41 | else |
| 42 | notok |
| 43 | continue # nothing else will work |
| 44 | fi |
| 45 | |
| 46 | testname="arch_get_kernel_flavour want $WANT_FLAVOUR, got $GOT_FLAVOUR" |
| 47 | if [ "$WANT_FLAVOUR" = "$GOT_FLAVOUR" ]; then |
| 48 | ok |
| 49 | else |
| 50 | notok |
| 51 | fi |
| 52 | |
| 53 | # Are the correct kernels treated as usable? |
| 54 | |
| 55 | for kernel in $USABLE; do |
| 56 | testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel should be usable" |
| 57 | if arch_check_usable_kernel "$kernel" "$GOT_FLAVOUR"; then |
| 58 | ok |
| 59 | else |
| 60 | notok |
| 61 | fi |
| 62 | done |
| 63 | |
| 64 | # By default any postfix should be allowed |
| 65 | for kernel in $USABLE; do |
| 66 | testname="arch_check_usable_kernel $KERNEL_MAJOR ${kernel}-<postfix> should be usable" |
| 67 | if arch_check_usable_kernel "${kernel}-postfix" "$GOT_FLAVOUR"; then |
| 68 | ok |
| 69 | else |
| 70 | notok |
| 71 | fi |
| 72 | done |
| 73 | |
| 74 | for kernel in $UNUSABLE; do |
| 75 | testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel should be unusable" |
| 76 | if arch_check_usable_kernel "$kernel" "$GOT_FLAVOUR"; then |
| 77 | notok |
| 78 | else |
| 79 | ok |
| 80 | fi |
| 81 | done |
| 82 | |
| 83 | # Is the correct preference order of default kernels selected? |
| 84 | |
| 85 | testname="arch_get_kernel $KERNEL_MAJOR exit code" |
| 86 | if GOT_KERNELS="$(arch_get_kernel "$GOT_FLAVOUR" | tr '\n' ' ' | sed 's/ *$//')"; then |
| 87 | ok |
| 88 | else |
| 89 | notok |
| 90 | continue # the rest won't work |
| 91 | fi |
| 92 | |
| 93 | testname="arch_get_kernel want '$WANT_KERNELS', got '$GOT_KERNELS'" |
| 94 | if [ "$WANT_KERNELS" = "$GOT_KERNELS" ]; then |
| 95 | ok |
| 96 | else |
| 97 | notok |
| 98 | fi |
| 99 | done |