summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-23 08:04:11 -0500
committerimarom <imarom@cisco.com>2016-02-23 08:04:11 -0500
commit81059eb5df274efe48ad3914039ddb657c3285ab (patch)
treec508f7cb036f7a63129dd23c6e3dd0cc5b698e7d
parenta420b4c469c49c01c5de6756e2955beb4c714728 (diff)
global srand messed up stuff
moved to local rand_r
-rw-r--r--src/sim/trex_sim.h5
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp4
-rw-r--r--src/stateless/cp/trex_stateless_port.h8
3 files changed, 10 insertions, 7 deletions
diff --git a/src/sim/trex_sim.h b/src/sim/trex_sim.h
index 99bfb28e..21498978 100644
--- a/src/sim/trex_sim.h
+++ b/src/sim/trex_sim.h
@@ -111,14 +111,15 @@ public:
int run(int argc, char **argv) {
TrexStatelessCfg cfg;
- cfg.m_port_count = 1;
+ cfg.m_port_count = 2;
cfg.m_rpc_req_resp_cfg = NULL;
cfg.m_rpc_async_cfg = NULL;
cfg.m_rpc_server_verbose = false;
- cfg.m_platform_api = new SimPlatformApi(1);;
+ cfg.m_platform_api = new SimPlatformApi(1);
cfg.m_publisher = NULL;
set_stateless_obj(new TrexStateless(cfg));
+
assert( CMsgIns::Ins()->Create(4) );
int rc = gtest_main(argc, argv);
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 75f77cf7..99b6565c 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -657,7 +657,7 @@ TrexPortOwner::TrexPortOwner() {
m_is_free = true;
/* for handlers random generation */
- srand(time(NULL));
+ m_seed = time(NULL);
}
/**
@@ -675,7 +675,7 @@ TrexPortOwner::generate_handler() {
/* generate 8 bytes of random handler */
for (int i = 0; i < 8; ++i) {
- ss << alphanum[rand() % (sizeof(alphanum) - 1)];
+ ss << alphanum[rand_r(&m_seed) % (sizeof(alphanum) - 1)];
}
return (ss.str());
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index a101cef0..49e69757 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -93,6 +93,8 @@ private:
/* handler genereated internally */
std::string m_handler;
+ /* seed for generating random values */
+ unsigned int m_seed;
/* just references defaults... */
static const std::string g_unowned_name;
@@ -442,9 +444,9 @@ public:
static const std::initializer_list<std::string> g_types;
static const std::initializer_list<std::string> g_ops;
- mul_type_e m_type;
- mul_op_e m_op;
- double m_value;
+ mul_type_e m_type;
+ mul_op_e m_op;
+ double m_value;
};
#endif /* __TREX_STATELESS_PORT_H__ */