blob: 31aff8f501bbf80a7ae06bc123245e3a9ba733d6 [file] [log] [blame]
"""Tests for report."""
import os
import report
from wvtest import *
@wvtest
def LoadExternalData():
print
report.LoadNRates()
WVPASS(report.nrates)
idx = (0, 20, 800)
print 'Testing MCS rate in file', idx
WVPASSEQ(report.nrates[idx], 6.5 )
idx = (25, 40, 400)
print 'Testing computed MCS rate', idx
WVPASSEQ(report.nrates[idx], 120 )
print
report.LoadChannels()
WVPASS(report.channels)
ch = 5
print 'Testing 2.4GHz channel', ch
WVPASSEQ(report.channels[ch], 2432)
ch = 149
print 'Testing 5GHz channel', ch
WVPASSEQ(report.channels[ch], 5745)
@wvtest
def TVBoxReport():
rpt = 'testdata/wifi-1424739295.41-0010'
print 'Checking IP address'
with open(os.path.join(rpt, 'ipaddr')) as ip:
addrmap = report.ParseIpAddr(ip.read())
WVPASSEQ(addrmap.get('lo'), '127.0.0.1/32')
WVPASSEQ(addrmap.get('wcli0'), '192.168.1.222/24')
print 'Checking for link information'
with open(os.path.join(rpt, 'iwlink')) as iw:
data = report.ParseIwLink(iw.read())
WVPASSEQ(data.get('SSID'), 'GSAFNS1441P0208_TestWifi')
WVPASSEQ(data.get('BSSID'), 'f4:f5:e8:80:f3:d0')
steps, rssi, _, _, _, _, _, tcperf, udperf = report.ReportLine(rpt)
print ('Checking report. Implemented measures: steps, rssi, TCP performance, '
'UDP performance')
WVPASSEQ(steps, 10)
WVPASSEQ(rssi, -39)
WVPASSEQ(tcperf, 92.1)
WVPASSEQ(udperf, 91.2)
@wvtest
def MacbookReport():
rpt = 'testdata/wifi-1424744066.47-0010'
print ('Checking report. Implemented measures: steps, rssi, noise, devices '
'on channel, off channel, MCS, PHY rate, TCP performance, UDP '
'performance.')
(steps, rssi, noise, shared, conflict,
mcs, phy, tcperf, udperf) = report.ReportLine(rpt)
WVPASSEQ(steps, 10)
WVPASSEQ(rssi, -29)
WVPASSEQ(noise, -90)
WVPASSEQ(shared, 16)
WVPASSEQ(conflict, 10)
WVPASSEQ(mcs, 21)
WVPASS(abs(phy - 340.9) < 0.1)
WVPASSEQ(tcperf, 196.0)
WVPASSEQ(udperf, 260.0)