summaryrefslogtreecommitdiffstats
path: root/bootstrap-stage1-test.sh
blob: 80e6659bfac5e9b47d7760c740d5a78d02eef20a (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
#!/bin/sh

set -e

ARCH=

main()
{
	ARCH="$(cat /etc/proteanos_arch)"

	cat <<-EOF

		Testing packages in stage 1...
		==============================
		EOF

	test_packages
}

log()
{
	local msg i

	msg="$(printf "${@}")"
	printf '\n%s\n' "${msg}"
	i=0
	while [ ${i} -lt ${#msg} ]; do
		printf '-'
		i=$(($i + 1))
	done
	printf '\n\n'
}

test_packages()
{
	local zlib_upstream_ver

	cd root

	log 'Testing BusyBox...'
	sudo chroot . true

	log 'Testing GNU readelf...'
	sudo chroot . readelf -hl /usr/bin/readelf

	log 'Testing GCC...'
	zlib_upstream_ver="$(printf '%s' ../pkg/zlib/zlib-*.orig.tar* | sed \
		's|^.*/zlib-\([a-z0-9.~]*\).*\.orig\.tar.*$|\1|')"
	tar -xjOf ../pkg/zlib/zlib-*.orig.tar* \
		"zlib-${zlib_upstream_ver}/examples/fitblk.c" >fitblk.c
	sudo chroot . "${ARCH}-gcc" -lz -o /fitblk /fitblk.c
	sudo chroot . /fitblk | grep -F 'fitblk abort' >/dev/null

	cd ..
}

main "${@}"