summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOla x Nilsson <ola.x.nilsson@axis.com>2017-08-28 16:58:15 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-11 17:30:28 +0100
commit7470b7ef19233793a418b6a2f5dc3eb396fca4f4 (patch)
tree2ddd323eb76ce1bed7dab8945e0ec8c95641d165
parent1d5d4165a5bc257650a4c136dfa4a58ade3e404e (diff)
downloadpoky-7470b7ef19233793a418b6a2f5dc3eb396fca4f4.tar.gz
oeqa/selftest/case: Add recipeinc method
The recipeinc method returns the absolute path of the test_recipe.inc file of a specified recipe. It replaces four instances of identical code, and make it possible to access the filename from a testcase for cleanup. The write_recipeinc and append_recipeinc methods are changed to return the path to the file in case that is useful. The test_recipe.inc file is usually cleaned up in a finally block, but that block executes before any teardown operations. This blocks any teardown that requires the presence of the test_recipe.inc file. (From OE-Core rev: cdb431676456f47da1a3b70caddf49f083948798) Signed-off-by: Ola x Nilsson <olani@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/case.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index 871009c568..e09915b495 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -212,27 +212,33 @@ to ensure accurate results.")
212 self.logger.debug("Removing from: %s\n%s\n" % (self.testinc_path, data)) 212 self.logger.debug("Removing from: %s\n%s\n" % (self.testinc_path, data))
213 ftools.remove_from_file(self.testinc_path, data) 213 ftools.remove_from_file(self.testinc_path, data)
214 214
215 def recipeinc(self, recipe):
216 """Return absolute path of meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
217 return os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
218
215 def write_recipeinc(self, recipe, data): 219 def write_recipeinc(self, recipe, data):
216 """Write to meta-sefltest/recipes-test/<recipe>/test_recipe.inc""" 220 """Write to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
217 inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') 221 inc_file = self.recipeinc(recipe)
218 self.logger.debug("Writing to: %s\n%s\n" % (inc_file, data)) 222 self.logger.debug("Writing to: %s\n%s\n" % (inc_file, data))
219 ftools.write_file(inc_file, data) 223 ftools.write_file(inc_file, data)
224 return inc_file
220 225
221 def append_recipeinc(self, recipe, data): 226 def append_recipeinc(self, recipe, data):
222 """Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc""" 227 """Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
223 inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') 228 inc_file = self.recipeinc(recipe)
224 self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data)) 229 self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data))
225 ftools.append_file(inc_file, data) 230 ftools.append_file(inc_file, data)
231 return inc_file
226 232
227 def remove_recipeinc(self, recipe, data): 233 def remove_recipeinc(self, recipe, data):
228 """Remove data from meta-sefltest/recipes-test/<recipe>/test_recipe.inc""" 234 """Remove data from meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
229 inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') 235 inc_file = self.recipeinc(recipe)
230 self.logger.debug("Removing from: %s\n%s\n" % (inc_file, data)) 236 self.logger.debug("Removing from: %s\n%s\n" % (inc_file, data))
231 ftools.remove_from_file(inc_file, data) 237 ftools.remove_from_file(inc_file, data)
232 238
233 def delete_recipeinc(self, recipe): 239 def delete_recipeinc(self, recipe):
234 """Delete meta-sefltest/recipes-test/<recipe>/test_recipe.inc file""" 240 """Delete meta-sefltest/recipes-test/<recipe>/test_recipe.inc file"""
235 inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc') 241 inc_file = self.recipeinc(recipe)
236 self.logger.debug("Deleting file: %s" % inc_file) 242 self.logger.debug("Deleting file: %s" % inc_file)
237 try: 243 try:
238 os.remove(inc_file) 244 os.remove(inc_file)
@@ -259,13 +265,13 @@ to ensure accurate results.")
259 self.logger.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data)) 265 self.logger.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data))
260 ftools.write_file(self.machineinc_path, data) 266 ftools.write_file(self.machineinc_path, data)
261 267
262 # check does path exist 268 # check does path exist
263 def assertExists(self, expr, msg=None): 269 def assertExists(self, expr, msg=None):
264 if not os.path.exists(expr): 270 if not os.path.exists(expr):
265 msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr)) 271 msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr))
266 raise self.failureException(msg) 272 raise self.failureException(msg)
267 273
268 # check does path not exist 274 # check does path not exist
269 def assertNotExists(self, expr, msg=None): 275 def assertNotExists(self, expr, msg=None):
270 if os.path.exists(expr): 276 if os.path.exists(expr):
271 msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr)) 277 msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))