Blob Blame History Raw
From 2e5694ac0dadd85d6f99661f2530194732ba8fd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Tue, 29 Dec 2020 17:46:51 +0100
Subject: [PATCH] i686 has 4-byte-aligned [iu]64s, so fix/comment out bits of
 tests that need that

Ref: #64
---
 tests/error/unaligned.rs | 6 ++++++
 tests/util/mod.rs        | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/error/unaligned.rs b/tests/error/unaligned.rs
index fcd6d5b..779c6a6 100644
--- a/tests/error/unaligned.rs
+++ b/tests/error/unaligned.rs
@@ -1,6 +1,8 @@
 use safe_transmute::{transmute_many_permissive, transmute_to_bytes};
 use safe_transmute::error::{UnalignedError, Error};
 #[cfg(feature = "alloc")]
+use core::mem::align_of;
+#[cfg(feature = "alloc")]
 use alloc::vec::Vec;
 
 
@@ -66,6 +68,10 @@ fn unaligned_slicing_integers() {
 
 #[cfg(feature = "alloc")]
 fn unaligned_slicing_integers_with_try_copy<'a>(bytes: &'a [u8]) -> Result<(), Error<'a, u8, u64>> {
+    if align_of::<u64>() != 8 {  // i686
+        return Ok(());
+    }
+
     for i in 4..8 {
         // transmute unaligned content by copying
         let outcome = transmute_many_permissive::<u64>(&bytes[i..]);
diff --git a/tests/util/mod.rs b/tests/util/mod.rs
index 362642d..381e702 100644
--- a/tests/util/mod.rs
+++ b/tests/util/mod.rs
@@ -36,7 +36,7 @@ fn smoke_check_alignment_from_4() {
 #[test]
 fn smoke_check_alignment_from_8() {
     let x: [i64; 5] = [0x5555_5555_5555_5555; 5];
-    assert_eq!(align_of::<[i64; 5]>(), 8);
+    // assert_eq!(align_of::<[i64; 5]>(), 8);  // False on i686, holds on amd64.
     assert_eq!(check_alignment::<_, u8>(&x[..]), Ok(()));
     assert_eq!(check_alignment::<_, i8>(&x[..]), Ok(()));
     assert_eq!(check_alignment::<_, u16>(&x[..]), Ok(()));
-- 
2.30.0