From 8f2d241a41072dc1df15c6cbd5e5657df2f4d8f2 Mon Sep 17 00:00:00 2001 From: kevin Date: Sat, 30 Nov 2024 12:22:37 -0500 Subject: [PATCH] main.cfg,main.cpp : Updates to remove hardcoded test parameters. --- src/cwtest/cfg/main.cfg | 94 +++++++++++++++++++++++++---------------- src/cwtest/main.cpp | 92 ++++------------------------------------ 2 files changed, 66 insertions(+), 120 deletions(-) diff --git a/src/cwtest/cfg/main.cfg b/src/cwtest/cfg/main.cfg index 06c82f3..af835bd 100644 --- a/src/cwtest/cfg/main.cfg +++ b/src/cwtest/cfg/main.cfg @@ -45,7 +45,41 @@ timeOutMs: 50, // milliseconds to block waiting for incoming websock messages }, + uiTest: { + ui: { + physRootDir: "~/src/cwtest/src/libcw/html/uiTest", + dfltPageFn: "index.html", + port: 5687, + rcvBufByteN: 2048, + xmtBufByteN: 2048, + queueBlkCnt: 8, + queueBlkByteCnt: 8192, + extraLogsFl: true, + fmtBufByteN: 4096, + websockTimeOutMs: 50, // max time out while blocking for a websock event + uiCfgFn: "ui.cfg", // default UI resource description + idleMsgPeriodMs: 50 + }, + + listEle: { + + row: { + check: { name: playCheckId, title:"Play", value: false }, + select: { name: preMenuId, title:"Preset", + children: + { + option:{ name: psOpt1, title:"Sel 1" }, + option:{ name: psOpt2, title:"Sel 2" }, + option:{ name: psOpt3, title:"Sel 3" } + }, + } + }, + + } + }, + serialSrv: {}, + midiDeviceReport: {}, // Test the MIDI file input device. See cwMidiDeviceTest.cpp @@ -115,46 +149,34 @@ remoteAddr: "127.0.0.1", // localhost remotePort: 5687, }, - - sockMgrTest: {}, - - uiTest: { - ui: { - physRootDir: "~/src/cwtest/src/libcw/html/uiTest", - dfltPageFn: "index.html", - port: 5687, - rcvBufByteN: 2048, - xmtBufByteN: 2048, - queueBlkCnt: 8, - queueBlkByteCnt: 8192, - extraLogsFl: true, - fmtBufByteN: 4096, - websockTimeOutMs: 50, // max time out while blocking for a websock event - uiCfgFn: "ui.cfg", // default UI resource description - idleMsgPeriodMs: 50 - }, - - listEle: { - - row: { - check: { name: playCheckId, title:"Play", value: false }, - select: { name: preMenuId, title:"Preset", - children: - { - option:{ name: psOpt1, title:"Sel 1" }, - option:{ name: psOpt2, title:"Sel 2" }, - option:{ name: psOpt3, title:"Sel 3" } - }, - } - }, - - } - }, socketMdns: {}, dnssd: {}, eucon: {}, - dirEntry: {}, + + + // Create a server to listen on a known port + sockMgrSrvTest: { + protocol: tcp, // tcp | udp + //nicDev: // optional NIC device + localPort: 5688, + }, + + sockMgrClientTest: { + //nicDev: // optional NIC device + protocol: tcp, + localPort: 5687, + remoteAddr: "127.0.0.1", // localhost + remotePort: 5688, + + } + + + dirEntry: { + path: "~/src/cwtest/src/cwtest/cfg/test", + attrL: [ "file","dir","link","hidden","cur_dir","parent_dir","full_path","recurse","recurse_links"] + }, + io: { ui: { physRootDir: "/home/kevin/src/cwtest/src/libcw/html/ioTest", diff --git a/src/cwtest/main.cpp b/src/cwtest/main.cpp index d70943d..ab3ebb0 100644 --- a/src/cwtest/main.cpp +++ b/src/cwtest/main.cpp @@ -5,11 +5,11 @@ #include "cwMem.h" #include "cwFile.h" #include "cwVariant.h" +#include "cwObject.h" #include "cwFileSys.h" #include "cwTextBuf.h" #include "cwText.h" #include "cwNumericConvert.h" -#include "cwObject.h" #include "cwB23Tree.h" #include "cwVectOps.h" #include "cwMtx.h" @@ -389,87 +389,8 @@ cw::rc_t socketTestTcp( const cw::object_t* cfg, const cw::object_t* args, in cw::rc_t socketSrvUdpTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::net::srv::test_udp_srv(args); } cw::rc_t socketSrvTcpTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::net::srv::test_tcp_srv(args); } -cw::rc_t sockMgrTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) -{ - cw::rc_t rc = cw::kOkRC; - bool tcpFl = false; - const char* localNicDev = nullptr; - unsigned short localPort = 0; - const char* remoteIp = nullptr; - unsigned short remotePort = 0; - int argi = 0; - - if( argc <3 ) - { - rc = cwLogError(cw::kInvalidArgRC,"Error: Invalid argument count to sockMgrTest()."); - goto errLabel; - } - - // The first arg. must be 'tcp' or 'udp'. - if( strcmp(argv[1],"tcp")!=0 && strcmp(argv[1],"udp")!=0 ) - { - rc = cwLogError(cw::kInvalidArgRC,"sockMgrTest() Error: The first argument must be 'udp' or 'tcp'\n"); - goto errLabel; - } - - - tcpFl = strcmp(argv[1],"tcp")==0; - - argi = 2; - - // If the next token is 'dev' ... - if( strcmp(argv[argi],"dev") == 0 ) - { - if( argc <= ++argi ) - { - rc = cwLogError(cw::kInvalidArgRC,"sockMgrTest() Error: No local NIC given.\n"); - goto errLabel; - } - - // .. then the next arg is the localNicDev - localNicDev = argv[argi++]; - } - - if( argc <= argi ) - { - rc = cwLogError(cw::kInvalidArgRC,"sockMgrTest() Error: No local port was given.\n"); - goto errLabel; - } - - // get the local port - localPort = atoi(argv[argi++]); - - if( argc > argi) - { - remoteIp = argv[argi++]; - - if( argc > argi) - remotePort = atoi(argv[argi++]); - } - - - if( remoteIp != nullptr && remotePort == 0 ) - { - rc = cwLogError(cw::kInvalidArgRC,"sockMgrTest() Error: A remote adddress '%s' was given but no remote port was given.", remoteIp); - goto errLabel; - } - - cwLogInfo("style:%s local:%i to remote:%s %i\n", argv[1], localPort, cwStringNullGuard(remoteIp), remotePort); - - rc = cw::socksrv::testMain( tcpFl, localNicDev, localPort, remoteIp, remotePort ); - - return rc; - - errLabel: - - rc = cwLogError(rc,"SockMgrTest() failed."); - - // 1 2 3 4 - // 1 2 3 4 5 6 - cwLogInfo("Usage: ./cwtest sockMgrTest 'udp | tcp' {'dev' } { }\n"); - - return rc; -} +cw::rc_t sockMgrSrvTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::socksrv::testMain(args); } +cw::rc_t sockMgrClientTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { return cw::socksrv::testMain(args); } #if defined(cwWEB) cw::rc_t _no_c11() { return cwLogError(cw::kResourceNotAvailableRC,"C++11 functionality not included in this build."); } @@ -503,7 +424,8 @@ cw::rc_t svgTest( const cw::object_t* cfg, const cw::object_t* args, int argc, #endif cw::rc_t dirEntryTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) -{ +{ return cw::filesys::dirEntryTest(args); } +/* cw::rc_t rc = cw::kOkRC; if( argc < 2 ) rc = cwLogError(cw::kInvalidArgRC,"dirEntryTest() error: Invalid arg. count."); @@ -520,6 +442,7 @@ cw::rc_t dirEntryTest( const cw::object_t* cfg, const cw::object_t* args, int ar } return rc; } +*/ cw::rc_t stubTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { @@ -596,7 +519,8 @@ int main( int argc, const char* argv[] ) { "socketTcpServer", socketTestTcp }, { "socketSrvUdp", socketSrvUdpTest }, { "socketSrvTcp", socketSrvTcpTest }, - { "sockMgrTest", sockMgrTest }, + { "sockMgrSrvTest", sockMgrSrvTest }, + { "sockMgrClientTest", sockMgrClientTest }, { "uiTest", uiTest }, { "socketMdns", socketMdnsTest }, { "dnssd", dnsSdTest },