test_openrtm_aist.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 PKG = 'openrtm_aist'
00004 import roslib; roslib.load_manifest(PKG)  # This line is not needed with Catkin.
00005 
00006 import os
00007 import sys
00008 import unittest
00009 
00010 code = """
00011 #include <rtm/Manager.h>
00012 int main (int argc, char** argv)
00013 {
00014   RTC::Manager* manager;
00015   manager = RTC::Manager::init(argc, argv);
00016   return 0;
00017 }
00018 """
00019 from subprocess import call, check_output, Popen, PIPE, STDOUT
00020 
00021 ## A sample python unit test
00022 class TestCompile(unittest.TestCase):
00023     PKG_CONFIG_PATH = ''
00024 
00025     def setUp(self):
00026         # if rosbuild environment
00027         openrtm_path = check_output(['rospack','find','openrtm_aist']).rstrip()
00028         if os.path.exists(os.path.join(openrtm_path, "bin")) :
00029             self.PKG_CONFIG_PATH='PKG_CONFIG_PATH=%s/lib/pkgconfig:$PKG_CONFIG_PATH'%(openrtm_path)
00030 
00031     ## test 1 == 1
00032     def test_compile_pkg_config(self):
00033         global PID
00034         print "`pkg-config openrtm-aist --cflags --libs` =",check_output("%s pkg-config openrtm-aist --cflags --libs"%(self.PKG_CONFIG_PATH), shell=True, stderr=STDOUT)
00035         print "%s g++ -o openrtm-sample-pkg-config /tmp/%d-openrtm-sample.cpp `pkg-config openrtm-aist --cflags --libs`"%(self.PKG_CONFIG_PATH, PID)
00036         ret = call("g++ -o openrtm-sample-pkg-config /tmp/%d-openrtm-sample.cpp `%s pkg-config openrtm-aist --cflags --libs`"%(PID, self.PKG_CONFIG_PATH), shell=True)
00037         self.assertTrue(ret==0)
00038 
00039     def test_compile_rtm_config(self):
00040         global PID
00041         print "`rosrun openrtm_aist rtm-config --cflags --libs` =",check_output("rosrun openrtm_aist rtm-config --cflags --libs", shell=True, stderr=STDOUT)
00042         ret = call("g++ -o openrtm-sample-pkg-config /tmp/%d-openrtm-sample.cpp `rosrun openrtm_aist rtm-config --cflags --libs`"%(PID), shell=True)
00043         self.assertTrue(ret==0)
00044 
00045     def test_share(self):
00046         # check if rtshell runs
00047         print "`rospack find openrtm_aist`/share/openrtm-1.1/example/rtc.conf = ",os.path.join(check_output(['rospack','find','openrtm_aist']).rstrip(), "share/openrtm-1.1/example/rtc.conf")
00048         self.assertTrue(os.path.exists(os.path.join(check_output(['rospack','find','openrtm_aist']).rstrip(), "share/openrtm-1.1/example/rtc.conf")))
00049 
00050     def test_example(self):
00051         print "`pkg-config openrtm-aist --variable=rtm_exampledir`/SeqInComp =",os.path.join(check_output("%s pkg-config openrtm-aist --variable=rtm_exampledir"%(self.PKG_CONFIG_PATH), shell=True).rstrip(), "SeqInComp")
00052         self.assertTrue(os.path.exists(os.path.join(check_output("%s pkg-config openrtm-aist --variable=rtm_exampledir"%(self.PKG_CONFIG_PATH), shell=True).rstrip(), "SeqInComp")))
00053         print "`pkg-config openrtm_aist rtm-config --rtm-exampledir`/SeqInComp =",os.path.join(check_output(['rosrun','openrtm_aist','rtm-config','--rtm-exampledir']).rstrip(), "SeqInComp")
00054         self.assertTrue(os.path.exists(os.path.join(check_output(['rosrun','openrtm_aist','rtm-config','--rtm-exampledir']).rstrip(), "SeqInComp")))
00055 
00056 if __name__ == '__main__':
00057     import rostest
00058     global PID
00059     PID = os.getpid()
00060     f = open("/tmp/%d-openrtm-sample.cpp"%(PID),'w')
00061     f.write(code)
00062     f.close()
00063     rostest.rosrun(PKG, 'test_openrtm_aist', TestCompile) 
00064 
00065 
00066 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Oct 6 2014 03:09:13