mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 15:12:25 +00:00 
			
		
		
		
	APKResolution: Uses loose version matching
Allows for more flexible version matching e.g. specifying a version of 4, 4.3, 4.3.1 will all resolve to an apk version of 4.3.1
This commit is contained in:
		| @@ -279,7 +279,19 @@ def apk_version_matches(path, version): | ||||
|     info = ApkInfo(path) | ||||
|     if info.version_name == version or info.version_code == version: | ||||
|         return True | ||||
|     return False | ||||
|     return loose_version_matching(version, info.version_name) | ||||
|  | ||||
| def loose_version_matching(config_version, apk_version): | ||||
|     config_version = config_version.split('.') | ||||
|     apk_version = apk_version.split('.') | ||||
|  | ||||
|     if len(apk_version) < len(config_version): | ||||
|         return False  # More specific version requested than available | ||||
|  | ||||
|     for i in xrange(len(config_version)): | ||||
|         if config_version[i] != apk_version[i]: | ||||
|             return False | ||||
|     return True | ||||
|  | ||||
|  | ||||
| def file_name_matches(path, pattern): | ||||
|   | ||||
| @@ -20,7 +20,7 @@ import time | ||||
| from wa import Parameter | ||||
| from wa.framework.plugin import TargetedPlugin | ||||
| from wa.framework.resource import (ApkFile, JarFile, ReventFile, NO_ONE, | ||||
|                                    Executable, File) | ||||
|                                    Executable, File, loose_version_matching) | ||||
| from wa.framework.exception import WorkloadError | ||||
| from wa.utils.types import ParameterDict | ||||
| from wa.utils.revent import ReventRecorder | ||||
| @@ -468,6 +468,13 @@ class PackageHandler(object): | ||||
|                                              strict=self.strict) | ||||
|         if self.apk_file: | ||||
|             self.apk_info = ApkInfo(self.apk_file) | ||||
|             if self.version: | ||||
|                 installed_version = self.target.get_package_version(self.apk_info.package) | ||||
|                 host_version = self.apk_info.version_name | ||||
|                 if (installed_version != host_version and | ||||
|                         loose_version_matching(self.version, installed_version)): | ||||
|                     msg = 'Multiple matching packages found for {}; host version: {}, device version: {}' | ||||
|                     raise WorkloadError(msg.format(self.owner, host_version, installed_version)) | ||||
|         else: | ||||
|             if not self.owner.package_names and not self.package: | ||||
|                 msg = 'No package name(s) specified and no matching APK file found on host' | ||||
| @@ -487,7 +494,8 @@ class PackageHandler(object): | ||||
|  | ||||
|             if self.version: | ||||
|                 for package in installed_versions: | ||||
|                     if self.version == self.target.get_package_version(package): | ||||
|                     package_version = self.target.get_package_version(package) | ||||
|                     if loose_version_matching(self.version, package_version): | ||||
|                         self.package = package | ||||
|                         break | ||||
|             else: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user