summaryrefslogtreecommitdiffstats
path: root/tests/topotests/tc_basic
diff options
context:
space:
mode:
Diffstat (limited to 'tests/topotests/tc_basic')
-rwxr-xr-xtests/topotests/tc_basic/test_tc_basic.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/topotests/tc_basic/test_tc_basic.py b/tests/topotests/tc_basic/test_tc_basic.py
index f64e83c..822d201 100755
--- a/tests/topotests/tc_basic/test_tc_basic.py
+++ b/tests/topotests/tc_basic/test_tc_basic.py
@@ -22,9 +22,8 @@ sys.path.append(os.path.join(CWD, "../lib/"))
from lib.topogen import Topogen, TopoRouter
from lib.topolog import logger
-pytestmark = [
- pytest.mark.sharpd
-]
+pytestmark = [pytest.mark.sharpd]
+
def build_topo(tgen):
"Build function"
@@ -42,6 +41,7 @@ def build_topo(tgen):
switch = tgen.add_switch("s2")
switch.add_link(r2)
+
# New form of setup/teardown using pytest fixture
@pytest.fixture(scope="module")
def tgen(request):
@@ -79,22 +79,28 @@ def skip_on_failure(tgen):
if tgen.routers_have_failure():
pytest.skip("skipped because of previous test failure")
+
def fetch_iproute2_tc_info(r, interface):
qdisc = r.cmd("tc qdisc show dev %s" % interface)
tclass = r.cmd("tc class show dev %s" % interface)
tfilter = r.cmd("tc filter show dev %s" % interface)
return qdisc, tclass, tfilter
+
# ===================
# The tests functions
# ===================
+
def test_tc_basic(tgen):
"Test installing one pair of filter & class by sharpd"
r1 = tgen.gears["r1"]
intf = "r1-eth0"
- r1.vtysh_cmd("sharp tc dev %s source 192.168.100.0/24 destination 192.168.101.0/24 ip-protocol tcp src-port 8000 dst-port 8001 rate 20mbit" % intf)
+ r1.vtysh_cmd(
+ "sharp tc dev %s source 192.168.100.0/24 destination 192.168.101.0/24 ip-protocol tcp src-port 8000 dst-port 8001 rate 20mbit"
+ % intf
+ )
time.sleep(3)
@@ -115,6 +121,7 @@ def test_tc_basic(tgen):
assert "dst_port 8001" in tfilter
assert "src_port 8000" in tfilter
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
- sys.exit(pytest.main(args)) \ No newline at end of file
+ sys.exit(pytest.main(args))