summaryrefslogtreecommitdiff
path: root/test-cli/test/tests/qwifi.py
diff options
context:
space:
mode:
authorHector Fernandez <hector@iatec.biz>2020-06-17 09:44:56 +0200
committerHector Fernandez <hector@iatec.biz>2020-06-17 09:44:56 +0200
commit09b3bb38fc7305c9b47c29bc90ebc9c636827307 (patch)
treea793c8f232031183960178d2a18fcde4baf3348f /test-cli/test/tests/qwifi.py
parent0dd2613b88d937e71b274d68924088b1bad65de4 (diff)
downloadboard-09b3bb38fc7305c9b47c29bc90ebc9c636827307.zip
board-09b3bb38fc7305c9b47c29bc90ebc9c636827307.tar.gz
board-09b3bb38fc7305c9b47c29bc90ebc9c636827307.tar.bz2
SOPA0000: Added support for saving results (strings or files) in the DB. It also saves a final DMESG file.
Diffstat (limited to 'test-cli/test/tests/qwifi.py')
-rw-r--r--test-cli/test/tests/qwifi.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/test-cli/test/tests/qwifi.py b/test-cli/test/tests/qwifi.py
index 684cb34..0944dd7 100644
--- a/test-cli/test/tests/qwifi.py
+++ b/test-cli/test/tests/qwifi.py
@@ -1,6 +1,7 @@
import unittest
import sh
import re
+import json
class Qwifi(unittest.TestCase):
@@ -9,6 +10,7 @@ class Qwifi(unittest.TestCase):
__bwexpected = None
__port = None
params = None
+ __bwreal = None
# varlist content: serverip, bwexpected, port
def __init__(self, testname, testfunc, varlist):
@@ -46,8 +48,8 @@ class Qwifi(unittest.TestCase):
if result:
# execute iperf command against the server
try:
- p = sh.iperf("-c", self.__serverip, "-x", "CMSV", "-n", self.__numbytestx, "-f", "m", "-p",
- self.__port, _timeout=20)
+ p = sh.iperf3("-c", self.__serverip, "-n", self.__numbytestx, "-f", "m", "-p", self.__port,
+ "-J", _timeout=20)
except sh.TimeoutException:
self.fail("failed: iperf timeout reached")
@@ -56,18 +58,15 @@ class Qwifi(unittest.TestCase):
if p.stdout == "":
self.fail("failed: error executing iperf command")
# analyze output string
- # split by lines
- lines = p.stdout.splitlines()
- # get first line
- dat = lines[1].decode('ascii')
- # search for the BW value
- a = re.search("\d+(\.\d)? Mbits/sec", dat)
- b = a.group().split()
- bwreal = b[0]
+ data = json.loads(p.stdout.decode('ascii'))
+ self.__bwreal = float(data['end']['sum_received']['bits_per_second']) / 1024 / 1024
+ # save result file
+ with open('/tmp/wifi-iperf.json', 'w') as outfile:
+ json.dump(data, outfile)
# check if BW is in the expected range
- self.failUnless(float(bwreal) > float(self.__bwexpected) * 0.9,
- "failed: speed is lower than spected. Speed(MB/s)" + str(bwreal))
+ self.failUnless(self.__bwreal > float(self.__bwexpected) * 0.9,
+ "failed: speed is lower than spected. Speed(Mbits/s)" + str(self.__bwreal))
else:
self.fail("failed: could not complete iperf command")
else:
@@ -78,3 +77,14 @@ class Qwifi(unittest.TestCase):
self.fail("failed: wifi module is not connected to the router.")
else:
self.fail("failed: couldn't execute iw command")
+
+ def getresults(self):
+ # resultlist is a python list of python dictionaries
+ resultlist = [
+ {
+ "desc": "iperf3 output",
+ "data": "/tmp/wifi-iperf.json",
+ "type": "file"
+ }
+ ]
+ return resultlist