Skip to content

Commit 78b6d0a

Browse files
committed
Initial implementation of tests with sanitizers
1 parent 68c9730 commit 78b6d0a

File tree

14 files changed

+411
-27
lines changed

14 files changed

+411
-27
lines changed

.github/workflows/ci.yml renamed to .github/workflows/ci-miri.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Miri CI
22

33
on:
44
push:
@@ -16,45 +16,45 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v3
1818
- name: Setup environment
19-
run: bash ./ci-setup.sh
19+
run: bash ./ci-miri-setup.sh
2020
- name: Test
21-
run: bash ./ci-test.sh core
21+
run: bash ./ci-miri-test.sh core
2222

2323
test-alloc:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v3
2727
- name: Setup environment
28-
run: bash ./ci-setup.sh
28+
run: bash ./ci-miri-setup.sh
2929
- name: Test
30-
run: bash ./ci-test.sh alloc
30+
run: bash ./ci-miri-test.sh alloc
3131

3232
test-std:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- uses: actions/checkout@v3
3636
- name: Setup environment
37-
run: bash ./ci-setup.sh
37+
run: bash ./ci-miri-setup.sh
3838
- name: Test
39-
run: bash ./ci-test.sh std
39+
run: bash ./ci-miri-test.sh std
4040

4141
test-simd:
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v3
4545
- name: Setup environment
46-
run: bash ./ci-setup.sh
46+
run: bash ./ci-miri-setup.sh
4747
- name: Test
48-
run: bash ./ci-test.sh simd
48+
run: bash ./ci-miri-test.sh simd
4949

5050
test-stdarch:
5151
runs-on: ubuntu-latest
5252
steps:
5353
- uses: actions/checkout@v3
5454
- name: Setup environment
55-
run: bash ./ci-setup.sh
55+
run: bash ./ci-miri-setup.sh
5656
- name: Test
57-
run: bash ./ci-test.sh stdarch
57+
run: bash ./ci-miri-test.sh stdarch
5858

5959
# Send a Zulip notification when a cron job fails
6060
cron-fail-notify:

.github/workflows/ci-sanitizers.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Miri CI
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
pull_request:
8+
branches:
9+
- 'master'
10+
schedule:
11+
- cron: '00 2 * * *' # At 02:00 UTC every day (like rustup-components-history).
12+
13+
jobs:
14+
test-core:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Setup environment
19+
run: bash ./ci-sanitizers-setup.sh
20+
- name: Test ASAN
21+
run: bash ./ci-sanitizers-test.sh core address
22+
- name: Test MSAN
23+
run: bash ./ci-sanitizers-test.sh core memory
24+
- name: Test TSAN
25+
run: bash ./ci-sanitizers-test.sh core thread
26+
- name: Test CFISAN
27+
run: bash ./ci-sanitizers-test.sh core cfi
28+
29+
# test-alloc:
30+
# runs-on: ubuntu-latest
31+
# steps:
32+
# - uses: actions/checkout@v3
33+
# - name: Setup environment
34+
# run: bash ./ci-sanitizers-setup.sh
35+
# - name: Test
36+
# run: bash ./ci-sanitizers-test.sh alloc
37+
38+
# test-std:
39+
# runs-on: ubuntu-latest
40+
# steps:
41+
# - uses: actions/checkout@v3
42+
# - name: Setup environment
43+
# run: bash ./ci-sanitizers-setup.sh
44+
# - name: Test
45+
# run: bash ./ci-sanitizers-test.sh std
46+
47+
# test-simd:
48+
# runs-on: ubuntu-latest
49+
# steps:
50+
# - uses: actions/checkout@v3
51+
# - name: Setup environment
52+
# run: bash ./ci-sanitizers-setup.sh
53+
# - name: Test
54+
# run: bash ./ci-sanitizers-test.sh simd
55+
56+
# test-stdarch:
57+
# runs-on: ubuntu-latest
58+
# steps:
59+
# - uses: actions/checkout@v3
60+
# - name: Setup environment
61+
# run: bash ./ci-sanitizers-setup.sh
62+
# - name: Test
63+
# run: bash ./ci-sanitizers-test.sh stdarch
64+
65+
# Send a Zulip notification when a cron job fails
66+
# cron-fail-notify:
67+
# name: cronjob failure notification
68+
# runs-on: ubuntu-latest
69+
# needs: [test-core, test-alloc, test-std, test-simd]
70+
# if: github.event_name == 'schedule' && (failure() || cancelled())
71+
# steps:
72+
# - name: Install zulip-send
73+
# run: pip3 install zulip
74+
# - name: Send Zulip notification
75+
# shell: bash
76+
# env:
77+
# ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
78+
# ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
79+
# run: |
80+
# ~/.local/bin/zulip-send --stream miri --subject "Cron Job Failure (miri-test-libstd, $(date -u +%Y-%m))" \
81+
# --message 'Dear @*T-miri*,
82+
83+
# The standard library test suite is [failing under Miri]('"https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"'). Would you mind investigating this issue?
84+
85+
# Thanks in advance!
86+
# Sincerely,
87+
# The Miri Cronjobs Bot' \
88+
# --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[workspace]
22
members = [
3-
"core_miri_test",
4-
"alloc_miri_test",
5-
"std_miri_test",
3+
"core_sanity_test",
4+
"alloc_sanity_test",
5+
"std_sanity_test",
66
]
77

88
exclude = [

alloc_miri_test/Cargo.toml renamed to alloc_sanity_test/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2-
name = "alloc_miri_test"
2+
name = "alloc_sanity_test"
33
version = "0.0.0"
44
autotests = false
55
autobenches = false
66
edition = "2021"
77

88
[lib]
9-
name = "alloc_miri_test"
9+
name = "alloc_sanity_test"
1010
path = "../library/alloc/src/lib.rs"
1111

1212
[features]
File renamed without changes.

ci-test.sh renamed to ci-miri-test.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ DEFAULTFLAGS="-Zmiri-retag-fields -Zrandomize-layout -Zmiri-strict-provenance"
55

66
# apply our patch
77
rm -rf rust-src-patched
8-
cp -a $(rustc --print sysroot)/lib/rustlib/src/rust/ rust-src-patched
8+
cp -a "$(rustc --print sysroot)/lib/rustlib/src/rust/" rust-src-patched
99
( cd rust-src-patched && patch -f -p1 < ../rust-src.diff >/dev/null ) || ( echo "Applying rust-src.diff failed!" && exit 1 )
10-
export MIRI_LIB_SRC=$(pwd)/rust-src-patched/library
10+
MIRI_LIB_SRC="$(pwd)/rust-src-patched/library"
11+
export MIRI_LIB_SRC
1112

1213
# run the tests (some also without validation, to exercise those code paths in Miri)
1314
case "$1" in
@@ -60,13 +61,13 @@ std)
6061
echo "::group::Testing std core ($CORE on $TARGET)"
6162
MIRIFLAGS="$DEFAULTFLAGS -Zmiri-disable-isolation" \
6263
./run-test.sh std --target $TARGET --lib --tests \
63-
-- $CORE \
64+
-- "$CORE" \
6465
2>&1 | ts -i '%.s '
6566
echo "::endgroup::"
6667
echo "::group::Testing std core docs ($CORE on $TARGET, ignore leaks)"
6768
MIRIFLAGS="$DEFAULTFLAGS -Zmiri-ignore-leaks -Zmiri-disable-isolation" \
6869
./run-test.sh std --target $TARGET --doc \
69-
-- $CORE \
70+
-- "$CORE" \
7071
2>&1 | ts -i '%.s '
7172
echo "::endgroup::"
7273
done
@@ -85,7 +86,7 @@ std)
8586
echo "::endgroup::"
8687
;;
8788
simd)
88-
cd $MIRI_LIB_SRC/portable-simd
89+
cd "$MIRI_LIB_SRC/portable-simd"
8990
export RUSTFLAGS="-Ainternal_features ${RUSTFLAGS:-}"
9091
export RUSTDOCFLAGS="-Ainternal_features ${RUSTDOCFLAGS:-}"
9192

@@ -108,7 +109,7 @@ stdarch)
108109
for TARGET in x86_64-unknown-linux-gnu i686-unknown-linux-gnu; do
109110
echo "::group::Testing stdarch ($TARGET)"
110111
MIRIFLAGS="$DEFAULTFLAGS" \
111-
./run-stdarch-test.sh $TARGET \
112+
./miri-run-stdarch-test.sh $TARGET \
112113
2>&1 | ts -i '%.s '
113114
echo "::endgroup::"
114115
done

ci-sanitizers-setup.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -eauxo pipefail
3+
4+
## Shared setup code for CI jobs
5+
6+
# We need 'ts'
7+
sudo apt-get -y install moreutils
8+
echo
9+
10+
# And of course we need Rust
11+
if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then
12+
RUST_TOOLCHAIN=nightly
13+
else
14+
RUST_TOOLCHAIN=$(cat rust-version)
15+
fi
16+
echo "Installing Rust version: $RUST_TOOLCHAIN"
17+
rustup toolchain install "$RUST_TOOLCHAIN"
18+
rustup override set "$RUST_TOOLCHAIN"

0 commit comments

Comments
 (0)