Skip to content

Commit a0e8a05

Browse files
Testing DSR, now working with teporary command line and monitor msg handling.
1 parent 72a60a7 commit a0e8a05

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

test/test_data_blaster/monitor_msg_handling.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,25 @@ class monitor_connector {
6767
monitor_connector(chops::net::net_ip& net_ip,
6868
std::string_view monitor_port, std::string_view monitor_host,
6969
std::promise<void> prom,
70-
chops::net::err_wait_q& err_wq) : m_monitor(), m_io_output()
71-
// fill in initializer list, promise must use std::move
72-
70+
chops::net::err_wait_q& err_wq) :
71+
m_monitor(), m_io_output(), m_prom(std::move(prom))
7372
{
7473
// make_tcp_connector, start, provide state chg func obj that does start_io,
7574
// providing msg handler for shutdown, make_err_func_with_wait_queue for error display
7675
}
7776
void send_monitor_msg (const monitor_msg_data& msg_data) const {
7877

7978
}
79+
// temporary - used for testing DSR
80+
void shutdown() {
81+
// send shutdown msg
82+
m_prom.set_value();
83+
}
8084

8185
private:
8286
chops::net::net_entity m_monitor;
8387
chops::net::tcp_io_output m_io_output;
88+
std::promise<void> m_prom;
8489
// more member data to fill in
8590

8691
};

test/test_data_blaster/tcp_dsr.cpp

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include <cstddef> // std::size_t
18+
#include <cstdlib> // std::exit
1819
#include <utility> // std::move
1920
#include <thread>
2021
#include <future>
@@ -39,7 +40,7 @@
3940
#include "test_data_blaster/dsr_args.hpp"
4041
#include "test_data_blaster/monitor_msg_handling.hpp"
4142

42-
const std::string_view msg_prefix { "Tasty testing!" };
43+
const std::string_view msg_prefix { "Tasty!" };
4344

4445
void send_mon_msg (chops::test::monitor_connector& mon,
4546
chops::test::monitor_msg_data& mon_msg,
@@ -58,15 +59,14 @@ void send_mon_msg (chops::test::monitor_connector& mon,
5859
mon_msg.m_outgoing_queue_size = oqs ? (*oqs).output_queue_size : 0u;
5960
// mon.send_monitor_msg(mon_msg);
6061
// temporary display until monitor functionality is ready
61-
std::cerr << "Mon msg: " << mon_msg.m_dsr_name << ", " <<
62+
std::cerr << "Mon: " << mon_msg.m_dsr_name << ", " <<
6263
mon_msg.m_protocol << ", " <<
6364
mon_msg.m_remote_addr << ", " <<
6465
(mon_msg.m_direction == chops::test::monitor_msg_data::incoming ? "incoming, " : "outgoing, ") <<
6566
mon_msg.m_curr_msg_num << "/" << mon_msg.m_total_msgs_to_send << ", " <<
66-
mon_msg.m_curr_msg_size << ", " <<
67-
mon_msg.m_curr_msg_beginning << ", " <<
68-
mon_msg.m_outgoing_queue_size << std::endl;
69-
67+
mon_msg.m_curr_msg_size << ", q sz: " <<
68+
mon_msg.m_outgoing_queue_size << ", " <<
69+
mon_msg.m_curr_msg_beginning << std::endl;
7070
}
7171
}
7272

@@ -181,6 +181,29 @@ void start_entity (chops::net::net_entity ent, char body_char,
181181
// 8 - host, if connector
182182
auto temp_parse_cmd (int argc, char* argv[]) {
183183

184+
if (argc < 8) {
185+
std::cerr << "Parameters (temporary):" << '\n' <<
186+
" name R/n mod cnt delay A/C port (host)" << '\n' <<
187+
" where:" << '\n' <<
188+
" name = DSR name" << '\n' <<
189+
" R = reply (anything else means no reply)" << '\n' <<
190+
" mod = display modulo number" << '\n' <<
191+
" cnt = send count (0 for receive only)" << '\n' <<
192+
" delay = delay in milliseconds between sends (ignored if send count is 0)" << '\n' <<
193+
" A/C = A for acceptor, C for connector" << '\n' <<
194+
" port = port number (for either acceptor or connector)" << '\n' <<
195+
" host = if connector, host name or IP number" << '\n' << std::endl;
196+
std::exit(0);
197+
}
198+
// 1 - dsr name
199+
// 2 - R for reply
200+
// 3 - mod
201+
// 4 - send count
202+
// 5 - delay
203+
// 6 - A for acceptor, C for connector
204+
// 7 - port
205+
// 8 - host, if connector
206+
184207
chops::test::tcp_dsr_args parms;
185208
parms.m_dsr_name = std::string(argv[1]);
186209
parms.m_reply = (*(argv[2]) == 'R');
@@ -234,6 +257,9 @@ int main (int argc, char* argv[]) {
234257
start_entity(ent, body_char++, parms, send_futs, mon, mon_msg, err_wq);
235258
}
236259

260+
// temporary - wait a while, then cause future to pop
261+
std::this_thread::sleep_for(std::chrono::minutes(1));
262+
mon.shutdown();
237263
// everything up and running, block waiting on shutdown msg
238264
shutdown_fut.get(); // monitor sent shutdown msg
239265
nip.stop_all(); // stop all entities

0 commit comments

Comments
 (0)