diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-11-29 12:07:53 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-12-01 11:38:36 +0000 |
commit | 28cbaf1de10bb6afb5986404912e0a3956863886 (patch) | |
tree | 5561eb669bec69521f4d74d8a53f5787fb97abcb | |
parent | 4482befac6d8126d7f0c046546b0b851cb11545e (diff) | |
download | poky-28cbaf1de10bb6afb5986404912e0a3956863886.tar.gz |
oeqa/selftest/context: Improve log file handling
The existing logfile is simply placed in the current directory. Since the test
changes cwd to BUILDDIR, the symlink to the log can be placed in an invalid
directory. We also see trackbacks if the symlink is invalid.
Improve things by:
* Placing logs in LOG_DIR (or BUILDDIR if unset).
* Using a full path to the log meaning the log and link are placed in the same directory.
* Using lexists instead of exists so invalid symlinks are handled correctly.
(From OE-Core rev: 750ece11bed0e62a11e0003d1d16a81f7c219761)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/context.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py index dab7268829..c521290327 100644 --- a/meta/lib/oeqa/selftest/context.py +++ b/meta/lib/oeqa/selftest/context.py | |||
@@ -101,10 +101,15 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
101 | 101 | ||
102 | def _process_args(self, logger, args): | 102 | def _process_args(self, logger, args): |
103 | args.test_start_time = time.strftime("%Y%m%d%H%M%S") | 103 | args.test_start_time = time.strftime("%Y%m%d%H%M%S") |
104 | args.output_log = '%s-results-%s.log' % (self.name, args.test_start_time) | ||
105 | args.test_data_file = None | 104 | args.test_data_file = None |
106 | args.CASES_PATHS = None | 105 | args.CASES_PATHS = None |
107 | 106 | ||
107 | bbvars = get_bb_vars() | ||
108 | logdir = os.environ.get("BUILDDIR") | ||
109 | if 'LOG_DIR' in bbvars: | ||
110 | logdir = bbvars['LOG_DIR'] | ||
111 | args.output_log = logdir + '/%s-results-%s.log' % (self.name, args.test_start_time) | ||
112 | |||
108 | super(OESelftestTestContextExecutor, self)._process_args(logger, args) | 113 | super(OESelftestTestContextExecutor, self)._process_args(logger, args) |
109 | 114 | ||
110 | if args.list_modules: | 115 | if args.list_modules: |
@@ -114,7 +119,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
114 | elif args.list_tests: | 119 | elif args.list_tests: |
115 | args.list_tests = 'name' | 120 | args.list_tests = 'name' |
116 | 121 | ||
117 | self.tc_kwargs['init']['td'] = get_bb_vars() | 122 | self.tc_kwargs['init']['td'] = bbvars |
118 | self.tc_kwargs['init']['machines'] = self._get_available_machines() | 123 | self.tc_kwargs['init']['machines'] = self._get_available_machines() |
119 | 124 | ||
120 | builddir = os.environ.get("BUILDDIR") | 125 | builddir = os.environ.get("BUILDDIR") |
@@ -304,7 +309,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
304 | 309 | ||
305 | output_link = os.path.join(os.path.dirname(args.output_log), | 310 | output_link = os.path.join(os.path.dirname(args.output_log), |
306 | "%s-results.log" % self.name) | 311 | "%s-results.log" % self.name) |
307 | if os.path.exists(output_link): | 312 | if os.path.lexists(output_link): |
308 | os.remove(output_link) | 313 | os.remove(output_link) |
309 | os.symlink(args.output_log, output_link) | 314 | os.symlink(args.output_log, output_link) |
310 | 315 | ||