-
Notifications
You must be signed in to change notification settings - Fork 0
133 lines (133 loc) · 5.29 KB
/
safety.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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"