osbase/bringup: add bringup
Introduce a library which handles the bringup of a running environment
for supervisor runnables.
Change-Id: I03c049d1bac7afdc71dfa24247923070982f07cd
Reviewed-on: https://review.monogon.dev/c/monogon/+/2930
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/osbase/bringup/test/BUILD.bazel b/osbase/bringup/test/BUILD.bazel
new file mode 100644
index 0000000..7e010e0
--- /dev/null
+++ b/osbase/bringup/test/BUILD.bazel
@@ -0,0 +1,111 @@
+load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
+load("//osbase/build:def.bzl", "node_initramfs")
+load("//osbase/build:efi.bzl", "efi_unified_kernel_image")
+
+go_test(
+ name = "test_test",
+ size = "medium",
+ srcs = ["run_test.go"],
+ data = [
+ ":kernel_failed",
+ ":kernel_succeeded",
+ "//third_party/edk2:OVMF_CODE.fd",
+ "//third_party/edk2:OVMF_VARS.fd",
+ "@qemu//:qemu-x86_64-softmmu",
+ ],
+ importpath = "source.monogon.dev/metropolis/installer/test",
+ visibility = ["//visibility:private"],
+ x_defs = {
+ "xOvmfVarsPath": "$(rlocationpath //third_party/edk2:OVMF_VARS.fd )",
+ "xOvmfCodePath": "$(rlocationpath //third_party/edk2:OVMF_CODE.fd )",
+ "xQemuPath": "$(rlocationpath @qemu//:qemu-x86_64-softmmu )",
+ "xSucceedKernelPath": "$(rlocationpath :kernel_succeeded )",
+ "xFailedKernelPath": "$(rlocationpath :kernel_failed )",
+ },
+ deps = [
+ "//osbase/cmd",
+ "@io_bazel_rules_go//go/runfiles:go_default_library",
+ ],
+)
+
+go_library(
+ name = "succeeded_lib",
+ srcs = ["main_succeeded.go"],
+ importpath = "source.monogon.dev/osbase/bringup/test",
+ visibility = ["//visibility:private"],
+ deps = [
+ "//osbase/bootparam",
+ "//osbase/bringup",
+ "//osbase/efivarfs",
+ "//osbase/logtree",
+ "//osbase/supervisor",
+ "@org_golang_x_sys//unix",
+ "@org_uber_go_multierr//:multierr",
+ ],
+)
+
+go_binary(
+ name = "succeeded",
+ embed = [":succeeded_lib"],
+ visibility = ["//visibility:private"],
+)
+
+node_initramfs(
+ name = "initramfs_succeeded",
+ files = {
+ ":succeeded": "/init",
+ },
+ fsspecs = [
+ "//osbase/build:earlydev.fsspec",
+ ],
+ visibility = ["//visibility:private"],
+)
+
+efi_unified_kernel_image(
+ name = "kernel_succeeded",
+ cmdline = "quiet console=ttyS0 init=/init",
+ initrd = [":initramfs_succeeded"],
+ kernel = "//third_party/linux",
+ visibility = ["//visibility:private"],
+)
+
+go_library(
+ name = "failed_lib",
+ srcs = ["main_failed.go"],
+ importpath = "source.monogon.dev/osbase/bringup/test",
+ visibility = ["//visibility:private"],
+ deps = [
+ "//osbase/bootparam",
+ "//osbase/bringup",
+ "//osbase/efivarfs",
+ "//osbase/logtree",
+ "//osbase/supervisor",
+ "@org_golang_x_sys//unix",
+ "@org_uber_go_multierr//:multierr",
+ ],
+)
+
+go_binary(
+ name = "failed",
+ embed = [":failed_lib"],
+ visibility = ["//visibility:private"],
+)
+
+node_initramfs(
+ name = "initramfs_failed",
+ files = {
+ ":failed": "/init",
+ },
+ fsspecs = [
+ "//osbase/build:earlydev.fsspec",
+ ],
+ visibility = ["//visibility:private"],
+)
+
+efi_unified_kernel_image(
+ name = "kernel_failed",
+ cmdline = "quiet console=ttyS0 init=/init",
+ initrd = [":initramfs_failed"],
+ kernel = "//third_party/linux",
+ visibility = ["//visibility:private"],
+)