Skip to content

Commit 99c2b1f

Browse files
committed
test: add sanitizer integration pipeline
Add a dedicated integration test that runs vmm Rust integration tests under ASAN, and wire a Buildkite pipeline generator for periodic sanitizer runs. Also document the run command and harden tools/test.sh for local runs under set -u by guarding BUILDKITE variable access. Signed-off-by: Aaron Ang <aaron.angyd@gmail.com>
1 parent 326fc46 commit 99c2b1f

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

.buildkite/pipeline_sanitizers.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Generate Buildkite pipelines dynamically."""
6+
7+
from common import BKPipeline
8+
9+
pipeline = BKPipeline(with_build_step=False)
10+
11+
pipeline.build_group_per_arch(
12+
"sanitizers",
13+
pipeline.devtool_test(
14+
devtool_opts="--no-build",
15+
pytest_opts="integration_tests/build/test_sanitizers.py",
16+
),
17+
)
18+
19+
print(pipeline.to_json())

tests/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ Unlike unit tests, Rust integration tests are each run in a separate process.
111111
To learn more about Rust integration test, see
112112
[the Rust book](https://doc.rust-lang.org/book/ch11-03-test-organization.html#integration-tests).
113113

114+
## Sanitizer Runs
115+
116+
Firecracker also has a dedicated build test that runs Rust integration tests
117+
under sanitizers:
118+
119+
```bash
120+
tools/devtool -y test -- -m nonci integration_tests/build/test_sanitizers.py
121+
```
122+
123+
The Buildkite sanitizer pipeline is generated by
124+
[`pipeline_sanitizers.py`](../.buildkite/pipeline_sanitizers.py).
125+
114126
## A/B-Tests
115127

116128
A/B-Testing is a testing strategy where some test function is executed twice in
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
"""Run Rust integration tests under sanitizers."""
4+
5+
import platform
6+
7+
import pytest
8+
9+
from framework import defs
10+
from host_tools.cargo_build import cargo, get_rustflags
11+
12+
TARGET = f"{platform.machine()}-unknown-linux-gnu"
13+
SANITIZERS = ("address",)
14+
REPO_ROOT = defs.FC_WORKSPACE_DIR
15+
VMM_TEST_TARGETS = sorted((REPO_ROOT / "src" / "vmm" / "tests").glob("*.rs"))
16+
17+
18+
@pytest.mark.nonci
19+
@pytest.mark.timeout(3600)
20+
@pytest.mark.parametrize("sanitizer", SANITIZERS)
21+
def test_rust_integration_tests_under_sanitizer(sanitizer):
22+
"""Run vmm Rust integration tests under the specified sanitizer."""
23+
cargo_args = " ".join(
24+
[
25+
f"--target {TARGET}",
26+
"-p vmm",
27+
*(f"--test {path.stem}" for path in VMM_TEST_TARGETS),
28+
]
29+
)
30+
target_dir = defs.LOCAL_BUILD_PATH / "cargo_target" / "sanitizers" / sanitizer
31+
rustflags = get_rustflags() + f"-Zsanitizer={sanitizer}"
32+
cargo(
33+
"test",
34+
cargo_args,
35+
"--test-threads=1",
36+
nightly=True,
37+
cwd=str(REPO_ROOT),
38+
env={
39+
"CARGO_TARGET_DIR": str(target_dir),
40+
"RUSTFLAGS": rustflags,
41+
},
42+
)

tools/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} --pdbcls=IPython.terminal.debugger:Te
5353

5454
# if the tests failed and we are running in CI, print some disk usage stats
5555
# to help troubleshooting
56-
if [ $ret != 0 ] && [ "$BUILDKITE" == "true" ]; then
56+
if [ $ret != 0 ] && [ "${BUILDKITE:-false}" == "true" ]; then
5757
df -ih
5858
df -h
5959
du -h / 2>/dev/null |sort -h |tail -32

0 commit comments

Comments
 (0)