From a9649ddc44a7b29e44342bdf9b6660e1e2675a5f Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 8 Jul 2020 14:59:18 +0200 Subject: [PATCH] disks/zpool_status: add test for pool with special character Signed-off-by: Dominik Csapak --- src/tools/disks/zpool_status.rs | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/tools/disks/zpool_status.rs b/src/tools/disks/zpool_status.rs index f333d538..3b0edc88 100644 --- a/src/tools/disks/zpool_status.rs +++ b/src/tools/disks/zpool_status.rs @@ -430,3 +430,38 @@ errors: No known data errors Ok(()) } + +#[test] +fn test_zpool_status_parser3() -> Result<(), Error> { + + let output = r###" pool: bt-est + state: ONLINE + scan: none requested +config: + + NAME STATE READ WRITE CKSUM + bt-est ONLINE 0 0 0 + mirror-0 ONLINE 0 0 0 + /dev/sda1 ONLINE 0 0 0 + /dev/sda2 ONLINE 0 0 0 + mirror-1 ONLINE 0 0 0 + /dev/sda3 ONLINE 0 0 0 + /dev/sda4 ONLINE 0 0 0 + logs + /dev/sda5 ONLINE 0 0 0 + +errors: No known data errors +"###; + + let key_value_list = parse_zpool_status(&output)?; + for (k, v) in key_value_list { + println!("{} => {}", k,v); + if k == "config" { + let vdev_list = parse_zpool_status_config_tree(&v)?; + let _tree = vdev_list_to_tree(&vdev_list); + //println!("TREE1 {}", serde_json::to_string_pretty(&tree)?); + } + } + + Ok(()) +}