37 #include <gtest/gtest.h> 41 #include <sys/types.h> 42 #include <sys/param.h> 51 #include <urdf_parser/urdf_parser.h> 52 #include <boost/function.hpp> 53 #include <urdf_model/model.h> 57 return system((executable +
" " + args).c_str());
60 int walker( std::string & result,
int& test_result)
64 d = opendir(
"robots" );
69 while( ( dir = readdir( d ) ) )
71 if( strcmp( dir->d_name,
"." ) == 0 ||
72 strcmp( dir->d_name,
".." ) == 0 )
76 if( dir->d_type != DT_DIR )
78 std::string dir_name = dir->d_name;
79 if (dir_name.find(std::string(
".urdf.xacro")) == dir_name.size()-11)
82 getcwd( pwd, MAXPATHLEN );
83 std::string name = std::string(pwd)+
"/robots/"+dir_name;
84 printf(
"\n\ntesting: %s\n",name.c_str());
88 runExternalProcess(
"rosrun xacro xacro", name+
" --inorder > `rospack find pr2_description`/test/tmp.urdf" );
89 std::string
path = std::string(pwd)+
"/test/tmp.urdf";
92 std::string xml_string;
93 std::fstream xml_file(path.c_str(), std::fstream::in);
94 while ( xml_file.good() )
97 std::getline( xml_file, line);
98 xml_string += (line +
"\n");
103 if (!robot) test_result = test_result || 1;
117 if(
walker( result, test_result ) == 0 )
119 printf(
"Found: %s\n", result.c_str() );
127 EXPECT_TRUE(test_result == 0);
130 int main(
int argc,
char **argv)
132 testing::InitGoogleTest(&argc, argv);
133 return RUN_ALL_TESTS();
int main(int argc, char **argv)
int walker(std::string &result, int &test_result)
int runExternalProcess(const std::string &executable, const std::string &args)
TEST(URDF, CorrectFormat)