MCPcopy Create free account
hub / github.com/SoarGroup/Soar / createKernelAndAgents

Method createKernelAndAgents

Tests/UnitTests/src/iotest.cpp:103–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void IOTest::createKernelAndAgents(const KernelBitset& options, int port)
104{
105 CPPUNIT_ASSERT(pKernel == NULL);
106
107 if (options.test(EMBEDDED))
108 {
109 CPPUNIT_ASSERT(!remote);
110 if (options.test(USE_CLIENT_THREAD))
111 {
112 pKernel = sml::Kernel::CreateKernelInCurrentThread(options.test(FULLY_OPTIMIZED), sml::Kernel::GetDefaultPort());
113 }
114 else
115 {
116 pKernel = sml::Kernel::CreateKernelInNewThread(sml::Kernel::GetDefaultPort());
117 }
118 }
119 else
120 {
121 CPPUNIT_ASSERT(remote);
122 pKernel = sml::Kernel::CreateRemoteConnection(true, 0, port);
123 }
124
125 CPPUNIT_ASSERT(pKernel != NULL);
126 CPPUNIT_ASSERT_MESSAGE(pKernel->GetLastErrorDescription(), !pKernel->HadError());
127
128 pKernel->SetAutoCommit(options.test(AUTO_COMMIT_ENABLED)) ;
129
130 // Set this to true to give us lots of extra debug information on remote clients
131 // (useful in a test app like this).
132 // pKernel->SetTraceCommunications(true) ;
133
134 CPPUNIT_ASSERT(std::string(pKernel->GetSoarKernelVersion()) == std::string(sml::sml_Names::kSoarVersionValue));
135
136 // Report the number of agents (always 0 unless this is a remote connection to a CLI or some such)
137 CPPUNIT_ASSERT(pKernel->GetNumberAgents() == 0);
138
139 // NOTE: We don't delete the agent pointer. It's owned by the kernel
140 sml::Agent* pAgent = pKernel->CreateAgent("IOTest") ;
141 CPPUNIT_ASSERT_MESSAGE(pKernel->GetLastErrorDescription(), !pKernel->HadError());
142 CPPUNIT_ASSERT(pAgent != NULL);
143
144 // a number of tests below depend on running full decision cycles.
145 pAgent->ExecuteCommandLine("set-stop-phase --before --input") ;
146 CPPUNIT_ASSERT_MESSAGE("set-stop-phase --before --input", pAgent->GetLastCommandLineResult());
147
148 pAgent->ExecuteCommandLine("watch 0") ;
149 pAgent->ExecuteCommandLine("waitsnc --on") ;
150
151 CPPUNIT_ASSERT(pKernel->GetNumberAgents() == 1);
152}
153
154void IOTest::testInputLeak()
155{

Callers

nothing calls this directly

Calls 8

GetSoarKernelVersionMethod · 0.80
CreateAgentMethod · 0.80
GetDefaultPortFunction · 0.50
HadErrorMethod · 0.45
GetNumberAgentsMethod · 0.45
ExecuteCommandLineMethod · 0.45

Tested by

no test coverage detected