Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions bazel/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,33 @@ def _mcopy(ctx):
out = ctx.actions.declare_file(ctx.label.name)

command = "cp -p {fs} {output} && chmod +w {output} ".format(fs = ctx.file.fs.path, output = out.path)
for src in ctx.files.srcs:
command += "&& mcopy -mi {output} -sQ {src_path} ::/{filename} ".format(output = out.path, src_path = src.path, filename = ctx.attr.remap_paths.get(src.basename, src.basename))
inputs = []
for srcs, dest in ctx.attr.srcmap.items():
src_files = srcs[DefaultInfo].files.to_list()
for src_file in src_files:
inputs.append(src_file)
if dest.endswith("/"):
dest_path = dest + src_file.basename
else:
dest_path = dest
command += "&& mcopy -mi {output} -sQ {src_path} ::/{dest} ".format(
output = out.path,
src_path = src_file.path,
dest = dest_path.removeprefix("/"),
)

ctx.actions.run_shell(
command = command,
inputs = ctx.files.srcs + [ctx.file.fs],
inputs = inputs + [ctx.file.fs],
outputs = [out],
)
return [DefaultInfo(files = depset([out]), runfiles = ctx.runfiles(files = [out]))]

mcopy = rule(
implementation = _mcopy,
attrs = {
"srcs": attr.label_list(allow_files = True),
"srcmap": attr.label_keyed_string_dict(allow_files = True),
"fs": attr.label(allow_single_file = True),
"remap_paths": attr.string_dict(),
},
)

Expand Down
67 changes: 25 additions & 42 deletions rs/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,9 @@ oci_tar(

uvm_config_image(
name = "colocate_uvm_config_image",
srcs = [
":ubuntu_test_runtime.tar",
"//rs/tests:activate-systest-uvm-config",
],
remap_paths = {
"activate-systest-uvm-config": "activate",
srcmap = {
":ubuntu_test_runtime.tar": "ubuntu_test_runtime.tar",
"//rs/tests:activate-systest-uvm-config": "activate",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)
Expand All @@ -161,12 +158,9 @@ exports_files([

uvm_config_image(
name = "jaeger_uvm_config_image",
srcs = [
":jaeger.tar",
":jaeger_activate.sh",
],
remap_paths = {
"jaeger_activate.sh": "activate",
srcmap = {
":jaeger.tar": "jaeger.tar",
":jaeger_activate.sh": "activate",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)
Expand Down Expand Up @@ -213,42 +207,34 @@ oci_tar(

uvm_config_image(
name = "ckbtc_uvm_config_image",
srcs = [
":bitcoind.tar",
":dogecoind.tar",
":minica.tar",
":nginx-proxy.tar",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key",
"//rs/tests/httpbin-rs:httpbin.tar",
],
remap_paths = {
"canister_http_test_ca.cert": "cert.pem",
"canister_http_test_ca.key": "key.pem",
srcmap = {
":bitcoind.tar": "bitcoind.tar",
":dogecoind.tar": "dogecoind.tar",
":minica.tar": "minica.tar",
":nginx-proxy.tar": "nginx-proxy.tar",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "cert.pem",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "key.pem",
"//rs/tests/httpbin-rs:httpbin.tar": "httpbin.tar",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)

uvm_config_image(
name = "impersonate_upstreams_uvm_config_image",
srcs = [
":minica.tar",
":static-file-server.tar",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key",
],
remap_paths = {
"canister_http_test_ca.cert": "minica.pem",
"canister_http_test_ca.key": "minica-key.pem",
srcmap = {
":minica.tar": "minica.tar",
":static-file-server.tar": "static-file-server.tar",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "minica.pem",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "minica-key.pem",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)

uvm_config_image(
name = "ic_gateway_uvm_config_image",
srcs = [
":ic_gatewayd.tar",
],
srcmap = {
":ic_gatewayd.tar": "ic_gatewayd.tar",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)

Expand All @@ -266,12 +252,9 @@ exports_files([

uvm_config_image(
name = "vector_with_log_fetcher_image",
srcs = [
":vector-with-log-fetcher.tar",
":vector_activate.sh",
],
remap_paths = {
"vector_activate.sh": "activate",
srcmap = {
":vector-with-log-fetcher.tar": "vector-with-log-fetcher.tar",
":vector_activate.sh": "activate",
},
tags = ["manual"],
)
Expand Down
28 changes: 9 additions & 19 deletions rs/tests/cross_chain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ system_test_nns(
],
)

filegroup(
name = "erc20_contract",
srcs = [
"ERC20.sol",
],
)

oci_tar(
name = "foundry.tar",
image = "@foundry",
Expand All @@ -83,11 +76,11 @@ oci_tar(

uvm_config_image(
name = "cketh_uvm_config_image",
srcs = [
":erc20_contract",
":foundry.tar",
"//rs/ethereum/cketh/minter:helper_contracts",
],
srcmap = {
":ERC20.sol": "ERC20.sol",
":foundry.tar": "foundry.tar",
"//rs/ethereum/cketh/minter:helper_contracts": "/",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)

Expand All @@ -98,13 +91,10 @@ exports_files([

uvm_config_image(
name = "btc_uvm_config_image",
srcs = [
":bitcoind.tar",
":btc_integration/bitcoin.conf",
":btc_integration/btc_activate.sh",
],
remap_paths = {
"btc_activate.sh": "activate",
srcmap = {
":bitcoind.tar": "bitcoind.tar",
":btc_integration/bitcoin.conf": "bitcoin.conf",
":btc_integration/btc_activate.sh": "activate",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)
Expand Down
17 changes: 6 additions & 11 deletions rs/tests/networking/canister_http/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ oci_tar(

uvm_config_image(
name = "http_uvm_config_image",
srcs = [
":minica.tar",
":universal_vm_activation.sh",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key",
"//rs/tests/httpbin-rs:httpbin.tar",
],
remap_paths = {
"universal_vm_activation.sh": "activate",
"canister_http_test_ca.cert": "cert.pem",
"canister_http_test_ca.key": "key.pem",
srcmap = {
":minica.tar": "minica.tar",
":universal_vm_activation.sh": "activate",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.cert": "cert.pem",
"//ic-os/components:networking/dev-certs/canister_http_test_ca.key": "key.pem",
"//rs/tests/httpbin-rs:httpbin.tar": "httpbin.tar",
},
tags = ["manual"], # this target will be built if required as a dependency of another target
)
12 changes: 6 additions & 6 deletions rs/tests/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ system_test(
uvm_config_image(
name = "root_tests_config_image",
testonly = True,
srcs = [
"//rs/ic_os/device:device_test",
"//rs/ic_os/os_tools/guest_disk:guest_disk_test",
"//rs/ic_os/os_tools/guest_vm_runner:upgrade_device_mapper_test",
"//rs/tests:ubuntu_test_runtime.tar",
],
srcmap = {
"//rs/ic_os/device:device_test": "device_test",
"//rs/ic_os/os_tools/guest_disk:guest_disk_test": "guest_disk_test",
"//rs/ic_os/os_tools/guest_vm_runner:upgrade_device_mapper_test": "upgrade_device_mapper_test",
"//rs/tests:ubuntu_test_runtime.tar": "ubuntu_test_runtime.tar",
},
tags = ["manual"],
)

Expand Down
11 changes: 4 additions & 7 deletions rs/tests/system_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,19 @@ def system_test_nns(name, enable_head_nns_variant = True, enable_mainnet_nns_var
)
return struct(test_driver_target = mainnet_nns_systest.test_driver_target)

def uvm_config_image(name, tags = None, visibility = None, srcs = None, remap_paths = None, testonly = True):
def uvm_config_image(name, tags = None, visibility = None, srcmap = None, testonly = True):
"""This macro creates bazel targets for uvm config images.

Args:
name: This name will be used for the target.
tags: Controls execution of targets. "manual" excludes a target from wildcard targets like (..., :*, :all). See: https://bazel.build/reference/test-encyclopedia#tag-conventions
visibility: Target visibility controls who may depend on a target.
srcs: Source files that are copied into a vfat image.
remap_paths: Dict that maps a current filename to a desired filename,
e.g. {"activate.sh": "activate"}
srcmap: Dictionary of source files to copy into a vfat image mapped to their desired path in the image.
testonly: If True, the target is only available in test configurations.
"""
native.genrule(
name = name + "_size",
srcs = srcs,
srcs = srcmap.keys(),
outs = [name + "_size.txt"],
cmd = "du --bytes -csL $(SRCS) | awk '$$2 == \"total\" {print 2 * $$1 + 1048576}' > $@",
tags = ["manual"],
Expand All @@ -367,9 +365,8 @@ def uvm_config_image(name, tags = None, visibility = None, srcs = None, remap_pa

mcopy(
name = name + "_mcopy",
srcs = srcs,
srcmap = srcmap,
fs = ":" + name + "_vfat",
remap_paths = remap_paths,
tags = ["manual"],
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:private"],
Expand Down
Loading