1 ##########################################################################
2 # Copyright (c) 2017, ETH Zurich.
5 # This file is distributed under the terms in the attached LICENSE file.
6 # If you do not find this file, copies can be found by writing to:
7 # ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
8 ##########################################################################
15 from common import TestCommon, TimeoutError
16 from results import RowResults, PassFailResult
18 TEST_TIMEOUT = datetime.timedelta(minutes=8)
20 class DevifTests(TestCommon):
22 def __init__(self, options):
23 super(DevifTests, self).__init__(options)
25 def get_module_name(self):
28 def boot(self, *args):
29 super(DevifTests, self).boot(*args)
30 self.set_timeout(TEST_TIMEOUT)
33 def get_modules(self, build, machine):
34 self.machine = machine.name
35 modules = super(DevifTests, self).get_modules(build, machine)
36 modules.add_module("e10k", ["auto", "function=0"])
37 modules.add_module("sfn5122f", ["auto", "function=0"])
38 modules.add_module("devif_idc", ["core=1"])
40 f = os.popen('ifconfig eno2 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
42 packedIP = socket.inet_aton(ip_string)
43 src_ip = struct.unpack("!L", packedIP)[0]
45 if self.CARD == "sfn5122f":
46 dst_string = subprocess.check_output('nslookup %s-sf.in.barrelfish.org | grep Address | sed -n 2p | awk -F\" \" \'{print $NF}\'' % machine.name, shell=True)
48 dst_string = subprocess.check_output('nslookup %s-e10k.in.barrelfish.org | grep Address | sed -n 2p | awk -F\" \" \'{print $NF}\'' % machine.name, shell=True)
50 packedIP = socket.inet_aton(dst_string)
51 dst_ip = struct.unpack("!L", packedIP)[0]
53 modules.add_module(self.get_module_name(), ["core=2", self.OP, src_ip, dst_ip, self.CARD])
56 def get_finish_string(self):
59 def process_line(self, line):
60 m = re.match(r'# IP Addr (\d+\.\d+\.\d+\.\d+)', line)
62 self.loop = subprocess.Popen('while :; do echo -n "Data Data Data" | nc -4u -q1 %s 7; done' % m.group(1), shell=True)
65 def process_data(self, testdir, rawiter):
67 if not (self.loop is None):
72 return PassFailResult(True)
74 return PassFailResult(False)
78 class DevifNetTxSF(DevifTests):
79 ''' Devif Net TX Test'''
80 name = "devif_nettx_sf"
85 class DevifNetTxE10k(DevifTests):
86 ''' Devif Net TX Test'''
87 name = "devif_nettx_e10k"
92 class DevifNetRxSF(DevifTests):
93 ''' Devif Net RX Test'''
94 name = "devif_netrx_sf"
99 class DevifNetRxE10k(DevifTests):
100 ''' Devif Net RX Test'''
101 name = "devif_netrx_e10k"
104 f = os.popen('ifconfig eno2 | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1')
106 packedIP = socket.inet_aton(ip_string)
107 src_ip = struct.unpack("!L", packedIP)[0]
110 class DevifIdcTest(DevifTests):
111 ''' Devif IDC Test'''
112 name = "devif_idc_test"
118 class DevifDebug(DevifTests):
119 ''' Devif Debug Backend Test'''
122 def get_modules(self, build, machine):
123 self.machine = machine.name
124 modules = super(DevifTests, self).get_modules(build, machine)
125 modules.add_module("devif_idc", ["core=1"])
126 modules.add_module("devif_debug_test")
130 def process_data(self, testdir, rawiter):
132 if "SUCCESS" in line:
133 return PassFailResult(True)
135 return PassFailResult(False)