From 5b86d80e0f1955633c805b37377b5021b006245f Mon Sep 17 00:00:00 2001 From: James Chacon Date: Mon, 5 Jun 2023 10:05:14 -0700 Subject: [PATCH] Dependabot cleanup and fixup CI (#6) * We hae binaries. So dependabot everything. Also remote nostd * Remove our old CI * Add miri flag, disable loom * Update config.toml to take linking options out. Those should remain local, not checked in. * Disable isolation in miri as we need to read in test input files * Bump msrv to 1.65 * suppress leak suppressions file for now * Bump msrv comment explaining why * Change test to see if miri gets happier * Fixup tests trying to get miri to work. Turns out it won't due to: https://github.com/rust-lang/unsafe-code-guidelines/issues/134 so disable that check * take 2 for multiple miri flags * Try adding a leak suppresions file * try putting lsan at top level * Rework a few things: sanitizer - specify path relative in github actions miri - use sampling of tests from cpu. Otheriwse it OOMs * Specify tests better * Break miri up for c64basic vs cpu For CPU only do a subset and run in separate runs to avoid OOMs. Try again to get leak detector happy * Change to a test miri can run. Try a different way to pass lsan suppressions file --- .cargo/config.toml | 18 --------------- .github/dependabot.yml | 10 ++++---- .github/workflows/check.yml | 2 +- .github/workflows/ci.yml | 26 --------------------- .github/workflows/nostd.yml | 28 ---------------------- .github/workflows/safety.yml | 45 +++++++++++++++++++++++------------- cpu/src/tests.rs | 10 ++------ lsan-suppressions.txt | 2 ++ 8 files changed, 39 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/nostd.yml create mode 100644 lsan-suppressions.txt diff --git a/.cargo/config.toml b/.cargo/config.toml index cdb14f7..bd8bb3d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,21 +1,3 @@ -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-Clink-arg=-fuse-ld=lld"] - -# NOTE: you must manually install https://github.com/michaeleisel/zld on mac. you can easily do this with the "brew" package manager: -# `brew install michaeleisel/zld/zld` -[target.x86_64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/zld"] - -[target.aarch64-apple-darwin] -rustflags = ["-C", "link-arg=-fuse-ld=/opt/homebrew/bin/zld"] - -[target.x86_64-pc-windows-msvc] -linker = "rust-lld.exe" - -[target.wasm32-unknown-unknown] -runner = "wasm-server-runner" - [target.'cfg(all())'] rustflags = [ "-Wclippy::pedantic", diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8139a93..82c4a47 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,10 +8,10 @@ updates: directory: / schedule: interval: daily - ignore: - - dependency-name: "*" + #ignore: + # - dependency-name: "*" # patch and minor updates don't matter for libraries # remove this ignore rule if your package has binaries - update-types: - - "version-update:semver-patch" - - "version-update:semver-minor" + # update-types: + # - "version-update:semver-patch" + # - "version-update:semver-minor" diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3fb97ad..0c49097 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -79,7 +79,7 @@ jobs: # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability strategy: matrix: - msrv: [1.56.1] # 2021 edition requires 1.56 + msrv: [1.65] # let/else support name: ubuntu / ${{ matrix.msrv }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 8576df6..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Cargo Build & Test - -on: - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build_and_test: - name: Rust project - latest - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - toolchain: - - stable - - beta - - nightly - steps: - - uses: actions/checkout@v3 - - uses: giraffate/clippy-action@v1 - - run: rustup update ${{ matrix.toolchain }} && rustup component add clippy && rustup default ${{ matrix.toolchain }} - - run: cargo build --verbose - - run: cargo test --verbose - \ No newline at end of file diff --git a/.github/workflows/nostd.yml b/.github/workflows/nostd.yml deleted file mode 100644 index 32d56c3..0000000 --- a/.github/workflows/nostd.yml +++ /dev/null @@ -1,28 +0,0 @@ -permissions: - contents: read -on: - push: - branches: [main] - pull_request: -# Spend CI time only on latest ref: https://github.com/jonhoo/rust-ci-conf/pull/5 -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true -name: no-std -jobs: - nostd: - runs-on: ubuntu-latest - name: ${{ matrix.target }} - strategy: - matrix: - target: [thumbv7m-none-eabi, aarch64-unknown-none] - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: rustup target add ${{ matrix.target }} - run: rustup target add ${{ matrix.target }} - - name: cargo check - run: cargo check --target ${{ matrix.target }} --no-default-features diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml index eb5a5d6..ecdb6e6 100644 --- a/.github/workflows/safety.yml +++ b/.github/workflows/safety.yml @@ -44,7 +44,7 @@ jobs: if: always() run: cargo test --all-features --target x86_64-unknown-linux-gnu env: - LSAN_OPTIONS: "suppressions=lsan-suppressions.txt" + LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan-suppressions.txt" RUSTFLAGS: "-Z sanitizer=leak" miri: runs-on: ubuntu-latest @@ -59,20 +59,33 @@ jobs: with: toolchain: ${{ env.NIGHTLY }} components: miri - - name: cargo miri test - run: cargo miri test + - name: cargo miri test c64basic + run: cargo miri test -p c64basic env: - MIRIFLAGS: "" - loom: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install stable - uses: dtolnay/rust-toolchain@stable - - name: cargo test --test loom - run: cargo test --release --test loom + # Disable isolation as we load external input files/images. + MIRIFLAGS: "-Zmiri-disable-isolation" + - name: cargo miri test cpu + run: | + # Only test a subset and do them in separate runs or miri OOMs + for i in init_tests irq_and_nmi load_tests store_tests nop_hlt_tests::classic_nop_0x02_hlt rom_tests::undocumented_opcodes_test; do + echo Testing $i + cargo miri test -p cpu $i + done env: - LOOM_MAX_PREEMPTIONS: 2 - RUSTFLAGS: "--cfg loom" + # Ignore leaks - cpu test does this on purpose. + # Disable isolation as we load external input files/images. + # Stacked borrows because eyre doesn't work. + MIRIFLAGS: "-Zmiri-ignore-leaks -Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" + #loom: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v3 + # with: + # submodules: true + # - name: Install stable + # uses: dtolnay/rust-toolchain@stable + # - name: cargo test --test loom + # run: cargo test --release --test loom + # env: + # LOOM_MAX_PREEMPTIONS: 2 + # RUSTFLAGS: "--cfg loom" diff --git a/cpu/src/tests.rs b/cpu/src/tests.rs index c2c419f..41a593b 100644 --- a/cpu/src/tests.rs +++ b/cpu/src/tests.rs @@ -183,10 +183,7 @@ macro_rules! init_test { let mut cpu = setup($type, 0x1212, 0xEA, None, None, None, None); // This should fail - { - let ret = cpu.reset(); - assert!(ret.is_err(), "reset worked before power_on"); - } + assert!(cpu.reset().is_err(), "reset worked before power_on"); // Now it should work. cpu.power_on()?; @@ -197,10 +194,7 @@ macro_rules! init_test { } // This should fail now. - { - let ret = cpu.power_on(); - assert!(ret.is_err(), "power_on passes twice"); - } + assert!(cpu.power_on().is_err(), "power_on passes twice"); } if $rand { assert!(track.len() == 2, "didn't get both decimal states"); diff --git a/lsan-suppressions.txt b/lsan-suppressions.txt new file mode 100644 index 0000000..1d7c7d4 --- /dev/null +++ b/lsan-suppressions.txt @@ -0,0 +1,2 @@ +# These tests are intended to leak some top level objects +leak:cpu::tests::