aboutsummaryrefslogtreecommitdiff
path: root/tests/machine/testscript
blob: 91313d31bb89637d8b8ae15967e91d36c8c5ffa1 (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
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
# file      : tests/machine/testscript
# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
# license   : TBC; see accompanying LICENSE file

# Note that if interrupted (^C) during machine execution, then have to
# delete iptables rules manually. To list, use -S, to delete -D:
#
# iptables -t nat -S
# iptables -S

test.options = --cpu 8 --ram 10485760 --verbose 3

tftp = /build/tftp
machines = /btrfs/boris/machines # @@ TODO

toolchain_url   = https://stage.build2.org/0
toolchain_trust = B8:52:AB:94:C5:FA:73:F3:53:D3:F1:EB:0F:E0:E4:06:32:3F:E2:46:22:FA:39:05:C8:FA:70:B7:21:E2:46:C5

pkg = hello
ver = 1.0.0
rep = https://build2.org/pkg/1/stage/stable
rfp = FF:DF:7D:38:67:4E:C3:82:65:7E:EE:1F:D4:80:EC:56:C4:33:5B:65:3F:9B:29:9A:30:56:B9:77:B9:F2:01:94

# Download the toolchain.
#
# Note: similar logic to what we have in Build OS.
#
+mkdir -p $tftp/toolchains/default/
+curl -s -S -f -L $toolchain_url/toolchain.sha256 >=toolchain.sha256

+sed -n -e 's%^[0-9a-f]+ \*(.+)$%\1%p' toolchain.sha256 | set -e archives
+sed -n -e 's%^(.+/)?build2-toolchain-([^.]+\.[^.]+\.[^-]+(-[ab]\.[^.+]+)?).*\.tar.*%\2%p' <"$archives" | set version
+sha256sum -b toolchain.sha256 | sed -n -e 's%^([0-9a-f]+) .*$%\1%p' | set checksum

+/bin/bash -c "while read i && test -n \"\$i\"; do \
b=`basename \$i` ; \
f=$tftp/toolchains/default/\$b; \
echo \$b: 1>&2; \
curl -# -f -L -z \$f -o \$f $toolchain_url/\$i; \
ln -sf \$b `sed -n -re 's/^\(.+\)-$version\(\\..+\)?\(\\.zip|\\.tar\\..+\|-.+)/\\1\\3/p' <<<\$f`; \
done" <"$archives" 2>|

+echo "$version"         >=$tftp/toolchains/default/version
+echo "$toolchain_trust" >=$tftp/toolchains/default/trust

#\
#
# To test the bootstrap script locally, start the TFTP server in
# $tftp/toolchains/default/.
#

sudo /usr/sbin/in.tftpd \
  --foreground \
  --address :55123 \
  --user "$(whoami)" \
  --permissive \
  --create \
  --secure \
  "$(pwd)"

# Then uncommen testing setting (after option parsing) and run:

etc/bootstrap/bbot-bootstrap.sh # Should bootstrap (check manifest on TFTP).
etc/bootstrap/bbot-bootstrap.sh # Should startup (fails with invalid manifest).

# The same can be done for batch files but from the Windows VM.

# Can also provide a test task manifest from below.

#\

# Boostrap and list the machines.
#
test.options += --machines $machines --toolchain-id $checksum

+$* --dump-machines 2>| | sed -n -e 's/^name: (.+)$/\1/p' | set -n machine

# Perform a test build.
#
+echo "building on $machine" >&2 2>|

+cat <<"EOI" | $* --fake-request - --dump-result >| 2>|
  : 1
  name: $pkg
  version: $ver
  repository: $rep
  trust: $rfp
  machine: $machine
  EOI