blob: 10b84f16ee11d848fe8ed1bc18be193a20ca493c [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 Portnovac7d52b52015-12-15 15:16:34 +020019 count = 0
Yulia Portnovab0c977c2015-12-11 19:23:28 +020020 for res in data[0]:
Yulia Portnova043fa792015-12-15 17:12:24 +020021 msgs, success, duration = res.raw_result.strip().split('\n')
Yulia Portnova2be79a92015-12-22 12:46:10 +020022 count += int(msgs)
Yulia Portnova2b63d582015-12-14 15:16:52 +020023 success_vals.append(float(success))
24 duration_vals.append(float(duration))
Yulia Portnovab0c977c2015-12-11 19:23:28 +020025
Yulia Portnova043fa792015-12-15 17:12:24 +020026 totalt = max(duration_vals)
Yulia Portnovac7d52b52015-12-15 15:16:34 +020027 totalms = int(count / totalt)
Yulia Portnova2b63d582015-12-14 15:16:52 +020028 sucesst = int(sum(success_vals) / len(success_vals))
Yulia Portnovab0c977c2015-12-11 19:23:28 +020029 tab = texttable.Texttable(max_width=120)
30 tab.set_deco(tab.HEADER | tab.VLINES | tab.BORDER)
Yulia Portnova2b63d582015-12-14 15:16:52 +020031 tab.header(["Bandwidth m/s", "Success %"])
32 tab.add_row([totalms, sucesst])
Yulia Portnovab0c977c2015-12-11 19:23:28 +020033 return tab.draw()