()
| 901 | |
| 902 | #[test] |
| 903 | fn test_parse_lsblk_swraid() { |
| 904 | let fixture = include_str!("../tests/fixtures/lsblk-swraid.json"); |
| 905 | let devs: DevicesOutput = serde_json::from_str(fixture).unwrap(); |
| 906 | assert_eq!(devs.blockdevices.len(), 2); |
| 907 | |
| 908 | // In a software RAID (mdadm) setup each disk is individually |
| 909 | // partitioned with its own GPT table and ESP. The root partition |
| 910 | // (sda3/sdb3) is a linux_raid_member assembled into md0. |
| 911 | // find_partition_of_esp should locate the ESP as a direct child of |
| 912 | // each disk — no recursion through an md array is needed here. |
| 913 | let sda = &devs.blockdevices[0]; |
| 914 | let esp = sda.find_partition_of_esp().unwrap(); |
| 915 | assert_eq!(esp.name, "sda1"); |
| 916 | assert_eq!(esp.partn, Some(1)); |
| 917 | assert_eq!(esp.parttype.as_deref().unwrap(), ESP); |
| 918 | assert_eq!(esp.fstype.as_deref().unwrap(), "vfat"); |
| 919 | |
| 920 | let sdb = &devs.blockdevices[1]; |
| 921 | let esp = sdb.find_partition_of_esp().unwrap(); |
| 922 | assert_eq!(esp.name, "sdb1"); |
| 923 | assert_eq!(esp.partn, Some(1)); |
| 924 | assert_eq!(esp.parttype.as_deref().unwrap(), ESP); |
| 925 | assert_eq!(esp.fstype.as_deref().unwrap(), "vfat"); |
| 926 | |
| 927 | // Verify the md0 RAID array is visible as a child of the root |
| 928 | // partition on each disk. |
| 929 | let sda3 = sda |
| 930 | .children |
| 931 | .as_ref() |
| 932 | .unwrap() |
| 933 | .iter() |
| 934 | .find(|c| c.name == "sda3") |
| 935 | .unwrap(); |
| 936 | assert_eq!(sda3.fstype.as_deref().unwrap(), "linux_raid_member"); |
| 937 | let md0 = sda3 |
| 938 | .children |
| 939 | .as_ref() |
| 940 | .unwrap() |
| 941 | .iter() |
| 942 | .find(|c| c.name == "md0") |
| 943 | .unwrap(); |
| 944 | assert_eq!(md0.fstype.as_deref().unwrap(), "ext4"); |
| 945 | } |
| 946 | |
| 947 | #[test] |
| 948 | fn test_mbr_esp_detection() { |
nothing calls this directly
no test coverage detected