1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00

fw/target: add versioning to TargetInfo

Add format_version class attribute to TargetInfo to track format
changes. This is checked when deserializing from POD to catch format
changes between cached and obtained TargetInfo's.
This commit is contained in:
Sergei Trofimov 2018-11-02 11:48:00 +00:00 committed by Marc Bonnici
parent 17bb0083e5
commit d1fba957b3

View File

@ -22,6 +22,7 @@ from devlib.target import KernelConfig, KernelVersion, Cpuinfo
from devlib.utils.android import AndroidProperties
from wa.framework.configuration.core import settings
from wa.framework.exception import ConfigError
from wa.utils.serializer import read_pod, write_pod
@ -247,8 +248,15 @@ def write_target_info_cache(cache):
def get_target_info_from_cache(system_id):
cache = read_target_info_cache()
pod = cache.get(system_id, None)
if not pod:
return None
pod_version = pod.get('format_version', 0)
if pod_version != TargetInfo.format_version:
msg = 'Target info version mismatch. Expected {}, but found {}.\nTry deleting {}'
raise ConfigError(msg.format(TargetInfo.format_version, pod_version,
settings.target_info_cache_file))
return TargetInfo.from_pod(pod)
@ -262,6 +270,8 @@ def cache_target_info(target_info, overwrite=False):
class TargetInfo(object):
format_version = 1
@staticmethod
def from_pod(pod):
instance = TargetInfo()
@ -305,6 +315,7 @@ class TargetInfo(object):
def to_pod(self):
pod = {}
pod['format_version'] = self.format_version
pod['target'] = self.target
pod['abi'] = self.abi
pod['cpus'] = [c.to_pod() for c in self.cpus]