test-network: check port range and ipproto attributes are supported by kernel and ip command

This commit is contained in:
Yu Watanabe 2019-02-06 09:27:28 +01:00
parent 6d6308f677
commit d586a2c30c
1 changed files with 24 additions and 0 deletions

View File

@ -47,6 +47,28 @@ def expectedFailureIfERSPANModuleIsNotAvailable():
return f
def expectedFailureIfRoutingPolicyPortRangeIsNotAvailable():
def f(func):
rc = subprocess.call(['ip', 'rule', 'add', 'from', '192.168.100.19', 'sport', '1123-1150', 'dport', '3224-3290', 'table', '7'])
if rc == 0:
subprocess.call(['ip', 'rule', 'del', 'from', '192.168.100.19', 'sport', '1123-1150', 'dport', '3224-3290', 'table', '7'])
return func
else:
return unittest.expectedFailure(func)
return f
def expectedFailureIfRoutingPolicyIPProtoIsNotAvailable():
def f(func):
rc = subprocess.call(['ip', 'rule', 'add', 'not', 'from', '192.168.100.19', 'ipproto', 'tcp', 'table', '7'])
if rc == 0:
subprocess.call(['ip', 'rule', 'del', 'not', 'from', '192.168.100.19', 'ipproto', 'tcp', 'table', '7'])
return func
else:
return unittest.expectedFailure(func)
return f
def setUpModule():
os.makedirs(network_unit_file_path, exist_ok=True)
@ -653,6 +675,7 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities):
subprocess.call(['ip', 'rule', 'del', 'table', '7'])
@expectedFailureIfRoutingPolicyPortRangeIsNotAvailable()
def test_routing_policy_rule_port_range(self):
self.copy_unit_to_networkd_unit_path('25-fibrule-port-range.network', '11-dummy.netdev')
self.start_networkd()
@ -670,6 +693,7 @@ class NetworkdNetWorkTests(unittest.TestCase, Utilities):
subprocess.call(['ip', 'rule', 'del', 'table', '7'])
@expectedFailureIfRoutingPolicyIPProtoIsNotAvailable()
def test_routing_policy_rule_invert(self):
self.copy_unit_to_networkd_unit_path('25-fibrule-invert.network', '11-dummy.netdev')
self.start_networkd()