random var crash when range is full uint32_t or full uint64_t
authorimarom <[email protected]>
Sun, 28 Feb 2016 15:02:09 +0000 (17:02 +0200)
committerimarom <[email protected]>
Mon, 29 Feb 2016 07:43:45 +0000 (09:43 +0200)
linux_dpdk/d
scripts/automation/trex_control_plane/stl/console/trex_console.py
src/stateless/cp/trex_stream_vm.h

index dfa5d8e..8e511bb 100644 (file)
@@ -1,2 +1,4 @@
+#!/bin/bash
+
 rm -f ../linux_dpdk/build_dpdk/linux_dpdk/_t-rex-64
-./b --target=_t-rex-64-debug
+./b --target=_t-rex-64-debug $@
index 5381746..ffad03f 100755 (executable)
@@ -339,6 +339,27 @@ class TRexConsole(TRexGeneralCmd):
     def help_portattr (self):
         return self.do_portattr("-h")
 
+    @verify_connected
+    def do_map (self, line):
+        '''Maps ports topology\n'''
+        ports = self.stateless_client.get_acquired_ports()
+        if not ports:
+            print "No ports acquired\n"
+
+        with self.stateless_client.logger.supress():
+            table = stl_map_ports(self.stateless_client, ports = ports)
+
+        tmp = list(ports)
+        print format_text('\nAcquired ports topology:\n', 'bold', 'underline')
+        while tmp:
+            a = tmp.pop(0)
+            b = table[a]
+            tmp.remove(b)
+
+            print "port {0} <--> port {1}".format(a, b)
+
+        print ""
+
     def do_history (self, line):
         '''Manage the command history\n'''
 
index 4a0b1d5..58d43bd 100644 (file)
@@ -175,7 +175,7 @@ public:
 
     inline void run_rand(uint8_t * flow_var,uint32_t *per_thread_random) {
         uint32_t * p=(uint32_t *)(flow_var+m_flow_offset);
-        *p= m_min_val + (vm_rand32(per_thread_random) % (int)(m_max_val - m_min_val + 1));
+        *p = m_min_val + (vm_rand32(per_thread_random) % ((uint64_t)(m_max_val) - m_min_val + 1));
     }
 
 } __attribute__((packed)) ;
@@ -208,7 +208,12 @@ public:
 
     inline void run_rand(uint8_t * flow_var,uint32_t *per_thread_random) {
         uint64_t * p=(uint64_t *)(flow_var+m_flow_offset);
-        *p= m_min_val + ( vm_rand64(per_thread_random)  % (int)(m_max_val - m_min_val + 1));
+
+        if ((m_max_val - m_min_val) == UINT64_MAX) {
+            *p = vm_rand64(per_thread_random);
+        } else {
+            *p = m_min_val + ( vm_rand64(per_thread_random)  % ( (uint64_t)m_max_val - m_min_val + 1) );
+        }
     }