-
Notifications
You must be signed in to change notification settings - Fork 140
/
build.sh
executable file
·143 lines (135 loc) · 4.52 KB
/
build.sh
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
#!/bin/sh
#
# THIS IS NOT THE BUILD SCRIPT FOR SOLO5. DO NOT RUN THIS SCRIPT MANUALLY
# UNLESS YOU KNOW WHAT YOU ARE DOING, AND WHAT THE SCRIPT DOES.
#
# This script is used for automated builds with surf-build and Travis CI.
# See https://github.com/Solo5/solo5-ci for details.
#
if type gmake >/dev/null 2>&1; then
MAKE=gmake
else
MAKE=make
fi
message()
{
printf %80s\\n | tr " " "\*"
echo "$@"
printf %80s\\n | tr " " "\*"
}
do_info()
{
message "System information:"
uname -a
# XXX: Only looking at TARGET_{CC,LD} here -- sync with what configure.sh
# does or add a "verbose" mode to that instead?
CC=${TARGET_CC:-cc}
LD=${TARGET_LD:-ld}
echo "Compiler (${CC}) version:"
${CC} --version
echo "Compiler version detail:"
${CC} -v
echo "Linker (${LD}) version:"
${LD} -v
}
try()
{
if ( eval "$@" ); then
:
else
echo "FAILURE: '$@' failed: Status: $?"
exit 1
fi
}
do_basic()
{
message "Starting build."
try ./configure.sh
try ${MAKE}
# Some CIs can now run tests, so do that.
if [ -n "${SURF_RUN_TESTS}" ]; then
message "Running tests:"
try ${SURF_SUDO} tests/setup-tests.sh
try ${SURF_SUDO} tests/run-tests.sh
# On Linux x86_64 Debian VMs only, also test solo5-virtio-mkimage.
# Specifically don't run this on Ubuntu (Travis) as their syslinux
# package is broken and incomplete. The following seems as good a way
# as any to tell we're on actual Debian as opposed to Ubuntu.
if gcc --version 2>/dev/null | grep -q Debian; then
if [ "$(uname -s)" = "Linux" -a "$(uname -m)" = "x86_64" ]; then
message "Testing solo5-virtio-mkimage.sh:"
try scripts/virtio-mkimage/solo5-virtio-mkimage.sh \
test.img tests/test_hello/test_hello.virtio
# XXX Can't use try() here due to 83 == OK
timeout 10s \
qemu-system-x86_64 -machine q35 \
-display none -serial file:serial.out \
-drive file=test.img,if=virtio,format=raw \
-device isa-debug-exit
if grep -q 'solo5_exit(0) called' serial.out; then
echo "SUCCESS"
rm -f test.img serial.out
else
echo "FAILURE. Log follows:"
cat serial.out
exit 1
fi
fi
fi
fi
message "Testing 'make install'."
try ${MAKE} install DESTDIR=/tmp/install
message "Testing 'make distrib'."
try ${MAKE} distrib
}
do_e2e()
{
message "Starting E2E tests."
(
# Force the package universe used by the E2E tests to use this
# checked out copy of Solo5.
u_SOLO5=./tests/e2e-mirage-solo5/universe/solo5-bindings-hvt
set -xe
rm -f ${u_SOLO5}/local ${u_SOLO5}/master ${u_SOLO5}/release
ln -s $(readlink -f .) ${u_SOLO5}/local
# Hack around the fact that OPAM switches are not relocatable by running out
# of the fixed path '/tmp/e2e'. This allows us to make use of the base
# switch cache which has been pre-populated on the CI VM.
mkdir -p /tmp/e2e
# /tmp/e2e can't be a symlink for ... various reasons...
${SURF_SUDO} mount --bind $(readlink -f ./tests/e2e-mirage-solo5) /tmp/e2e
mkdir -p /tmp/e2e/run/switch
ln -s /home/build/cache/switch.tar.gz /tmp/e2e/run/switch.tar.gz
) || exit 1
cd /tmp/e2e
try $(opam env) dune exec bin/main.exe
}
case "${SURF_BUILD_TYPE}" in
basic)
# Squash warnings from Git if not configured.
if [ ! -f "${HOME}/.gitconfig" ]; then
git config --local user.name "Solo5 CI"
git config --local user.email build@example.com
fi
${SURF_SUDO} git config --global --add safe.directory $(pwd)
do_info
do_basic
;;
e2e)
do_info
do_e2e
;;
*)
echo "ERROR: SURF_BUILD_TYPE not set."
echo "NOTE: This is not the build script for Solo5."
echo "NOTE: Do not run this script manually, unless you know what you are doing,"
echo "NOTE: and you know what the script does."
exit 1
;;
esac
# surf-build sometimes fails spuriously with an 'EBADF: bad file descriptor,
# write' just before exiting. We attempt to work around this in the CI driver
# script by looking for the message below in the build log.
message "BUILD SUCCEEDED"
# NOTE: Failure exit status is returned in try(), if we got here then the build
# NOTE: completed.