summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorLucian Musat <george.l.musat@intel.com>2015-09-24 17:21:53 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-28 11:58:23 +0100
commit0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9 (patch)
tree142f761c4caf6fc97f3613b6682cef517efa17da /meta
parente3ff509091cbbfdef851f8a3c9e31c7b76d37e89 (diff)
downloadopenembedded-core-0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9.tar.gz
openembedded-core-0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9.tar.bz2
openembedded-core-0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9.zip
oeqa/decorators: Add timestamp to decorator logs.
To avoid logs being overwriten when running the automated tests multiple times, log files include timestamps in their names and a link is created to point to the latest one. Signed-off-by: Lucian Musat <george.l.musat@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/decorators.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index b6adcb1846..7116208380 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -111,6 +111,12 @@ class NoParsingFilter(logging.Filter):
def LogResults(original_class):
orig_method = original_class.run
+ from time import strftime, gmtime
+ caller = os.path.basename(sys.argv[0])
+ timestamp = strftime('%Y%m%d%H%M%S',gmtime())
+ logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
+ linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')
+
#rewrite the run method of unittest.TestCase to add testcase logging
def run(self, result, *args, **kws):
orig_method(self, result, *args, **kws)
@@ -127,14 +133,13 @@ def LogResults(original_class):
#create custom logging level for filtering.
custom_log_level = 100
logging.addLevelName(custom_log_level, 'RESULTS')
- caller = os.path.basename(sys.argv[0])
def results(self, message, *args, **kws):
if self.isEnabledFor(custom_log_level):
self.log(custom_log_level, message, *args, **kws)
logging.Logger.results = results
- logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'),
+ logging.basicConfig(filename=logfile,
filemode='w',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%H:%M:%S',
@@ -163,6 +168,14 @@ def LogResults(original_class):
local_log.results("Testcase "+str(test_case)+": PASSED")
original_class.run = run
+
+ # Create symlink to the current log
+ if os.path.islink(linkfile):
+ os.unlink(linkfile)
+ elif os.path.isfile(linkfile):
+ os.remove(linkfile)
+ os.symlink(logfile, linkfile)
+
return original_class
class TimeOut(BaseException):