39 #include <gtest/gtest.h>    43 #include <sys/types.h>    44 #include <sys/param.h>    54   return system((executable + 
" " + args).c_str());
    62   stream = popen(cmd.c_str(), 
"r");
    65     char buffer[MAXPATHLEN];
    67       if (fgets(buffer, MAXPATHLEN, stream) != NULL) data.append(buffer);
    71   unsigned pos = data.find_first_of(
'\n');
    72   return data.substr(0, pos);
    75 int walker(
char *result, 
int *test_result)
    79   if (package_path.find(
"sr_description") == std::string::npos)
    81     printf(
"cannot find package in path %s\n", package_path.c_str());
    87     printf(
"sr_description robots path : %s\n", (package_path+
"/robots").c_str());
    92   d = opendir((package_path+
"/robots").c_str());
    95     printf(
"no robots found\n");
    99   while ((dir = readdir(d)))
   101     if (strcmp(dir->d_name, 
".") == 0 ||
   102         strcmp(dir->d_name, 
"..") == 0)
   106     if (dir->d_type != DT_DIR)
   108       std::string dir_name = dir->d_name;
   109       if (dir_name.find(std::string(
".urdf.xacro")) == dir_name.size()-11)
   111         printf(
"\n\ntesting: %s\n", (package_path+
"/robots/"+dir_name).c_str());
   112         printf(
"xacro --inorder %s/robots/%s  > "   113                "`rospack find sr_description`/test/tmp.urdf",
   114                package_path.c_str(), dir_name.c_str() );
   116                            package_path+
"/robots/"+dir_name+
" > `rospack find sr_description`/test/tmp.urdf");
   118         *test_result = *test_result || 
runExternalProcess(
"check_urdf", 
"`rospack find sr_description`/test/tmp.urdf");
   119         printf(
"\n looking for unexpanded xacro tags\n");
   121         *test_result = *test_result ||
   124       if (*test_result != 0)
   136   char buf[MAXPATHLEN] = { 0 };
   137   if (
walker(buf, &test_result) == 0)
   139     printf(
"Found: %s\n", buf);
   146   EXPECT_EQ(test_result, 0);
   149 int main(
int argc, 
char **argv)
   151   testing::InitGoogleTest(&argc, argv);
   152   return RUN_ALL_TESTS();
 
int runExternalProcess(const std::string &executable, const std::string &args)
TEST(URDF, CorrectFormat)
int walker(char *result, int *test_result)
int main(int argc, char **argv)
std::string getCommandOutput(std::string cmd)