typekit_scripting_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <rtt/os/main.h>
5 #include <rtt/TaskContext.hpp>
6 
7 
8 void throw_function() {
9  throw std::exception();
10 }
11 
12 class KDLPluginScriptingTest : public testing::Test {
13 
14 protected:
16  tc("test")
17  {
18  }
19 
20  virtual void SetUp() {
21  ASSERT_TRUE(RTT::plugin::PluginLoader::Instance()->loadTypekit("kdl_typekit",RTT::plugin::PluginLoader::Instance()->getPluginPath())) << "Failed to load kdl typekit";
22  ASSERT_TRUE(tc.loadService("scripting")) << "Unable to load scripting service";
23  scripting = boost::dynamic_pointer_cast<RTT::scripting::ScriptingService>( tc.provides()->getService("scripting") );
24  ASSERT_TRUE(scripting.get()) << "Failed to get loaded scripting service";
25 
26  tc.addOperation("throw",&throw_function);
27  tc.setPeriod(0.01);
28  ASSERT_TRUE(scripting->loadPrograms("./typekit-test.ops",false)) << "Failed to load test program";
29  ASSERT_TRUE(tc.start()) << "Failed to start TaskContext";
30  }
31  virtual void TearDown() {
32  }
33 
36 };
37 
39  std::vector<std::string> programs = scripting->getProgramList();
40 
41  for(std::vector<std::string>::const_iterator it = programs.begin(); it != programs.end(); ++it) {
42  RTT::scripting::ProgramInterfacePtr program = scripting->getProgram(*it);
43  ASSERT_TRUE(program.get()) << "Failed to get program " << *it;
44  ASSERT_TRUE(program->start());
45  while(program->isRunning()) {
46  ASSERT_FALSE(program->inError()) << "Program " << *it << " failed on line " << program->getLineNumber();
47  usleep(1000);
48  }
49  ASSERT_FALSE(program->inError()) << "Program " << *it << " failed on line " << program->getLineNumber();
50  }
51 }
52 
53 int ORO_main(int argc, char **argv){
54  testing::InitGoogleTest(&argc,argv);
55  return RUN_ALL_TESTS();
56 }
57 
boost::shared_ptr< ScriptingService > shared_ptr
Service::shared_ptr provides()
void throw_function()
bool loadService(const std::string &service_name)
int usleep(unsigned int us)
boost::shared_ptr< ProgramInterface > ProgramInterfacePtr
RTT::scripting::ScriptingService::shared_ptr scripting
int ORO_main(int argc, char **argv)
static boost::shared_ptr< PluginLoader > Instance()
TEST_F(KDLPluginScriptingTest, ScriptTest)
Operation< Signature > & addOperation(Operation< Signature > &op)
virtual bool setPeriod(Seconds s)
virtual bool start()


kdl_typekit
Author(s): Steven Bellens, Ruben Smits
autogenerated on Wed Jul 3 2019 19:39:45