YAML profiles fixup
authorimarom <[email protected]>
Tue, 9 Feb 2016 14:02:04 +0000 (09:02 -0500)
committerimarom <[email protected]>
Tue, 9 Feb 2016 14:10:23 +0000 (09:10 -0500)
12 files changed:
scripts/automation/trex_control_plane/stl/examples/stl_imix.py
scripts/automation/trex_control_plane/stl/examples/stl_simple_burst.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_sim.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py
scripts/yaml/burst_1000_pkt.yaml
scripts/yaml/burst_1pkt_1burst.yaml
scripts/yaml/burst_1pkt_vm.yaml
scripts/yaml/imix_1pkt_tuple_gen.yaml
scripts/yaml/imix_3pkt.yaml
scripts/yaml/udp_rand_size.yaml
scripts/yaml/udp_rand_size_9k.yaml
src/gtest/trex_stateless_gtest.cpp

index ad329e1..b9fbbbb 100644 (file)
@@ -35,7 +35,8 @@ def imix_test ():
         dir_1 = table['dir'][1]
 
         # load IMIX profile
-        streams = c.load_profile('../../../../stl/profiles/imix.py')
+        profile = STLProfile.load_py('../../../../stl/profiles/imix.py')
+        streams = profile.get_streams()
 
         # add both streams to ports
         c.add_streams(streams, ports = dir_0)
index fd3bd0d..ed0cb93 100644 (file)
@@ -59,31 +59,6 @@ def simple_burst ():
         print "\nTest has failed :-(\n"
 
 
-#
-def sheker ():
-    pkt = STLPktBuilder(pkt = Ether()/IP(src="16.0.0.1",dst="48.0.0.1")/UDP(dport=12,sport=1025)/IP()/'a_payload_example')
-
-    # create two bursts and link them
-    s1 = STLStream(name = 'A',
-                   packet = pkt,
-                   mode = STLTXSingleBurst(total_pkts = 5000),
-                   next = 'B')
-        
-    s2 = STLStream(name = 'B',
-                   self_start = False,
-                   packet = pkt,
-                   mode = STLTXSingleBurst(total_pkts = 3000))
-
-    profile = STLProfile([s1, s2])
-    print "**** BEFORE ****\n"
-    print profile
-    profile.to_yaml('1.yaml')
-    loaded_profile = STLProfile.load_yaml('1.yaml')
-    print "**** AFTER ****\n"
-    print loaded_profile
-    exit(0)
-
-sheker()
 # run the tests
-#simple_burst()
+simple_burst()
 
index 1252b75..9cea3ea 100644 (file)
@@ -140,7 +140,14 @@ class STLSim(object):
 
         # handle YAMLs
         for input_file in input_files:
-            stream_list += STLClient.load_profile(input_file)
+            try:
+                profile = STLProfile.load(input_file)
+            except STLError as e:
+                print format_text("\nError while loading profile '{0}'\n".format(input_file), 'bold')
+                print e.brief() + "\n"
+                return
+
+            stream_list += profile.get_streams()
 
 
         # load streams
index 8ad15a5..9c190da 100644 (file)
@@ -271,7 +271,7 @@ class YAMLLoader(object):
 
         # hack the VM fields for now
         if 'vm' in s_obj:
-            stream.fields['vm'] = s_obj['vm']
+            stream.fields['vm'].update(s_obj['vm'])
 
         return stream
 
@@ -281,7 +281,11 @@ class YAMLLoader(object):
             # read YAML and pass it down to stream object
             yaml_str = f.read()
 
-            objects = yaml.load(yaml_str)
+            try:
+                objects = yaml.load(yaml_str)
+            except yaml.parser.ParserError as e:
+                raise STLError(str(e))
+
             streams = [self.__parse_stream(object) for object in objects]
             
             return streams
index f982fa4..99a121e 100644 (file)
@@ -1,39 +1,33 @@
 ### Single stream UDP packet, 64B ###
 #####################################
 - name: stream0
+  next: stream1
   stream:
     self_start: True
-    next_stream_id: stream1
     packet:
-      binary: cap2/udp_64B.pcap
+      pcap: udp_64B_no_crc.pcap
     mode:
       type: single_burst
       pps: 100
       total_pkts : 10000
-    rx_stats: []
-    vm: []
     
 - name: stream1
+  next: stream2
   stream:
     self_start: False
-    next_stream_id: stream2
     packet:
-      binary: cap2/udp_64B.pcap
+      pcap: udp_64B_no_crc.pcap
     mode:
       type: single_burst
       pps: 100
       total_pkts : 10000
-    rx_stats: []
-    vm: []
 
 - name: stream2
   stream:
     self_start: False
     packet:
-      binary: cap2/udp_64B.pcap
+      pcap: udp_64B_no_crc.pcap
     mode:
       type: single_burst
       pps: 100
       total_pkts : 10000
-    rx_stats: []
-    vm: []    
\ No newline at end of file
index defa776..76c411a 100644 (file)
@@ -4,11 +4,8 @@
   stream:
     self_start: True
     packet:
-      binary: cap2/udp_64B.pcap
+      pcap: udp_64B_no_crc.pcap
     mode:
       type: single_burst
       pps: 100
       total_pkts : 100
-    rx_stats: []
-    vm: []
-    
index e202b42..246b881 100644 (file)
@@ -4,12 +4,11 @@
   stream:
     self_start: True
     packet:
-      binary: stl/udp_64B_no_crc.pcap  # pcap should not include CRC
+      pcap: udp_64B_no_crc.pcap  # pcap should not include CRC
     mode:
       type: single_burst
       total_pkts: 100
       pps: 100
-    rx_stats: []
 
     vm:
       instructions: [
index 78156e5..5ca232c 100644 (file)
@@ -4,60 +4,39 @@
   stream:
     self_start: True
     packet:
-      binary: stl/udp_64B_no_crc.pcap  # pcap should not include CRC
+      pcap: udp_64B_no_crc.pcap  # pcap should not include CRC
     mode:
       type: continuous
       pps: 100
-    rx_stats: []
 
     # program that define 1M flows with IP range 16.0.0.1-16.0.0.254
     # we will create a script that do that for you 
     # this is the low level instructions 
-    vm: [
-               {
-                 "type" : "tuple_flow_var",   # name of the command 
+    vm: 
+       instructions: 
+          -     type        : "tuple_flow_var"     # name of the command 
+                name        : "tuple_gen"          # tuple_gen.ip tuple_gen.port can be used 
 
-                 "name" : "tuple_gen",    # tuple_gen.ip tuple_gen.port can be used 
-
-                 "ip_min"   : 0x10000001,  # min ip 16.0.0.1
-                 "ip_max"   : 0x100000fe,  # max ip 16.0.0.254
+                ip_min      : 0x10000001           # min ip 16.0.0.1
+                ip_max      : 0x100000fe           # max ip 16.0.0.254
                   
-                 "port_min" : 1025,        # min port 1025     
-                 "port_max" : 65500,       # max port 65500
+                port_min    : 1025                 # min port 1025     
+                port_max    : 65500                # max port 65500
                   
-                 "limit_flows" : 1000000,  # number of flows 
-                 "flags"       : 0,        # 1 - for unlimited  
-               },
-
-               {
-                  "type" : "write_flow_var", # command name 
+                limit_flows : 1000000              # number of flows 
+                flags       : 0                    # 1 - for unlimited  
 
-                  "name" : "tuple_gen.ip",  # varible to write     
-                  
-                  "add_value" : 0,          # no need to add value     
-                  
-                  "is_big_endian" : true,   # write as big edian 
-                  
-                  "pkt_offset" : 26,        # write tuple_gen.ip into ipv4.src_ip   
-               },
+          -     type           : "write_flow_var"     # command name 
+                name           : "tuple_gen.ip"       # varible to write     
+                add_value      : 0                    # no need to add value     
+                is_big_endian  : true                 # write as big edian 
+                pkt_offset     : 26                   # write tuple_gen.ip into ipv4.src_ip   
                
-               {
-                  "type" : "fix_checksum_ipv4", # fix ipv4 header checksum 
-
-                  "pkt_offset" : 14,          # offset of ipv4 header 
-                  
-               },
-
-               {
-                  "type" : "write_flow_var", # command name 
-
-                  "name" : "tuple_gen.port",  # varible to write     
-                  
-                  "add_value" : 0,          # no need to add value     
-                  
-                  "is_big_endian" : true,   # write as big edian 
-                  
-                  "pkt_offset" : 34,        # write tuple_gen.port into udp.src_port
-               }
-
-        ]
+          -     type           : "fix_checksum_ipv4"        # fix ipv4 header checksum 
+                pkt_offset     : 14                         # offset of ipv4 header 
+                  
+          -     type           : "write_flow_var"           # command name 
+                name           : "tuple_gen.port"           # varible to write     
+                add_value      : 0                          # no need to add value     
+                is_big_endian  : true                       # write as big edian 
+                pkt_offset     : 34                         # write tuple_gen.port into udp.src_port
index bc28549..82d9193 100644 (file)
@@ -4,29 +4,23 @@
   stream:
     self_start: True
     packet:
-      binary: stl/udp_64B_no_crc.pcap  # pcap should not include CRC
+      pcap: udp_64B_no_crc.pcap  # pcap should not include CRC
     mode:
       type: continuous
       pps: 28
-    rx_stats: []
-    vm: []
 - name: udp_594B
   stream:
     self_start: True
     packet:
-      binary: stl/udp_594B_no_crc.pcap  # pcap should not include CRC
+      pcap: udp_594B_no_crc.pcap  # pcap should not include CRC
     mode:
       type: continuous
       pps: 20
-    rx_stats: []
-    vm: []
 - name: udp_1518B
   stream:
     self_start: True
     packet:
-      binary: stl/udp_1518B_no_crc.pcap # pcap should not include CRC
+      pcap: udp_1518B_no_crc.pcap # pcap should not include CRC
     mode:
       type: continuous
       pps: 4
-    rx_stats: []
-    vm: []
\ No newline at end of file
index 2bbad4a..ab1d21b 100644 (file)
@@ -4,11 +4,10 @@
   stream:
     self_start: True
     packet:
-      binary: stl/udp_1518B_no_crc.pcap 
+      pcap: udp_1518B_no_crc.pcap 
     mode:
       type: continuous
       pps: 100
-    rx_stats: []
 
     # random packet size 60-1500 update ip.len/checksum/udp.len
     vm: 
index ecdd7ae..0d7d1ec 100644 (file)
@@ -4,11 +4,10 @@
   stream:
     self_start: True
     packet:
-      binary: stl/ipv4_udp_9k.pcap # should not include CRC 9K ip+14 = 9230 +FCS(by NIC)=9234 
+      pcap: ipv4_udp_9k.pcap # should not include CRC 9K ip+14 = 9230 +FCS(by NIC)=9234 
     mode:
       type: continuous
       pps: 100
-    rx_stats: []
 
     # random packet size 60-max packet size update ip.len/checksum/udp.len
     vm: 
index f01346b..90f0606 100644 (file)
@@ -994,7 +994,7 @@ TEST_F(basic_vm, vm_syn_attack) {
     vm.Dump(stdout);
 
     CPcapLoader pcap;
-    pcap.load_pcap_file("stl/syn_packet.pcap",0);
+    pcap.load_pcap_file("yaml/syn_packet.pcap",0);
 
     
 
@@ -1120,7 +1120,7 @@ TEST_F(basic_vm, vm_inc_size_64_128) {
     vm.add_instruction( new StreamVmInstructionWriteToPkt( "rand_pkt_size_var",32+6, -(14+20),true)
                         );
 
-    run_vm_program(vm,"stl/udp_1518B_no_crc.pcap","stl_vm_inc_size_64_128",20);
+    run_vm_program(vm,"yaml/udp_1518B_no_crc.pcap","stl_vm_inc_size_64_128",20);
 }
 
 TEST_F(basic_vm, vm_random_size_64_128) {
@@ -1150,7 +1150,7 @@ TEST_F(basic_vm, vm_random_size_64_128) {
                         );
 
 
-    run_vm_program(vm,"stl/udp_1518B_no_crc.pcap","stl_vm_rand_size_64_128",20);
+    run_vm_program(vm,"yaml/udp_1518B_no_crc.pcap","stl_vm_rand_size_64_128",20);
 
 }
 
@@ -1186,7 +1186,7 @@ TEST_F(basic_vm, vm_random_size_64_127_128) {
     bool fail=false;
 
     try {
-       run_vm_program(vm,"stl/udp_64B_no_crc.pcap","stl_vm_rand_size_64B_127_128",20);
+       run_vm_program(vm,"yaml/udp_64B_no_crc.pcap","stl_vm_rand_size_64B_127_128",20);
      } catch (const TrexException &ex) {
         fail=true;
     }
@@ -1222,7 +1222,7 @@ TEST_F(basic_vm, vm_random_size_500b_0_9k) {
     vm.add_instruction( new StreamVmInstructionWriteToPkt( "rand_pkt_size_var",32+6, -(14+20),true)
                         );
 
-    run_vm_program(vm,"stl/udp_594B_no_crc.pcap","stl_vm_rand_size_512B_64_128",10);
+    run_vm_program(vm,"yaml/udp_594B_no_crc.pcap","stl_vm_rand_size_512B_64_128",10);
 
 }
 
@@ -2404,7 +2404,7 @@ TEST_F(basic_stl, vm_enable1) {
 
     CEnableVm vm_test;
     vm_test.m_out_file = "exp/stl_vm_enable1";
-    vm_test.m_input_packet = "stl/udp_594B_no_crc.pcap";
+    vm_test.m_input_packet = "yaml/udp_594B_no_crc.pcap";
     vm_test.run(false);
 }