summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-28 17:02:09 +0200
committerimarom <imarom@cisco.com>2016-02-29 09:43:45 +0200
commite71182209be5870d31cc409a32e3d81f1641b00e (patch)
treedf808ecbd3e5e25638fb5bb2e749e2c4f8ebc052
parenta9c35eacd8caebe65e8c685f9285740b2764ea21 (diff)
random var crash when range is full uint32_t or full uint64_t
-rw-r--r--linux_dpdk/d4
-rwxr-xr-xscripts/automation/trex_control_plane/stl/console/trex_console.py21
-rw-r--r--src/stateless/cp/trex_stream_vm.h9
3 files changed, 31 insertions, 3 deletions
diff --git a/linux_dpdk/d b/linux_dpdk/d
index dfa5d8e8..8e511bbf 100644
--- a/linux_dpdk/d
+++ b/linux_dpdk/d
@@ -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 $@
diff --git a/scripts/automation/trex_control_plane/stl/console/trex_console.py b/scripts/automation/trex_control_plane/stl/console/trex_console.py
index 53817464..ffad03f3 100755
--- a/scripts/automation/trex_control_plane/stl/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/stl/console/trex_console.py
@@ -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'''
diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h
index 4a0b1d59..58d43bd4 100644
--- a/src/stateless/cp/trex_stream_vm.h
+++ b/src/stateless/cp/trex_stream_vm.h
@@ -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) );
+ }
}