From b9b50e4b83ee9e3c079e2be48205d40371a97fda Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 20 Sep 2021 13:52:02 +0200 Subject: [PATCH] Add some more documentation to SIMD/no-SIMD testing. --- .github/workflows/ci.yml | 5 +++-- crosstest/src/main.rs | 17 ++++++++++++++++- src/memory_layout.rs | 7 +++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29e5deb..0bd25dd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,11 +67,12 @@ jobs: run: cargo doc --verbose - name: Run SIMD/no-SIMD tests run: | + # See crosstest/main.rs for more info on the test cd crosstest - # Create some no-simd test files + # Create a no-simd test file in /tmp cargo run --verbose --features no_simd -- write cargo clean - # Create some simd test files and test the no-simd files + # Create a simd-enabled test file and test the no-simd file cargo run --verbose -- write read cargo clean # Test the simd-enabled files we generated in the last step diff --git a/crosstest/src/main.rs b/crosstest/src/main.rs index 76a9d7a..91ebbd1 100644 --- a/crosstest/src/main.rs +++ b/crosstest/src/main.rs @@ -1,5 +1,20 @@ // This test makes sure that a hash table generated with SIMD support -// can be loaded on a platform without SIMD support. +// can be loaded on a platform without SIMD support and vice versa. +// +// It works this way: +// +// The executable has two options: "write" and "read". When "write" is +// enabled, it will write a hashtable to /tmp. When "read" is enabled, +// it will try to read a hashtable from /tmp and verify that it contains +// the expected data. +// +// We compile the executable two times, once with and once without SIMD +// support. With both versions we generate a hashtable in /tmp and then +// try to load and verify that hashtable with the respective other +// version of the executable, that is, the SIMD-version will try to load +// the non-SIMD version and vice versa. +// +// See .github/workflows/ci.yml for how this is used. struct FxConfig; diff --git a/src/memory_layout.rs b/src/memory_layout.rs index 510871d..18b9e96 100644 --- a/src/memory_layout.rs +++ b/src/memory_layout.rs @@ -62,8 +62,11 @@ impl Header { if raw_bytes.len() != bytes_needed::(self.slot_count()) { return Err(Error(format!( - "Provided allocation has wrong size for slot count {}", - self.slot_count() + "Provided allocation has wrong size for slot count {}. \ + The allocation's size is {} but the expected size is {}.", + self.slot_count(), + raw_bytes.len(), + bytes_needed::(self.slot_count()), ))); }