Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 1 | import os.path |
| 2 | |
| 3 | |
| 4 | import texttable |
| 5 | |
| 6 | |
| 7 | from ..itest import TwoScriptTest |
| 8 | |
| 9 | |
| 10 | class OmgTest(TwoScriptTest): |
| 11 | root = os.path.dirname(__file__) |
| 12 | pre_run_script = os.path.join(root, "prepare.sh") |
| 13 | run_script = os.path.join(root, "run.sh") |
| 14 | |
| 15 | @classmethod |
| 16 | def format_for_console(cls, data): |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame^] | 17 | success_vals = [] |
| 18 | duration_vals = [] |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 19 | for res in data[0]: |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame^] | 20 | success, duration = res.raw_result.strip().split('\n') |
| 21 | success_vals.append(float(success)) |
| 22 | duration_vals.append(float(duration)) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 23 | |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame^] | 24 | totalt = sum(duration_vals) |
| 25 | totalms = int(100 * 2 * len(duration_vals) / totalt) |
| 26 | sucesst = int(sum(success_vals) / len(success_vals)) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 27 | tab = texttable.Texttable(max_width=120) |
| 28 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER) |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame^] | 29 | tab.header(["Bandwidth m/s", "Success %"]) |
| 30 | tab.add_row([totalms, sucesst]) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 31 | return tab.draw() |