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 f02eaf9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 11 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:
packages: qemu qemu-user qemu-user-static qemu-system-s390x gcc-s390x-linux-gnu gcc-i686-linux-gnu
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 -p zlib-rs --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
14 changes: 7 additions & 7 deletions zlib-rs/src/deflate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4059,24 +4059,24 @@ mod test {
strategy: Strategy::Default,
};

let _x86_64 = [
let x86 = [
24, 149, 99, 96, 96, 96, 96, 208, 6, 17, 112, 138, 129, 193, 128, 1, 29, 24, 50, 208,
1, 200, 146, 169, 79, 24, 74, 59, 96, 147, 52, 71, 22, 70, 246, 88, 26, 94, 80, 128,
83, 6, 162, 219, 144, 76, 183, 210, 5, 8, 67, 105, 7, 108, 146, 230, 216, 133, 145,
129, 22, 3, 3, 131, 17, 3, 0, 3, 228, 25, 128,
];

let _aarch64 = [
let other = [
24, 149, 99, 96, 96, 96, 96, 208, 6, 17, 112, 138, 129, 193, 128, 1, 29, 24, 50, 208,
1, 200, 146, 169, 79, 24, 74, 59, 96, 147, 52, 71, 22, 70, 246, 88, 26, 94, 80, 128,
83, 6, 162, 219, 144, 76, 183, 210, 5, 8, 67, 105, 36, 159, 35, 128, 57, 118, 97, 100,
160, 197, 192, 192, 96, 196, 0, 0, 3, 228, 25, 128,
];

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

#[cfg(target_arch = "aarch64")]
fuzz_based_test(&input, config, &_aarch64);
if cfg!(any(target_arch = "x86_64", target_arch = "x86")) {
fuzz_based_test(&input, config, &x86);
} else {
fuzz_based_test(&input, config, &other);
}
}
}

0 comments on commit f02eaf9

Please sign in to comment.