help was broken in the simulator
authorimarom <[email protected]>
Tue, 16 Feb 2016 08:49:36 +0000 (03:49 -0500)
committerimarom <[email protected]>
Tue, 16 Feb 2016 11:14:41 +0000 (06:14 -0500)
also some more bugs

scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.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/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py
src/rpc-server/commands/trex_rpc_cmd_stream.cpp

index c3fa70e..838a49e 100644 (file)
@@ -57,7 +57,7 @@ class Port(object):
 
 
     def err(self, msg):
-        return RC_ERR("port {0} : {1}".format(self.port_id, msg))
+        return RC_ERR("port {0} : {1}\n".format(self.port_id, msg))
 
     def ok(self, data = ""):
         return RC_OK(data)
@@ -203,7 +203,7 @@ class Port(object):
 
         rc = self.transmit_batch(batch)
         if not rc:
-            return self.err(rc.err())
+            return self.err(str(rc))
 
 
         # the only valid state now
index 380b7a3..907125e 100644 (file)
@@ -27,8 +27,6 @@ from trex_stl_client import STLClient
 
 import re
 import json
-import zlib
-import struct
 
 
 import argparse
@@ -218,19 +216,14 @@ class STLSim(object):
 
 
     # internal run
-    def __run (self, cmds_json, zipped = True):
+    def __run (self, cmds_json):
 
         # write to temp file
         f = tempfile.NamedTemporaryFile(delete = False)
 
         msg = json.dumps(cmds_json)
 
-        # stress the zip path
-        if zipped:
-            compressed = zlib.compress(msg)
-            new_msg = struct.pack(">II", 0xABE85CEA, len(msg)) + compressed
-
-        f.write(new_msg)
+        f.write(msg)
         f.close()
 
         # launch bp-sim
index 68f8f69..130beab 100644 (file)
@@ -111,7 +111,7 @@ class STLStream(object):
                   rx_stats = None,
                   next = None,
                   stream_id = None,
-                  action_count =0,
+                  action_count = 0,
                   mac_src_override_by_pkt=None,
                   mac_dst_override_mode=None    #see  STLStreamDstMAC_xx
                   ):
index 58306c5..84dd509 100755 (executable)
@@ -71,7 +71,7 @@ match_multiplier_help = """Multiplier should be passed in the following format:
                           will provide a percentage of the line rate. examples
                           '-m 10', '-m 10kbps', '-m 10mpps', '-m 23%%'
 
-                          '-m 23%%'   : is 23% L1 bandwidth 
+                          '-m 23%%'   : is 23%% L1 bandwidth 
                           '-m 23mbps' : is 23mbps in L2 bandwidth (including FCS+4)
                           """
 
index 0f74e19..8d813b7 100644 (file)
@@ -26,6 +26,7 @@ limitations under the License.
 #include <trex_streams_compiler.h>
 #include <common/base64.h>
 #include <iostream>
+#include <memory>
 
 using namespace std;
 
@@ -48,7 +49,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
     string type = parse_string(mode, "type", result);
 
     /* allocate a new stream based on the type */
-    TrexStream *stream = allocate_new_stream(section, port_id, stream_id, result);
+    std::unique_ptr<TrexStream> stream( allocate_new_stream(section, port_id, stream_id, result) );
 
     /* save this for future queries */
     stream->store_stream_json(section);
@@ -57,14 +58,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
     stream->m_enabled         = parse_bool(section, "enabled", result);
     stream->m_self_start      = parse_bool(section, "self_start", result);
     stream->m_flags           = parse_int(section, "flags", result);
-    int cnt  = parse_int(section, "action_count", result);
-    if (cnt<0 || cnt >= UINT16_MAX) {
-        std::stringstream ss;
-        ss << "bad action_count provided: should be between " << 0 << " and " << UINT16_MAX;
-        delete stream;
-        generate_execute_err(result, ss.str()); 
-    }
-    stream->m_action_count    = (uint16_t)cnt;
+    stream->m_action_count    = parse_uint16(section, "action_count", result);
 
     /* inter stream gap */
     stream->m_isg_usec  = parse_double(section, "isg", result);
@@ -78,7 +72,6 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
     if ( (pkt_binary.size() < TrexStream::MIN_PKT_SIZE_BYTES) || (pkt_binary.size() > TrexStream::MAX_PKT_SIZE_BYTES) ) {
         std::stringstream ss;
         ss << "bad packet size provided: should be between " << TrexStream::MIN_PKT_SIZE_BYTES << " and " << TrexStream::MAX_PKT_SIZE_BYTES;
-        delete stream;
         generate_execute_err(result, ss.str()); 
     }
 
@@ -104,7 +97,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
 
     /* parse VM */
     const Json::Value &vm =  parse_object(section ,"vm", result);
-    parse_vm(vm, stream, result);
+    parse_vm(vm, stream.get(), result);
 
     /* parse RX info */
     const Json::Value &rx = parse_object(section, "rx_stats", result);
@@ -119,12 +112,13 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
     }
 
     /* make sure this is a valid stream to add */
-    validate_stream(stream, result);
+    validate_stream(stream.get(), result);
 
     TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(stream->m_port_id);
 
     try {
-        port->add_stream(stream);
+        port->add_stream(stream.get());
+        stream.release();
     } catch (const TrexException &ex) {
         generate_execute_err(result, ex.what());
     }