crc32c
crc32c copied to clipboard
Software crc32c produces wrong results on big endian CPUs
I am trying to run some code which uses crc32c
on powerpc 32 and 64 bit and I noticed it produces incorrect results.
I have tried to run the test suite of this crate using cross
and they indeed fail:
❯❯❯ ~/github/crc32c ❯ cross test --target powerpc-unknown-linux-gnu
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Finished test [unoptimized + debuginfo] target(s) in 0.15s
Running unittests src/lib.rs (/target/powerpc-unknown-linux-gnu/debug/deps/crc32c-06d60a5bbd004a3e)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/simple.rs (/target/powerpc-unknown-linux-gnu/debug/deps/simple-63febc81630ac4ff)
running 6 tests
test crc ... ok
test crc_append ... ok
test crc_combine ... FAILED
test long_string ... FAILED
test very_big ... FAILED
test very_small ... ok
failures:
---- crc_combine stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `689410915`,
right: `3475076554`', tests/simple.rs:25:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- long_string stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `550182489`,
right: `372323125`', tests/simple.rs:55:5
---- very_big stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `314413457`,
right: `1410821608`', tests/simple.rs:63:5
failures:
crc_combine
long_string
very_big
test result: FAILED. 3 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
error: test failed, to rerun pass '--test simple'
❯❯❯ ~/github/crc32c ❯ cross test --target powerpc64-unknown-linux-gnu
warning: unused manifest key: target.aarch64-unknown-linux-gnu.linker
Finished test [unoptimized + debuginfo] target(s) in 0.14s
Running unittests src/lib.rs (/target/powerpc64-unknown-linux-gnu/debug/deps/crc32c-d3c4704dfac2e462)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running tests/simple.rs (/target/powerpc64-unknown-linux-gnu/debug/deps/simple-7936969e39a66f78)
running 6 tests
test crc ... ok
test crc_append ... ok
test crc_combine ... FAILED
test long_string ... FAILED
test very_big ... FAILED
test very_small ... ok
failures:
---- crc_combine stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `2861399345`,
right: `3645618169`', tests/simple.rs:25:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- long_string stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `550182489`,
right: `372323125`', tests/simple.rs:55:5
---- very_big stdout ----
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `314413457`,
right: `1410821608`', tests/simple.rs:63:5
failures:
crc_combine
long_string
very_big
test result: FAILED. 3 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s
error: test failed, to rerun pass '--test simple'