File: misc.test

package info (click to toggle)
genimage 19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 988 kB
  • sloc: ansic: 5,606; sh: 1,132; makefile: 194
file content (145 lines) | stat: -rwxr-xr-x 4,891 bytes parent folder | download
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
test_description="Misc Image Tests"

. "$(dirname "${0}")/test-setup.sh"

exec_test_set_prereq dd
exec_test_set_prereq diff
exec_test_set_prereq qemu-img
test_expect_success dd,diff,qemu-img "qemu" "
	setup_test_images &&
	run_genimage qemu.config test.qcow &&
	qemu-img check images/test.qcow &&
	zcat '${testdir}/qemu.qcow.gz' > qemu.qcow &&
	qemu-img compare images/test.qcow qemu.qcow
"

setup_fit_its() {
	setup_test_images &&
	cp ${testdir}/fit.its input/
}

exec_test_set_prereq mkimage
exec_test_set_prereq dtc
test_expect_success mkimage,dtc "fit" "
	setup_fit_its &&
	run_genimage fit.config test.fit
"

setup_rauc() {
	rm -rf input &&
	mkdir input &&
	cp -r "${testdir}"/rauc-openssl-ca input/ &&
	echo "test" > input/rauc.content &&
	echo "xtest2" > input/rauc2.content
}

version_lt() {
	first="$(printf "${1}\n${2}" | sort -V | head -n1)"
	test "${first}" == "${1}" && test "${1}" != "${2}"
}

rauc_cmp() {
	if version_lt "${rauc_version}" "1.6"; then
		test_cmp "${testdir}/${1}.raucb.info.1" "${1}.raucb.info"
	elif version_lt "${rauc_version}" "1.9"; then
		test_cmp "${testdir}/${1}.raucb.info.2" "${1}.raucb.info"
	elif version_lt "${rauc_version}" "1.10"; then
		test_cmp "${testdir}/${1}.raucb.info.3" "${1}.raucb.info"
	else
		TEST_CMP="diff -wu" test_cmp "${testdir}/${1}.raucb.info.4" "${1}.raucb.info"
	fi
}

exec_test_set_prereq rauc
test_expect_success rauc "rauc" "
	rauc_version="$(rauc --version | sed 's/rauc //')"
	setup_rauc &&
	run_genimage rauc.config test.raucb &&
	rauc info \
		--keyring input/rauc-openssl-ca/ca.cert.pem \
		--cert input/rauc-openssl-ca/ca.cert.pem \
		images/test.raucb | grep -v cms_get_enveloped_type \
		| sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \
		      -e '/Bundle Format:[ \t]*plain$/d' \
		> test.raucb.info &&
	rauc_cmp test
	rauc info \
		--keyring input/rauc-openssl-ca/ca.cert.pem \
		--cert input/rauc-openssl-ca/ca.cert.pem \
		images/test2.raucb | grep -v cms_get_enveloped_type \
		| sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \
		      -e '/Bundle Format:[ \t]*plain$/d' \
		> test2.raucb.info &&
	rauc_cmp test2
"

exec_test_set_prereq simg2img
test_expect_success simg2img "android-sparse" "
	setup_test_images &&
	# make sure there is a 4*32k hole at the end
	i=16
	truncate --size=\$[i*(i+1)*i*i*512+32768*4] input/interleaved
	for i in \`seq 16\`; do
		dd if=/dev/urandom of=input/interleaved conv=notrunc seek=\$[i*i] count=\$[i] bs=\$[i*i*512] || break
	done &&
	dd if=/dev/urandom of=input/not-aligned count=9 bs=1024
	run_genimage sparse.config &&
	# simg2img will expand the partial block
	truncate --size=12k input/not-aligned
	md5sum images/test.hdimage input/interleaved input/not-aligned > md5sum &&
	rm images/test.hdimage input/interleaved input/not-aligned &&
	check_size_range images/interleaved.sparse 9732408 9732580 &&
	simg2img images/test.sparse images/test.hdimage &&
	simg2img images/interleaved.sparse input/interleaved &&
	simg2img images/not-aligned.sparse input/not-aligned &&
	md5sum -c md5sum &&

	run_genimage sparse-fill.config &&
	# simg2img will expand the partial block
	truncate --size=12k input/not-aligned
	md5sum images/test.hdimage input/interleaved input/not-aligned > md5sum &&
	rm images/test.hdimage input/interleaved input/not-aligned &&
	check_size_range images/interleaved.sparse 9732408 9732580 &&
	simg2img images/test.sparse images/test.hdimage &&
	simg2img images/interleaved.sparse input/interleaved &&
	simg2img images/not-aligned.sparse input/not-aligned &&
	md5sum -c md5sum
"

exec_test_set_prereq fiptool
test_expect_success fiptool "fip" "
	setup_test_images &&
	run_genimage fip.config test.fip &&
	check_size_range images/test.fip 12804 13056 &&
	fiptool info images/test.fip
"

test_expect_success fiptool "fip-size" "
	setup_test_images &&
	test_must_fail run_genimage fip-size.config test.fip
"

exec_test_set_prereq mdadm
test_expect_success mdadm "mdraid" "
	run_genimage_root mdraid.config test.mdraid-a &&
	LANG=C mdadm --examine images/test.mdraid-a | tee images/test.mdraid-a.txt &&
	LANG=C mdadm --examine images/test.mdraid-b | tee images/test.mdraid-b.txt &&
	grep 'Checksum.*correct$' images/test.mdraid-a.txt &&
	grep 'State.*active$' images/test.mdraid-a.txt &&
	grep 'Internal Bitmap.*sectors' images/test.mdraid-a.txt &&
	grep 'Bad Block Log.*entries available' images/test.mdraid-a.txt &&
	grep -Ev '(Device UUID|Checksum|Device Role) :' images/test.mdraid-a.txt | tail -n +2 > images/test.mdraid-a.arr.txt &&
	grep -Ev '(Device UUID|Checksum|Device Role) :' images/test.mdraid-b.txt | tail -n +2 > images/test.mdraid-b.arr.txt &&
	diff images/test.mdraid-a.arr.txt images/test.mdraid-b.arr.txt
"

test_expect_success "custom" "
	run_genimage custom.config test.custom &&
	echo 'Hello genimage!' > images/test.custom.expect &&
	test_cmp images/test.custom.expect images/test.custom
"

test_done

# vim: syntax=sh