Skip to content

Commit a12b56e

Browse files
committed
test: Allow get_binary to compile example from different package
Previously, it could only compile examples from the main firecracker package. To compile examples from package "x", we need to pass `-p x`. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent b53d634 commit a12b56e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/host_tools/cargo_build.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ def cargo_test(path, extra_args=""):
6666

6767

6868
@with_filelock
69-
def get_binary(name, *, workspace_dir=FC_WORKSPACE_DIR, example=False):
69+
def get_binary(name, *, workspace_dir=FC_WORKSPACE_DIR, example=None):
7070
"""Build a binary"""
7171
target = DEFAULT_BUILD_TARGET
7272
target_dir = workspace_dir / "build" / "cargo_target"
7373
bin_path = target_dir / target / "release" / name
7474
cmd = f"-p {name}"
7575
if example:
76-
bin_path = target_dir / target / "release" / "examples" / name
77-
cmd = f"--example {name}"
76+
bin_path = target_dir / target / "release" / "examples" / example
77+
cmd += f" --example {example}"
7878
if not bin_path.exists():
7979
env = {"RUSTFLAGS": get_rustflags()}
8080
cargo(
@@ -99,9 +99,9 @@ def get_firecracker_binaries(*, workspace_dir=FC_WORKSPACE_DIR):
9999
)
100100

101101

102-
def get_example(name, *args, **kwargs):
102+
def get_example(name, *args, package="firecracker", **kwargs):
103103
"""Build an example binary"""
104-
return get_binary(name, *args, **kwargs, example=True)
104+
return get_binary(package, *args, **kwargs, example=name)
105105

106106

107107
@with_filelock

0 commit comments

Comments
 (0)