libfdt: tests: Improve assert!() error messages
Make assert!() log as much context as possible on error by reworking
uses of unwrap() or is_{some,none}() in the macro.
To illustrate, using
let x = Some(42);
assert_eq!(x, None);
instead of assert!(x.is_none()) prints out
assertion `left == right` failed
left: Some(42)
right: None
instead of "assertion failed: x.is_none()".
Test: atest liblibfdt.integration_test
Change-Id: Ia1c4a3af02d1e2df747ef82c8b963166c39de450
diff --git a/libs/libfdt/src/lib.rs b/libs/libfdt/src/lib.rs
index 0a97141..96ac3f4 100644
--- a/libs/libfdt/src/lib.rs
+++ b/libs/libfdt/src/lib.rs
@@ -499,6 +499,12 @@
}
}
+impl<'a> PartialEq for FdtNode<'a> {
+ fn eq(&self, other: &Self) -> bool {
+ self.fdt.as_ptr() == other.fdt.as_ptr() && self.offset == other.offset
+ }
+}
+
/// Phandle of a FDT node
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -535,6 +541,7 @@
}
/// Mutable FDT node.
+#[derive(Debug)]
pub struct FdtNodeMut<'a> {
fdt: &'a mut Fdt,
offset: c_int,