Skip to content

Commit ea328d1

Browse files
committed
test: test with-serde feature in CI
Do a build-test of the `with-serde` feature. Also do some simple round-trip testing to ensure consistent serialization (particularly, for the items that have manual (De)Serialize implementations). Signed-off-by: Patrick Roy <[email protected]>
1 parent da48ab3 commit ea328d1

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

.buildkite/custom-tests.json

+18-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,24 @@
1717
]
1818
},
1919
{
20-
"test_name": "check-warnings-fam",
21-
"command": "RUSTFLAGS=\"-D warnings\" cargo check --features=fam-wrappers",
20+
"test_name": "build-serde-gnu",
21+
"command": "cargo build --release --features=serde",
22+
"platform": [
23+
"x86_64",
24+
"aarch64"
25+
]
26+
},
27+
{
28+
"test_name": "build-serde-musl",
29+
"command": "cargo build --release --features=serde --target {target_platform}-unknown-linux-musl",
30+
"platform": [
31+
"x86_64",
32+
"aarch64"
33+
]
34+
},
35+
{
36+
"test_name": "check-warnings-all-features",
37+
"command": "RUSTFLAGS=\"-D warnings\" cargo check --all-features",
2238
"platform": [
2339
"x86_64",
2440
"aarch64"

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ serde = ["dep:serde", "serde/derive", "dep:zerocopy"]
2323
vmm-sys-util = { version = "0.12.1", optional = true }
2424
serde = { version = "1.0.0", optional = true, features = ["derive"] }
2525
zerocopy = { version = "0.7.32", optional = true, features = ["derive"] }
26+
27+
[dev-dependencies]
28+
bincode = "1.3.3"

coverage_config_aarch64.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"coverage_score": 60.9,
33
"exclude_path": "",
4-
"crate_features": "fam-wrappers"
4+
"crate_features": "fam-wrappers,serde"
55
}

coverage_config_x86_64.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 100,
2+
"coverage_score": 64,
33
"exclude_path": ".*bindings\\.rs",
4-
"crate_features": "fam-wrappers"
4+
"crate_features": "fam-wrappers,serde"
55
}

src/arm64/serialize.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ mod tests {
1818
use bindings::*;
1919
use serde::{Deserialize, Serialize};
2020

21-
fn is_serde<T: Serialize + for<'de> Deserialize<'de>>() {}
21+
fn is_serde<T: Serialize + for<'de> Deserialize<'de> + Default>() {
22+
let serialized = bincode::serialize(&T::default()).unwrap();
23+
let deserialized = bincode::deserialize::<T>(serialized.as_ref()).unwrap();
24+
let serialized_again = bincode::serialize(&deserialized).unwrap();
25+
// Compare the serialized state after a roundtrip, to work around issues with
26+
// bindings not implementing `PartialEq`.
27+
assert_eq!(serialized, serialized_again);
28+
}
2229

2330
#[test]
2431
fn static_assert_serde_implementations() {

src/x86_64/serialize.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ mod tests {
7373
use super::*;
7474
use bindings::*;
7575

76-
fn is_serde<T: Serialize + for<'de> Deserialize<'de>>() {}
76+
fn is_serde<T: Serialize + for<'de> Deserialize<'de> + Default>() {
77+
let serialized = bincode::serialize(&T::default()).unwrap();
78+
let deserialized = bincode::deserialize::<T>(serialized.as_ref()).unwrap();
79+
let serialized_again = bincode::serialize(&deserialized).unwrap();
80+
// Compare the serialized state after a roundtrip, to work around issues with
81+
// bindings not implementing `PartialEq`.
82+
assert_eq!(serialized, serialized_again);
83+
}
7784

7885
#[test]
7986
fn static_assert_serde_implementations() {

0 commit comments

Comments
 (0)