configure: Enable test and libs for zstd
[qemu.git] / tests / vm / netbsd
1 #!/usr/bin/env python3
2 #
3 # NetBSD VM image
4 #
5 # Copyright 2017-2019 Red Hat Inc.
6 #
7 # Authors:
8 #  Fam Zheng <famz@redhat.com>
9 #  Gerd Hoffmann <kraxel@redhat.com>
10 #
11 # This code is licensed under the GPL version 2 or later.  See
12 # the COPYING file in the top-level directory.
13 #
14
15 import os
16 import sys
17 import time
18 import subprocess
19 import basevm
20
21 class NetBSDVM(basevm.BaseVM):
22     name = "netbsd"
23     arch = "x86_64"
24
25     link = "https://cdn.netbsd.org/pub/NetBSD/NetBSD-8.1/images/NetBSD-8.1-amd64.iso"
26     csum = "718f275b7e0879599bdac95630c5e3f2184700032fdb6cdebf3bdd63687898c48ff3f08f57b89f4437a86cdd8ea07c01a39d432dbb37e1e4b008f4985f98da3f"
27     size = "20G"
28     pkgs = [
29         # tools
30         "git-base",
31         "pkgconf",
32         "xz",
33         "python37",
34
35         # gnu tools
36         "bash",
37         "gmake",
38         "gsed",
39         "flex", "bison",
40
41         # libs: crypto
42         "gnutls",
43
44         # libs: images
45         "jpeg",
46         "png",
47
48         # libs: ui
49         "SDL2",
50         "gtk3+",
51         "libxkbcommon",
52
53         # libs: migration
54         "zstd",
55     ]
56
57     BUILD_SCRIPT = """
58         set -e;
59         rm -rf /home/qemu/qemu-test.*
60         cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
61         mkdir src build; cd src;
62         tar -xf /dev/rld1a;
63         cd ../build
64         ../src/configure --python=python3.7 --disable-opengl {configure_opts};
65         gmake --output-sync -j{jobs} {target} {verbose};
66     """
67     poweroff = "/sbin/poweroff"
68
69     # Workaround for NetBSD + IPv6 + slirp issues.
70     # NetBSD seems to ignore the ICMPv6 Destination Unreachable
71     # messages generated by slirp.  When the host has no IPv6
72     # connectivity, this causes every connection to ftp.NetBSD.org
73     # take more than a minute to be established.
74     ipv6 = False
75
76     def build_image(self, img):
77         cimg = self._download_with_cache(self.link, sha512sum=self.csum)
78         img_tmp = img + ".tmp"
79         iso = img + ".install.iso"
80
81         self.print_step("Preparing iso and disk image")
82         subprocess.check_call(["ln", "-f", cimg, iso])
83         self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
84
85         self.print_step("Booting installer")
86         self.boot(img_tmp, extra_args = [
87             "-bios", "pc-bios/bios-256k.bin",
88             "-machine", "graphics=off",
89             "-cdrom", iso
90         ])
91         self.console_init()
92         self.console_wait("Primary Bootstrap")
93
94         # serial console boot menu output doesn't work for some
95         # reason, so we have to fly blind ...
96         for char in list("5consdev com0\n"):
97             time.sleep(0.2)
98             self.console_send(char)
99             self.console_consume()
100         self.console_wait_send("> ", "boot\n")
101
102         self.console_wait_send("Terminal type",            "xterm\n")
103         self.console_wait_send("a: Installation messages", "a\n")
104         self.console_wait_send("b: US-English",            "b\n")
105         self.console_wait_send("a: Install NetBSD",        "a\n")
106         self.console_wait("Shall we continue?")
107         self.console_wait_send("b: Yes",                   "b\n")
108
109         self.console_wait_send("a: ld0",                   "a\n")
110         self.console_wait_send("a: This is the correct",   "a\n")
111         self.console_wait_send("b: Use the entire disk",   "b\n")
112         self.console_wait("NetBSD bootcode")
113         self.console_wait_send("a: Yes",                   "a\n")
114         self.console_wait_send("b: Use existing part",     "b\n")
115         self.console_wait_send("x: Partition sizes ok",    "x\n")
116         self.console_wait_send("for your NetBSD disk",     "\n")
117         self.console_wait("Shall we continue?")
118         self.console_wait_send("b: Yes",                   "b\n")
119
120         self.console_wait_send("b: Use serial port com0",  "b\n")
121         self.console_wait_send("f: Set serial baud rate",  "f\n")
122         self.console_wait_send("a: 9600",                  "a\n")
123         self.console_wait_send("x: Exit",                  "x\n")
124
125         self.console_wait_send("a: Full installation",     "a\n")
126         self.console_wait_send("a: CD-ROM",                "a\n")
127
128         self.print_step("Installation started now, this will take a while")
129         self.console_wait_send("Hit enter to continue",    "\n")
130
131         self.console_wait_send("d: Change root password",  "d\n")
132         self.console_wait_send("a: Yes",                   "a\n")
133         self.console_wait("New password:")
134         self.console_send("%s\n" % self.ROOT_PASS)
135         self.console_wait("New password:")
136         self.console_send("%s\n" % self.ROOT_PASS)
137         self.console_wait("Retype new password:")
138         self.console_send("%s\n" % self.ROOT_PASS)
139
140         self.console_wait_send("o: Add a user",            "o\n")
141         self.console_wait("username")
142         self.console_send("%s\n" % self.GUEST_USER)
143         self.console_wait("to group wheel")
144         self.console_wait_send("a: Yes",                   "a\n")
145         self.console_wait_send("a: /bin/sh",               "a\n")
146         self.console_wait("New password:")
147         self.console_send("%s\n" % self.GUEST_PASS)
148         self.console_wait("New password:")
149         self.console_send("%s\n" % self.GUEST_PASS)
150         self.console_wait("Retype new password:")
151         self.console_send("%s\n" % self.GUEST_PASS)
152
153         self.console_wait_send("a: Configure network",     "a\n")
154         self.console_wait_send("a: vioif0",                "a\n")
155         self.console_wait_send("Network media type",       "\n")
156         self.console_wait("autoconfiguration")
157         self.console_wait_send("a: Yes",                   "a\n")
158         self.console_wait_send("DNS domain",               "localnet\n")
159         self.console_wait("Are they OK?")
160         self.console_wait_send("a: Yes",                   "a\n")
161         self.console_wait("installed in /etc")
162         self.console_wait_send("a: Yes",                   "a\n")
163
164         self.console_wait_send("e: Enable install",        "e\n")
165         proxy = os.environ.get("http_proxy")
166         if not proxy is None:
167             self.console_wait_send("f: Proxy",             "f\n")
168             self.console_wait("Proxy")
169             self.console_send("%s\n" % proxy)
170         self.console_wait_send("x: Install pkgin",         "x\n")
171         self.console_init(1200)
172         self.console_wait_send("Hit enter to continue", "\n")
173         self.console_init()
174
175         self.console_wait_send("g: Enable sshd",           "g\n")
176         self.console_wait_send("x: Finished conf",         "x\n")
177         self.console_wait_send("Hit enter to continue",    "\n")
178
179         self.print_step("Installation finished, rebooting")
180         self.console_wait_send("d: Reboot the computer",   "d\n")
181
182         # setup qemu user
183         prompt = "localhost$"
184         self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
185         self.console_wait_send(prompt, "exit\n")
186
187         # setup root user
188         prompt = "localhost#"
189         self.console_ssh_init(prompt, "root", self.ROOT_PASS)
190         self.console_sshd_config(prompt)
191
192         # setup virtio-blk #1 (tarfile)
193         self.console_wait(prompt)
194         self.console_send("echo 'chmod 666 /dev/rld1a' >> /etc/rc.local\n")
195
196         # turn off mprotect (conflicts with tcg)
197         self.console_wait(prompt)
198         self.console_send("echo security.pax.mprotect.enabled=0 >> /etc/sysctl.conf\n")
199
200         self.print_step("Configuration finished, rebooting")
201         self.console_wait_send(prompt, "reboot\n")
202         self.console_wait("login:")
203         self.wait_ssh()
204
205         self.print_step("Installing packages")
206         self.ssh_root_check("pkgin update\n")
207         self.ssh_root_check("pkgin -y install %s\n" % " ".join(self.pkgs))
208
209         # shutdown
210         self.ssh_root(self.poweroff)
211         self.console_wait("entering state S5")
212         self.wait()
213
214         os.rename(img_tmp, img)
215         os.remove(iso)
216         self.print_step("All done")
217
218 if __name__ == "__main__":
219     sys.exit(basevm.main(NetBSDVM))