Use ASAN when running unit tests in CI#56
Conversation
5734b31 to
6572533
Compare
| source "${HOME}"/.cargo/env && | ||
| rustup component add rust-src --toolchain nightly && | ||
| TARGET=$(rustc --version --verbose | grep host | cut -d" " -f2) && | ||
| RUSTFLAGS="-Z sanitizer=address" cargo +nightly test -Z build-std --target "$TARGET" |
There was a problem hiding this comment.
Tests are invoked from the image itself nowadays:
https://github.com/stackrox/berserker/blob/main/Dockerfile.build#L32
There was a problem hiding this comment.
I now invoke the ASAN unit tests from the image itself.
881dc23 to
d030a12
Compare
d030a12 to
c135bad
Compare
ebc47a6 to
bcef02e
Compare
Co-authored-by: Dmitrii Dolgov <9erthalion6@gmail.com>
To prevent memory leaks from allocations in helper functions, remember references to allocated objects. For now we assume only CString is reference.
7ef2bab to
2fab6d0
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds configurable stable and nightly container testing with nightly address-sanitizer execution. It also tracks allocated JIT C-string pointers, releases them through a generated cleanup call, and reformats comments and documentation. ChangesNightly toolchain and script cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Makefile
participant Containerfile
participant Rustup
participant Cargo
participant ScriptWorker
participant Runtime
Makefile->>Containerfile: build nightly image
Containerfile->>Rustup: install nightly toolchain and rust-src
Containerfile->>Cargo: run sanitizer-enabled tests
ScriptWorker->>Runtime: dispatch C-string instruction
Runtime-->>ScriptWorker: return runtime result
ScriptWorker->>Runtime: invoke final cleanup
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Containerfile`:
- Line 1: Fix the Dockerfile lint issues by updating the stage alias in the
top-level FROM instruction to use matching uppercase AS, and change the
ENTRYPOINT in the Containerfile to JSON/exec form instead of shell form. Use the
FROM and ENTRYPOINT instructions in this file as the targets for the cleanup.
- Around line 45-50: The nightly ASAN test branch in the Containerfile is
missing the crate’s `nightly` Cargo feature, so the `sanitize` feature gate in
`src/lib.rs` never turns on. Update the `cargo +nightly test` invocation in this
RUN block to include the crate’s `nightly` feature alongside the existing `-Z
build-std` and `RUSTFLAGS="-Z sanitizer=address"` settings, so the ASAN path
actually exercises the intended nightly-only code.
In `@Makefile`:
- Around line 9-10: The Makefile’s two docker build steps currently reuse the
same berserker tag, so the nightly build overwrites the stable image. Update the
second docker build invocation to use a distinct tag for the nightly variant
while keeping the first build as the default berserker image, so later steps
consume the intended stable image; make this change in the build commands near
the two docker build lines.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: af1e2ced-f111-4070-bda9-21101f6c0352
📒 Files selected for processing (7)
Cargo.tomlContainerfileMakefilesrc/lib.rssrc/main.rssrc/worker/script.rssrc/worker/syscalls/ioctl.rs
| @@ -1,10 +1,8 @@ | |||
| FROM registry.fedoraproject.org/fedora:43 as builder | |||
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Minor Dockerfile lint fixes flagged by pipeline.
as should match FROM casing (AS) on line 1, and ENTRYPOINT should use JSON/exec form on line 62.
🧹 Proposed fix
-FROM registry.fedoraproject.org/fedora:43 as builder
+FROM registry.fedoraproject.org/fedora:43 AS builder-ENTRYPOINT berserker
+ENTRYPOINT ["berserker"]Also applies to: 62-62
🧰 Tools
🪛 GitHub Actions: Main berserker CI / 0_build-and-push.txt
[warning] 1-1: Dockerfile lint warning: FromAsCasing - 'as' and 'FROM' keywords' casing do not match.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Containerfile` at line 1, Fix the Dockerfile lint issues by updating the
stage alias in the top-level FROM instruction to use matching uppercase AS, and
change the ENTRYPOINT in the Containerfile to JSON/exec form instead of shell
form. Use the FROM and ENTRYPOINT instructions in this file as the targets for
the cleanup.
Source: Pipeline failures
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Containerfile.test`:
- Line 1: Update the Containerfile.test base image and the Makefile targets that
build and run tests so the base image is explicitly selectable, with distinct
stable and nightly test images exercising their corresponding toolchains. Ensure
the default test flow runs the stable image while retaining an explicit nightly
test path, and avoid leaving either built tool image unused.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 4442deaf-4b9b-4bd7-9a9a-363557287891
📒 Files selected for processing (5)
ContainerfileContainerfile.testMakefilesrc/lib.rssrc/worker/script.rs
💤 Files with no reviewable changes (1)
- src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (3)
- Makefile
- Containerfile
- src/worker/script.rs
Molter73
left a comment
There was a problem hiding this comment.
A single comment on the nightly feature probably being able to be removed, otherwise LGTM!
|
|
||
| [features] | ||
| default = [] | ||
| nightly = [] |
There was a problem hiding this comment.
Do we still need this feature?
Adds CI unit test jobs with and without ASAN.
The ASAN tests found a failure https://github.com/stackrox/berserker/actions/runs/24287041420/job/70918030561?pr=56 when the target branch was #55