summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2017-01-13 10:47:53 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:20 +0000
commit58789be270c903bf75c1946a4c626b37a5bcdc72 (patch)
treedb84f05a6ab1fdeac5cdd1224558216e562f35d6 /meta/lib/oeqa/utils
parentf8d7db1905902c048d22c86ecddd1be98419bbaf (diff)
downloadpoky-58789be270c903bf75c1946a4c626b37a5bcdc72.tar.gz
testimage.bbclass: Add package install feature
This allows to use the package install feature with the new OEQA framework. [YOCTO #10234] (From OE-Core rev: 077dc19445574457769eb4f231de97e8059cb75e) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/package_manager.py46
1 files changed, 33 insertions, 13 deletions
diff --git a/meta/lib/oeqa/utils/package_manager.py b/meta/lib/oeqa/utils/package_manager.py
index ab0d3e5564..92646488da 100644
--- a/meta/lib/oeqa/utils/package_manager.py
+++ b/meta/lib/oeqa/utils/package_manager.py
@@ -1,7 +1,8 @@
1import bb 1import os
2import json 2import json
3import shutil 3import shutil
4 4
5from oeqa.core.utils.test import getCaseFile, getCaseMethod
5 6
6def get_package_manager(d, root_path): 7def get_package_manager(d, root_path):
7 """ 8 """
@@ -86,6 +87,7 @@ def extract_packages(d, needed_packages):
86 Extract packages that will be needed during runtime. 87 Extract packages that will be needed during runtime.
87 """ 88 """
88 89
90 import bb
89 import oe.path 91 import oe.path
90 92
91 extracted_path = d.getVar('TEST_EXTRACTED_DIR') 93 extracted_path = d.getVar('TEST_EXTRACTED_DIR')
@@ -152,20 +154,38 @@ def _copy_package(d, pkg):
152 shutil.copy2(file_path, dst_dir) 154 shutil.copy2(file_path, dst_dir)
153 shutil.rmtree(pkg_path) 155 shutil.rmtree(pkg_path)
154 156
155def install_uninstall_packages(self, test_id, pkg_dir, install): 157def install_package(test_case):
156 """ 158 """
157 Check if the test requires a package and Install/Unistall it in the DUT 159 Installs package in DUT if required.
158 """ 160 """
161 needed_packages = test_needs_package(test_case)
162 if needed_packages:
163 _install_uninstall_packages(needed_packages, test_case, True)
159 164
160 test = test_id.split('.')[4] 165def uninstall_package(test_case):
161 module = self.getModulefromID(test_id) 166 """
162 json = self._getJsonFile(module) 167 Uninstalls package in DUT if required.
163 if json: 168 """
164 needed_packages = self._getNeededPackages(json, test) 169 needed_packages = test_needs_package(test_case)
170 if needed_packages:
171 _install_uninstall_packages(needed_packages, test_case, False)
172
173def test_needs_package(test_case):
174 """
175 Checks if a test case requires to install/uninstall packages.
176 """
177 test_file = getCaseFile(test_case)
178 json_file = _get_json_file(test_file)
179
180 if json_file:
181 test_method = getCaseMethod(test_case)
182 needed_packages = _get_needed_packages(json_file, test_method)
165 if needed_packages: 183 if needed_packages:
166 self._install_uninstall_packages(needed_packages, pkg_dir, install) 184 return needed_packages
185
186 return None
167 187
168def _install_uninstall_packages(self, needed_packages, pkg_dir, install=True): 188def _install_uninstall_packages(needed_packages, test_case, install=True):
169 """ 189 """
170 Install/Unistall packages in the DUT without using a package manager 190 Install/Unistall packages in the DUT without using a package manager
171 """ 191 """
@@ -179,12 +199,12 @@ def _install_uninstall_packages(self, needed_packages, pkg_dir, install=True):
179 pkg = package['pkg'] 199 pkg = package['pkg']
180 rm = package.get('rm', False) 200 rm = package.get('rm', False)
181 extract = package.get('extract', True) 201 extract = package.get('extract', True)
182 src_dir = os.path.join(pkg_dir, pkg) 202 src_dir = os.path.join(test_case.tc.extract_dir, pkg)
183 203
184 # Install package 204 # Install package
185 if install and extract: 205 if install and extract:
186 self.target.connection.copy_dir_to(src_dir, '/') 206 test_case.tc.target.copyDirTo(src_dir, '/')
187 207
188 # Unistall package 208 # Unistall package
189 elif not install and rm: 209 elif not install and rm:
190 self.target.connection.delete_dir_structure(src_dir, '/') 210 test_case.tc.target.deleteDirStructure(src_dir, '/')