thin-provisioning-tools
thin-provisioning-tools copied to clipboard
Fix compilation on i686
Compilation on i686 ends with error:
error[E0308]: mismatched types
--> src/write_batcher/tests.rs:100:51
|
100 | let mut rng = rand::rngs::SmallRng::from_seed([0; 32]);
| ------------------------------- ^^^^^^^ expected an array with a fixed size of 16 elements, found one with 32 elements
| |
| arguments to this function are incorrect
|
This is error from Fedora build system, running tests on 64 bit system in 32 bit chroot.
Not sure this affects other 32 bit platforms, using only x86.
Reported as not reproducible on 64 bit system when building with cargo build --target i686-unknown-linux-gnu, this is not working on my system, can not try with test instead of build
The random seed for SmallRng is 128-bit on 32-bit platforms, and 256-bit on 64-bit platforms (for PRNGs Xoshiro128PlusPlus and Xoshiro256PlusPlus, respectively). I would prefer this way:
diff --git a/src/write_batcher/tests.rs b/src/write_batcher/tests.rs
index 2da65396..85ef7daf 100644
--- a/src/write_batcher/tests.rs
+++ b/src/write_batcher/tests.rs
@@ -96,8 +96,10 @@ fn writes_should_be_performed_in_batch() {
#[test]
fn write_hit() {
+ type SeedType = <SmallRng as rand::SeedableRng>::Seed;
+
let mut src = vec![0u8; 4096];
- let mut rng = rand::rngs::SmallRng::from_seed([0; 32]);
+ let mut rng = SmallRng::from_seed(SeedType::default());
rng.fill_bytes(&mut src[4..]);
assert!(checksum::write_checksum(&mut src[..], BT::NODE).is_ok());
@@ -132,8 +134,10 @@ fn write_hit() {
#[test]
fn read_hit() {
+ type SeedType = <SmallRng as rand::SeedableRng>::Seed;
+
let mut src = vec![0u8; 4096];
- let mut rng = rand::rngs::SmallRng::from_seed([0; 32]);
+ let mut rng = SmallRng::from_seed(SeedType::default());
rng.fill_bytes(&mut src[4..]);
assert!(checksum::write_checksum(&mut src[..], BT::NODE).is_ok());