Asm macro support #662
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: safety | |
jobs: | |
sanitizers: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Cache git folder | |
id: cache-git | |
uses: actions/cache@v4 | |
with: | |
enableCrossOsArchive: true | |
path: TomHarte | |
key: git-folder2 | |
- if: steps.cache-git.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: 'TomHarte/ProcessorTests' | |
path: 'TomHarte' | |
- name: cache-update | |
if: steps.cache-git.outputs.cache-hit == 'true' | |
run: cd TomHarte && git pull | |
- name: Install nightly | |
uses: dtolnay/rust-toolchain@nightly | |
- run: | | |
# to get the symbolizer for debug symbol resolution | |
sudo apt install llvm | |
# to fix buggy leak analyzer: | |
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer | |
# ensure there's a profile.dev section | |
if ! grep -qE '^[ \t]*[profile.dev]' Cargo.toml; then | |
echo >> Cargo.toml | |
echo '[profile.dev]' >> Cargo.toml | |
fi | |
# remove pre-existing opt-levels in profile.dev | |
sed -i '/^\s*\[profile.dev\]/,/^\s*\[/ {/^\s*opt-level/d}' Cargo.toml | |
# now set opt-level to 1 | |
sed -i '/^\s*\[profile.dev\]/a opt-level = 1' Cargo.toml | |
cat Cargo.toml | |
name: Enable debug symbols | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: "sanitizer" | |
- name: cargo test -Zsanitizer=address | |
# only --lib --tests b/c of https://github.com/rust-lang/rust/issues/53945 | |
run: | | |
sed -i -e 's:\(any(miri,\):\1sanitize="address",:g' monitor/src/tests.rs | |
echo '#![feature(cfg_sanitize)]' > /tmp/foo | |
cat monitor/src/lib.rs >> /tmp/foo | |
cp /tmp/foo monitor/src/lib.rs | |
cargo test --lib --tests --all-features --target x86_64-unknown-linux-gnu | |
env: | |
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0" | |
RUSTFLAGS: "-Z sanitizer=address" | |
# The package is checked out at the same level as the cpu package | |
# so this ref is one level back. | |
TOM_HARTE_PROCESSOR_TESTS: "../TomHarte" | |
- name: cargo test -Zsanitizer=leak | |
if: always() | |
run: cargo test --all-features --target x86_64-unknown-linux-gnu | |
env: | |
LSAN_OPTIONS: "suppressions=${{ github.workspace }}/lsan-suppressions.txt" | |
RUSTFLAGS: "-Z sanitizer=leak" | |
# The package is checked out at the same level as the cpu package | |
# so this ref is one level back. | |
TOM_HARTE_PROCESSOR_TESTS: "../TomHarte" | |
miri: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- run: | | |
echo "NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV | |
- name: Install ${{ env.NIGHTLY }} | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY }} | |
components: miri | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
key: "miri" | |
- name: cargo miri test c64basic | |
run: cargo miri test -p c64basic | |
env: | |
# Disable isolation as we load external input files/images. | |
# Stacked borrows because eyre doesn't work. | |
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" | |
- name: cargo miri test cpu | |
run: | | |
# Only test a subset and do them in separate runs or miri OOMs | |
for i in init_tests::nmos6510 irq_and_nmi load_tests store_tests nop_hlt_tests::classic_nop_0x02_hlt rom_tests::undocumented_opcodes_test c6510_io_tests disassemble_test ::flags_test invalid_states tick_next tick_tests; do | |
echo Testing $i | |
cargo miri test -p cpu $i | |
done | |
env: | |
# Disable isolation as we load external input files/images. | |
# Stacked borrows because eyre doesn't work. | |
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" | |
- name: cargo miri test monitor | |
run: | | |
# One test doesn't work so exclude it but do all the others | |
for i in `cargo t -p monitor -- --list 2> /dev/null|egrep ^tests|awk '{print $1}'|sed -e 's:.$::g'|egrep -v tests::step_tests`; do | |
cargo miri test -p monitor $i -- --exact | |
done | |
env: | |
# Disable isolation as we load external input files/images. | |
# Stacked borrows because eyre doesn't work. | |
MIRIFLAGS: "-Zmiri-disable-isolation -Zmiri-disable-stacked-borrows" | |
#loom: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v4 | |
# 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" |