Skip to content

Commit 34ee078

Browse files
committed
test: add sanitizer integration pipeline
Add a dedicated integration test to run 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 143a4ce commit 34ee078

4 files changed

Lines changed: 72 additions & 1 deletion

File tree

.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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
from uuid import uuid4
7+
8+
import pytest
9+
10+
from framework import defs
11+
from host_tools.cargo_build import cargo
12+
13+
TARGET = f"{platform.machine()}-unknown-linux-gnu"
14+
SANITIZERS = ("address",)
15+
REPO_ROOT = defs.FC_WORKSPACE_DIR
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+
target_flag_var = f"CARGO_TARGET_{TARGET.upper().replace('-', '_')}_RUSTFLAGS"
24+
target_dir = (
25+
defs.LOCAL_BUILD_PATH
26+
/ "cargo_target"
27+
/ "sanitizers"
28+
/ (f"{sanitizer}-{uuid4().hex}")
29+
)
30+
cargo(
31+
"test",
32+
f"--target {TARGET} -p vmm --test integration_tests",
33+
"--test-threads=1",
34+
nightly=True,
35+
cwd=str(REPO_ROOT),
36+
env={
37+
"CARGO_TARGET_DIR": str(target_dir),
38+
target_flag_var: f"-Zsanitizer={sanitizer}",
39+
},
40+
)

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)