[rust][inspect] Remove root name in Inspector::new
TESTED=fx run-test rust-crates-tests -t fuchsia_inspect_lib_test
Change-Id: I180946f1cc832e494263e06fdb719e7ef88c546e
diff --git a/garnet/public/rust/fuchsia-inspect/src/vmo/constants.rs b/garnet/public/rust/fuchsia-inspect/src/vmo/constants.rs
index 3effe35..1e60dd0 100644
--- a/garnet/public/rust/fuchsia-inspect/src/vmo/constants.rs
+++ b/garnet/public/rust/fuchsia-inspect/src/vmo/constants.rs
@@ -34,3 +34,6 @@
/// The size for order NUM_ORDERS-1 (the maximum order)
pub const MAX_ORDER_SIZE: usize = 1 << MAX_ORDER_SHIFT;
+
+/// Name of the root node
+pub const ROOT_NAME: &str = "root";
diff --git a/garnet/public/rust/fuchsia-inspect/src/vmo/mod.rs b/garnet/public/rust/fuchsia-inspect/src/vmo/mod.rs
index 47c1d93b..845a8c4 100644
--- a/garnet/public/rust/fuchsia-inspect/src/vmo/mod.rs
+++ b/garnet/public/rust/fuchsia-inspect/src/vmo/mod.rs
@@ -61,17 +61,20 @@
/// Root API for inspect. Used to create the VMO and get the root node.
impl Inspector {
/// Create a new Inspect VMO object with the given maximum size.
- pub fn new(max_size: usize, name: &str) -> Result<Self, Error> {
+ pub fn new(max_size: usize) -> Result<Self, Error> {
let (mapping, _) = Mapping::allocate(max_size)
.map_err(|e| format_err!("failed to allocate vmo zx status={}", e))?;
let heap = Heap::new(Rc::new(mapping))?;
let state = State::create(heap)?;
- let root_node =
- Node::allocate(Arc::new(Mutex::new(state)), name, constants::ROOT_PARENT_INDEX)?;
+ let root_node = Node::allocate(
+ Arc::new(Mutex::new(state)),
+ constants::ROOT_NAME,
+ constants::ROOT_PARENT_INDEX,
+ )?;
Ok(Inspector { root_node })
}
- /// Create the root of the VMO object with the given |name|.
+ /// Get the root of the VMO object.
pub fn root(&self) -> &Node {
&self.root_node
}
@@ -250,6 +253,13 @@
use std::rc::Rc;
#[test]
+ fn inspector() {
+ let inspector = Inspector::new(4096).unwrap();
+ let root_name_block = inspector.root().state.lock().heap.get_block(2).unwrap();
+ assert_eq!(root_name_block.name_contents().unwrap(), constants::ROOT_NAME);
+ }
+
+ #[test]
fn node() {
let mapping = Rc::new(Mapping::allocate(4096).unwrap().0);
let state = get_state(mapping.clone());