[oe-commits] [openembedded-core] 11/11: oeqa/utils/decorators: LogResults fix race condition in linkfile
git at git.openembedded.org
git at git.openembedded.org
Wed Sep 14 21:42:51 UTC 2016
rpurdie pushed a commit to branch master-next
in repository openembedded-core.
commit ec1aeca2f3c65ccc35b467fd460e3be74ef3de28
Author: Aníbal Limón <anibal.limon at linux.intel.com>
AuthorDate: Tue Sep 13 15:25:42 2016 -0500
oeqa/utils/decorators: LogResults fix race condition in linkfile
In order to avoid race condition when test if exists the linkfile
use bb.utils.lock, the best solution is to create a unique name
for the link file.
There is no way to create a unique linkfile name at this decorator
because is needed the machine and image variables, those variables
can't be passed easily in this code.
To avoid broke test export functionality use a try/except because bb
isn't available when use test export
[YOCTO #10225]
Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
meta/lib/oeqa/utils/decorators.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 615fd95..25f9c54 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -189,10 +189,24 @@ def LogResults(original_class):
if passed:
local_log.results("Testcase "+str(test_case)+": PASSED")
+ # XXX: In order to avoid race condition when test if exists the linkfile
+ # use bb.utils.lock, the best solution is to create a unique name for the
+ # link file.
+ try:
+ import bb
+ has_bb = True
+ lockfilename = linkfile + '.lock'
+ except ImportError:
+ has_bb = False
+
+ if has_bb:
+ lf = bb.utils.lockfile(lockfilename, block=True)
# Create symlink to the current log
if os.path.lexists(linkfile):
os.remove(linkfile)
os.symlink(logfile, linkfile)
+ if has_bb:
+ bb.utils.unlockfile(lf)
original_class.run = run
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Openembedded-commits
mailing list