X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=blobdiff_plain;f=test%2Ftest_punt.py;h=74dc923365c45d361ad5a960ff634bf67a39e185;hp=e265dc01f9b195120383939018c4854048a04dd8;hb=8feeaff56;hpb=a7427ec6f86cbeba7594f98e41fecab291d66b73 diff --git a/test/test_punt.py b/test/test_punt.py index e265dc01f9b..74dc923365c 100644 --- a/test/test_punt.py +++ b/test/test_punt.py @@ -2,20 +2,25 @@ import binascii import random import socket -import unittest import os -import scapy.layers.inet6 as inet6 import threading import struct - from struct import unpack, unpack_from + +try: + import unittest2 as unittest +except ImportError: + import unittest + from util import ppp, ppc from re import compile import scapy.compat from scapy.packet import Raw from scapy.layers.l2 import Ether from scapy.layers.inet import IP, UDP, ICMP +import scapy.layers.inet6 as inet6 from scapy.layers.inet6 import IPv6, ICMPv6DestUnreach +import six from framework import VppTestCase, VppTestRunner @@ -189,8 +194,10 @@ class TestIP4PuntSocket(TestPuntSocket): # # configure a punt socket # - self.vapi.punt_socket_register(1111, self.tempdir+"/socket_punt_1111") - self.vapi.punt_socket_register(2222, self.tempdir+"/socket_punt_2222") + self.vapi.punt_socket_register(1111, b"%s/socket_punt_1111" % + six.ensure_binary(self.tempdir)) + self.vapi.punt_socket_register(2222, b"%s/socket_punt_2222" % + six.ensure_binary(self.tempdir)) punts = self.vapi.punt_socket_dump(is_ip6=0) self.assertEqual(len(punts), 2) self.assertEqual(punts[0].punt.l4_port, 1111) @@ -206,8 +213,10 @@ class TestIP4PuntSocket(TestPuntSocket): # # configure a punt socket again # - self.vapi.punt_socket_register(1111, self.tempdir+"/socket_punt_1111") - self.vapi.punt_socket_register(3333, self.tempdir+"/socket_punt_3333") + self.vapi.punt_socket_register(1111, b"%s/socket_punt_1111" % + six.ensure_binary(self.tempdir)) + self.vapi.punt_socket_register(3333, b"%s/socket_punt_3333" % + six.ensure_binary(self.tempdir)) punts = self.vapi.punt_socket_dump(is_ip6=0) self.assertEqual(len(punts), 3) @@ -253,9 +262,10 @@ class TestIP4PuntSocket(TestPuntSocket): # # configure a punt socket # - self.socket_client_create(self.tempdir+"/socket_" + str(port)) - self.vapi.punt_socket_register(port, self.tempdir+"/socket_" + - str(port)) + self.socket_client_create(b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), port)) + self.vapi.punt_socket_register(port, b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), port)) punts = self.vapi.punt_socket_dump(is_ip6=0) self.assertEqual(len(punts), 1) @@ -293,7 +303,7 @@ class TestIP4PuntSocket(TestPuntSocket): self.portsCheck[p] = 0 # - # create stream with random pakets count per given ports + # create stream with random packets count per given ports # pkts = list() for _ in range(0, self.nr_packets): @@ -316,8 +326,10 @@ class TestIP4PuntSocket(TestPuntSocket): # configure a punt socket # for p in self.ports: - self.socket_client_create(self.tempdir+"/socket_" + str(p)) - self.vapi.punt_socket_register(p, self.tempdir+"/socket_" + str(p)) + self.socket_client_create(b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), p)) + self.vapi.punt_socket_register(p, b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), p)) punts = self.vapi.punt_socket_dump(is_ip6=0) self.assertEqual(len(punts), len(self.ports)) @@ -350,7 +362,7 @@ class TestIP4PuntSocket(TestPuntSocket): self.portsCheck[p] = 0 # - # create stream with random pakets count per given ports + # create stream with random packets count per given ports # pkts = list() for _ in range(0, self.nr_packets): @@ -372,9 +384,12 @@ class TestIP4PuntSocket(TestPuntSocket): # configure a punt socket # - self.socket_client_create(self.tempdir+"/socket_multi") + self.socket_client_create(b"%s/socket_multi" % + six.ensure_binary(self.tempdir)) for p in self.ports: - self.vapi.punt_socket_register(p, self.tempdir+"/socket_multi") + self.vapi.punt_socket_register(p, + b"%s/socket_multi" % + six.ensure_binary(self.tempdir)) punts = self.vapi.punt_socket_dump(is_ip6=0) self.assertEqual(len(punts), len(self.ports)) @@ -433,9 +448,11 @@ class TestIP6PuntSocket(TestPuntSocket): # # configure a punt socket # - self.vapi.punt_socket_register(1111, self.tempdir+"/socket_1111", + self.vapi.punt_socket_register(1111, b"%s/socket_1111" % + six.ensure_binary(self.tempdir), is_ip4=0) - self.vapi.punt_socket_register(2222, self.tempdir+"/socket_2222", + self.vapi.punt_socket_register(2222, b"%s/socket_2222" % + six.ensure_binary(self.tempdir), is_ip4=0) punts = self.vapi.punt_socket_dump(is_ip6=1) self.assertEqual(len(punts), 2) @@ -452,7 +469,8 @@ class TestIP6PuntSocket(TestPuntSocket): # # configure a punt socket again # - self.vapi.punt_socket_register(1111, self.tempdir+"/socket_1111", + self.vapi.punt_socket_register(1111, b"%s/socket_1111" % + six.ensure_binary(self.tempdir), is_ip4=0) punts = self.vapi.punt_socket_dump(is_ip6=1) self.assertEqual(len(punts), 2) @@ -499,9 +517,10 @@ class TestIP6PuntSocket(TestPuntSocket): # # configure a punt socket # - self.socket_client_create(self.tempdir+"/socket_" + str(port)) - self.vapi.punt_socket_register(port, self.tempdir+"/socket_" + - str(port), is_ip4=0) + self.socket_client_create(b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), port)) + self.vapi.punt_socket_register(port, b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), port), is_ip4=0) punts = self.vapi.punt_socket_dump(is_ip6=1) self.assertEqual(len(punts), 1) @@ -539,7 +558,7 @@ class TestIP6PuntSocket(TestPuntSocket): self.portsCheck[p] = 0 # - # create stream with random pakets count per given ports + # create stream with random packets count per given ports # pkts = list() for _ in range(0, self.nr_packets): @@ -562,9 +581,10 @@ class TestIP6PuntSocket(TestPuntSocket): # configure a punt socket # for p in self.ports: - self.socket_client_create(self.tempdir+"/socket_" + str(p)) - self.vapi.punt_socket_register(p, self.tempdir+"/socket_" + str(p), - is_ip4=0) + self.socket_client_create(b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), p)) + self.vapi.punt_socket_register(p, b"%s/socket_%d" % ( + six.ensure_binary(self.tempdir), p), is_ip4=0) punts = self.vapi.punt_socket_dump(is_ip6=1) self.assertEqual(len(punts), len(self.ports)) @@ -597,7 +617,7 @@ class TestIP6PuntSocket(TestPuntSocket): self.portsCheck[p] = 0 # - # create stream with random pakets count per given ports + # create stream with random packets count per given ports # pkts = list() for _ in range(0, self.nr_packets): @@ -620,9 +640,12 @@ class TestIP6PuntSocket(TestPuntSocket): # # configure a punt socket # - self.socket_client_create(self.tempdir+"/socket_multi") + self.socket_client_create(b"%s/socket_multi" % + six.ensure_binary(self.tempdir)) for p in self.ports: - self.vapi.punt_socket_register(p, self.tempdir+"/socket_multi", + self.vapi.punt_socket_register(p, + b"%s/socket_multi" % + six.ensure_binary(self.tempdir), is_ip4=0) punts = self.vapi.punt_socket_dump(is_ip6=1) self.assertEqual(len(punts), len(self.ports))