From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Cc: joshuagloe@gmail.com
Subject: [PATCH] oeqa/utils/decorators: LogResults fix race condition in linkfile
Date: Tue, 13 Sep 2016 15:25:42 -0500 [thread overview]
Message-ID: <1473798342-12583-1-git-send-email-anibal.limon@linux.intel.com> (raw)
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@linux.intel.com>
---
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
--
2.1.4
reply other threads:[~2016-09-13 20:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473798342-12583-1-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=joshuagloe@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox