mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-18 20:11:20 +00:00
fw/execution: record resource hashes in metadata
As part of resolving a resource, record its MD5 hash in the output metadata. In order to enable this, resource resolution is now done via the context, rather than directly via the ResourceResolver (in order not to introduce a context dependency in the Gui object, context now emulates the resolver interface).
This commit is contained in:
parent
e5e8406e1f
commit
2ff06af632
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -181,6 +182,17 @@ class ExecutionContext(object):
|
|||||||
def write_state(self):
|
def write_state(self):
|
||||||
self.run_output.write_state()
|
self.run_output.write_state()
|
||||||
|
|
||||||
|
def get_resource(self, resource, strict=True):
|
||||||
|
result = self.resolver.get(resource, strict)
|
||||||
|
if os.path.isfile(result):
|
||||||
|
with open(result, 'rb') as fh:
|
||||||
|
md5hash = hashlib.md5(fh.read())
|
||||||
|
key = '{}/{}'.format(resource.owner, os.path.basename(result))
|
||||||
|
self.update_metadata('hashes', key, md5hash.hexdigest())
|
||||||
|
return result
|
||||||
|
|
||||||
|
get = get_resource # alias to allow a context to act as a resolver
|
||||||
|
|
||||||
def get_metric(self, name):
|
def get_metric(self, name):
|
||||||
try:
|
try:
|
||||||
return self.output.get_metric(name)
|
return self.output.get_metric(name)
|
||||||
|
@ -73,7 +73,7 @@ class Workload(TargetedPlugin):
|
|||||||
self.asset_files = []
|
self.asset_files = []
|
||||||
self.deployed_assets = []
|
self.deployed_assets = []
|
||||||
|
|
||||||
def init_resources(self, context):
|
def init_resources(self, resolver):
|
||||||
"""
|
"""
|
||||||
This method may be used to perform early resource discovery and
|
This method may be used to perform early resource discovery and
|
||||||
initialization. This is invoked during the initial loading stage and
|
initialization. This is invoked during the initial loading stage and
|
||||||
@ -83,7 +83,7 @@ class Workload(TargetedPlugin):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
for asset in self.deployable_assets:
|
for asset in self.deployable_assets:
|
||||||
self.asset_files.append(context.resolver.get(File(self, asset)))
|
self.asset_files.append(resolver.get(File(self, asset)))
|
||||||
|
|
||||||
@once_per_instance
|
@once_per_instance
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
@ -689,7 +689,7 @@ class PackageHandler(object):
|
|||||||
def resolve_package_from_host(self, context):
|
def resolve_package_from_host(self, context):
|
||||||
self.logger.debug('Resolving package on host system')
|
self.logger.debug('Resolving package on host system')
|
||||||
if self.package_name:
|
if self.package_name:
|
||||||
self.apk_file = context.resolver.get(ApkFile(self.owner,
|
self.apk_file = context.get_resource(ApkFile(self.owner,
|
||||||
variant=self.variant,
|
variant=self.variant,
|
||||||
version=self.version,
|
version=self.version,
|
||||||
package=self.package_name,
|
package=self.package_name,
|
||||||
@ -699,7 +699,7 @@ class PackageHandler(object):
|
|||||||
else:
|
else:
|
||||||
available_packages = []
|
available_packages = []
|
||||||
for package in self.owner.package_names:
|
for package in self.owner.package_names:
|
||||||
apk_file = context.resolver.get(ApkFile(self.owner,
|
apk_file = context.get_resource(ApkFile(self.owner,
|
||||||
variant=self.variant,
|
variant=self.variant,
|
||||||
version=self.version,
|
version=self.version,
|
||||||
package=package,
|
package=package,
|
||||||
|
@ -70,7 +70,7 @@ class FilePoller(Instrument):
|
|||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
if not self.target.is_rooted and self.as_root:
|
if not self.target.is_rooted and self.as_root:
|
||||||
raise ConfigError('The target is not rooted, cannot run poller as root.')
|
raise ConfigError('The target is not rooted, cannot run poller as root.')
|
||||||
host_poller = context.resolver.get(Executable(self, self.target.abi,
|
host_poller = context.get_resource(Executable(self, self.target.abi,
|
||||||
"poller"))
|
"poller"))
|
||||||
target_poller = self.target.install(host_poller)
|
target_poller = self.target.install(host_poller)
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Dhrystone(Workload):
|
|||||||
@once
|
@once
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
resource = Executable(self, self.target.abi, 'dhrystone')
|
resource = Executable(self, self.target.abi, 'dhrystone')
|
||||||
host_exe = context.resolver.get(resource)
|
host_exe = context.get_resource(resource)
|
||||||
Dhrystone.target_exe = self.target.install(host_exe)
|
Dhrystone.target_exe = self.target.install(host_exe)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -62,7 +62,7 @@ class Hackbench(Workload):
|
|||||||
|
|
||||||
@once
|
@once
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
host_binary = context.resolver.get(Executable(self, self.target.abi, self.binary_name))
|
host_binary = context.get_resource(Executable(self, self.target.abi, self.binary_name))
|
||||||
Hackbench.target_binary = self.target.install(host_binary)
|
Hackbench.target_binary = self.target.install(host_binary)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -63,7 +63,7 @@ class HWUITest(Workload):
|
|||||||
|
|
||||||
@once
|
@once
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
host_exe = context.resolver.get(Executable(self,
|
host_exe = context.get_resource(Executable(self,
|
||||||
self.target.abi,
|
self.target.abi,
|
||||||
BINARY))
|
BINARY))
|
||||||
HWUITest.target_exe = self.target.install(host_exe)
|
HWUITest.target_exe = self.target.install(host_exe)
|
||||||
|
@ -308,7 +308,7 @@ class Meabo(Workload):
|
|||||||
@once
|
@once
|
||||||
def _install_executable(self, context):
|
def _install_executable(self, context):
|
||||||
resource = Executable(self, self.target.abi, 'meabo')
|
resource = Executable(self, self.target.abi, 'meabo')
|
||||||
host_exe = context.resolver.get(resource)
|
host_exe = context.get_resource(resource)
|
||||||
Meabo.target_exe = self.target.install(host_exe)
|
Meabo.target_exe = self.target.install(host_exe)
|
||||||
|
|
||||||
@once
|
@once
|
||||||
|
@ -65,7 +65,7 @@ class Memcpy(Workload):
|
|||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
self.binary_name = 'memcpy'
|
self.binary_name = 'memcpy'
|
||||||
resource = Executable(self, self.target.abi, self.binary_name)
|
resource = Executable(self, self.target.abi, self.binary_name)
|
||||||
host_binary = context.resolver.get(resource)
|
host_binary = context.get_resource(resource)
|
||||||
Memcpy.target_exe = self.target.install_if_needed(host_binary)
|
Memcpy.target_exe = self.target.install_if_needed(host_binary)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -62,7 +62,7 @@ class Openssl(Workload):
|
|||||||
Openssl.target_exe = 'openssl'
|
Openssl.target_exe = 'openssl'
|
||||||
else:
|
else:
|
||||||
resource = Executable(self, self.target.abi, 'openssl')
|
resource = Executable(self, self.target.abi, 'openssl')
|
||||||
host_exe = context.resolver.get(resource)
|
host_exe = context.get_resource(resource)
|
||||||
Openssl.target_exe = self.target.install(host_exe)
|
Openssl.target_exe = self.target.install(host_exe)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -71,9 +71,9 @@ class Recentfling(Workload):
|
|||||||
raise WorkloadError("This workload relies on ``dumpsys gfxinfo`` \
|
raise WorkloadError("This workload relies on ``dumpsys gfxinfo`` \
|
||||||
only present in Android M and onwards")
|
only present in Android M and onwards")
|
||||||
|
|
||||||
defs_host = context.resolver.get(File(self, "defs.sh"))
|
defs_host = context.get_resource(File(self, "defs.sh"))
|
||||||
Recentfling.defs_target = self.target.install(defs_host)
|
Recentfling.defs_target = self.target.install(defs_host)
|
||||||
recentfling_host = context.resolver.get(File(self, "recentfling.sh"))
|
recentfling_host = context.get_resource(File(self, "recentfling.sh"))
|
||||||
Recentfling.recentfling_target = self.target.install(recentfling_host)
|
Recentfling.recentfling_target = self.target.install(recentfling_host)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -149,10 +149,10 @@ class RtApp(Workload):
|
|||||||
# available to other instances of the workload
|
# available to other instances of the workload
|
||||||
RtApp.target_working_directory = self.target.path.join(self.target.working_directory,
|
RtApp.target_working_directory = self.target.path.join(self.target.working_directory,
|
||||||
'rt-app-working')
|
'rt-app-working')
|
||||||
RtApp.host_binary = context.resolver.get(Executable(self,
|
RtApp.host_binary = context.get_resource(Executable(self,
|
||||||
self.target.abi,
|
self.target.abi,
|
||||||
BINARY_NAME), strict=False)
|
BINARY_NAME), strict=False)
|
||||||
RtApp.workgen_script = context.resolver.get(File(self, 'workgen'))
|
RtApp.workgen_script = context.get_resource(File(self, 'workgen'))
|
||||||
self.target.execute('mkdir -p {}'.format(self.target_working_directory))
|
self.target.execute('mkdir -p {}'.format(self.target_working_directory))
|
||||||
self._deploy_rt_app_binary_if_necessary()
|
self._deploy_rt_app_binary_if_necessary()
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ class RtApp(Workload):
|
|||||||
RtApp.target_binary = self.target.install(self.host_binary)
|
RtApp.target_binary = self.target.install(self.host_binary)
|
||||||
|
|
||||||
def _load_json_config(self, context):
|
def _load_json_config(self, context):
|
||||||
user_config_file = self._get_raw_json_config(context.resolver)
|
user_config_file = self._get_raw_json_config(context)
|
||||||
config_file = self._generate_workgen_config(user_config_file,
|
config_file = self._generate_workgen_config(user_config_file,
|
||||||
context.output_directory)
|
context.output_directory)
|
||||||
with open(config_file) as fh:
|
with open(config_file) as fh:
|
||||||
|
@ -80,7 +80,7 @@ class StressNg(Workload):
|
|||||||
raise WorkloadError('stress-ng requires root premissions to run')
|
raise WorkloadError('stress-ng requires root premissions to run')
|
||||||
|
|
||||||
resource = Executable(self, self.target.abi, 'stress-ng')
|
resource = Executable(self, self.target.abi, 'stress-ng')
|
||||||
host_exe = context.resolver.get(resource)
|
host_exe = context.get_resource(resource)
|
||||||
StressNg.binary = self.target.install(host_exe)
|
StressNg.binary = self.target.install(host_exe)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
@ -106,7 +106,7 @@ class Sysbench(Workload):
|
|||||||
@once
|
@once
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
exe = Executable(self, self.target.abi, 'sysbench')
|
exe = Executable(self, self.target.abi, 'sysbench')
|
||||||
host_binary = context.resolver.get(exe)
|
host_binary = context.get_resource(exe)
|
||||||
Sysbench.target_binary = self.target.install(host_binary)
|
Sysbench.target_binary = self.target.install(host_binary)
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user