Skip to content

Commit 5b41c8e

Browse files
author
Zhiting Zhu
committed
Layout related tests for derive PartialEq
1 parent 93e7ccd commit 5b41c8e

14 files changed

+78
-73
lines changed

tests/expectations/tests/issue-648-derive-debug-with-padding.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ impl Clone for NoDebug {
3030
impl Default for NoDebug {
3131
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
3232
}
33-
/// This should derive Debug/Hash because the padding size is less than the max derive
34-
/// Debug/Hash impl for arrays. However, we conservatively don't derive Debug/Hash because
33+
/// This should derive Debug/Hash/PartialEq because the padding size is less than the max derive
34+
/// Debug/Hash/PartialEq impl for arrays. However, we conservatively don't derive Debug/Hash because
3535
/// we determine Debug derive-ability before we compute padding, which happens at
3636
/// codegen. (Again, we expect to get the alignment wrong for similar reasons.)
3737
#[repr(C)]

tests/expectations/tests/layout_array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Default for rte_mempool_ops {
106106
}
107107
/// The rte_spinlock_t type.
108108
#[repr(C)]
109-
#[derive(Debug, Default, Copy, Hash)]
109+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
110110
pub struct rte_spinlock_t {
111111
/// < lock status 0 = unlocked, 1 = locked
112112
pub locked: ::std::os::raw::c_int,
@@ -181,7 +181,7 @@ pub struct malloc_heap {
181181
pub total_size: usize,
182182
}
183183
#[repr(C)]
184-
#[derive(Debug, Copy, Hash)]
184+
#[derive(Debug, Copy, Hash, PartialEq)]
185185
pub struct malloc_heap__bindgen_ty_1 {
186186
pub lh_first: *mut malloc_elem,
187187
}
@@ -239,7 +239,7 @@ impl Default for malloc_heap {
239239
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
240240
}
241241
#[repr(C)]
242-
#[derive(Debug, Default, Copy, Hash)]
242+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
243243
pub struct malloc_elem {
244244
pub _address: u8,
245245
}

tests/expectations/tests/layout_array_too_long.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum _bindgen_ty_1 {
2020
}
2121
/// @internal fragmented mbuf
2222
#[repr(C)]
23-
#[derive(Debug, Copy, Hash)]
23+
#[derive(Debug, Copy, Hash, PartialEq)]
2424
pub struct ip_frag {
2525
/// < offset into the packet
2626
pub ofs: u16,
@@ -59,7 +59,7 @@ impl Default for ip_frag {
5959
}
6060
/// @internal <src addr, dst_addr, id> to uniquely indetify fragmented datagram.
6161
#[repr(C)]
62-
#[derive(Debug, Default, Copy, Hash)]
62+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
6363
pub struct ip_frag_key {
6464
/// < src address, first 8 bytes used for IPv4
6565
pub src_dst: [u64; 4usize],
@@ -115,7 +115,7 @@ pub struct ip_frag_pkt {
115115
pub __bindgen_padding_0: [u64; 6usize],
116116
}
117117
#[repr(C)]
118-
#[derive(Debug, Copy, Hash)]
118+
#[derive(Debug, Copy, Hash, PartialEq)]
119119
pub struct ip_frag_pkt__bindgen_ty_1 {
120120
pub tqe_next: *mut ip_frag_pkt,
121121
pub tqe_prev: *mut *mut ip_frag_pkt,
@@ -196,7 +196,7 @@ impl Default for ip_frag_pkt {
196196
}
197197
/// < fragment mbuf
198198
#[repr(C)]
199-
#[derive(Debug, Default, Copy, Hash)]
199+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
200200
pub struct rte_mbuf {
201201
pub _address: u8,
202202
}

tests/expectations/tests/layout_eth_conf.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum rte_eth_rx_mq_mode {
5252
}
5353
/// A structure used to configure the RX features of an Ethernet port.
5454
#[repr(C)]
55-
#[derive(Debug, Copy, Hash)]
55+
#[derive(Debug, Copy, Hash, PartialEq)]
5656
pub struct rte_eth_rxmode {
5757
/// The multi-queue packet distribution mode to be used, e.g. RSS.
5858
pub mq_mode: rte_eth_rx_mq_mode,
@@ -470,7 +470,7 @@ pub enum rte_eth_tx_mq_mode {
470470
}
471471
/// A structure used to configure the TX features of an Ethernet port.
472472
#[repr(C)]
473-
#[derive(Debug, Copy, Hash)]
473+
#[derive(Debug, Copy, Hash, PartialEq)]
474474
pub struct rte_eth_txmode {
475475
/// < TX multi-queues mode.
476476
pub mq_mode: rte_eth_tx_mq_mode,
@@ -641,7 +641,7 @@ impl rte_eth_txmode {
641641
/// types of IPv4/IPv6 packets to which the RSS hashing must be applied.
642642
/// Supplying an *rss_hf* equal to zero disables the RSS feature.
643643
#[repr(C)]
644-
#[derive(Debug, Copy, Hash)]
644+
#[derive(Debug, Copy, Hash, PartialEq)]
645645
pub struct rte_eth_rss_conf {
646646
/// < If not NULL, 40-byte hash key.
647647
pub rss_key: *mut u8,
@@ -718,7 +718,7 @@ pub struct rte_eth_vmdq_dcb_conf {
718718
pub dcb_tc: [u8; 8usize],
719719
}
720720
#[repr(C)]
721-
#[derive(Debug, Default, Copy, Hash)]
721+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
722722
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
723723
/// < The vlan id of the received frame
724724
pub vlan_id: u16,
@@ -798,7 +798,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
798798
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
799799
}
800800
#[repr(C)]
801-
#[derive(Debug, Copy, Hash)]
801+
#[derive(Debug, Copy, Hash, PartialEq)]
802802
pub struct rte_eth_dcb_rx_conf {
803803
/// < Possible DCB TCs, 4 or 8 TCs
804804
pub nb_tcs: rte_eth_nb_tcs,
@@ -830,7 +830,7 @@ impl Default for rte_eth_dcb_rx_conf {
830830
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
831831
}
832832
#[repr(C)]
833-
#[derive(Debug, Copy, Hash)]
833+
#[derive(Debug, Copy, Hash, PartialEq)]
834834
pub struct rte_eth_vmdq_dcb_tx_conf {
835835
/// < With DCB, 16 or 32 pools.
836836
pub nb_queue_pools: rte_eth_nb_pools,
@@ -864,7 +864,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
864864
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
865865
}
866866
#[repr(C)]
867-
#[derive(Debug, Copy, Hash)]
867+
#[derive(Debug, Copy, Hash, PartialEq)]
868868
pub struct rte_eth_dcb_tx_conf {
869869
/// < Possible DCB TCs, 4 or 8 TCs.
870870
pub nb_tcs: rte_eth_nb_tcs,
@@ -896,7 +896,7 @@ impl Default for rte_eth_dcb_tx_conf {
896896
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
897897
}
898898
#[repr(C)]
899-
#[derive(Debug, Copy, Hash)]
899+
#[derive(Debug, Copy, Hash, PartialEq)]
900900
pub struct rte_eth_vmdq_tx_conf {
901901
/// < VMDq mode, 64 pools.
902902
pub nb_queue_pools: rte_eth_nb_pools,
@@ -939,7 +939,7 @@ pub struct rte_eth_vmdq_rx_conf {
939939
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
940940
}
941941
#[repr(C)]
942-
#[derive(Debug, Default, Copy, Hash)]
942+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
943943
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
944944
/// < The vlan id of the received frame
945945
pub vlan_id: u16,
@@ -1052,7 +1052,7 @@ pub enum rte_fdir_status_mode {
10521052
}
10531053
/// A structure used to define the input for IPV4 flow
10541054
#[repr(C)]
1055-
#[derive(Debug, Default, Copy, Hash)]
1055+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
10561056
pub struct rte_eth_ipv4_flow {
10571057
/// < IPv4 source address in big endian.
10581058
pub src_ip: u32,
@@ -1102,7 +1102,7 @@ impl Clone for rte_eth_ipv4_flow {
11021102
}
11031103
/// A structure used to define the input for IPV6 flow
11041104
#[repr(C)]
1105-
#[derive(Debug, Default, Copy, Hash)]
1105+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
11061106
pub struct rte_eth_ipv6_flow {
11071107
/// < IPv6 source address in big endian.
11081108
pub src_ip: [u32; 4usize],
@@ -1153,7 +1153,7 @@ impl Clone for rte_eth_ipv6_flow {
11531153
/// A structure used to configure FDIR masks that are used by the device
11541154
/// to match the various fields of RX packet headers.
11551155
#[repr(C)]
1156-
#[derive(Debug, Default, Copy, Hash)]
1156+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
11571157
pub struct rte_eth_fdir_masks {
11581158
/// < Bit mask for vlan_tci in big endian
11591159
pub vlan_tci_mask: u16,
@@ -1239,7 +1239,7 @@ pub enum rte_eth_payload_type {
12391239
/// A structure used to select bytes extracted from the protocol layers to
12401240
/// flexible payload for filter
12411241
#[repr(C)]
1242-
#[derive(Debug, Copy, Hash)]
1242+
#[derive(Debug, Copy, Hash, PartialEq)]
12431243
pub struct rte_eth_flex_payload_cfg {
12441244
/// < Payload type
12451245
pub type_: rte_eth_payload_type,
@@ -1274,7 +1274,7 @@ impl Default for rte_eth_flex_payload_cfg {
12741274
/// A structure used to define FDIR masks for flexible payload
12751275
/// for each flow type
12761276
#[repr(C)]
1277-
#[derive(Debug, Default, Copy, Hash)]
1277+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
12781278
pub struct rte_eth_fdir_flex_mask {
12791279
pub flow_type: u16,
12801280
pub mask: [u8; 16usize],
@@ -1304,7 +1304,7 @@ impl Clone for rte_eth_fdir_flex_mask {
13041304
/// A structure used to define all flexible payload related setting
13051305
/// include flex payload and flex mask
13061306
#[repr(C)]
1307-
#[derive(Debug, Copy, Hash)]
1307+
#[derive(Debug, Copy, Hash, PartialEq)]
13081308
pub struct rte_eth_fdir_flex_conf {
13091309
/// < The number of following payload cfg
13101310
pub nb_payloads: u16,
@@ -1353,7 +1353,7 @@ impl Default for rte_eth_fdir_flex_conf {
13531353
///
13541354
/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
13551355
#[repr(C)]
1356-
#[derive(Debug, Copy, Hash)]
1356+
#[derive(Debug, Copy, Hash, PartialEq)]
13571357
pub struct rte_fdir_conf {
13581358
/// < Flow Director mode.
13591359
pub mode: rte_fdir_mode,
@@ -1411,7 +1411,7 @@ impl Default for rte_fdir_conf {
14111411
}
14121412
/// A structure used to enable/disable specific device interrupts.
14131413
#[repr(C)]
1414-
#[derive(Debug, Default, Copy, Hash)]
1414+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
14151415
pub struct rte_intr_conf {
14161416
/// enable/disable lsc interrupt. 0 (default) - disable, 1 enable
14171417
pub lsc: u16,

tests/expectations/tests/layout_eth_conf_1_0.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ impl <T> ::std::fmt::Debug for __BindgenUnionField<T> {
3131
impl <T> ::std::hash::Hash for __BindgenUnionField<T> {
3232
fn hash<H: ::std::hash::Hasher>(&self, _state: &mut H) { }
3333
}
34+
impl <T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
35+
fn eq(&self, _other: &__BindgenUnionField<T>) -> bool { true }
36+
}
3437
pub const ETH_MQ_RX_RSS_FLAG: ::std::os::raw::c_uint = 1;
3538
pub const ETH_MQ_RX_DCB_FLAG: ::std::os::raw::c_uint = 2;
3639
pub const ETH_MQ_RX_VMDQ_FLAG: ::std::os::raw::c_uint = 4;
@@ -79,7 +82,7 @@ pub enum rte_eth_rx_mq_mode {
7982
}
8083
/// A structure used to configure the RX features of an Ethernet port.
8184
#[repr(C)]
82-
#[derive(Debug, Copy, Hash)]
85+
#[derive(Debug, Copy, Hash, PartialEq)]
8386
pub struct rte_eth_rxmode {
8487
/// The multi-queue packet distribution mode to be used, e.g. RSS.
8588
pub mq_mode: rte_eth_rx_mq_mode,
@@ -497,7 +500,7 @@ pub enum rte_eth_tx_mq_mode {
497500
}
498501
/// A structure used to configure the TX features of an Ethernet port.
499502
#[repr(C)]
500-
#[derive(Debug, Copy, Hash)]
503+
#[derive(Debug, Copy, Hash, PartialEq)]
501504
pub struct rte_eth_txmode {
502505
/// < TX multi-queues mode.
503506
pub mq_mode: rte_eth_tx_mq_mode,
@@ -668,7 +671,7 @@ impl rte_eth_txmode {
668671
/// types of IPv4/IPv6 packets to which the RSS hashing must be applied.
669672
/// Supplying an *rss_hf* equal to zero disables the RSS feature.
670673
#[repr(C)]
671-
#[derive(Debug, Copy, Hash)]
674+
#[derive(Debug, Copy, Hash, PartialEq)]
672675
pub struct rte_eth_rss_conf {
673676
/// < If not NULL, 40-byte hash key.
674677
pub rss_key: *mut u8,
@@ -745,7 +748,7 @@ pub struct rte_eth_vmdq_dcb_conf {
745748
pub dcb_tc: [u8; 8usize],
746749
}
747750
#[repr(C)]
748-
#[derive(Debug, Default, Copy, Hash)]
751+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
749752
pub struct rte_eth_vmdq_dcb_conf__bindgen_ty_1 {
750753
/// < The vlan id of the received frame
751754
pub vlan_id: u16,
@@ -825,7 +828,7 @@ impl Default for rte_eth_vmdq_dcb_conf {
825828
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
826829
}
827830
#[repr(C)]
828-
#[derive(Debug, Copy, Hash)]
831+
#[derive(Debug, Copy, Hash, PartialEq)]
829832
pub struct rte_eth_dcb_rx_conf {
830833
/// < Possible DCB TCs, 4 or 8 TCs
831834
pub nb_tcs: rte_eth_nb_tcs,
@@ -857,7 +860,7 @@ impl Default for rte_eth_dcb_rx_conf {
857860
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
858861
}
859862
#[repr(C)]
860-
#[derive(Debug, Copy, Hash)]
863+
#[derive(Debug, Copy, Hash, PartialEq)]
861864
pub struct rte_eth_vmdq_dcb_tx_conf {
862865
/// < With DCB, 16 or 32 pools.
863866
pub nb_queue_pools: rte_eth_nb_pools,
@@ -891,7 +894,7 @@ impl Default for rte_eth_vmdq_dcb_tx_conf {
891894
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
892895
}
893896
#[repr(C)]
894-
#[derive(Debug, Copy, Hash)]
897+
#[derive(Debug, Copy, Hash, PartialEq)]
895898
pub struct rte_eth_dcb_tx_conf {
896899
/// < Possible DCB TCs, 4 or 8 TCs.
897900
pub nb_tcs: rte_eth_nb_tcs,
@@ -923,7 +926,7 @@ impl Default for rte_eth_dcb_tx_conf {
923926
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
924927
}
925928
#[repr(C)]
926-
#[derive(Debug, Copy, Hash)]
929+
#[derive(Debug, Copy, Hash, PartialEq)]
927930
pub struct rte_eth_vmdq_tx_conf {
928931
/// < VMDq mode, 64 pools.
929932
pub nb_queue_pools: rte_eth_nb_pools,
@@ -966,7 +969,7 @@ pub struct rte_eth_vmdq_rx_conf {
966969
pub pool_map: [rte_eth_vmdq_rx_conf__bindgen_ty_1; 64usize],
967970
}
968971
#[repr(C)]
969-
#[derive(Debug, Default, Copy, Hash)]
972+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
970973
pub struct rte_eth_vmdq_rx_conf__bindgen_ty_1 {
971974
/// < The vlan id of the received frame
972975
pub vlan_id: u16,
@@ -1079,7 +1082,7 @@ pub enum rte_fdir_status_mode {
10791082
}
10801083
/// A structure used to define the input for IPV4 flow
10811084
#[repr(C)]
1082-
#[derive(Debug, Default, Copy, Hash)]
1085+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
10831086
pub struct rte_eth_ipv4_flow {
10841087
/// < IPv4 source address in big endian.
10851088
pub src_ip: u32,
@@ -1129,7 +1132,7 @@ impl Clone for rte_eth_ipv4_flow {
11291132
}
11301133
/// A structure used to define the input for IPV6 flow
11311134
#[repr(C)]
1132-
#[derive(Debug, Default, Copy, Hash)]
1135+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
11331136
pub struct rte_eth_ipv6_flow {
11341137
/// < IPv6 source address in big endian.
11351138
pub src_ip: [u32; 4usize],
@@ -1180,7 +1183,7 @@ impl Clone for rte_eth_ipv6_flow {
11801183
/// A structure used to configure FDIR masks that are used by the device
11811184
/// to match the various fields of RX packet headers.
11821185
#[repr(C)]
1183-
#[derive(Debug, Default, Copy, Hash)]
1186+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
11841187
pub struct rte_eth_fdir_masks {
11851188
/// < Bit mask for vlan_tci in big endian
11861189
pub vlan_tci_mask: u16,
@@ -1266,7 +1269,7 @@ pub enum rte_eth_payload_type {
12661269
/// A structure used to select bytes extracted from the protocol layers to
12671270
/// flexible payload for filter
12681271
#[repr(C)]
1269-
#[derive(Debug, Copy, Hash)]
1272+
#[derive(Debug, Copy, Hash, PartialEq)]
12701273
pub struct rte_eth_flex_payload_cfg {
12711274
/// < Payload type
12721275
pub type_: rte_eth_payload_type,
@@ -1301,7 +1304,7 @@ impl Default for rte_eth_flex_payload_cfg {
13011304
/// A structure used to define FDIR masks for flexible payload
13021305
/// for each flow type
13031306
#[repr(C)]
1304-
#[derive(Debug, Default, Copy, Hash)]
1307+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
13051308
pub struct rte_eth_fdir_flex_mask {
13061309
pub flow_type: u16,
13071310
pub mask: [u8; 16usize],
@@ -1331,7 +1334,7 @@ impl Clone for rte_eth_fdir_flex_mask {
13311334
/// A structure used to define all flexible payload related setting
13321335
/// include flex payload and flex mask
13331336
#[repr(C)]
1334-
#[derive(Debug, Copy, Hash)]
1337+
#[derive(Debug, Copy, Hash, PartialEq)]
13351338
pub struct rte_eth_fdir_flex_conf {
13361339
/// < The number of following payload cfg
13371340
pub nb_payloads: u16,
@@ -1380,7 +1383,7 @@ impl Default for rte_eth_fdir_flex_conf {
13801383
///
13811384
/// If mode is RTE_FDIR_DISABLE, the pballoc value is ignored.
13821385
#[repr(C)]
1383-
#[derive(Debug, Copy, Hash)]
1386+
#[derive(Debug, Copy, Hash, PartialEq)]
13841387
pub struct rte_fdir_conf {
13851388
/// < Flow Director mode.
13861389
pub mode: rte_fdir_mode,
@@ -1438,7 +1441,7 @@ impl Default for rte_fdir_conf {
14381441
}
14391442
/// A structure used to enable/disable specific device interrupts.
14401443
#[repr(C)]
1441-
#[derive(Debug, Default, Copy, Hash)]
1444+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
14421445
pub struct rte_intr_conf {
14431446
/// enable/disable lsc interrupt. 0 (default) - disable, 1 enable
14441447
pub lsc: u16,
@@ -1551,7 +1554,7 @@ impl Default for rte_eth_conf__bindgen_ty_1 {
15511554
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
15521555
}
15531556
#[repr(C)]
1554-
#[derive(Debug, Default, Copy, Hash)]
1557+
#[derive(Debug, Default, Copy, Hash, PartialEq)]
15551558
pub struct rte_eth_conf__bindgen_ty_2 {
15561559
pub vmdq_dcb_tx_conf: __BindgenUnionField<rte_eth_vmdq_dcb_tx_conf>,
15571560
pub dcb_tx_conf: __BindgenUnionField<rte_eth_dcb_tx_conf>,

0 commit comments

Comments
 (0)