Skip to content

Commit

Permalink
Initial implementation of tests with sanitizers
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Oct 6, 2023
1 parent 68c9730 commit e66c6e3
Show file tree
Hide file tree
Showing 14 changed files with 411 additions and 27 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml → .github/workflows/ci-miri.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: Miri CI

on:
push:
Expand All @@ -16,45 +16,45 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-setup.sh
run: bash ./ci-miri-setup.sh
- name: Test
run: bash ./ci-test.sh core
run: bash ./ci-miri-test.sh core

test-alloc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-setup.sh
run: bash ./ci-miri-setup.sh
- name: Test
run: bash ./ci-test.sh alloc
run: bash ./ci-miri-test.sh alloc

test-std:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-setup.sh
run: bash ./ci-miri-setup.sh
- name: Test
run: bash ./ci-test.sh std
run: bash ./ci-miri-test.sh std

test-simd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-setup.sh
run: bash ./ci-miri-setup.sh
- name: Test
run: bash ./ci-test.sh simd
run: bash ./ci-miri-test.sh simd

test-stdarch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-setup.sh
run: bash ./ci-miri-setup.sh
- name: Test
run: bash ./ci-test.sh stdarch
run: bash ./ci-miri-test.sh stdarch

# Send a Zulip notification when a cron job fails
cron-fail-notify:
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/ci-sanitizers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Sanitizers CI

on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
schedule:
- cron: '00 2 * * *' # At 02:00 UTC every day (like rustup-components-history).

jobs:
test-core:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-sanitizers-setup.sh
- name: Test ASAN
run: bash ./ci-sanitizers-test.sh core address
- name: Test MSAN
run: bash ./ci-sanitizers-test.sh core memory
- name: Test TSAN
run: bash ./ci-sanitizers-test.sh core thread
- name: Test CFISAN
run: bash ./ci-sanitizers-test.sh core cfi

# test-alloc:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup environment
# run: bash ./ci-sanitizers-setup.sh
# - name: Test
# run: bash ./ci-sanitizers-test.sh alloc

# test-std:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup environment
# run: bash ./ci-sanitizers-setup.sh
# - name: Test
# run: bash ./ci-sanitizers-test.sh std

# test-simd:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup environment
# run: bash ./ci-sanitizers-setup.sh
# - name: Test
# run: bash ./ci-sanitizers-test.sh simd

# test-stdarch:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup environment
# run: bash ./ci-sanitizers-setup.sh
# - name: Test
# run: bash ./ci-sanitizers-test.sh stdarch

# Send a Zulip notification when a cron job fails
# cron-fail-notify:
# name: cronjob failure notification
# runs-on: ubuntu-latest
# needs: [test-core, test-alloc, test-std, test-simd]
# if: github.event_name == 'schedule' && (failure() || cancelled())
# steps:
# - name: Install zulip-send
# run: pip3 install zulip
# - name: Send Zulip notification
# shell: bash
# env:
# ZULIP_BOT_EMAIL: ${{ secrets.ZULIP_BOT_EMAIL }}
# ZULIP_API_TOKEN: ${{ secrets.ZULIP_API_TOKEN }}
# run: |
# ~/.local/bin/zulip-send --stream miri --subject "Cron Job Failure (miri-test-libstd, $(date -u +%Y-%m))" \
# --message 'Dear @*T-miri*,

# 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?

# Thanks in advance!
# Sincerely,
# The Miri Cronjobs Bot' \
# --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[workspace]
members = [
"core_miri_test",
"alloc_miri_test",
"std_miri_test",
"core_sanity_test",
"alloc_sanity_test",
"std_sanity_test",
]

exclude = [
Expand Down
4 changes: 2 additions & 2 deletions alloc_miri_test/Cargo.toml → alloc_sanity_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "alloc_miri_test"
name = "alloc_sanity_test"
version = "0.0.0"
autotests = false
autobenches = false
edition = "2021"

[lib]
name = "alloc_miri_test"
name = "alloc_sanity_test"
path = "../library/alloc/src/lib.rs"

[features]
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions ci-test.sh → ci-miri-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ DEFAULTFLAGS="-Zmiri-retag-fields -Zrandomize-layout -Zmiri-strict-provenance"

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

# run the tests (some also without validation, to exercise those code paths in Miri)
case "$1" in
Expand Down Expand Up @@ -60,13 +61,13 @@ std)
echo "::group::Testing std core ($CORE on $TARGET)"
MIRIFLAGS="$DEFAULTFLAGS -Zmiri-disable-isolation" \
./run-test.sh std --target $TARGET --lib --tests \
-- $CORE \
-- "$CORE" \
2>&1 | ts -i '%.s '
echo "::endgroup::"
echo "::group::Testing std core docs ($CORE on $TARGET, ignore leaks)"
MIRIFLAGS="$DEFAULTFLAGS -Zmiri-ignore-leaks -Zmiri-disable-isolation" \
./run-test.sh std --target $TARGET --doc \
-- $CORE \
-- "$CORE" \
2>&1 | ts -i '%.s '
echo "::endgroup::"
done
Expand All @@ -85,7 +86,7 @@ std)
echo "::endgroup::"
;;
simd)
cd $MIRI_LIB_SRC/portable-simd
cd "$MIRI_LIB_SRC/portable-simd"
export RUSTFLAGS="-Ainternal_features ${RUSTFLAGS:-}"
export RUSTDOCFLAGS="-Ainternal_features ${RUSTDOCFLAGS:-}"

Expand All @@ -108,7 +109,7 @@ stdarch)
for TARGET in x86_64-unknown-linux-gnu i686-unknown-linux-gnu; do
echo "::group::Testing stdarch ($TARGET)"
MIRIFLAGS="$DEFAULTFLAGS" \
./run-stdarch-test.sh $TARGET \
./miri-run-stdarch-test.sh $TARGET \
2>&1 | ts -i '%.s '
echo "::endgroup::"
done
Expand Down
18 changes: 18 additions & 0 deletions ci-sanitizers-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -eauxo pipefail

## Shared setup code for CI jobs

# We need 'ts'
sudo apt-get -y install moreutils
echo

# And of course we need Rust
if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then
RUST_TOOLCHAIN=nightly
else
RUST_TOOLCHAIN=$(cat rust-version)
fi
echo "Installing Rust version: $RUST_TOOLCHAIN"
rustup toolchain install "$RUST_TOOLCHAIN"
rustup override set "$RUST_TOOLCHAIN"
Loading

0 comments on commit e66c6e3

Please sign in to comment.