From c3fb1aa4a03665a6dc861499537698993767ed78 Mon Sep 17 00:00:00 2001 From: hector <42570491+majinghe@users.noreply.github.com> Date: Wed, 2 Dec 2026 03:48:51 -0800 Subject: [PATCH 1/2] ci: compile the nixl feature only on RDMA path changes (#9851) * ci: compile the nixl feature only on RDMA path changes Add a path-filtered workflow so the optional nixl build runs on pull requests and main pushes that touch NIXL/RDMA sources, and on manual dispatch. It reads the hosted Rust cache and does not save it. Co-authored-by: hector * ci: run the nixl compile check on the rdma runner Use the bare self-hosted label and a cache key that is not shared with the ubuntu-latest lanes. Co-authored-by: hector * ci: register the path-filtered nixl compile workflow Record the event-driven workflow in the validation registry and match future nixl RPC modules with the same path glob as the feature check. Co-authored-by: hector --------- Co-authored-by: Cursor Agent Co-authored-by: hector --- .github/actionlint.yaml | 1 + .github/scheduled-validations.json | 23 ++++ .github/workflows/README.md | 2 +- .github/workflows/rdma-build.yml | 139 +++++++++++++++++++++++ .github/workflows/rdma-feature-check.yml | 2 + docs/testing/ci-gates.md | 1 + 6 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/rdma-build.yml diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 2a8d870930..08cff6082f 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -7,3 +7,4 @@ self-hosted-runner: - dind-sm-standard-2 - smoke-testing - pf-testing + - rdma diff --git a/.github/scheduled-validations.json b/.github/scheduled-validations.json index f148d751aa..0d30e7d15c 100644 --- a/.github/scheduled-validations.json +++ b/.github/scheduled-validations.json @@ -296,6 +296,29 @@ "origin": "baseline", "alert_contract": "scheduled-validation" }, + { + "workflow": ".github/workflows/rdma-build.yml", + "name": "S3-over-RDMA compile", + "roles": [ + "pr", + "manual" + ], + "events": [ + "pull_request", + "push", + "workflow_dispatch" + ], + "cadence": "event", + "timezone": "UTC", + "schedule": [], + "owner": "@overtrue", + "policy": "active", + "monitor": "none", + "result_owner": "rdma-build.yml", + "disposition": "retained independent entry", + "monitor_reason": "Event-driven or operator-requested work has no periodic freshness obligation.", + "origin": "added" + }, { "workflow": ".github/workflows/rdma-feature-check.yml", "name": "S3-over-RDMA feature check", diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 0f43c9a021..e8890ff618 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -45,7 +45,7 @@ A hosted runner is also the only choice for a few things the pods cannot do: `mo - Every `shared-key` has exactly one writer. `cache-warm.yml` owns `ci-dev`, `ci-feat-proto` and `ci-uring`; every other `./.github/actions/setup` call states `cache-save-if` explicitly, and `scripts/security/check_cache_save_if.sh` fails the build when one does not. - The `ci-dev` key ends in a digest of `warm-ci-dev`'s build commands. Changing what that job warms therefore needs a new key, or readers keep restoring the old artifacts: `scripts/ci_gate.py --check-workflow` prints the key the commands require and fails until the writer and every registered `sm-standard-4` reader (`ci.yml`, `dual-stack-nightly.yml`, `e2e-replication-nightly.yml`, `fuzz.yml`, `gateway-acceptance.yml`, `mint.yml` and `reference-parity.yml`) name it. -- All readers of a key run on the same image as its writer. Keys that live on hosted runners say so in their name (`ci-uring` is warmed on `ubuntu-latest`; `ci-e2e-distributed-hosted` is written on `ubuntu-latest` by `e2e-distributed.yml` and read without saving by hosted server/E2E lanes such as `gateway-acceptance.yml`, `on-demand-migration-interop.yml`, `oidc-keycloak.yml`, `minio-interop.yml`, `e2e-upgrade.yml` and `rdma-feature-check.yml`). +- All readers of a key run on the same image as its writer. Keys that live on hosted runners say so in their name (`ci-uring` is warmed on `ubuntu-latest`; `ci-e2e-distributed-hosted` is written on `ubuntu-latest` by `e2e-distributed.yml` and read without saving by hosted server/E2E lanes such as `gateway-acceptance.yml`, `on-demand-migration-interop.yml`, `oidc-keycloak.yml`, `minio-interop.yml`, `e2e-upgrade.yml` and `rdma-feature-check.yml`). `rdma-build.yml` owns `ci-nixl-rdma` on the `rdma` label and is the only job that saves it. - Moving a job between pools therefore means renaming its key. The new key is empty until a run from `main` (a scheduled run, or a manual dispatch of that workflow from `main`) saves it; until then that lane does a cold build. The `build.yml` aarch64 release legs append `-ubicloud-arm` for this reason. `cache-warm.yml` does not write those keys. - `CARGO_BUILD_JOBS` and every other `CARGO*`, `CC*`, `CFLAGS*`, `CXX*`, `CMAKE*` and `RUST*` variable is hashed into the key. `ci.yml` sets `CARGO_BUILD_JOBS` at step level for that reason; promoting it to job level rotates the key for every lane that shares it. diff --git a/.github/workflows/rdma-build.yml b/.github/workflows/rdma-build.yml new file mode 100644 index 0000000000..79390ca8b9 --- /dev/null +++ b/.github/workflows/rdma-build.yml @@ -0,0 +1,139 @@ +# Copyright 2024 RustFS Team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: S3-over-RDMA compile + +# Compile the optional `nixl` feature when NIXL/RDMA sources change. +# Pull requests and pushes to main share one path list; workflow_dispatch +# runs the same job with no path filter. Unrelated changes do not start a runner. +# +# The job runs on the self-hosted `rdma` label, the same bare-label form as +# `smoke-testing` and `sm-standard-4`. nixl-sys links libnixl when that +# runner has it installed (NIXL_PREFIX, default /opt/nvidia/nvda_nixl, or +# pkg-config). When the libraries are absent it compiles wrapper.h plus the +# dlopen stub. This job does not set NIXL_NO_STUBS_FALLBACK. bindgen needs +# g++ and libclang; the setup action installs a C toolchain, and the step +# below adds libclang only when the image lacks it. +# +# Host-memory unit tests and the cuObject SDK lane stay in +# rdma-feature-check.yml (pull requests, weekly schedule, manual dispatch). +# Not a required check and not part of the `Test and Lint` aggregate. +# +# When adding a nixl-gated module, extend both path lists below. GitHub +# filters are whole files: shared files are listed because they contain +# `feature = "nixl"` branches, and crates/config/src/constants/internode.rs +# also holds unrelated internode constants. + +on: + pull_request: + branches: [main] + paths: + - "crates/nixl/**" + - "crates/ecstore/src/cluster/rpc/nixl_internode.rs" + - "crates/ecstore/src/cluster/rpc/nixl_internode/**" + - "crates/config/src/constants/internode.rs" + - "rustfs/src/app/multipart_usecase/upload_part.rs" + - "rustfs/src/app/object/cuobject.rs" + - "rustfs/src/app/object/get.rs" + - "rustfs/src/app/object/mod.rs" + - "rustfs/src/app/object/put.rs" + - "rustfs/src/app/storage_api.rs" + - "rustfs/src/startup_server.rs" + - "rustfs/src/storage/rpc/http_service.rs" + - "rustfs/src/storage/rpc/mod.rs" + - "rustfs/src/storage/rpc/nixl*" + - "rustfs/src/storage/storage_api.rs" + - "Cargo.toml" + - "rustfs/Cargo.toml" + - ".github/workflows/rdma-build.yml" + push: + branches: [main] + paths: + - "crates/nixl/**" + - "crates/ecstore/src/cluster/rpc/nixl_internode.rs" + - "crates/ecstore/src/cluster/rpc/nixl_internode/**" + - "crates/config/src/constants/internode.rs" + - "rustfs/src/app/multipart_usecase/upload_part.rs" + - "rustfs/src/app/object/cuobject.rs" + - "rustfs/src/app/object/get.rs" + - "rustfs/src/app/object/mod.rs" + - "rustfs/src/app/object/put.rs" + - "rustfs/src/app/storage_api.rs" + - "rustfs/src/startup_server.rs" + - "rustfs/src/storage/rpc/http_service.rs" + - "rustfs/src/storage/rpc/mod.rs" + - "rustfs/src/storage/rpc/nixl*" + - "rustfs/src/storage/storage_api.rs" + - "Cargo.toml" + - "rustfs/Cargo.toml" + - ".github/workflows/rdma-build.yml" + workflow_dispatch: + +permissions: + contents: read + +# Cancel a superseded pull-request attempt. Pushes and manual runs finish. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + nixl-build: + name: cargo check and test compile (nixl) + # Hardware: the RDMA/NIXL runner. Hosted ubuntu-latest has no NIXL/UCX + # libraries. The label matches smoke-testing and sm-standard-4 (bare + # label, not a [self-hosted, ...] list). + runs-on: rdma + timeout-minutes: 60 + env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" + steps: + - name: Checkout repository + uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7 + with: + persist-credentials: false + + - name: Setup Rust environment + uses: ./.github/actions/setup + with: + rust-version: stable + # Own key: rust-cache does not include the runner label, and + # ci-e2e-distributed-hosted is written on ubuntu-latest. + cache-shared-key: ci-nixl-rdma + cache-save-if: ${{ github.ref == 'refs/heads/main' }} + install-build-packaging-tools: 'false' + + - name: Install only missing native build tools + run: | + packages=() + command -v g++ >/dev/null || packages+=(g++) + ldconfig -p | grep -q 'libclang' || packages+=(libclang-dev) + if (( ${#packages[@]} )); then + sudo apt-get update + sudo apt-get install --no-install-recommends -y "${packages[@]}" + fi + + - name: Check the nixl feature build + run: cargo check --locked -p rustfs --features nixl + + # Compiles rustfs-nixl unit and integration tests, including client-http. + # Does not execute them: the host-memory suite runs in rdma-feature-check.yml. + # `cargo test --no-run -p rustfs` is not used; that harness is the workspace + # test build and does not fit this runner. + - name: Compile rustfs-nixl tests + run: cargo test --locked --no-run -p rustfs-nixl --features client-http diff --git a/.github/workflows/rdma-feature-check.yml b/.github/workflows/rdma-feature-check.yml index ef93492f49..002b256414 100644 --- a/.github/workflows/rdma-feature-check.yml +++ b/.github/workflows/rdma-feature-check.yml @@ -2,6 +2,8 @@ name: S3-over-RDMA feature check # Compile the optional RDMA features independently. The cuObject tests link # the NVIDIA SDK and exercise the host-side behavior on a CPU runner. +# Pushes to main are compiled by rdma-build.yml; this workflow keeps the +# rustfs-nixl unit tests, the cuObject SDK lane, and the weekly run. # Not a required check and not part of the `Test and Lint` aggregate. on: diff --git a/docs/testing/ci-gates.md b/docs/testing/ci-gates.md index cf37c0ed17..9582718eaa 100644 --- a/docs/testing/ci-gates.md +++ b/docs/testing/ci-gates.md @@ -65,6 +65,7 @@ The four site-replication state-writer concurrency proofs reserve the available | PR touching `paths` in `audit.yml` | `Cargo Deny`, `Workflow Pin Report`, `Dependency Review` | `audit.yml` `cargo-deny`, `workflow-pin-report`, `dependency-review` | Report-only | `cargo deny check`; `scripts/security/check_workflow_pins.sh` | | PR touching `paths` in `nix.yml` | `Nix Build & Check` | `nix.yml` `nix-validation` | Report-only | `nix flake check` | | PR touching `paths` in `windows-filesystem.yml` | `Rename Safety`, `Startup Smoke` | `windows-filesystem.yml` `rename-safety`, `startup-smoke` | Report-only | the `cargo test -p rustfs-ecstore --lib ` commands in the job, on Windows; `cargo build --locked -p rustfs --bin rustfs`, then `rustfs.exe --version` and a single-volume server polled on `/health/ready` | +| PR or main push touching `paths` in `rdma-build.yml` | `cargo check and test compile (nixl)` | `rdma-build.yml` `nixl-build` | Report-only | `cargo check --locked -p rustfs --features nixl`; `cargo test --locked --no-run -p rustfs-nixl --features client-http` | | PR touching `paths` in `coverage.yml` | `Workspace line coverage` | `coverage.yml` `coverage` | Report-only | `make coverage`; `python3 scripts/check_security_coverage.py target/llvm-cov/coverage.json` | | PR touching `paths` in `oidc-keycloak.yml` | `OIDC Keycloak live gate` | `oidc-keycloak.yml` `oidc-keycloak-live` | Report-only | `cargo build --locked -p rustfs --bin rustfs`, then `bash scripts/test/oidc_keycloak_live.sh ./target/debug/rustfs` | | PR touching `paths` in `targets-integration.yml` | `PostgreSQL, MySQL, AMQP, and NATS` | `targets-integration.yml` `targets-live` | Report-only | start the containers as in the job, export the `RUSTFS_TEST_*` DSNs, then the job's `cargo test --locked -p rustfs-targets --test -- --ignored --test-threads=1` commands | From d8e23538250e70ac05545388eac5fb5d7031c5f3 Mon Sep 17 00:00:00 2001 From: Chris An Date: Wed, 2 Dec 2026 19:48:58 +0800 Subject: [PATCH 2/2] fix(ci): prevent fuzz build OOM and stabilize workspace/http3 tests (#9856) * fix(ci): prevent fuzz build OOM and stabilize workspace/http3 tests * fix(fuzz): split fuzz build codegen units and bound dep opt-level/lld threads --- .config/nextest.toml | 15 +++++ .github/workflows/ci.yml | 4 +- .github/workflows/fuzz.yml | 10 ++- .../ecstore/src/bucket/quota/reservation.rs | 12 +++- fuzz/Cargo.toml | 64 +++++++++++++++++++ rustfs/src/server/tls_material.rs | 1 + scripts/fuzz/run.sh | 25 ++++++-- scripts/test_fuzz_runner.sh | 21 ++++++ 8 files changed, 143 insertions(+), 9 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 907a2e793e..73204580d0 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -144,6 +144,14 @@ threads-required = "num-test-threads" filter = 'package(rustfs) & test(=admin::handlers::table_catalog::tests::cold_object_registration_completes_while_other_bucket_backup_waits)' threads-required = "num-test-threads" +# This 12-disk three-pool hot-reload and Pool-0 decommission E2E fixture drives +# concurrent S3 traffic and durable pool migration under a 90s drain budget. +# Reserve capacity so sibling disk fixtures cannot starve its target capacity +# mutation gate; its deadlines, assertions, and zero-retry policy stay intact. +[[profile.default.overrides]] +filter = 'package(rustfs) & binary(pool_hot_reload_e2e_test) & test(=multi_pool_1_to_2_to_3_expand_and_3_to_2_pool0_removal_with_concurrent_s3_io_e2e)' +threads-required = "num-test-threads" + [[profile.default.overrides]] filter = 'package(rustfs-heal) & (binary(mrf_partial_write_test) | (binary(mrf_pipeline_test) & test(/^journal_replay_survives_/)) | test(=admin_selector_survives_sigkill_with_original_scope_and_receipts))' threads-required = "num-test-threads" @@ -511,6 +519,13 @@ threads-required = "num-test-threads" filter = 'package(rustfs) & test(=admin::handlers::table_catalog::tests::cold_object_registration_completes_while_other_bucket_backup_waits)' threads-required = "num-test-threads" +# Match the local capacity reservation for the 12-disk three-pool hot-reload +# and Pool-0 decommission E2E fixture; deadlines, assertions, and zero retries +# remain in force. +[[profile.ci.overrides]] +filter = 'package(rustfs) & binary(pool_hot_reload_e2e_test) & test(=multi_pool_1_to_2_to_3_expand_and_3_to_2_pool0_removal_with_concurrent_s3_io_e2e)' +threads-required = "num-test-threads" + [[profile.ci.overrides]] filter = 'package(rustfs-heal) & (binary(mrf_partial_write_test) | (binary(mrf_pipeline_test) & test(/^journal_replay_survives_/)) | test(=admin_selector_survives_sigkill_with_original_scope_and_receipts))' threads-required = "num-test-threads" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0584cc67b3..4352e3ad8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -404,8 +404,10 @@ jobs: needs: [ workspace-lint-and-build, classify-changes ] # The archive retains compile-time fixture paths and the large test set # requires the same runner image until the hosted-runtime pilot passes. + # Full mode runs archive extraction, the 75m workspace suite, the 80m + # serial ILM suite, and Vector KMS verification under their own step budgets. runs-on: sm-standard-4 - timeout-minutes: 90 + timeout-minutes: 180 env: CI_PACKAGES: ${{ needs.classify-changes.outputs.packages }} steps: diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index dd809235a9..68938d9e1e 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -190,7 +190,8 @@ jobs: FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu # Fuzz targets build without the dial9 feature, so tokio_unstable is not needed. - RUSTFLAGS: "-C target-feature=-crt-static" + # Use lld with bounded linker threads so linking all instrumented harnesses stays within the pod memory budget. + RUSTFLAGS: "-C target-feature=-crt-static -C link-arg=-fuse-ld=lld -C link-arg=-Wl,--threads=2" steps: - name: Checkout repository uses: actions/checkout@f548e57e544e1ff5a4c46bf1e1b8685f8e4a348a # v7 @@ -201,7 +202,7 @@ jobs: uses: ./.github/actions/setup with: rust-version: nightly - cache-shared-key: fuzz-nightly-${{ env.CARGO_BUILD_TARGET }}-${{ hashFiles('fuzz/Cargo.lock', 'fuzz/Cargo.toml', 'fuzz/fuzz_targets/**') }} + cache-shared-key: fuzz-nightly-${{ env.CARGO_BUILD_TARGET }}-cgu16-${{ hashFiles('fuzz/Cargo.lock', 'fuzz/Cargo.toml', 'fuzz/fuzz_targets/**') }} cache-save-if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }} - name: Install cargo-fuzz @@ -209,10 +210,15 @@ jobs: with: tool: cargo-fuzz + - name: Install lld + run: sudo apt-get update && sudo apt-get install -y --no-install-recommends lld + - name: Build selected fuzz targets env: # Keep memory-intensive instrumented rustc processes from crowding out the runner. CARGO_BUILD_JOBS: "2" + # Split monolithic ASan+SanCov LLVM modules across 16 codegen units so huge crates stay within 28 GB RAM. + FUZZ_CODEGEN_UNITS: "16" FUZZ_TARGET: ${{ needs.select-targets.outputs.targets_csv }} run: BUILD_ONLY=1 ./scripts/fuzz/run.sh diff --git a/crates/ecstore/src/bucket/quota/reservation.rs b/crates/ecstore/src/bucket/quota/reservation.rs index 6c8edcf3cc..7985ade825 100644 --- a/crates/ecstore/src/bucket/quota/reservation.rs +++ b/crates/ecstore/src/bucket/quota/reservation.rs @@ -2944,6 +2944,14 @@ mod tests { .expect("ledger") } + async fn read_test_ledger_synchronized(job: &ReconcileJob) -> QuotaLedger { + let object = ledger_object(&job.bucket); + let _guard = lock_v1_ledger(&job.store, &object, "quota_ledger_test_read", get_lock_acquire_timeout()) + .await + .expect("ledger lock"); + load_ledger_locked(Arc::clone(&job.store), &object).await.expect("ledger") + } + async fn drain_reconciliation_scheduler(job: &ReconcileJob) { let key = ( job.store.id, @@ -3419,7 +3427,7 @@ mod tests { pause.reached().await; let at_seed = overwrites.load(Ordering::SeqCst); assert!( - read_test_ledger(&job).await.scan_seed.is_some(), + read_test_ledger_synchronized(&job).await.scan_seed.is_some(), "the recount seeded over in-flight writes" ); // Admitted after the seed and visible to the walk: counted twice. @@ -3429,7 +3437,7 @@ mod tests { pause.0.release.notify_one(); drain_reconciliation_scheduler(&job).await; - let published = read_test_ledger(&job).await; + let published = read_test_ledger_synchronized(&job).await; let live = 10 + 35 + 1 + 5; assert!(published.scan_seed.is_none(), "the overlapping recount published"); assert_eq!( diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 7e77f1cce7..57c586db3f 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -50,6 +50,70 @@ debug = "line-tables-only" [profile.dev.package."*"] debug = false +# `cargo-fuzz build` compiles in release mode with `--config profile.release.debug="line-tables-only"`. +# Keep third-party dependencies (DataFusion, Arrow, Parquet, AWS SDK) at opt-level 1 without DWARF +# debuginfo so instrumented builds stay within the runner memory and artifact budgets, while +# preserving full optimization and line tables for the fuzz crate and RustFS workspace crates. +[profile.release] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package."*"] +opt-level = 1 +debug = false + +[profile.release.package.rustfs-ecstore] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-filemeta] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-kms] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-lifecycle] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-notify] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-policy] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-rio] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-s3select-api] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-s3select-query] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-security-governance] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-signer] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-sse] +opt-level = 3 +debug = "line-tables-only" + +[profile.release.package.rustfs-utils] +opt-level = 3 +debug = "line-tables-only" + [[bin]] name = "bucket_validation" path = "fuzz_targets/bucket_validation.rs" diff --git a/rustfs/src/server/tls_material.rs b/rustfs/src/server/tls_material.rs index 6a1b86c007..1f20a3abc3 100644 --- a/rustfs/src/server/tls_material.rs +++ b/rustfs/src/server/tls_material.rs @@ -2383,6 +2383,7 @@ mod tests { #[serial_test::serial] async fn http3_certificate_reload_updates_handshakes_and_retains_valid_config() { use crate::server::http3::tests::{client_endpoint, connect}; + ensure_rustls_crypto_provider(); let dir = TempDir::new().expect("TLS directory"); write_test_cert_pair(dir.path(), "localhost"); let snapshot = load_tls_material(dir.path().to_str().expect("TLS path")) diff --git a/scripts/fuzz/run.sh b/scripts/fuzz/run.sh index 3eb6cb3c5e..651a751273 100755 --- a/scripts/fuzz/run.sh +++ b/scripts/fuzz/run.sh @@ -31,6 +31,7 @@ # SKIP_BUILD — set to 1 to skip build phase (default: 0) # USE_PREBUILT_BINARY — set to 1 to run a prebuilt fuzz binary directly # PREBUILT_BINARY_DIR — directory containing prebuilt fuzz binaries +# FUZZ_CODEGEN_UNITS — optional positive integer passed as --codegen-units to cargo-fuzz set -eu @@ -45,6 +46,7 @@ BUILD_ONLY=${BUILD_ONLY:-0} SKIP_BUILD=${SKIP_BUILD:-0} USE_PREBUILT_BINARY=${USE_PREBUILT_BINARY:-0} PREBUILT_BINARY_DIR=${PREBUILT_BINARY_DIR:-} +FUZZ_CODEGEN_UNITS=${FUZZ_CODEGEN_UNITS:-} case "$MAX_TOTAL_TIME" in ''|0*|*[!0-9]*) @@ -62,6 +64,15 @@ if [ -n "$FUZZ_SEED" ]; then esac fi +if [ -n "$FUZZ_CODEGEN_UNITS" ]; then + case "$FUZZ_CODEGEN_UNITS" in + 0*|*[!0-9]*) + echo "FUZZ_CODEGEN_UNITS must be a positive decimal integer without leading zeroes: $FUZZ_CODEGEN_UNITS" >&2 + exit 1 + ;; + esac +fi + cd "$FUZZ_DIR" mkdir -p "$ARTIFACT_ROOT" @@ -126,7 +137,10 @@ PY if [ "$SKIP_BUILD" != "1" ]; then set -- if [ -n "${CARGO_TARGET_DIR:-}" ]; then - set -- --target-dir "$CARGO_TARGET_DIR" + set -- "$@" --target-dir "$CARGO_TARGET_DIR" + fi + if [ -n "$FUZZ_CODEGEN_UNITS" ]; then + set -- "$@" --codegen-units "$FUZZ_CODEGEN_UNITS" fi if [ "$targets" = "$registered_targets" ]; then # A single Cargo invocation shares the instrumented dependency build across all harnesses. @@ -208,11 +222,14 @@ for target in $targets; do else echo "==> cargo +nightly fuzz run $target (-max_total_time=$MAX_TOTAL_TIME, -seed=$seed, -artifact_prefix=$artifact_dir/)" set +e + set -- if [ -n "${CARGO_TARGET_DIR:-}" ]; then - cargo +nightly fuzz run --target-dir "$CARGO_TARGET_DIR" "$target" -- -max_total_time="$MAX_TOTAL_TIME" -seed="$seed" -artifact_prefix="$artifact_dir/" - else - cargo +nightly fuzz run "$target" -- -max_total_time="$MAX_TOTAL_TIME" -seed="$seed" -artifact_prefix="$artifact_dir/" + set -- "$@" --target-dir "$CARGO_TARGET_DIR" fi + if [ -n "$FUZZ_CODEGEN_UNITS" ]; then + set -- "$@" --codegen-units "$FUZZ_CODEGEN_UNITS" + fi + cargo +nightly fuzz run "$@" "$target" -- -max_total_time="$MAX_TOTAL_TIME" -seed="$seed" -artifact_prefix="$artifact_dir/" exit_code=$? set -e fi diff --git a/scripts/test_fuzz_runner.sh b/scripts/test_fuzz_runner.sh index 8d2f484e1a..76166bc386 100755 --- a/scripts/test_fuzz_runner.sh +++ b/scripts/test_fuzz_runner.sh @@ -140,4 +140,25 @@ for invalid_target in nonexistent "path_containment;id"; do fi done +PATH="$TMP_ROOT/bin:$PATH" \ +FAKE_CARGO_ARGS_FILE="$TMP_ROOT/build-cgu-args" \ +FUZZ_TARGET=path_containment \ +FUZZ_CODEGEN_UNITS=16 \ +BUILD_ONLY=1 \ + "$REPO_ROOT/scripts/fuzz/run.sh" + +grep -Fx '+nightly' "$TMP_ROOT/build-cgu-args" +grep -Fx 'fuzz' "$TMP_ROOT/build-cgu-args" +grep -Fx 'build' "$TMP_ROOT/build-cgu-args" +grep -Fx -- '--codegen-units' "$TMP_ROOT/build-cgu-args" +grep -Fx '16' "$TMP_ROOT/build-cgu-args" +grep -Fx 'path_containment' "$TMP_ROOT/build-cgu-args" + +for invalid_cgu in 0 016 not-a-number "16;id"; do + if FUZZ_TARGET=path_containment FUZZ_CODEGEN_UNITS="$invalid_cgu" BUILD_ONLY=1 "$REPO_ROOT/scripts/fuzz/run.sh" >/dev/null 2>&1; then + echo "invalid FUZZ_CODEGEN_UNITS was accepted: $invalid_cgu" >&2 + exit 1 + fi +done + echo "fuzz runner seed manifest tests passed"