Skip to contentSkip to conversation

oeqa/runtime/cases/ptest: Make output content path absolute

PATCH In review Andrej Valek 2 participants 3 messages Jun 22, 2020

lore
Share & tools
lore
#0 lore raw

cover oeqa/runtime/cases/ptest: Make output content path absolute

Ptests could be executed on any path. So output content should be placed in workdir and not into current directory. Different path outside of the builddir should be specified by setting TEST_LOG_DIR.

Isn't it better to use "os.chidir(self.td.get('TOPDIR'))" instead?

 meta/lib/oeqa/runtime/cases/ptest.py | 4 ++++
 1 file changed, 4 insertions(+)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 oeqa/runtime/cases/ptest: Make output content path absolute

The output content is created in current directory, because json content has no defined absolute path to WORKDIR as in bitbake.

---
 meta/lib/oeqa/runtime/cases/ptest.py | 4 ++++
 1 file changed, 4 insertions(+)
meta/lib/oeqa/runtime/cases/ptest.py +4 -0
index 1b1474adcf..919901d465 100644
@@ -42,6 +42,10 @@ class PtestRunnerTest(OERuntimeTestCase):
         # testdata.json is generated.
         if not test_log_dir:
             test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage')
+        # Make the test output path absolute, otherwise the output content will be
+        # is created relative to current directory
+        if not os.path.isabs(test_log_dir):
+            test_log_dir = os.path.join(self.td.get('TOPDIR', ''), test_log_dir)
         # Don't use self.td.get('DATETIME'), it's from testdata.json, not
         # up-to-date, and may cause "File exists" when re-reun.
         timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
Signature · 1 line
2.11.0
#2 lore raw
Quoted 14 lines · Andrej Valek

The output content is created in current directory, because json content has no defined absolute path to WORKDIR as in bitbake.

---
  meta/lib/oeqa/runtime/cases/ptest.py | 4 ++++
  1 file changed, 4 insertions(+)
meta/lib/oeqa/runtime/cases/ptest.py +0 -0
index 1b1474adcf..919901d465 100644

meta/lib/oeqa/runtime/cases/ptest.py class PtestRunnerTest(OERuntimeTestCase): · line 46

Quoted 5 lines
meta/lib/oeqa/runtime/cases/ptest.py +2 -0
@@ -42,6 +42,10 @@ class PtestRunnerTest(OERuntimeTestCase):
          # testdata.json is generated.
          if not test_log_dir:
              test_log_dir = os.path.join(self.td.get('WORKDIR', ''), 'testimage')
+        # Make the test output path absolute, otherwise the output content will be
+        # is created relative to current directory

'is' is not needed in above comment.

meta/lib/oeqa/runtime/cases/ptest.py class PtestRunnerTest(OERuntimeTestCase): · line 48

Quoted 2 lines
meta/lib/oeqa/runtime/cases/ptest.py +2 -0
+        if not os.path.isabs(test_log_dir):
+            test_log_dir = os.path.join(self.td.get('TOPDIR', ''), test_log_dir)

will it expose full paths in final logs ? that may be shared publically ?

Quoted 7 lines
meta/lib/oeqa/runtime/cases/ptest.py +0 -0
          # Don't use self.td.get('DATETIME'), it's from testdata.json, not
          # up-to-date, and may cause "File exists" when re-reun.
          timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S')