mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
1d5d4165a5
commit
7470b7ef19
@@ -212,27 +212,33 @@ to ensure accurate results.")
|
|||||||
self.logger.debug("Removing from: %s\n%s\n" % (self.testinc_path, data))
|
self.logger.debug("Removing from: %s\n%s\n" % (self.testinc_path, data))
|
||||||
ftools.remove_from_file(self.testinc_path, data)
|
ftools.remove_from_file(self.testinc_path, data)
|
||||||
|
|
||||||
|
def recipeinc(self, recipe):
|
||||||
|
"""Return absolute path of meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
||||||
|
return os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
|
||||||
|
|
||||||
def write_recipeinc(self, recipe, data):
|
def write_recipeinc(self, recipe, data):
|
||||||
"""Write to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
"""Write to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
||||||
inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
|
inc_file = self.recipeinc(recipe)
|
||||||
self.logger.debug("Writing to: %s\n%s\n" % (inc_file, data))
|
self.logger.debug("Writing to: %s\n%s\n" % (inc_file, data))
|
||||||
ftools.write_file(inc_file, data)
|
ftools.write_file(inc_file, data)
|
||||||
|
return inc_file
|
||||||
|
|
||||||
def append_recipeinc(self, recipe, data):
|
def append_recipeinc(self, recipe, data):
|
||||||
"""Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
"""Append data to meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
||||||
inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
|
inc_file = self.recipeinc(recipe)
|
||||||
self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data))
|
self.logger.debug("Appending to: %s\n%s\n" % (inc_file, data))
|
||||||
ftools.append_file(inc_file, data)
|
ftools.append_file(inc_file, data)
|
||||||
|
return inc_file
|
||||||
|
|
||||||
def remove_recipeinc(self, recipe, data):
|
def remove_recipeinc(self, recipe, data):
|
||||||
"""Remove data from meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
"""Remove data from meta-sefltest/recipes-test/<recipe>/test_recipe.inc"""
|
||||||
inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
|
inc_file = self.recipeinc(recipe)
|
||||||
self.logger.debug("Removing from: %s\n%s\n" % (inc_file, data))
|
self.logger.debug("Removing from: %s\n%s\n" % (inc_file, data))
|
||||||
ftools.remove_from_file(inc_file, data)
|
ftools.remove_from_file(inc_file, data)
|
||||||
|
|
||||||
def delete_recipeinc(self, recipe):
|
def delete_recipeinc(self, recipe):
|
||||||
"""Delete meta-sefltest/recipes-test/<recipe>/test_recipe.inc file"""
|
"""Delete meta-sefltest/recipes-test/<recipe>/test_recipe.inc file"""
|
||||||
inc_file = os.path.join(self.testlayer_path, 'recipes-test', recipe, 'test_recipe.inc')
|
inc_file = self.recipeinc(recipe)
|
||||||
self.logger.debug("Deleting file: %s" % inc_file)
|
self.logger.debug("Deleting file: %s" % inc_file)
|
||||||
try:
|
try:
|
||||||
os.remove(inc_file)
|
os.remove(inc_file)
|
||||||
@@ -259,13 +265,13 @@ to ensure accurate results.")
|
|||||||
self.logger.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data))
|
self.logger.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data))
|
||||||
ftools.write_file(self.machineinc_path, data)
|
ftools.write_file(self.machineinc_path, data)
|
||||||
|
|
||||||
# check does path exist
|
# check does path exist
|
||||||
def assertExists(self, expr, msg=None):
|
def assertExists(self, expr, msg=None):
|
||||||
if not os.path.exists(expr):
|
if not os.path.exists(expr):
|
||||||
msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr))
|
msg = self._formatMessage(msg, "%s does not exist" % safe_repr(expr))
|
||||||
raise self.failureException(msg)
|
raise self.failureException(msg)
|
||||||
|
|
||||||
# check does path not exist
|
# check does path not exist
|
||||||
def assertNotExists(self, expr, msg=None):
|
def assertNotExists(self, expr, msg=None):
|
||||||
if os.path.exists(expr):
|
if os.path.exists(expr):
|
||||||
msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))
|
msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))
|
||||||
|
|||||||
Reference in New Issue
Block a user