$search
00001 #!/usr/bin/env python 00002 # Software License Agreement (BSD License) 00003 # 00004 # Copyright (c) 2011, Willow Garage, Inc. 00005 # All rights reserved. 00006 # 00007 # Redistribution and use in source and binary forms, with or without 00008 # modification, are permitted provided that the following conditions 00009 # are met: 00010 # 00011 # * Redistributions of source code must retain the above copyright 00012 # notice, this list of conditions and the following disclaimer. 00013 # * Redistributions in binary form must reproduce the above 00014 # copyright notice, this list of conditions and the following 00015 # disclaimer in the documentation and/or other materials provided 00016 # with the distribution. 00017 # * Neither the name of Willow Garage, Inc. nor the names of its 00018 # contributors may be used to endorse or promote products derived 00019 # from this software without specific prior written permission. 00020 # 00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 # POSSIBILITY OF SUCH DAMAGE. 00033 # 00034 # Revision $Id: test_nodeprocess.py 11927 2010-10-27 08:48:11Z kwc $ 00035 00036 PKG = 'test_roslaunch' 00037 NAME = 'test_version' 00038 00039 import roslib; roslib.load_manifest(PKG) 00040 00041 import roslib.stacks 00042 00043 import os 00044 import sys 00045 import unittest 00046 import re 00047 00048 def get_ros_comm_version(): 00049 d = roslib.stacks.get_stack_dir('ros_comm') 00050 cmake_p = os.path.join(d, 'CMakeLists.txt') 00051 with open(cmake_p) as f: 00052 text = f.read() 00053 for l in text.split('\n'): 00054 if l.strip().startswith('rosbuild_make_distribution'): 00055 x_re = re.compile(r'[()]') 00056 lsplit = x_re.split(l.strip()) 00057 if len(lsplit) < 2: 00058 raise Exception("couldn't find version number in CMakeLists.txt:\n\n%s"%l) 00059 return lsplit[1] 00060 raise Exception("could not locate version number in stack CMakeLists.txt") 00061 00062 class TestCoreVersion(unittest.TestCase): 00063 00064 def test_version(self): 00065 import roslib.packages 00066 import roslaunch.config 00067 import roslaunch.xmlloader 00068 00069 # make sure roscore version is consistent with rosversion 00070 rosversion = get_ros_comm_version() 00071 00072 loader = roslaunch.xmlloader.XmlLoader() 00073 config = roslaunch.config.ROSLaunchConfig() 00074 d = roslib.packages.get_pkg_dir('roslaunch') 00075 filename = os.path.join(d, 'roscore.xml') 00076 loader.load(filename, config) 00077 core_version = config.params['/rosversion'].value 00078 00079 self.assertEquals(rosversion, core_version) 00080 00081 if __name__ == '__main__': 00082 import rostest 00083 rostest.unitrun('test_roslaunch', NAME, TestCoreVersion, coverage_packages=[]) 00084