blob: be5b550272df1bbfa91835bce902e4e4b97da8a6 [file] [log] [blame]
Yulia Portnovab0c977c2015-12-11 19:23:28 +02001import os.path
2
3
4import texttable
5
6
7from ..itest import TwoScriptTest
8
9
10class 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 Portnova2b63d582015-12-14 15:16:52 +020017 success_vals = []
18 duration_vals = []
Yulia Portnovab0c977c2015-12-11 19:23:28 +020019 for res in data[0]:
Yulia Portnova2b63d582015-12-14 15:16:52 +020020 success, duration = res.raw_result.strip().split('\n')
21 success_vals.append(float(success))
22 duration_vals.append(float(duration))
Yulia Portnovab0c977c2015-12-11 19:23:28 +020023
Yulia Portnova2b63d582015-12-14 15:16:52 +020024 totalt = sum(duration_vals)
25 totalms = int(100 * 2 * len(duration_vals) / totalt)
26 sucesst = int(sum(success_vals) / len(success_vals))
Yulia Portnovab0c977c2015-12-11 19:23:28 +020027 tab = texttable.Texttable(max_width=120)
28 tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
Yulia Portnova2b63d582015-12-14 15:16:52 +020029 tab.header(["Bandwidth m/s", "Success %"])
30 tab.add_row([totalms, sucesst])
Yulia Portnovab0c977c2015-12-11 19:23:28 +020031 return tab.draw()