2024-12-01 19:35:24 +00:00
|
|
|
//| Copyright: (C) 2020-2024 Kevin Larke <contact AT larke DOT org>
|
|
|
|
//| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
|
2024-05-10 01:55:38 +00:00
|
|
|
#include "cwCommon.h"
|
|
|
|
#include "cwLog.h"
|
|
|
|
#include "cwCommonImpl.h"
|
2024-05-29 16:33:13 +00:00
|
|
|
#include "cwTest.h"
|
2024-05-10 01:55:38 +00:00
|
|
|
#include "cwMem.h"
|
|
|
|
#include "cwText.h"
|
|
|
|
#include "cwNumericConvert.h"
|
|
|
|
#include "cwObject.h"
|
|
|
|
|
|
|
|
#include "cwTime.h"
|
|
|
|
#include "cwMidiDecls.h"
|
|
|
|
#include "cwMidi.h"
|
|
|
|
#include "cwFlowDecl.h"
|
|
|
|
#include "cwFlow.h"
|
|
|
|
#include "cwFlowTest.h"
|
|
|
|
|
|
|
|
|
2024-05-29 16:33:13 +00:00
|
|
|
cw::rc_t cw::flow::test( const test::test_args_t& args )
|
2024-05-10 01:55:38 +00:00
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc_t rc = kOkRC;
|
|
|
|
const char* proc_cfg_fname = nullptr;
|
|
|
|
const char* subnet_cfg_fname = nullptr;
|
|
|
|
object_t* class_cfg = nullptr;
|
|
|
|
object_t* subnet_cfg = nullptr;
|
|
|
|
handle_t flowH;
|
|
|
|
|
|
|
|
if( args.module_args == nullptr )
|
2024-05-10 01:55:38 +00:00
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc = cwLogError(kInvalidArgRC,"The flow test cases require module args.");
|
2024-05-10 01:55:38 +00:00
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
2024-05-29 16:33:13 +00:00
|
|
|
if((rc = args.module_args->readv("proc_cfg_fname",0,proc_cfg_fname,
|
|
|
|
"subnet_cfg_fname",0,subnet_cfg_fname)) != kOkRC )
|
2024-05-10 01:55:38 +00:00
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc = cwLogError(rc,"Flow module arg's parse failed.");
|
2024-05-10 01:55:38 +00:00
|
|
|
goto errLabel;
|
|
|
|
}
|
2024-05-29 16:33:13 +00:00
|
|
|
|
2024-05-10 01:55:38 +00:00
|
|
|
// parse the proc dict. file
|
|
|
|
if((rc = objectFromFile(proc_cfg_fname,class_cfg)) != kOkRC )
|
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc = cwLogError(rc,"The flow proc dictionary could not be read from '%s'.",cwStringNullGuard(proc_cfg_fname));
|
2024-05-10 01:55:38 +00:00
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parse the subnet dict file
|
|
|
|
if((rc = objectFromFile(subnet_cfg_fname,subnet_cfg)) != kOkRC )
|
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc = cwLogError(rc,"The flow subnet dictionary could not be read from '%s'.",cwStringNullGuard(subnet_cfg_fname));
|
2024-05-10 01:55:38 +00:00
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
2024-05-29 16:33:13 +00:00
|
|
|
// create the flow object
|
|
|
|
if((rc = create( flowH, class_cfg, args.test_args, subnet_cfg, args.out_dir)) != kOkRC )
|
2024-05-10 01:55:38 +00:00
|
|
|
{
|
2024-06-11 00:41:32 +00:00
|
|
|
rc = cwLogError(rc,"Flow object configure failed.");
|
2024-05-29 16:33:13 +00:00
|
|
|
goto errLabel;
|
2024-05-10 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
2024-06-11 00:41:32 +00:00
|
|
|
// create the flow object
|
|
|
|
if((rc = initialize( flowH )) != kOkRC )
|
|
|
|
{
|
|
|
|
rc = cwLogError(rc,"Flow object create failed.");
|
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
2024-05-29 16:33:13 +00:00
|
|
|
// run the network
|
|
|
|
if((rc = exec( flowH )) != kOkRC )
|
|
|
|
rc = cwLogError(rc,"Execution failed.");
|
|
|
|
|
|
|
|
errLabel:
|
|
|
|
// destroy the flow object
|
|
|
|
if((rc = destroy(flowH)) != kOkRC )
|
2024-05-10 01:55:38 +00:00
|
|
|
{
|
2024-05-29 16:33:13 +00:00
|
|
|
rc = cwLogError(rc,"Close the flow object.");
|
|
|
|
goto errLabel;
|
2024-05-10 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( class_cfg != nullptr )
|
|
|
|
class_cfg->free();
|
|
|
|
|
|
|
|
if( subnet_cfg != nullptr )
|
|
|
|
subnet_cfg->free();
|
|
|
|
|
|
|
|
return rc;
|
2024-05-29 16:33:13 +00:00
|
|
|
|
2024-05-10 01:55:38 +00:00
|
|
|
}
|