summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
diff options
context:
space:
mode:
authorVyacheslav Ogai <vyacheslav.ogai@gmail.com>2016-09-30 19:18:46 +0300
committerHanoh Haim <hhaim@cisco.com>2016-12-19 16:04:06 +0200
commit82a9911f91c5190b3e76ab161d51a1b780fcbbb8 (patch)
tree61e3c4f626a876a737c5382d2df5f7d1e3dfc35a /scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
parenta28ff745cc2a45df81bb34a56ca0294ece0b4087 (diff)
Added initial implementation of Field Engine support.
Signed-off-by: Vyacheslav Ogai <vyacheslav.ogai@gmail.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
index d1207ca5..ffc3b2b3 100644
--- a/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
+++ b/scripts/automation/trex_control_plane/stl/services/scapy_server/unit_tests/test_scapy_service.py
@@ -119,8 +119,9 @@ def test_get_definitions_all():
def test_get_definitions_ether():
res = get_definitions(["Ether"])
- assert(len(res) == 1)
- assert(res['protocols'][0]['id'] == "Ether")
+ protocols = res['protocols']
+ assert(len(protocols) == 1)
+ assert(protocols[0]['id'] == "Ether")
def test_get_payload_classes():
eth_payloads = get_payload_classes([{"id":"Ether"}])
@@ -249,3 +250,18 @@ def test_ip_definitions():
assert(fields[9]['id'] == 'chksum')
assert(fields[9]['auto'] == True)
+def test_generate_vm_instructions():
+ ip_pkt_model = [
+ layer_def("Ether"),
+ layer_def("IP", src="16.0.0.1", dst="48.0.0.1")
+ ]
+ ip_instructions_model = {"field_engine":{'global_parameters': {}, 'instructions': [{'id': "IP", 'fields': [{"fieldId": "src", 'parameters': {'min_value': "0", 'max_value': "16.0.0.255", 'step': "1", 'op': "inc"}},
+ {"fieldId": "ttl", 'parameters': {'min_value': "1", 'max_value': "17", 'step': "1", 'op': "inc"}}]}]}}
+ res = build_pkt_ex(ip_pkt_model, ip_instructions_model)
+ src_instruction = res['vm_instructions']['instructions'][0]
+ assert(src_instruction['min_value'] == 0)
+ assert(src_instruction['max_value'] == 268435711)
+
+ ttl_instruction = res['vm_instructions']['instructions'][2]
+ assert(ttl_instruction['min_value'] == 1)
+ assert(ttl_instruction['max_value'] == 17) \ No newline at end of file