diff options
Diffstat (limited to 'util/flashrom_tester/src')
| -rw-r--r-- | util/flashrom_tester/src/tests.rs | 16 | ||||
| -rw-r--r-- | util/flashrom_tester/src/utils.rs | 12 | 
2 files changed, 26 insertions, 2 deletions
diff --git a/util/flashrom_tester/src/tests.rs b/util/flashrom_tester/src/tests.rs index e0824283..8d5f19e8 100644 --- a/util/flashrom_tester/src/tests.rs +++ b/util/flashrom_tester/src/tests.rs @@ -289,17 +289,18 @@ fn partial_lock_test(section: LayoutNames) -> impl Fn(&mut TestEnv) -> TestResul          // Need a clean image for verification          env.ensure_golden()?; -        let (name, start, len) = utils::layout_section(env.layout(), section); +        let (wp_section_name, start, len) = utils::layout_section(env.layout(), section);          // Disable software WP so we can do range protection, but hardware WP          // must remain enabled for (most) range protection to do anything.          env.wp.set_hw(false)?.set_sw(false)?;          env.cmd.wp_range((start, len), true)?;          env.wp.set_hw(true)?; +        // Check that we cannot write to the protected region.          let rws = flashrom::ROMWriteSpecifics {              layout_file: Some(LAYOUT_FILE),              write_file: Some(env.random_data_file()), -            name_file: Some(name), +            name_file: Some(wp_section_name),          };          if env.cmd.write_file_with_layout(&rws).is_ok() {              return Err( @@ -310,6 +311,17 @@ fn partial_lock_test(section: LayoutNames) -> impl Fn(&mut TestEnv) -> TestResul          if !env.is_golden() {              return Err("Section didn't lock, has been overwritten with random data!".into());          } + +        // Check that we can write to the non protected region. +        let (non_wp_section_name, _, _) = +            utils::layout_section(env.layout(), section.get_non_overlapping_section()); +        let rws = flashrom::ROMWriteSpecifics { +            layout_file: Some(LAYOUT_FILE), +            write_file: Some(env.random_data_file()), +            name_file: Some(non_wp_section_name), +        }; +        env.cmd.write_file_with_layout(&rws)?; +          Ok(())      }  } diff --git a/util/flashrom_tester/src/utils.rs b/util/flashrom_tester/src/utils.rs index 8d3c3191..5a932a06 100644 --- a/util/flashrom_tester/src/utils.rs +++ b/util/flashrom_tester/src/utils.rs @@ -44,6 +44,18 @@ pub enum LayoutNames {      BottomQuad,  } +impl LayoutNames { +    // Return a section that does not overlap +    pub fn get_non_overlapping_section(&self) -> LayoutNames { +        match self { +            LayoutNames::TopQuad => LayoutNames::BottomQuad, +            LayoutNames::TopHalf => LayoutNames::BottomHalf, +            LayoutNames::BottomHalf => LayoutNames::TopHalf, +            LayoutNames::BottomQuad => LayoutNames::TopQuad, +        } +    } +} +  #[derive(Debug, PartialEq, Eq, Clone, Copy)]  pub struct LayoutSizes {      half_sz: i64,  | 
