Skip to content

Commit a7249ee

Browse files
committed
make etherencap test python3 compatible
1 parent bb33abd commit a7249ee

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

bessctl/conf/testing/module_tests/etherencap.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
def etherencap_crashtest():
44
encap1 = EtherEncap()
55
src = Source()
6-
metadata = SetMetadata(attrs=[{"name": "ether_src", "size": 6, "value_bin": "deadbeef1234".decode("hex")},
7-
{"name": "ether_dst", "size": 6, "value_bin": "1234deadbeef".decode("hex")},
8-
{"name" : "ether_type", "size": 2, "value_bin": "0800".decode("hex")}])
6+
metadata = SetMetadata(attrs=[{"name": "ether_src", "size": 6, "value_bin": binascii.unhexlify("deadbeef1234")},
7+
{"name": "ether_dst", "size": 6, "value_bin": binascii.unhexlify("1234deadbeef")},
8+
{"name" : "ether_type", "size": 2, "value_bin": binascii.unhexlify("0800")}])
99
rwtemp = [
1010
bytes(gen_packet(
1111
scapy.UDP,
@@ -17,7 +17,7 @@ def etherencap_crashtest():
1717
"1.2.3.4"))]
1818
src -> Rewrite(templates=rwtemp) -> metadata -> encap1 -> Sink()
1919
bess.resume_all()
20-
time.sleep(15)
20+
time.sleep(5)
2121
bess.pause_all()
2222

2323

@@ -40,15 +40,15 @@ def metadata_outputtest_fixedvalues():
4040
outdriver = PortOut(port=sockname)
4141

4242
encap2 = EtherEncap()
43-
metadata = SetMetadata(attrs=[{"name": "ether_src", "size": 6, "value_bin": "deadbeef1234".decode("hex")},
44-
{"name": "ether_dst", "size": 6, "value_bin": "1234deadbeef".decode("hex")},
45-
{"name" : "ether_type", "size": 2, "value_bin": "0800".decode("hex")}])
43+
metadata = SetMetadata(attrs=[{"name": "ether_src", "size": 6, "value_bin": binascii.unhexlify("deadbeef1234")},
44+
{"name": "ether_dst", "size": 6, "value_bin": binascii.unhexlify("1234deadbeef")},
45+
{"name" : "ether_type", "size": 2, "value_bin": binascii.unhexlify("0800")}])
4646
indriver -> metadata -> encap2 -> outdriver
4747

4848
bess.resume_all()
4949
mysocket.send(bytes(test_packet_in))
5050
return_data = mysocket.recv(2048)
5151
bess.pause_all()
52-
assert(str(return_data) == str(test_packet_out))
52+
assert(bytes(return_data) == bytes(test_packet_out))
5353

5454
CUSTOM_TEST_FUNCTIONS.append(metadata_outputtest_fixedvalues)

0 commit comments

Comments
 (0)