Skip to content

Initial implementation of tests with sanitizers #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e66c6e3
Initial implementation of tests with sanitizers
tgross35 Oct 6, 2023
fcf463d
Install lib source, update scripts
tgross35 Oct 6, 2023
1a7aec5
Command typo
tgross35 Oct 6, 2023
554f05b
Unbound var
tgross35 Oct 6, 2023
d8c1612
Fix more bash errors
tgross35 Oct 6, 2023
cf1f881
Enable tests for all crates
tgross35 Oct 6, 2023
5417399
Fix workflow
tgross35 Oct 6, 2023
89838b6
Update test matrix
tgross35 Oct 6, 2023
1241d06
fix workflow
tgross35 Oct 6, 2023
88be511
fix workflow
tgross35 Oct 6, 2023
86b2c45
Update workflow
tgross35 Oct 6, 2023
8c7cb72
Disable cfi for now
tgross35 Oct 6, 2023
b477e37
Update workflow
tgross35 Oct 6, 2023
a93f53c
Update CI once again
tgross35 Oct 6, 2023
7b57cc2
Update wf
tgross35 Oct 6, 2023
d3753c8
Update wf
tgross35 Oct 6, 2023
0cdc3bf
Update wf
tgross35 Oct 6, 2023
6b283c0
Update wf
tgross35 Oct 6, 2023
3951c08
Update wf
tgross35 Oct 6, 2023
e258e7e
Update wf
tgross35 Oct 6, 2023
e903448
Update wf to not exist so fast
tgross35 Oct 6, 2023
e9eb56c
update wf
tgross35 Oct 6, 2023
8711457
update wf
tgross35 Oct 6, 2023
8f89583
Remove filtering of tests
tgross35 Oct 6, 2023
75cbfc3
Fix misquote in ci
tgross35 Oct 6, 2023
a217313
Add llvm-symbolizer to CI
tgross35 Oct 6, 2023
a799c45
Add patches to rust source
tgross35 Oct 6, 2023
f10922a
Update pathces and cfg
tgross35 Oct 6, 2023
12fad0a
Fix path
tgross35 Oct 6, 2023
aa9b07c
Fix syntax
tgross35 Oct 6, 2023
a2ea0ff
Fix stdarch test, clean CI script and unused warnings
tgross35 Oct 6, 2023
b44c6ee
Cleanup attributes in alloc
tgross35 Oct 6, 2023
299c022
Update ASAN config
tgross35 Oct 6, 2023
fafc1d7
Fix alloc test
tgross35 Oct 6, 2023
705d153
Adjust san flags
tgross35 Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/ci-miri.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Miri 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-miri-setup.sh
# - name: Test
# run: bash ./ci-miri-test.sh core

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

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

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

# test-stdarch:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Setup environment
# run: bash ./ci-miri-setup.sh
# - name: Test
# run: bash ./ci-miri-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
76 changes: 76 additions & 0 deletions .github/workflows/ci-sanitizers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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).

# only one target for now
env:
TARGET: x86_64-unknown-linux-gnu
RUST_BACKTRACE: full

jobs:
enable_matrix:
strategy:
max-parallel: 10 # 30 jobs to run...
matrix:
crate: [core, alloc, std, simd, stdarch]
sanitizer: [address, memory, thread, cfi, safestack, leak]
# exclude:
# FIXME: cfi is a mix of lto, bitcode, 1-cgu, and it doesn't seem to
# even compile
# - sanitizer: cfi
# FIXME: we get some failures pretty early here
# - sanitizer: memory
# - sanitizer: leak
name: Test ${{ matrix.crate }} with ${{ matrix.sanitizer }} sanitizer
runs-on: ubuntu-latest
# continue running if other tests fail. Disable this once we get out of the
# prototype phase
if: always()
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- name: Setup environment
run: bash ./ci-sanitizers-setup.sh
- name: Run ${{ matrix.sanitizer }} sanitizer
# Mark everything as pass just so GH doesn't cancel on us as soon as there is a failure
run: >
./ci-sanitizers-test.sh ${{ matrix.crate }} ${{ matrix.sanitizer }} &&
echo 'good!' ||
printf "::endgroup::\nfail!\n";
mark_failure:
runs-on: ubuntu-latest
steps:
- run: sleep 2000 && echo 'that is enough time!'; exit 1

# 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
82 changes: 0 additions & 82 deletions .github/workflows/ci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target
Cargo.lock
rust-src-patched
rust-src-patched*
library
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
[workspace]
resolver = "2"

members = [
"core_miri_test",
"alloc_miri_test",
"std_miri_test",
"core_run_test",
"alloc_run_test",
"std_run_test",
]

exclude = [
# stdarch has its own Cargo workspace
"library/stdarch",
"rust-src-patched/library/stdarch",
"rust-src-patched-san/library/stdarch",
]
4 changes: 2 additions & 2 deletions alloc_miri_test/Cargo.toml → alloc_run_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "alloc_miri_test"
name = "alloc_run_test"
version = "0.0.0"
autotests = false
autobenches = false
edition = "2021"

[lib]
name = "alloc_miri_test"
name = "alloc_run_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
19 changes: 19 additions & 0 deletions ci-sanitizers-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eauxo pipefail

## Shared setup code for CI jobs

# We need 'ts' and 'llvm-symbolizer'
sudo apt-get -y install moreutils llvm
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" --component rust-src
rustup override set "$RUST_TOOLCHAIN"
Loading