Skip to content

Commit

Permalink
add QEMU CI support
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Aug 10, 2024
1 parent 2815421 commit 57ce15b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
with:
shared-key: "${{matrix.rust}}-${{matrix.target}}"
- name: cargo build
run: cargo build ${{ matrix.features }}
run: cargo build --target ${{matrix.target}} ${{ matrix.features }}
- name: cargo nextest # reports segfaults in a helpful way
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} --no-fail-fast
env:
Expand All @@ -101,6 +101,59 @@ jobs:
files: lcov.info
fail_ci_if_error: false

build-qemu:
name: QEMU build & test
runs-on: "${{ matrix.os }}"
strategy:
matrix:
include:
- rust: stable
os: ubuntu-latest
features: ""
target: "s390x-unknown-linux-gnu"
gcc: "s390x-linux-gnu-gcc"
- rust: stable
os: ubuntu-latest
features: ""
target: "i686-unknown-linux-gnu"
gcc: "i686-linux-gnu-gcc"
steps:
- uses: actions/checkout@v2
- uses: awalsh128/cache-apt-pkgs-action@latest
with: # gcc-s390x-linux-gnu
packages: qemu qemu-user qemu-user-static qemu-system-s390x gcc-i686-linux-gnu gcc-s390x g++-s390x
version: 1.0
- name: Checkout sources
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
persist-credentials: false
- name: Copy QEMU Cargo Config
run: |
mkdir -p .cargo
cp qemu-cargo-config.toml .cargo/config.toml
- name: Install toolchain
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
with:
toolchain: "stable"
targets: "${{ matrix.target }}"
- name: target
run: "rustc -vV | sed -n 's|host: ||p'"
- name: Rust cache
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8
with:
shared-key: "${{matrix.rust}}-${{matrix.target}}"
- name: Install cargo-nextest
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8
with:
tool: cargo-nextest
- name: cargo build
run: cargo build --target ${{matrix.target}} ${{ matrix.features }}
- name: cargo nextest # reports segfaults in a helpful way
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }}
env:
RUST_BACKTRACE: 1
CC: ${{matrix.gcc}}

clippy:
name: Clippy
strategy:
Expand Down
8 changes: 8 additions & 0 deletions qemu-cargo-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# gets copied to .cargo/config.toml on CI, meant to run tests under qemu

[target.s390x-unknown-linux-gnu]
runner = "qemu-s390x -L /usr/s390x-linux-gnu"
linker = "s390x-linux-gnu-gcc"

[target.i686-unknown-linux-gnu]
linker = "i686-linux-gnu-gcc"
18 changes: 15 additions & 3 deletions test-libz-rs-sys/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@ fn deflate_bound_gzip_header() {
}

#[test]
#[cfg_attr(
target_endian = "big",
ignore = "we don't support DFLTCC, which changes the bounds in zlib-ng"
)]
fn test_compress_bound_windows() {
let source_len = 4294967289 as core::ffi::c_ulong;

Expand All @@ -726,6 +730,10 @@ fn test_compress_bound_windows() {
}

#[test]
#[cfg_attr(
target_endian = "big",
ignore = "we don't support DFLTCC, which changes the bounds in zlib-ng"
)]
fn test_compress_bound() {
::quickcheck::quickcheck(test as fn(_) -> _);

Expand Down Expand Up @@ -1965,17 +1973,21 @@ mod fuzz_based_tests {
const LCET10: &str = include_str!("test-data/lcet10.txt");

#[test]
#[cfg_attr(miri, ignore)]
#[cfg_attr(
not(any(target_arch = "x86_64", target_arch = "aarch64")),
ignore = "https://github.com/memorysafety/zlib-rs/issues/91"
)]
#[cfg_attr(miri, ignore = "too slow")]
fn compress_lcet10() {
fuzz_based_test(LCET10.as_bytes(), DeflateConfig::default(), &[])
}

#[test]
#[cfg_attr(
target_arch = "aarch64",
not(target_arch = "x86_64"),
ignore = "https://github.com/memorysafety/zlib-rs/issues/91"
)]
#[cfg_attr(miri, ignore)]
#[cfg_attr(miri, ignore = "too slow")]
fn compress_paper_100k() {
let mut config = DeflateConfig::default();

Expand Down
2 changes: 1 addition & 1 deletion zlib-rs/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4073,7 +4073,7 @@ mod test {
160, 197, 192, 192, 96, 196, 0, 0, 3, 228, 25, 128,
];

#[cfg(target_arch = "x86_64")]
#[cfg(not(target_arch = "aarch64"))]
fuzz_based_test(&input, config, &_x86_64);

#[cfg(target_arch = "aarch64")]
Expand Down

0 comments on commit 57ce15b

Please sign in to comment.