def testDumpFlashImage(self): """Test the basic dump.""" args = rdf_chipsec_types.DumpFlashImageRequest() result = self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)[0] with vfs.VFSOpen(result.path) as image: self.assertEqual(image.read(0x20000), b"\xff" * 0x10000)
def testDumpFlashImageVerbose(self): """Test the basic dump with the verbose mode enabled.""" args = rdf_chipsec_types.DumpFlashImageRequest(log_level=1) result = self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)[0] with vfs.VFSOpen(result.path) as image: self.assertEqual(image.read(0x20000), b"\xff" * 0x10000) self.assertNotEqual(self.chipsec_mock.logger.logger.call_count, 0)
def testDumpFlashImageUnknownChipsetVerbose(self): """Test unknown chipset with verbose mode. If the chipset is unknown but verbose enabled, no exception is raised and at least one response should be returned with non-empty logs. """ self.chipsec_mock.chipset.cs = UnsupportedChipset args = rdf_chipsec_types.DumpFlashImageRequest(log_level=1) self.RunAction(self.grr_chipsec_module.DumpFlashImage, args) self.assertNotEqual(self.chipsec_mock.logger.logger.call_count, 0) self.assertNotEmpty(self.results) self.assertNotEmpty(self.results[0].logs) self.assertEqual(self.results[0].path.path, "")
def testDumpFlashImageOsHelperErrorChipset(self): """If an exception is raised by the helper layer, handle it.""" self.chipsec_mock.chipset.cs = FailingOsHelperChipset args = rdf_chipsec_types.DumpFlashImageRequest() self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)
def testDumpFlashImageUnknownChipset(self): """By default, if the chipset is unknown, no exception is raised.""" self.chipsec_mock.chipset.cs = UnsupportedChipset args = rdf_chipsec_types.DumpFlashImageRequest() self.RunAction(self.grr_chipsec_module.DumpFlashImage, args)