faft: Add methods to backup and restore kernel attributes
Some FAFT tests change kernel attributes like priority or tries flags.
We should restore them when the tests are done. Let's add methods to
backup and restore the attributes.
BUG=chromium:215787
TEST=Use the added methods in firmware_CgptState and check kernel
attributes are restored.
Change-Id: Id9d962483e6da0b209e35a9d6fe9ca4fa7505d77
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/185351
Reviewed-by: Yusuf Mohsinally <mohsinally@chromium.org>
diff --git a/client/cros/faft/rpc_functions.py b/client/cros/faft/rpc_functions.py
index 174a6c6..166af86 100755
--- a/client/cros/faft/rpc_functions.py
+++ b/client/cros/faft/rpc_functions.py
@@ -11,6 +11,7 @@
import common
from autotest_lib.client.cros.faft.utils import (cgpt_state,
+ cgpt_handler,
chromeos_interface,
firmware_updater,
flashrom_handler,
@@ -133,8 +134,10 @@
self._tpm_handler = tpm_handler.TpmHandler()
self._tpm_handler.init(self._chromeos_interface)
+ self._cgpt_handler = cgpt_handler.CgptHandler(self._chromeos_interface)
self._cgpt_state = cgpt_state.CgptState(
- 'SHORT', self._chromeos_interface, self._system_get_root_dev())
+ 'SHORT', self._chromeos_interface, self._system_get_root_dev(),
+ self._cgpt_handler)
self._updater = firmware_updater.FirmwareUpdater(self._chromeos_interface)
@@ -664,6 +667,27 @@
"""
return self._cgpt_state.get_step()
+ def _cgpt_get_attributes(self):
+ """Get kernel attributes."""
+ rootdev = self._system_get_root_dev()
+ self._cgpt_handler.read_device_info(rootdev)
+ return {'A': self._cgpt_handler.get_partition(rootdev, 'KERN-A'),
+ 'B': self._cgpt_handler.get_partition(rootdev, 'KERN-B')}
+
+ def _cgpt_set_attributes(self, attributes):
+ """Set kernel attributes."""
+ rootdev = self._system_get_root_dev()
+ allowed = ['priority', 'tries', 'successful']
+ for p in ('A', 'B'):
+ if p not in attributes:
+ continue
+ attr = dict()
+ for k in allowed:
+ if k in attributes[p]:
+ attr[k] = attributes[p][k]
+ if attr:
+ self._cgpt_handler.set_partition(rootdev, 'KERN-%s' % p, attr)
+
def _updater_setup(self, shellball=None):
"""Setup the updater.