File: dotest

package info (click to toggle)
base-installer 1.227
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,288 kB
  • sloc: sh: 1,587; ansic: 704; makefile: 59; perl: 50
file content (99 lines) | stat: -rwxr-xr-x 2,193 bytes parent folder | download | duplicates (4)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh
set -e

if [ "$TEST_VERBOSE" -ge 3 ]; then
	set -x
fi

. "$(dirname "$0")/../$ARCH.sh"

ok () {
	echo "PASS $testname"
}

notok () {
	echo "FAIL $testname"
}

log () {
	echo "$*" >&2
}

warning () {
	echo "warning: $*" >&2
}

for KERNEL_MAJOR in $MAJORS; do
	WANT_FLAVOUR="$FLAVOUR"
	KERNEL_LIST_NAME="KERNEL_$(echo "$KERNEL_MAJOR" | tr '.-' '__')"
	WANT_KERNELS="$(eval echo "\$$KERNEL_LIST_NAME" | tr '\n' ' ' | tr -s ' ' | sed 's/ *$//')"
	WANT_KERNEL_STEM="${WANT_KERNELS%% *}"
	WANT_KERNEL_STEM="${WANT_KERNEL_STEM#kernel-image-}"
	WANT_KERNEL_STEM="${WANT_KERNEL_STEM#linux-image-}"
	export KERNEL_MAJOR
	export KERNEL_VERSION="$(echo "$WANT_KERNEL_STEM" | cut -d - -f 1)"

	# Is the correct kernel flavour selected?

	testname="arch_get_kernel_flavour $KERNEL_MAJOR exit code"
	if GOT_FLAVOUR="$(arch_get_kernel_flavour)" && [ "$GOT_FLAVOUR" ] ; then
		ok
	else
		notok
		continue # nothing else will work
	fi

	testname="arch_get_kernel_flavour want $WANT_FLAVOUR, got $GOT_FLAVOUR"
	if [ "$WANT_FLAVOUR" = "$GOT_FLAVOUR" ]; then
		ok
	else
		notok
	fi

	# Are the correct kernels treated as usable?

	for kernel in $USABLE; do
		testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel should be usable"
		if arch_check_usable_kernel "$kernel" "$GOT_FLAVOUR"; then
			ok
		else
			notok
		fi
	done

	# By default any postfix should be allowed
	for kernel in $USABLE; do
		testname="arch_check_usable_kernel $KERNEL_MAJOR ${kernel}-<postfix> should be usable"
		if arch_check_usable_kernel "${kernel}-postfix" "$GOT_FLAVOUR"; then
			ok
		else
			notok
		fi
	done

	for kernel in $UNUSABLE; do
		testname="arch_check_usable_kernel $KERNEL_MAJOR $kernel should be unusable"
		if arch_check_usable_kernel "$kernel" "$GOT_FLAVOUR"; then
			notok
		else
			ok
		fi
	done

	# Is the correct preference order of default kernels selected?

	testname="arch_get_kernel $KERNEL_MAJOR exit code"
	if GOT_KERNELS="$(arch_get_kernel "$GOT_FLAVOUR" | tr '\n' ' ' | sed 's/ *$//')"; then
		ok
	else
		notok
		continue # the rest won't work
	fi

	testname="arch_get_kernel want '$WANT_KERNELS', got '$GOT_KERNELS'"
	if [ "$WANT_KERNELS" = "$GOT_KERNELS" ]; then
		ok
	else
		notok
	fi
done