summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZhiting Zhu <zzhu@mozilla.com>2017-08-04 17:53:35 -0700
committerZhiting Zhu <zzhu@mozilla.com>2017-08-09 15:19:00 -0700
commite967d18c2c7465bd2f3432e4f39776ffa4f1f3ad (patch)
tree45e533989e2bcc8675841f3ebc038208e65a5cda /tests
parentdf820a20ca904268033a04506b8c96b416ad90ba (diff)
Layout related tests for derive Hash
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/issue-648-derive-debug-with-padding.rs6
-rw-r--r--tests/expectations/tests/layout_array.rs6
-rw-r--r--tests/expectations/tests/layout_array_too_long.rs8
-rw-r--r--tests/expectations/tests/layout_eth_conf.rs39
-rw-r--r--tests/expectations/tests/layout_mbuf.rs29
-rw-r--r--tests/headers/issue-648-derive-debug-with-padding.h7
-rw-r--r--tests/headers/layout_array.h1
-rw-r--r--tests/headers/layout_array_too_long.h1
-rw-r--r--tests/headers/layout_eth_conf.h3
-rw-r--r--tests/headers/layout_mbuf.h3
10 files changed, 57 insertions, 46 deletions
diff --git a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
index bcd5141e..0e22eedf 100644
--- a/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
+++ b/tests/expectations/tests/issue-648-derive-debug-with-padding.rs
@@ -5,7 +5,7 @@
/// We emit a `[u8; 63usize]` padding field for this struct, which cannot derive
-/// Debug because 63 is over the hard coded limit. (Yes, this struct doesn't end
+/// Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end
/// up with the reight alignment, we're waiting on `#[repr(align="N")]` to land
/// in rustc).
#[repr(C)]
@@ -30,8 +30,8 @@ impl Clone for NoDebug {
impl Default for NoDebug {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
-/// This should derive Debug because the padding size is less than the max derive
-/// Debug impl for arrays. However, we conservatively don't derive Debug because
+/// This should derive Debug/Hash because the padding size is less than the max derive
+/// Debug/Hash impl for arrays. However, we conservatively don't derive Debug/Hash because
/// we determine Debug derive-ability before we compute padding, which happens at
/// codegen. (Again, we expect to get the alignment wrong for similar reasons.)
#[repr(C)]
diff --git a/tests/expectations/tests/layout_array.rs b/tests/expectations/tests/layout_array.rs
index bccd5004..8ec289d4 100644
--- a/tests/expectations/tests/layout_array.rs
+++ b/tests/expectations/tests/layout_array.rs
@@ -106,7 +106,7 @@ impl Default for rte_mempool_ops {
}
/// The rte_spinlock_t type.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_spinlock_t {
/// < lock status 0 = unlocked, 1 = locked
pub locked: ::std::os::raw::c_int,
@@ -181,7 +181,7 @@ pub struct malloc_heap {
pub total_size: usize,
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct malloc_heap__bindgen_ty_1 {
pub lh_first: *mut malloc_elem,
}
@@ -239,7 +239,7 @@ impl Default for malloc_heap {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct malloc_elem {
pub _address: u8,
}
diff --git a/tests/expectations/tests/layout_array_too_long.rs b/tests/expectations/tests/layout_array_too_long.rs
index 9c825625..6078e2cc 100644
--- a/tests/expectations/tests/layout_array_too_long.rs
+++ b/tests/expectations/tests/layout_array_too_long.rs
@@ -20,7 +20,7 @@ pub enum _bindgen_ty_1 {
}
/// @internal fragmented mbuf
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct ip_frag {
/// < offset into the packet
pub ofs: u16,
@@ -59,7 +59,7 @@ impl Default for ip_frag {
}
/// @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct ip_frag_key {
/// < src address, first 8 bytes used for IPv4
pub src_dst: [u64; 4usize],
@@ -115,7 +115,7 @@ pub struct ip_frag_pkt {
pub __bindgen_padding_0: [u64; 6usize],
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct ip_frag_pkt__bindgen_ty_1 {
pub tqe_next: *mut ip_frag_pkt,
pub tqe_prev: *mut *mut ip_frag_pkt,
@@ -196,7 +196,7 @@ impl Default for ip_frag_pkt {
}
/// < fragment mbuf
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf {
pub _address: u8,
}
diff --git a/tests/expectations/tests/layout_eth_conf.rs b/tests/expectations/tests/layout_eth_conf.rs
index a51e40bc..6cf37ac5 100644
--- a/tests/expectations/tests/layout_eth_conf.rs
+++ b/tests/expectations/tests/layout_eth_conf.rs
@@ -28,6 +28,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt.write_str("__BindgenUnionField")
}
}
+impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+}
pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1;
pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2;
pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4;
@@ -76,7 +79,7 @@ pub enum rte_eth_rx_mq_mode {
}
/// A structure used to configure the RX features of an Ethernet port.
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_rxmode {
/// The multi-queue packet distribution mode to be used, e.g. RSS.
pub mq_mode: rte_eth_rx_mq_mode,
@@ -494,7 +497,7 @@ pub enum rte_eth_tx_mq_mode {
}
/// A structure used to configure the TX features of an Ethernet port.
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_txmode {
/// < TX multi-queues mode.
pub mq_mode: rte_eth_tx_mq_mode,
@@ -665,7 +668,7 @@ impl rte_eth_txmode {
/// types of IPv4/IPv6 packets to which the RSS hashing must be applied.
/// Supplying an *rss_hf* equal to zero disables the RSS feature.
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_rss_conf {
/// < If not NULL, 40-byte hash key.
pub rss_key: *mut u8,
@@ -742,7 +745,7 @@ pub struct rte_eth_vmdq_dcb_conf {
pub dcb_tc: [u8; 8usize],
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
/// < The vlan id of the received frame
pub vlan_id: u16,
@@ -822,7 +825,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_dcb_rx_conf {
/// < Possible DCB TCs, 4 or 8 TCs
pub nb_tcs: rte_eth_nb_tcs,
@@ -854,7 +857,7 @@ impl Default for rte_eth_dcb_rx_conf {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_vmdq_dcb_tx_conf {
/// < With DCB, 16 or 32 pools.
pub nb_queue_pools: rte_eth_nb_pools,
@@ -888,7 +891,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_dcb_tx_conf {
/// < Possible DCB TCs, 4 or 8 TCs.
pub nb_tcs: rte_eth_nb_tcs,
@@ -920,7 +923,7 @@ impl Default for rte_eth_dcb_tx_conf {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_vmdq_tx_conf {
/// < VMDq mode, 64 pools.
pub nb_queue_pools: rte_eth_nb_pools,
@@ -963,7 +966,7 @@ pub struct rte_eth_vmdq_rx_conf {
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
/// < The vlan id of the received frame
pub vlan_id: u16,
@@ -1076,7 +1079,7 @@ pub enum rte_fdir_status_mode {
}
/// A structure used to define the input for IPV4 flow
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_ipv4_flow {
/// < IPv4 source address in big endian.
pub src_ip: u32,
@@ -1126,7 +1129,7 @@ impl Clone for rte_eth_ipv4_flow {
}
/// A structure used to define the input for IPV6 flow
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_ipv6_flow {
/// < IPv6 source address in big endian.
pub src_ip: [u32; 4usize],
@@ -1177,7 +1180,7 @@ impl Clone for rte_eth_ipv6_flow {
/// A structure used to configure FDIR masks that are used by the device
/// to match the various fields of RX packet headers.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_fdir_masks {
/// < Bit mask for vlan_tci in big endian
pub vlan_tci_mask: u16,
@@ -1263,7 +1266,7 @@ pub enum rte_eth_payload_type {
/// A structure used to select bytes extracted from the protocol layers to
/// flexible payload for filter
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_flex_payload_cfg {
/// < Payload type
pub type_: rte_eth_payload_type,
@@ -1298,7 +1301,7 @@ impl Default for rte_eth_flex_payload_cfg {
/// A structure used to define FDIR masks for flexible payload
/// for each flow type
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_fdir_flex_mask {
pub flow_type: u16,
pub mask: [u8; 16usize],
@@ -1328,7 +1331,7 @@ impl Clone for rte_eth_fdir_flex_mask {
/// A structure used to define all flexible payload related setting
/// include flex payload and flex mask
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_eth_fdir_flex_conf {
/// < The number of following payload cfg
pub nb_payloads: u16,
@@ -1377,7 +1380,7 @@ impl Default for rte_eth_fdir_flex_conf {
///
/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
#[repr(C)]
-#[derive(Debug, Copy)]
+#[derive(Debug, Copy, Hash)]
pub struct rte_fdir_conf {
/// < Flow Director mode.
pub mode: rte_fdir_mode,
@@ -1435,7 +1438,7 @@ impl Default for rte_fdir_conf {
}
/// A structure used to enable/disable specific device interrupts.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_intr_conf {
/// enable/disable lsc interrupt. 0 (default) - disable, 1 enable
pub lsc: u16,
@@ -1548,7 +1551,7 @@ impl Default for rte_eth_conf__bindgen_ty_1 {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_eth_conf__bindgen_ty_2 {
pub vmdq_dcb_tx_conf: __BindgenUnionField<rte_eth_vmdq_dcb_tx_conf>,
pub dcb_tx_conf: __BindgenUnionField<rte_eth_dcb_tx_conf>,
diff --git a/tests/expectations/tests/layout_mbuf.rs b/tests/expectations/tests/layout_mbuf.rs
index 77198c35..5e08af3c 100644
--- a/tests/expectations/tests/layout_mbuf.rs
+++ b/tests/expectations/tests/layout_mbuf.rs
@@ -28,6 +28,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
fmt.write_str("__BindgenUnionField")
}
}
+impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
+ fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
+}
pub const RTE_CACHE_LINE_MIN_SIZE: ::std::os::raw::c_uint = 64;
pub const RTE_CACHE_LINE_SIZE: ::std::os::raw::c_uint = 64;
pub type phys_addr_t = u64;
@@ -36,7 +39,7 @@ pub type MARKER8 = [u8; 0usize];
pub type MARKER64 = [u64; 0usize];
/// The atomic counter structure.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_atomic16_t {
/// < An internal counter value.
pub cnt: i16,
@@ -110,7 +113,7 @@ pub struct rte_mbuf {
/// or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
/// config option.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_1 {
/// < Atomically accessed refcnt
pub refcnt_atomic: __BindgenUnionField<rte_atomic16_t>,
@@ -141,7 +144,7 @@ impl Clone for rte_mbuf__bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_2 {
/// < L2/L3/L4 and tunnel information.
pub packet_type: __BindgenUnionField<u32>,
@@ -149,7 +152,7 @@ pub struct rte_mbuf__bindgen_ty_2 {
pub bindgen_union_field: u32,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_2__bindgen_ty_1 {
pub _bitfield_1: [u8; 4usize],
pub __bindgen_align: [u32; 0usize],
@@ -472,7 +475,7 @@ impl Clone for rte_mbuf__bindgen_ty_2 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_3 {
/// < RSS hash result if RSS enabled
pub rss: __BindgenUnionField<u32>,
@@ -485,20 +488,20 @@ pub struct rte_mbuf__bindgen_ty_3 {
pub bindgen_union_field: [u32; 2usize],
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1 {
pub __bindgen_anon_1: rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1,
pub hi: u32,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1 {
pub __bindgen_anon_1: __BindgenUnionField<rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1>,
pub lo: __BindgenUnionField<u32>,
pub bindgen_union_field: u32,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 {
pub hash: u16,
pub id: u16,
@@ -582,7 +585,7 @@ impl Clone for rte_mbuf__bindgen_ty_3__bindgen_ty_1 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_3__bindgen_ty_2 {
pub lo: u32,
pub hi: u32,
@@ -646,7 +649,7 @@ impl Clone for rte_mbuf__bindgen_ty_3 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_4 {
/// < Can be used for external metadata
pub userdata: __BindgenUnionField<*mut ::std::os::raw::c_void>,
@@ -677,7 +680,7 @@ impl Clone for rte_mbuf__bindgen_ty_4 {
fn clone(&self) -> Self { *self }
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_5 {
/// < combined for easy fetch
pub tx_offload: __BindgenUnionField<u64>,
@@ -685,7 +688,7 @@ pub struct rte_mbuf__bindgen_ty_5 {
pub bindgen_union_field: u64,
}
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mbuf__bindgen_ty_5__bindgen_ty_1 {
pub _bitfield_1: [u16; 4usize],
pub __bindgen_align: [u64; 0usize],
@@ -1082,7 +1085,7 @@ impl Default for rte_mbuf {
}
/// < Pool from which mbuf was allocated.
#[repr(C)]
-#[derive(Debug, Default, Copy)]
+#[derive(Debug, Default, Copy, Hash)]
pub struct rte_mempool {
pub _address: u8,
}
diff --git a/tests/headers/issue-648-derive-debug-with-padding.h b/tests/headers/issue-648-derive-debug-with-padding.h
index 2bd5927a..fbe98678 100644
--- a/tests/headers/issue-648-derive-debug-with-padding.h
+++ b/tests/headers/issue-648-derive-debug-with-padding.h
@@ -1,6 +1,7 @@
+// bindgen-flags: --with-derive-hash
/**
* We emit a `[u8; 63usize]` padding field for this struct, which cannot derive
- * Debug because 63 is over the hard coded limit. (Yes, this struct doesn't end
+ * Debug/Hash because 63 is over the hard coded limit. (Yes, this struct doesn't end
* up with the reight alignment, we're waiting on `#[repr(align="N")]` to land
* in rustc).
*/
@@ -10,8 +11,8 @@ struct NoDebug {
} __attribute__((__aligned__(64)));
/**
- * This should derive Debug because the padding size is less than the max derive
- * Debug impl for arrays. However, we conservatively don't derive Debug because
+ * This should derive Debug/Hash because the padding size is less than the max derive
+ * Debug/Hash impl for arrays. However, we conservatively don't derive Debug/Hash because
* we determine Debug derive-ability before we compute padding, which happens at
* codegen. (Again, we expect to get the alignment wrong for similar reasons.)
*/
diff --git a/tests/headers/layout_array.h b/tests/headers/layout_array.h
index 4b99e0ed..fb071df6 100644
--- a/tests/headers/layout_array.h
+++ b/tests/headers/layout_array.h
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/layout_array_too_long.h b/tests/headers/layout_array_too_long.h
index 9be037ab..61f0c269 100644
--- a/tests/headers/layout_array_too_long.h
+++ b/tests/headers/layout_array_too_long.h
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
diff --git a/tests/headers/layout_eth_conf.h b/tests/headers/layout_eth_conf.h
index a742ee5f..7333f528 100644
--- a/tests/headers/layout_eth_conf.h
+++ b/tests/headers/layout_eth_conf.h
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
@@ -424,4 +425,4 @@ struct rte_eth_conf {
uint32_t dcb_capability_en;
struct rte_fdir_conf fdir_conf; /**< FDIR configuration. */
struct rte_intr_conf intr_conf; /**< Interrupt mode configuration. */
-}; \ No newline at end of file
+};
diff --git a/tests/headers/layout_mbuf.h b/tests/headers/layout_mbuf.h
index dc1c1b24..9166bac7 100644
--- a/tests/headers/layout_mbuf.h
+++ b/tests/headers/layout_mbuf.h
@@ -1,3 +1,4 @@
+// bindgen-flags: --with-derive-hash
#define RTE_CACHE_LINE_MIN_SIZE 64 /**< Minimum Cache line size. */
@@ -184,4 +185,4 @@ struct rte_mbuf {
/** Timesync flags for use with IEEE1588. */
uint16_t timesync;
-} __rte_cache_aligned; \ No newline at end of file
+} __rte_cache_aligned;