Change in osmo-gsm-tester[master]: Add test log to junit output

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Feb 24 19:38:02 UTC 2020


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17252 )


Change subject: Add test log to junit output
......................................................................

Add test log to junit output

Change-Id: Ieb5566a41ecf3a9512db579eb37e8d8ed5325057
---
M src/osmo_gsm_tester/log.py
M src/osmo_gsm_tester/report.py
M src/osmo_gsm_tester/test.py
3 files changed, 16 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/52/17252/1

diff --git a/src/osmo_gsm_tester/log.py b/src/osmo_gsm_tester/log.py
index 7c4ae44..d60bf0b 100644
--- a/src/osmo_gsm_tester/log.py
+++ b/src/osmo_gsm_tester/log.py
@@ -574,6 +574,9 @@
             self.log_file.flush()
             self.log_file.close()
 
+    def log_file_path(self):
+        return self.path
+
 def run_logging_exceptions(func, *func_args, return_on_failure=None, **func_kwargs):
     try:
         return func(*func_args, **func_kwargs)
diff --git a/src/osmo_gsm_tester/report.py b/src/osmo_gsm_tester/report.py
index 4919937..6ee3464 100644
--- a/src/osmo_gsm_tester/report.py
+++ b/src/osmo_gsm_tester/report.py
@@ -20,6 +20,7 @@
 import math
 from datetime import datetime
 import xml.etree.ElementTree as et
+from xml.sax.saxutils import escape
 from . import test
 
 def trial_to_junit_write(trial, junit_path):
@@ -63,6 +64,13 @@
     elif t.status != test.Test.PASS:
         error = et.SubElement(testcase, 'error')
         error.text = 'could not run'
+    sout = et.SubElement(testcase, 'system-out')
+    log_file = t.log_file_path()
+    if log_file is not None:
+        with open(log_file, 'r') as myfile:
+            sout.text = escape(myfile.read())
+    else:
+        sout.text = 'test log file not available'
     return testcase
 
 def trial_to_text(trial):
diff --git a/src/osmo_gsm_tester/test.py b/src/osmo_gsm_tester/test.py
index 4d4353a..66e8656 100644
--- a/src/osmo_gsm_tester/test.py
+++ b/src/osmo_gsm_tester/test.py
@@ -86,7 +86,6 @@
         finally:
             if self.log_target:
                 self.log_target.remove()
-                self.log_target = None
 
     def name(self):
         l = log.get_line_for_src(self.path)
@@ -119,4 +118,9 @@
         self.status = Test.SKIP
         self.duration = 0
 
+    def log_file_path(self):
+        if self.log_target is None:
+            return None
+        return self.log_target.log_file_path()
+
 # vim: expandtab tabstop=4 shiftwidth=4

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17252
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Change-Id: Ieb5566a41ecf3a9512db579eb37e8d8ed5325057
Gerrit-Change-Number: 17252
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200224/7e2969bd/attachment.htm>


More information about the gerrit-log mailing list