MCPcopy Create free account
hub / github.com/bootc-dev/bootc / test_read_boot_fstab_entry

Function test_read_boot_fstab_entry

crates/lib/src/install.rs:3049–3088  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3047
3048 #[test]
3049 fn test_read_boot_fstab_entry() -> Result<()> {
3050 let td = cap_std_ext::cap_tempfile::TempDir::new(cap_std::ambient_authority())?;
3051
3052 // Test with no /etc/fstab
3053 assert!(read_boot_fstab_entry(&td)?.is_none());
3054
3055 // Test with /etc/fstab but no /boot entry
3056 td.create_dir("etc")?;
3057 td.write("etc/fstab", "UUID=test-uuid / ext4 defaults 0 0\n")?;
3058 assert!(read_boot_fstab_entry(&td)?.is_none());
3059
3060 // Test with /boot entry
3061 let fstab_content = "\
3062# /etc/fstab
3063UUID=root-uuid / ext4 defaults 0 0
3064UUID=boot-uuid /boot ext4 ro 0 0
3065UUID=home-uuid /home ext4 defaults 0 0
3066";
3067 td.write("etc/fstab", fstab_content)?;
3068 let boot_spec = read_boot_fstab_entry(&td)?.unwrap();
3069 assert_eq!(boot_spec.source, "UUID=boot-uuid");
3070 assert_eq!(boot_spec.target, "/boot");
3071 assert_eq!(boot_spec.fstype, "ext4");
3072 assert_eq!(boot_spec.options, Some("ro".to_string()));
3073
3074 // Test with /boot entry with comments
3075 let fstab_content = "\
3076# /etc/fstab
3077# Created by anaconda
3078UUID=root-uuid / ext4 defaults 0 0
3079# Boot partition
3080UUID=boot-uuid /boot ext4 defaults 0 0
3081";
3082 td.write("etc/fstab", fstab_content)?;
3083 let boot_spec = read_boot_fstab_entry(&td)?.unwrap();
3084 assert_eq!(boot_spec.source, "UUID=boot-uuid");
3085 assert_eq!(boot_spec.target, "/boot");
3086
3087 Ok(())
3088 }
3089
3090 #[test]
3091 fn test_require_dir_contains_only_mounts() -> Result<()> {

Callers

nothing calls this directly

Calls 1

read_boot_fstab_entryFunction · 0.85

Tested by

no test coverage detected