Skip to content

Commit fce7e0f

Browse files
committed
uefi-raw: add ABI test for IpAddress
1 parent 9c14c01 commit fce7e0f

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
@@ -212,4 +212,18 @@ mod tests {
212212
let uefi_addr = IpAddress::from(core_addr);
213213
assert_eq!(unsafe { uefi_addr.v6.0 }, TEST_IPV6);
214214
}
215+
216+
// Ensure that our IpAddress type can be put into a packed struct,
217+
// even when it is normally 4 byte aligned.
218+
#[test]
219+
fn test_efi_ip_address_abi() {
220+
#[repr(C, packed)]
221+
struct PackedHelper<T>(T);
222+
223+
assert_eq!(align_of::<IpAddress>(), 4);
224+
assert_eq!(size_of::<IpAddress>(), 16);
225+
226+
assert_eq!(align_of::<PackedHelper<IpAddress>>(), 1);
227+
assert_eq!(size_of::<PackedHelper<IpAddress>>(), 16);
228+
}
215229
}

0 commit comments

Comments
 (0)