diff options
author | 2017-02-06 21:16:27 +0200 | |
---|---|---|
committer | 2017-02-06 21:16:27 +0200 | |
commit | df1e9dba223530013f851287a3a3a85abd076727 (patch) | |
tree | 3287b2623908a065313cb77cd2902e02cc8efb78 /scripts/automation/regression/stateless_tests | |
parent | 6b3fabf419252d33a5c11a21cef85fdb6c19284c (diff) |
STL API: ping_ip returns data + formatted string and status
Regression: add test for IPv6 ping and scan
Change-Id: Ic9d15f0b7ea44fcc11336b95c012ceaa04af9e2d
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/automation/regression/stateless_tests')
-rwxr-xr-x | scripts/automation/regression/stateless_tests/stl_ipv6_test.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/automation/regression/stateless_tests/stl_ipv6_test.py b/scripts/automation/regression/stateless_tests/stl_ipv6_test.py new file mode 100755 index 00000000..c56c9b5d --- /dev/null +++ b/scripts/automation/regression/stateless_tests/stl_ipv6_test.py @@ -0,0 +1,60 @@ +#!/usr/bin/python +from .stl_general_test import CStlGeneral_Test +from trex_stl_lib.api import * + +class STLIPv6_Test(CStlGeneral_Test): + """Tests for IPv6 scan6/ping_ip """ + + def setUp(self): + CStlGeneral_Test.setUp(self) + print('') + self.stl_trex.set_service_mode(ports = [0]) + + def tearDown(self): + CStlGeneral_Test.tearDown(self) + self.stl_trex.set_service_mode(ports = [0], enabled = False) + + def test_ipv6_ping(self): + ping_count = 5 + expected_replies = 4 # allow one loss + results = self.stl_trex.ping_ip(src_port = 0, dst_ip = 'ff02::1', count = ping_count) + good_replies = len(filter(lambda result: result['status'] == 'success', results)) + if self.is_loopback: + # negative test, loopback + if good_replies > 0: + self.fail('We should not respond to IPv6 in loopback at this stage, bug!\nOutput: %s' % results) + else: + print('No IPv6 replies in loopback as expected.') + else: + # positive test, DUT + if good_replies < expected_replies: + self.fail('Got only %s good replies out of %s.\nOutput: %s' % (good_replies, ping_count, results)) + else: + print('Got replies from DUT as expected.') + + # negative test, unknown IP + results = self.stl_trex.ping_ip(src_port = 0, dst_ip = '1234::1234', count = ping_count) + good_replies = len(filter(lambda result: result['status'] == 'success', results)) + if good_replies > 0: + self.fail('We have answers from unknown IPv6, bug!\nOutput: %s' % results) + else: + print('Got no replies from unknown IPv6 as expected.') + + def test_ipv6_scan6(self): + results = self.stl_trex.scan6(ports = 0) + if self.is_loopback: + # negative test, loopback + if results[0]: + self.fail("Scan6 found devices in loopback, we don't answer to IPv6 now, bug!\nOutput: %s" % results) + else: + print('No devices found in loopback as expected.') + else: + # positive test, DUT + if len(results[0]) > 1: + self.fail('Found more than one device at port 0: %s' % results) + elif len(results[0]) == 1: + print('Found one device as expected:\n{type:10} - {mac:20} - {ipv6}'.format(**results[0][0])) + else: + self.fail('Did not find IPv6 devices.') + + |