aboutsummaryrefslogtreecommitdiff
path: root/tests/machine/testscript
blob: 9265334d0c26dd402fb86ef1332e751b660084f4 (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
90
91
92
93
94
95
96
97
# file      : tests/machine/testscript
# copyright : Copyright (c) 2014-2019 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 = 37:CE:2C:A5:1D:CF:93:81:D7:07:46:AD:66:B3:C3:90:83:B8:96:9E:34:F0:E7:B3:A2:B0:6C:EF:66:A4:BE:65

pkg = hello
ver = 1.0.0
rep_url = https://hello.stage.build2.org/1/stable
rep_type = pkg
rfp = 37:CE:2C:A5:1D:CF:93:81:D7:07:46:AD:66:B3:C3:90:83:B8:96:9E:34:F0:E7:B3:A2:B0:6C:EF:66:A4:BE:65

# @@ There is currently no way to obtain a valid (default?) target for the
# machine so assume it is a x86-64-bit build for something.
#
target = x86_64-unknown-unknown

# Download the toolchain.
#
# Note: similar logic to what we have in Build OS.
#
+mkdir -p $tftp/toolchains/default/
+curl -sS --fail --location $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 -# --fail --location --time-cond \$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-url: $rep_url
  repository-type: $rep_type
  trust: $rfp
  machine: $machine
  target: $target
  EOI