Skip to content

Commit dcb85d5

Browse files
committed
add QEMU CI support
1 parent 2815421 commit dcb85d5

File tree

4 files changed

+78
-5
lines changed

4 files changed

+78
-5
lines changed

.github/workflows/checks.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
with:
8585
shared-key: "${{matrix.rust}}-${{matrix.target}}"
8686
- name: cargo build
87-
run: cargo build ${{ matrix.features }}
87+
run: cargo build --target ${{matrix.target}} ${{ matrix.features }}
8888
- name: cargo nextest # reports segfaults in a helpful way
8989
run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} --no-fail-fast
9090
env:
@@ -101,6 +101,59 @@ jobs:
101101
files: lcov.info
102102
fail_ci_if_error: false
103103

104+
build-qemu:
105+
name: QEMU build & test
106+
runs-on: "${{ matrix.os }}"
107+
strategy:
108+
matrix:
109+
include:
110+
- rust: stable
111+
os: ubuntu-latest
112+
features: ""
113+
target: "s390x-unknown-linux-gnu"
114+
gcc: "s390x-linux-gnu-gcc"
115+
- rust: stable
116+
os: ubuntu-latest
117+
features: ""
118+
target: "i686-unknown-linux-gnu"
119+
gcc: "i686-linux-gnu-gcc"
120+
steps:
121+
- uses: actions/checkout@v2
122+
- uses: awalsh128/cache-apt-pkgs-action@latest
123+
with:
124+
packages: qemu qemu-user qemu-user-static qemu-system-s390x gcc-s390x-linux-gnu gcc-i686-linux-gnu
125+
version: 1.0
126+
- name: Checkout sources
127+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
128+
with:
129+
persist-credentials: false
130+
- name: Copy QEMU Cargo Config
131+
run: |
132+
mkdir -p .cargo
133+
cp qemu-cargo-config.toml .cargo/config.toml
134+
- name: Install toolchain
135+
uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248
136+
with:
137+
toolchain: "stable"
138+
targets: "${{ matrix.target }}"
139+
- name: target
140+
run: "rustc -vV | sed -n 's|host: ||p'"
141+
- name: Rust cache
142+
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8
143+
with:
144+
shared-key: "${{matrix.rust}}-${{matrix.target}}"
145+
- name: Install cargo-nextest
146+
uses: taiki-e/install-action@56ab7930c591507f833cbaed864d201386d518a8
147+
with:
148+
tool: cargo-nextest
149+
- name: cargo build
150+
run: cargo build --target ${{matrix.target}} ${{ matrix.features }}
151+
- name: cargo nextest # reports segfaults in a helpful way
152+
run: cargo nextest run -p zlib-rs --target ${{matrix.target}} ${{ matrix.features }}
153+
env:
154+
RUST_BACKTRACE: 1
155+
CC: ${{matrix.gcc}}
156+
104157
clippy:
105158
name: Clippy
106159
strategy:

qemu-cargo-config.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# gets copied to .cargo/config.toml on CI, meant to run tests under qemu
2+
3+
[target.s390x-unknown-linux-gnu]
4+
runner = "qemu-s390x -L /usr/s390x-linux-gnu"
5+
linker = "s390x-linux-gnu-gcc"
6+
7+
[target.i686-unknown-linux-gnu]
8+
linker = "i686-linux-gnu-gcc"

test-libz-rs-sys/src/deflate.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ fn deflate_bound_gzip_header() {
716716
}
717717

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

@@ -726,6 +730,10 @@ fn test_compress_bound_windows() {
726730
}
727731

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

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

19671975
#[test]
1968-
#[cfg_attr(miri, ignore)]
1976+
#[cfg_attr(
1977+
not(any(target_arch = "x86_64", target_arch = "aarch64")),
1978+
ignore = "https://github.com/memorysafety/zlib-rs/issues/91"
1979+
)]
1980+
#[cfg_attr(miri, ignore = "too slow")]
19691981
fn compress_lcet10() {
19701982
fuzz_based_test(LCET10.as_bytes(), DeflateConfig::default(), &[])
19711983
}
19721984

19731985
#[test]
19741986
#[cfg_attr(
1975-
target_arch = "aarch64",
1987+
not(target_arch = "x86_64"),
19761988
ignore = "https://github.com/memorysafety/zlib-rs/issues/91"
19771989
)]
1978-
#[cfg_attr(miri, ignore)]
1990+
#[cfg_attr(miri, ignore = "too slow")]
19791991
fn compress_paper_100k() {
19801992
let mut config = DeflateConfig::default();
19811993

zlib-rs/src/deflate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4073,7 +4073,7 @@ mod test {
40734073
160, 197, 192, 192, 96, 196, 0, 0, 3, 228, 25, 128,
40744074
];
40754075

4076-
#[cfg(target_arch = "x86_64")]
4076+
#[cfg(not(target_arch = "aarch64"))]
40774077
fuzz_based_test(&input, config, &_x86_64);
40784078

40794079
#[cfg(target_arch = "aarch64")]

0 commit comments

Comments
 (0)