00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 import roslib; roslib.load_manifest('test_rosdep')
00033
00034 import os
00035 import struct
00036 import sys
00037 import unittest
00038 import subprocess
00039 import shutil
00040 import tempfile
00041
00042 import rosunit
00043 import rosdep.core
00044
00045
00046 class RosdepCommandlineTest(unittest.TestCase):
00047 """ Basic Tripwire Testing"""
00048
00049
00050
00051 def test_Rosdep_commandline_satisfy(self):
00052 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "test_rosdep"]))
00053 self.assertEqual(0,subprocess.call(["rosdep", "generate_bash", "test_rosdep"]))
00054 def test_Rosdep_commandline_satisfy_y(self):
00055 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "-y", "test_rosdep", "rosdep"]))
00056 def test_Rosdep_commandline_satisfy_multiple(self):
00057 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "test_rosdep", "rosdep"]))
00058 def test_Rosdep_commandline_check(self):
00059 self.assertEqual(0,subprocess.call(["rosdep", "check", "test_rosdep"]))
00060 def test_Rosdep_commandline_what_needs(self):
00061 self.assertEqual(0,subprocess.call(["rosdep", "what_needs", "boost"]))
00062 def test_Rosdep_commandline_where_defined(self):
00063 self.assertEqual(0,subprocess.call(["rosdep", "where_defined", "boost"]))
00064
00065
00066 class RosdepCommandlineExternalPackages(unittest.TestCase):
00067
00068 def setUp(self):
00069 self.tempdir = tempfile.mkdtemp()
00070 shutil.copytree(os.path.join(roslib.packages.get_pkg_dir('test_rosdep'),
00071 'embedded_test_packages'),
00072 self.tempdir+"/packges")
00073
00074 self.env = os.environ
00075 self.env['ROS_PACKAGE_PATH'] = self.tempdir+":"+self.env['ROS_PACKAGE_PATH']
00076 self.env['ROSDEP_DEBUG']='true'
00077
00078 def tearDown(self):
00079 shutil.rmtree(self.tempdir)
00080
00081 def test_check_legacy_apt(self):
00082 my_env = self.env.copy()
00083 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00084 self.assertEqual(0,subprocess.call(["rosdep", "check", "rosdep_legacy_apt"], env=my_env))
00085 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "rosdep_legacy_apt"], env=my_env))
00086 self.assertEqual(0,subprocess.call(["rosdep", "install", "rosdep_legacy_apt"], env=my_env))
00087
00088
00089 def test_apt(self):
00090 my_env = self.env.copy()
00091 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00092 self.assertEqual(0,subprocess.call(["rosdep", "check", "rosdeptest"], env=my_env))
00093 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "rosdeptest"], env=my_env))
00094 self.assertEqual(0,subprocess.call(["rosdep", "install", "rosdeptest"], env=my_env))
00095
00096 def REMOVED_UNTIL_PIP_IN_DEFAULT_test_pip(self):
00097 my_env = self.env.copy()
00098 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00099 self.assertEqual(0,subprocess.call(["rosdep", "check", "rosdep_pip_test"], env=my_env))
00100 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "rosdep_pip_test"], env=my_env))
00101 self.assertEqual(0,subprocess.call(["rosdep", "install", "rosdep_pip_test"], env=my_env))
00102
00103 def test_check_test_missing(self):
00104 my_env = self.env.copy()
00105 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00106 self.assertEqual(1,subprocess.call(["rosdep", "check", "rosdep_test_missing"], env=my_env))
00107 self.assertEqual(1,subprocess.call(["rosdep", "satisfy", "rosdep_test_missing"], env=my_env))
00108 self.assertEqual(1,subprocess.call(["rosdep", "install", "rosdep_test_missing"], env=my_env))
00109
00110 def test_source(self):
00111 my_env = self.env.copy()
00112 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00113 try:
00114 os.remove('/tmp/test_sourcedep_installed')
00115 except:
00116 pass
00117 self.assertEqual(1,subprocess.call(["rosdep", "check", "rosdep_source"], env=my_env))
00118 self.assertEqual(1,subprocess.call(["rosdep", "satisfy", "rosdep_source"], env=my_env))
00119 self.assertEqual(0,subprocess.call(["rosdep", "install", "rosdep_source"], env=my_env))
00120 self.assertEqual(0,subprocess.call(["rosdep", "check", "rosdep_source"], env=my_env))
00121 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "rosdep_source"], env=my_env))
00122
00123
00124 def test_md5_source(self):
00125 my_env = self.env.copy()
00126 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00127 try:
00128 os.remove('/tmp/test_sourcedep_installed')
00129 except:
00130 pass
00131 self.assertEqual(1,subprocess.call(["rosdep", "check", "rosdep_md5_source"], env=my_env))
00132 self.assertEqual(1,subprocess.call(["rosdep", "satisfy", "rosdep_md5_source"], env=my_env))
00133 self.assertEqual(0,subprocess.call(["rosdep", "install", "rosdep_md5_source"], env=my_env))
00134 self.assertEqual(0,subprocess.call(["rosdep", "check", "rosdep_md5_source"], env=my_env))
00135 self.assertEqual(0,subprocess.call(["rosdep", "satisfy", "rosdep_md5_source"], env=my_env))
00136
00137 def test_invalid_md5_source(self):
00138 my_env = self.env.copy()
00139 my_env['ROS_OS_OVERRIDE']='ubuntu:lucid'
00140 try:
00141 os.remove('/tmp/test_sourcedep_installed')
00142 except:
00143 pass
00144 self.assertEqual(1,subprocess.call(["rosdep", "check", "rosdep_invalid_md5_source"], env=my_env))
00145 self.assertEqual(1,subprocess.call(["rosdep", "satisfy", "rosdep_invalid_md5_source"], env=my_env))
00146 self.assertEqual(1,subprocess.call(["rosdep", "install", "rosdep_invalid_md5_source"], env=my_env))
00147
00148
00149 if __name__ == '__main__':
00150 rosunit.unitrun('test_rosdep', 'test_commandline', RosdepCommandlineTest, coverage_packages=['rosdep.commandline'])
00151 rosunit.unitrun('test_rosdep', 'test_commandline', RosdepCommandlineExternalPackages, coverage_packages=['rosdep.commandline'])
00152