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 | c7d52b5 | 2015-12-15 15:16:34 +0200 | [diff] [blame] | 19 | count = 0 |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 20 | for res in data[0]: |
Yulia Portnova | 043fa79 | 2015-12-15 17:12:24 +0200 | [diff] [blame] | 21 | msgs, success, duration = res.raw_result.strip().split('\n') |
Yulia Portnova | 2be79a9 | 2015-12-22 12:46:10 +0200 | [diff] [blame] | 22 | count += int(msgs) |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame] | 23 | success_vals.append(float(success)) |
| 24 | duration_vals.append(float(duration)) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 25 | |
Yulia Portnova | 043fa79 | 2015-12-15 17:12:24 +0200 | [diff] [blame] | 26 | totalt = max(duration_vals) |
Yulia Portnova | c7d52b5 | 2015-12-15 15:16:34 +0200 | [diff] [blame] | 27 | totalms = int(count / totalt) |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame] | 28 | sucesst = int(sum(success_vals) / len(success_vals)) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 29 | tab = texttable.Texttable(max_width=120) |
| 30 | tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER) |
Yulia Portnova | 2b63d58 | 2015-12-14 15:16:52 +0200 | [diff] [blame] | 31 | tab.header(["Bandwidth m/s", "Success %"]) |
| 32 | tab.add_row([totalms, sucesst]) |
Yulia Portnova | b0c977c | 2015-12-11 19:23:28 +0200 | [diff] [blame] | 33 | return tab.draw() |