1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-02 11:22:41 +01:00

framework: Lock files which could be read/written to concurrently

Add file locking to files that could be read and written to concurrently
by separate wa processes causing race conditions.
This commit is contained in:
Marc Bonnici
2020-01-03 11:16:48 +00:00
committed by setrofim
parent d56f0fbe20
commit 607cff4c54
5 changed files with 65 additions and 50 deletions

View File

@@ -25,6 +25,7 @@ from wa.framework.configuration import settings
from wa.utils import log
from wa.utils.misc import get_object_name
from wa.utils.types import enum, list_or_string, prioritylist, version_tuple
from wa.utils.misc import lock_file
SourcePriority = enum(['package', 'remote', 'lan', 'local',
@@ -280,7 +281,8 @@ class ResourceResolver(object):
def apk_version_matches(path, version):
version = list_or_string(version)
info = ApkInfo(path)
with lock_file(path):
info = ApkInfo(path)
for v in version:
if info.version_name == v or info.version_code == v:
return True
@@ -290,7 +292,8 @@ def apk_version_matches(path, version):
def apk_version_matches_range(path, min_version=None, max_version=None):
info = ApkInfo(path)
with lock_file(path):
info = ApkInfo(path)
return range_version_matching(info.version_name, min_version, max_version)
@@ -333,18 +336,21 @@ def file_name_matches(path, pattern):
def uiauto_test_matches(path, uiauto):
info = ApkInfo(path)
with lock_file(path):
info = ApkInfo(path)
return uiauto == ('com.arm.wa.uiauto' in info.package)
def package_name_matches(path, package):
info = ApkInfo(path)
with lock_file(path):
info = ApkInfo(path)
return info.package == package
def apk_abi_matches(path, supported_abi, exact_abi=False):
supported_abi = list_or_string(supported_abi)
info = ApkInfo(path)
with lock_file(path):
info = ApkInfo(path)
# If no native code present, suitable for all devices.
if not info.native_code:
return True