Skip to content

Commit 2fd32a7

Browse files
committed
uefi-raw: add ABI test for IpAddress
1 parent bae8971 commit 2fd32a7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

uefi-raw/src/net.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,18 @@ mod tests {
202202
let uefi_addr = IpAddress::from(core_addr);
203203
assert_eq!(unsafe { uefi_addr.v6.0 }, TEST_IPV6);
204204
}
205+
206+
// Ensure that our IpAddress type can be put into a packed struct,
207+
// even when it is normally 4 byte aligned.
208+
#[test]
209+
fn test_efi_ip_address_abi() {
210+
#[repr(C, packed)]
211+
struct PackedHelper<T>(T);
212+
213+
assert_eq!(align_of::<IpAddress>(), 4);
214+
assert_eq!(size_of::<IpAddress>(), 16);
215+
216+
assert_eq!(align_of::<PackedHelper<IpAddress>>(), 1);
217+
assert_eq!(size_of::<PackedHelper<IpAddress>>(), 16);
218+
}
205219
}

0 commit comments

Comments
 (0)