summaryrefslogtreecommitdiffstats
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 12:00:22 +0100
commit3fb464f6af2ab7c8510996a675e45749a4f985b5 (patch)
tree8b8a0c509cba70844dba1d10dc341508c674386d
parent5f371e5a0b1039c2b16842c053ee6df6551f59b6 (diff)
downloadpoky-3fb464f6af2ab7c8510996a675e45749a4f985b5.tar.gz
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. (From OE-Core rev: 0aa6af4aec6f9773ec2aea929deb3a1ed049cbb9) Signed-off-by: Lucian Musat <george.l.musat@intel.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/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):
111def LogResults(original_class): 111def LogResults(original_class):
112 orig_method = original_class.run 112 orig_method = original_class.run
113 113
114 from time import strftime, gmtime
115 caller = os.path.basename(sys.argv[0])
116 timestamp = strftime('%Y%m%d%H%M%S',gmtime())
117 logfile = os.path.join(os.getcwd(),'results-'+caller+'.'+timestamp+'.log')
118 linkfile = os.path.join(os.getcwd(),'results-'+caller+'.log')
119
114 #rewrite the run method of unittest.TestCase to add testcase logging 120 #rewrite the run method of unittest.TestCase to add testcase logging
115 def run(self, result, *args, **kws): 121 def run(self, result, *args, **kws):
116 orig_method(self, result, *args, **kws) 122 orig_method(self, result, *args, **kws)
@@ -127,14 +133,13 @@ def LogResults(original_class):
127 #create custom logging level for filtering. 133 #create custom logging level for filtering.
128 custom_log_level = 100 134 custom_log_level = 100
129 logging.addLevelName(custom_log_level, 'RESULTS') 135 logging.addLevelName(custom_log_level, 'RESULTS')
130 caller = os.path.basename(sys.argv[0])
131 136
132 def results(self, message, *args, **kws): 137 def results(self, message, *args, **kws):
133 if self.isEnabledFor(custom_log_level): 138 if self.isEnabledFor(custom_log_level):
134 self.log(custom_log_level, message, *args, **kws) 139 self.log(custom_log_level, message, *args, **kws)
135 logging.Logger.results = results 140 logging.Logger.results = results
136 141
137 logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'), 142 logging.basicConfig(filename=logfile,
138 filemode='w', 143 filemode='w',
139 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', 144 format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
140 datefmt='%H:%M:%S', 145 datefmt='%H:%M:%S',
@@ -163,6 +168,14 @@ def LogResults(original_class):
163 local_log.results("Testcase "+str(test_case)+": PASSED") 168 local_log.results("Testcase "+str(test_case)+": PASSED")
164 169
165 original_class.run = run 170 original_class.run = run
171
172 # Create symlink to the current log
173 if os.path.islink(linkfile):
174 os.unlink(linkfile)
175 elif os.path.isfile(linkfile):
176 os.remove(linkfile)
177 os.symlink(logfile, linkfile)
178
166 return original_class 179 return original_class
167 180
168class TimeOut(BaseException): 181class TimeOut(BaseException):