mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 02:01:16 +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:
parent
17bb0083e5
commit
d1fba957b3
@ -22,6 +22,7 @@ from devlib.target import KernelConfig, KernelVersion, Cpuinfo
|
|||||||
from devlib.utils.android import AndroidProperties
|
from devlib.utils.android import AndroidProperties
|
||||||
|
|
||||||
from wa.framework.configuration.core import settings
|
from wa.framework.configuration.core import settings
|
||||||
|
from wa.framework.exception import ConfigError
|
||||||
from wa.utils.serializer import read_pod, write_pod
|
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):
|
def get_target_info_from_cache(system_id):
|
||||||
cache = read_target_info_cache()
|
cache = read_target_info_cache()
|
||||||
pod = cache.get(system_id, None)
|
pod = cache.get(system_id, None)
|
||||||
|
|
||||||
if not pod:
|
if not pod:
|
||||||
return None
|
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)
|
return TargetInfo.from_pod(pod)
|
||||||
|
|
||||||
|
|
||||||
@ -262,6 +270,8 @@ def cache_target_info(target_info, overwrite=False):
|
|||||||
|
|
||||||
class TargetInfo(object):
|
class TargetInfo(object):
|
||||||
|
|
||||||
|
format_version = 1
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_pod(pod):
|
def from_pod(pod):
|
||||||
instance = TargetInfo()
|
instance = TargetInfo()
|
||||||
@ -305,6 +315,7 @@ class TargetInfo(object):
|
|||||||
|
|
||||||
def to_pod(self):
|
def to_pod(self):
|
||||||
pod = {}
|
pod = {}
|
||||||
|
pod['format_version'] = self.format_version
|
||||||
pod['target'] = self.target
|
pod['target'] = self.target
|
||||||
pod['abi'] = self.abi
|
pod['abi'] = self.abi
|
||||||
pod['cpus'] = [c.to_pod() for c in self.cpus]
|
pod['cpus'] = [c.to_pod() for c in self.cpus]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user