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.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17359 ) Change subject: Allow overwriting test's report stdout text from inside test code ...................................................................... Allow overwriting test's report stdout text from inside test code Change-Id: Ie1c0ecf7464209a4241665025fda33ae624fc049 --- M src/osmo_gsm_tester/report.py M src/osmo_gsm_tester/test.py M suites/4g/iperf3_dl.py M suites/4g/iperf3_ul.py 4 files changed, 20 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/59/17359/1 diff --git a/src/osmo_gsm_tester/report.py b/src/osmo_gsm_tester/report.py index 8718d0e..5d23c38 100644 --- a/src/osmo_gsm_tester/report.py +++ b/src/osmo_gsm_tester/report.py @@ -86,12 +86,7 @@ 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_xml_invalid_characters(myfile.read()) - else: - sout.text = 'test log file not available' + sout.text = escape_xml_invalid_characters(t.report_stdout()) return testcase def trial_to_text(trial): diff --git a/src/osmo_gsm_tester/test.py b/src/osmo_gsm_tester/test.py index 66e8656..be6e8da 100644 --- a/src/osmo_gsm_tester/test.py +++ b/src/osmo_gsm_tester/test.py @@ -43,6 +43,7 @@ self.fail_type = None self.fail_message = None self.log_target = None + self._report_stdout = None def get_run_dir(self): if self._run_dir is None: @@ -118,9 +119,19 @@ 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() + def set_report_stdout(self, text): + 'Overwrite stdout text stored in report from inside a test' + self._report_stdout = text + + def report_stdout(self): + # If test overwrote the text, provide it: + if self._report_stdout is not None: + return self._report_stdout + # Otherwise vy default provide the entire test log: + if self.log_target is not None and self.log_target.log_file_path() is not None: + with open(self.log_target.log_file_path(), 'r') as myfile: + return myfile.read() + else: + return 'test log file not available' # vim: expandtab tabstop=4 shiftwidth=4 diff --git a/suites/4g/iperf3_dl.py b/suites/4g/iperf3_dl.py index fd77cd3..c98251b 100755 --- a/suites/4g/iperf3_dl.py +++ b/suites/4g/iperf3_dl.py @@ -45,4 +45,5 @@ max_rate = enb.ue_max_rate(downlink=True) res_str = ue.verify_metric(max_rate * 0.9, operation='avg', metric='dl_brate', criterion='gt') -print(res_str + '\n') +print(res_str) +test.set_report_stdout(res_str) diff --git a/suites/4g/iperf3_ul.py b/suites/4g/iperf3_ul.py index 20489b5..fe963a9 100755 --- a/suites/4g/iperf3_ul.py +++ b/suites/4g/iperf3_ul.py @@ -45,4 +45,5 @@ max_rate = enb.ue_max_rate(downlink=False) res_str = ue.verify_metric(max_rate * 0.9, operation='avg', metric='ul_brate', criterion='gt') -print(res_str + '\n') +print(res_str) +test.set_report_stdout(res_str) -- To view, visit https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17359 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: Ie1c0ecf7464209a4241665025fda33ae624fc049 Gerrit-Change-Number: 17359 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/20200304/6ab57287/attachment.htm>