From 01ae379526218e7f6ca28510b6c06098419b7380 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 10 Jun 2020 20:15:59 -0700 Subject: Import bytes-0.5.4 * Add OWNERS and Android.bp Bug: 143953733 Test: make Change-Id: Ica69d7252abb1c2967f2c0e11a62d0bd83192fb3 --- ci/azure-cross-compile.yml | 46 ++++++++++++++++++++++++++++++++++++++++++ ci/azure-deploy-docs.yml | 39 ++++++++++++++++++++++++++++++++++++ ci/azure-install-rust.yml | 33 ++++++++++++++++++++++++++++++ ci/azure-loom.yml | 15 ++++++++++++++ ci/azure-test-stable.yml | 50 ++++++++++++++++++++++++++++++++++++++++++++++ ci/azure-tsan.yml | 26 ++++++++++++++++++++++++ ci/tsan | 24 ++++++++++++++++++++++ 7 files changed, 233 insertions(+) create mode 100644 ci/azure-cross-compile.yml create mode 100644 ci/azure-deploy-docs.yml create mode 100644 ci/azure-install-rust.yml create mode 100644 ci/azure-loom.yml create mode 100644 ci/azure-test-stable.yml create mode 100644 ci/azure-tsan.yml create mode 100644 ci/tsan (limited to 'ci') diff --git a/ci/azure-cross-compile.yml b/ci/azure-cross-compile.yml new file mode 100644 index 0000000..be46ca3 --- /dev/null +++ b/ci/azure-cross-compile.yml @@ -0,0 +1,46 @@ +parameters: + cmd: build + rust_version: stable + +jobs: +- job: ${{ parameters.name }} + displayName: Cross + strategy: + matrix: + i686: + vmImage: ubuntu-16.04 + target: i686-unknown-linux-gnu + armv7: + vmImage: ubuntu-16.04 + target: armv7-unknown-linux-gnueabihf + powerpc: + vmImage: ubuntu-16.04 + target: powerpc-unknown-linux-gnu + powerpc64: + vmImage: ubuntu-16.04 + target: powerpc64-unknown-linux-gnu + wasm: + vmImage: ubuntu-16.04 + target: wasm32-unknown-unknown + pool: + vmImage: $(vmImage) + + steps: + - template: azure-install-rust.yml + parameters: + rust_version: ${{parameters.rust_version}} + + - script: cargo install cross + displayName: Install cross + condition: not(eq(variables['target'], 'wasm32-unknown-unknown')) + + - script: cross ${{ parameters.cmd }} --target $(target) + displayName: cross ${{ parameters.cmd }} --target $(target) + condition: not(eq(variables['target'], 'wasm32-unknown-unknown')) + + # WASM support + - script: | + rustup target add $(target) + cargo build --target $(target) + displayName: cargo build --target $(target) + condition: eq(variables['target'], 'wasm32-unknown-unknown') diff --git a/ci/azure-deploy-docs.yml b/ci/azure-deploy-docs.yml new file mode 100644 index 0000000..52ac48f --- /dev/null +++ b/ci/azure-deploy-docs.yml @@ -0,0 +1,39 @@ +parameters: + dependsOn: [] + +jobs: +- job: documentation + displayName: 'Deploy API Documentation' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) + pool: + vmImage: 'Ubuntu 16.04' + dependsOn: + - ${{ parameters.dependsOn }} + steps: + - template: azure-install-rust.yml + parameters: + rust_version: stable + - script: | + cargo doc --no-deps + cp -R target/doc '$(Build.BinariesDirectory)' + displayName: 'Generate Documentation' + - script: | + set -e + + git --version + ls -la + git init + git config user.name 'Deployment Bot (from Azure Pipelines)' + git config user.email 'deploy@tokio-rs.com' + git config --global credential.helper 'store --file ~/.my-credentials' + printf "protocol=https\nhost=github.com\nusername=carllerche\npassword=%s\n\n" "$GITHUB_TOKEN" | git credential-store --file ~/.my-credentials store + git remote add origin https://github.com/tokio-rs/bytes + git checkout -b gh-pages + git add . + git commit -m 'Deploy Bytes API documentation' + git push -f origin gh-pages + env: + GITHUB_TOKEN: $(githubPersonalToken) + workingDirectory: '$(Build.BinariesDirectory)' + displayName: 'Deploy Documentation' + diff --git a/ci/azure-install-rust.yml b/ci/azure-install-rust.yml new file mode 100644 index 0000000..0217659 --- /dev/null +++ b/ci/azure-install-rust.yml @@ -0,0 +1,33 @@ +steps: + # Linux and macOS. + - script: | + set -e + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none + export PATH=$PATH:$HOME/.cargo/bin + rustup toolchain install $RUSTUP_TOOLCHAIN + rustup default $RUSTUP_TOOLCHAIN + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + env: + RUSTUP_TOOLCHAIN: ${{parameters.rust_version}} + displayName: "Install rust (*nix)" + condition: not(eq(variables['Agent.OS'], 'Windows_NT')) + + # Windows. + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain none + set PATH=%PATH%;%USERPROFILE%\.cargo\bin + rustup toolchain install %RUSTUP_TOOLCHAIN% + rustup default %RUSTUP_TOOLCHAIN% + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + env: + RUSTUP_TOOLCHAIN: ${{parameters.rust_version}} + displayName: "Install rust (windows)" + condition: eq(variables['Agent.OS'], 'Windows_NT') + + # All platforms. + - script: | + rustup toolchain list + rustc -Vv + cargo -V + displayName: Query rust and cargo versions diff --git a/ci/azure-loom.yml b/ci/azure-loom.yml new file mode 100644 index 0000000..1db9c3a --- /dev/null +++ b/ci/azure-loom.yml @@ -0,0 +1,15 @@ +jobs: +- job: ${{parameters.name}} + displayName: Loom tests + pool: + vmImage: ubuntu-16.04 + + steps: + - template: azure-install-rust.yml + parameters: + rust_version: ${{parameters.rust_version}} + + - script: RUSTFLAGS="--cfg loom" cargo test --lib + displayName: RUSTFLAGS="--cfg loom" cargo test --lib + + diff --git a/ci/azure-test-stable.yml b/ci/azure-test-stable.yml new file mode 100644 index 0000000..e543eee --- /dev/null +++ b/ci/azure-test-stable.yml @@ -0,0 +1,50 @@ +parameters: + cmd: test + rust_version: stable + features: [] + +jobs: +- job: ${{ parameters.name }} + displayName: ${{ parameters.displayName }} + strategy: + matrix: + Linux: + vmImage: ubuntu-16.04 + + ${{ if parameters.cross }}: + MacOS: + vmImage: macOS-10.13 + Windows: + vmImage: vs2017-win2016 + pool: + vmImage: $(vmImage) + + steps: + - template: azure-install-rust.yml + parameters: + rust_version: ${{parameters.rust_version}} + + # Run with default crate features + - script: cargo ${{ parameters.cmd }} + displayName: cargo ${{ parameters.cmd }} + + # Run with each specified feature + - ${{ each feature in parameters.features }}: + - script: cargo ${{ parameters.cmd }} --features ${{ feature }} + displayName: cargo ${{ parameters.cmd }} --features ${{ feature }} + + - ${{ if eq(parameters.cmd, 'test') }}: + - script: cargo doc --no-deps + displayName: cargo doc --no-deps + + - ${{ if parameters.benches }}: + - script: cargo check --benches + displayName: Check benchmarks + + # Run with all features + - script: cargo ${{ parameters.cmd }} --all-features + displayName: cargo ${{ parameters.cmd }} --all-features + + # Run with no default features + - script: cargo check --no-default-features + displayName: cargo check --no-default-features diff --git a/ci/azure-tsan.yml b/ci/azure-tsan.yml new file mode 100644 index 0000000..198b187 --- /dev/null +++ b/ci/azure-tsan.yml @@ -0,0 +1,26 @@ +jobs: +- job: ${{ parameters.name }} + displayName: TSAN + pool: + vmImage: ubuntu-16.04 + + steps: + - template: azure-install-rust.yml + parameters: + rust_version: ${{ parameters.rust_version }} + + - script: | + set -e + + export RUST_TEST_THREADS=1 + export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" + export TSAN_OPTIONS="suppressions=`pwd`/ci/tsan" + + # Run address sanitizer + RUSTFLAGS="-Z sanitizer=address" \ + cargo test --target x86_64-unknown-linux-gnu --test test_bytes --test test_buf --test test_buf_mut + + # Run thread sanitizer + RUSTFLAGS="-Z sanitizer=thread" \ + cargo test --target x86_64-unknown-linux-gnu --test test_bytes --test test_buf --test test_buf_mut + displayName: TSAN / MSAN diff --git a/ci/tsan b/ci/tsan new file mode 100644 index 0000000..e53f9b8 --- /dev/null +++ b/ci/tsan @@ -0,0 +1,24 @@ +# TSAN suppressions file for `bytes` + +# TSAN does not understand fences and `Arc::drop` is implemented using a fence. +# This causes many false positives. +race:Arc*drop +race:arc*Weak*drop + +# `std` mpsc is not used in any Bytes code base. This race is triggered by some +# rust runtime logic. +race:std*mpsc_queue + +# Some test runtime races. Allocation should be race free +race:alloc::alloc + +# Not sure why this is warning, but it is in the test harness and not the library. +race:TestEvent*clone +race:test::run_tests_console::*closure + +# Probably more fences in std. +race:__call_tls_dtors + +# This ignores a false positive caused by `thread::park()`/`thread::unpark()`. +# See: https://github.com/rust-lang/rust/pull/54806#issuecomment-436193353 +race:pthread_cond_destroy -- cgit v1.2.3