diff options
author | 2016-01-27 10:47:40 -0500 | |
---|---|---|
committer | 2016-01-27 11:01:44 -0500 | |
commit | 7351ddb52a2162fc2ac303c687a2ed50cbb0843e (patch) | |
tree | dfba74936e5f671f7fa764e16efc6735d8defe43 /scripts/automation/regression/unit_tests | |
parent | 73d9481b063d851ba16dc853f7309e3080970408 (diff) |
API: example for bi-directional flows
Diffstat (limited to 'scripts/automation/regression/unit_tests')
3 files changed, 47 insertions, 42 deletions
diff --git a/scripts/automation/regression/unit_tests/functional_tests/pkt_builder_test.py b/scripts/automation/regression/unit_tests/functional_tests/pkt_builder_test.py index c2946798..d33d92fe 100755 --- a/scripts/automation/regression/unit_tests/functional_tests/pkt_builder_test.py +++ b/scripts/automation/regression/unit_tests/functional_tests/pkt_builder_test.py @@ -262,8 +262,10 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): self.pkt_bld.add_pkt_layer("l4_tcp", dpkt.tcp.TCP()) self.pkt_bld.set_pkt_payload("HelloWorld") - self.pkt_bld.set_vm_ip_range("l3", "src", - "10.0.0.1", "10.0.0.1", "10.0.0.255", 1, + self.pkt_bld.set_vm_ip_range("l3", + "src", + "10.0.0.1", + "10.0.0.255", "inc") # self.pkt_bld.set_vm_custom_range(layer_name="l3", # hdr_field="tos", @@ -272,15 +274,15 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): print '' self.pp.pprint(self.pkt_bld.vm.dump()) assert_equal(self.pkt_bld.vm.dump(), - { 'instructions': [ { 'init_value': '167772161', - 'max_value': '167772415', - 'min_value': '167772161', + { 'instructions': [ { 'init_value': 167772161, + 'max_value': 167772415, + 'min_value': 167772161, 'name': 'l3__src', 'op': 'inc', 'size': 4, 'type': 'flow_var'}, - { 'add_value': 1, - 'is_big_endian': False, + { 'add_value': 0, + 'is_big_endian': True, 'name': 'l3__src', 'pkt_offset': 26, 'type': 'write_flow_var'}, @@ -304,15 +306,15 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): print '' self.pp.pprint(self.pkt_bld.vm.dump()) assert_equal(self.pkt_bld.vm.dump(), - { 'instructions': [ { 'init_value': '167772161', - 'max_value': '167772415', - 'min_value': '167772161', + { 'instructions': [ { 'init_value': 167772161, + 'max_value': 167772415, + 'min_value': 167772161, 'name': 'l3__src', 'op': 'inc', 'size': 4, 'type': 'flow_var'}, { 'add_value': 1, - 'is_big_endian': False, + 'is_big_endian': True, 'name': 'l3__src', 'pkt_offset': 26, 'type': 'write_flow_var'}], @@ -335,15 +337,15 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): print '' self.pp.pprint(self.pkt_bld.vm.dump()) assert_equal(self.pkt_bld.vm.dump(), - { 'instructions': [ { 'init_value': '65537', - 'max_value': '65551', - 'min_value': '65537', + { 'instructions': [ { 'init_value': 65537, + 'max_value': 65551, + 'min_value': 65537, 'name': 'l3__src', 'op': 'inc', 'size': 4, 'type': 'flow_var'}, { 'add_value': 1, - 'is_big_endian': False, + 'is_big_endian': True, 'name': 'l3__src', 'pkt_offset': 34, 'type': 'write_flow_var'}], @@ -367,15 +369,15 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): print '' self.pp.pprint(self.pkt_bld.vm.dump()) assert_equal(self.pkt_bld.vm.dump(), - { 'instructions': [ { 'init_value': '10', - 'max_value': '200', - 'min_value': '10', + { 'instructions': [ { 'init_value': 10, + 'max_value': 200, + 'min_value': 10, 'name': 'l3__tos', 'op': 'inc', 'size': 1, 'type': 'flow_var'}, { 'add_value': 2, - 'is_big_endian': False, + 'is_big_endian': True, 'name': 'l3__tos', 'pkt_offset': 15, 'type': 'write_flow_var'}, @@ -390,8 +392,10 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): self.pkt_bld.add_pkt_layer("l4_tcp", dpkt.tcp.TCP()) self.pkt_bld.set_pkt_payload("HelloWorld") - self.pkt_bld.set_vm_ip_range("l3", "src", - "10.0.0.1", "10.0.0.1", "10.0.0.255", 1, + self.pkt_bld.set_vm_ip_range("l3", + "src", + "10.0.0.1", + "10.0.0.255", "inc") self.pkt_bld.set_vm_custom_range(layer_name="l3", hdr_field="tos", @@ -399,28 +403,29 @@ class CTRexPktBuilder_Test(pkt_bld_general_test.CGeneralPktBld_Test): operation="inc") print '' self.pp.pprint(self.pkt_bld.vm.dump()) + assert_equal(self.pkt_bld.vm.dump(), - {'instructions': [{'init_value': '167772161', - 'max_value': '167772415', - 'min_value': '167772161', + {'instructions': [{'init_value': 167772161, + 'max_value': 167772415, + 'min_value': 167772161, 'name': 'l3__src', 'op': 'inc', 'size': 4, 'type': 'flow_var'}, - {'init_value': '10', - 'max_value': '200', - 'min_value': '10', + {'init_value': 10, + 'max_value': 200, + 'min_value': 10, 'name': 'l3__tos', 'op': 'inc', 'size': 1, 'type': 'flow_var'}, {'add_value': 2, - 'is_big_endian': False, + 'is_big_endian': True, 'name': 'l3__tos', 'pkt_offset': 15, 'type': 'write_flow_var'}, - {'add_value': 1, - 'is_big_endian': False, + {'add_value': 0, + 'is_big_endian': True, 'name': 'l3__src', 'pkt_offset': 26, 'type': 'write_flow_var'}, diff --git a/scripts/automation/regression/unit_tests/functional_tests/vm_test.py b/scripts/automation/regression/unit_tests/functional_tests/vm_test.py index 603c52db..f3948d99 100755 --- a/scripts/automation/regression/unit_tests/functional_tests/vm_test.py +++ b/scripts/automation/regression/unit_tests/functional_tests/vm_test.py @@ -23,9 +23,9 @@ class CTRexVM_Test(pkt_bld_general_test.CGeneralPktBld_Test): # "big_endian": True, "op": "inc", # "split_by_core": False, - "init_value": "5", - "min_value": "1", - "max_value": "100"}) + "init_value": 5, + "min_value": 1, + "max_value": 100}) assert_raises(CTRexPktBuilder.VMFieldNameError, self.vm.add_flow_man_inst, "src_mac", no_field=1) def test_load_flow_man(self): @@ -50,16 +50,16 @@ class CTRexVM_Test(pkt_bld_general_test.CGeneralPktBld_Test): print '' pprint (self.vm.dump()) assert_equal(self.vm.dump(), - {'instructions': [{'init_value': '10', - 'max_value': '100', - 'min_value': '2', + {'instructions': [{'init_value': 10, + 'max_value': 100, + 'min_value': 2, 'name': 'src_ip', 'op': 'dec', 'size': 8, 'type': 'flow_var'}, - {'init_value': '5', - 'max_value': '100', - 'min_value': '1', + {'init_value': 5, + 'max_value': 100, + 'min_value': 1, 'name': 'dst_ip', 'op': 'inc', 'size': 8, diff --git a/scripts/automation/regression/unit_tests/functional_tests/vm_variable_test.py b/scripts/automation/regression/unit_tests/functional_tests/vm_variable_test.py index af56b1b1..699f1d97 100755 --- a/scripts/automation/regression/unit_tests/functional_tests/vm_variable_test.py +++ b/scripts/automation/regression/unit_tests/functional_tests/vm_variable_test.py @@ -50,9 +50,9 @@ class CTRexVMVariable_Test(pkt_bld_general_test.CGeneralPktBld_Test): # "big_endian": True, "op": "inc", # "split_by_core": False, - "init_value": "5", - "min_value": "1", - "max_value": "100"}) + "init_value": 5, + "min_value": 1, + "max_value": 100}) def tearDown(self): pass |