rust-lang / rustc-hash

Custom hash algorithm used by rustc (plus hashmap/set aliases): fast, deterministic, not secure
Apache License 2.0
377 stars 47 forks source link

tests added in v1.2.0 fail on big-endian architectures #43

Open decathorpe opened 4 months ago

decathorpe commented 4 months ago

The tests added in https://github.com/rust-lang/rustc-hash/pull/28 appear to assume little-endian byte order, and fail on big-endian architectures (the "cargo test" output below is from a s390x-unknown-linux-gnu machine).

I'm not sure if this is an indication of an issue with the actual implementation of rustc-hash on big-endian architectures, or if the hashes that are expected in tests are just hard-coded in little-endian byte-order but the actual results would be correct.

     Running `/builddir/build/BUILD/rustc-hash-1.2.0/target/rpm/deps/rustc_hash-3feb94ba4fd04739`
running 5 tests
test tests::signed ... FAILED
test seeded_state::tests::different_states_are_different ... ok
test tests::bytes ... FAILED
test tests::unsigned ... FAILED
test tests::with_seed_actually_different ... ok
failures:
---- tests::signed stdout ----
thread 'tests::signed' panicked at src/lib.rs:218:9:
assertion `left == right` failed
  left: 1714775736476281168
 right: 9223372036854775808
---- tests::bytes stdout ----
thread 'tests::bytes' panicked at src/lib.rs:267:9:
assertion `left == right` failed
  left: 4324798280752006973
 right: 16622306935539548858
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- tests::unsigned stdout ----
thread 'tests::unsigned' panicked at src/lib.rs:183:9:
assertion `left == right` failed
  left: 5871781006564002453
 right: 956286968014291186
failures:
    tests::bytes
    tests::signed
    tests::unsigned
test result: FAILED. 2 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--lib`
Noratrieb commented 4 months ago

that's definitely a test issue, just throw .to_le() into the test function to fix it, PRs welcome