def setUp(self):
     """
     initializes self.config and xmlrpc infrastructure
     """
     self._start_infrastructure()
     self.master = Master(port=self.port)
     self.master.start()
     self.config.master.uri = self.master.uri
     self._init_runner()
class ROSTestLaunchParent(roslaunch.parent.ROSLaunchParent):
    def __init__(self, config, roslaunch_files, port=0):
        if config is None:
            raise Exception("config not initialized")
        # we generate a run_id for each test
        run_id = roslaunch.core.generate_run_id()
        super(ROSTestLaunchParent, self).__init__(run_id,
                                                  roslaunch_files,
                                                  is_core=False,
                                                  is_rostest=True)
        self.config = config
        self.port = port
        self.master = None

    def _load_config(self):
        # disable super, just in case, though this shouldn't get called
        pass

    def setUp(self):
        """
        initializes self.config and xmlrpc infrastructure
        """
        self._start_infrastructure()
        self.master = Master(port=self.port)
        self.master.start()
        self.config.master.uri = self.master.uri
        self._init_runner()

    def tearDown(self):
        if self.runner is not None:
            runner = self.runner
            runner.stop()
        if self.master is not None:
            self.master.stop()
            self.master = None
        self._stop_infrastructure()

    def launch(self):
        """
        perform launch of nodes, does not launch tests.  rostest_parent
        follows a different pattern of init/run than the normal
        roslaunch, which is why it does not reuse start()/spin()
        """
        if self.runner is not None:
            return self.runner.launch()
        else:
            raise Exception("no runner to launch")

    def run_test(self, test):
        """
        run the test, blocks until completion 
        """
        if self.runner is not None:
            # run the test, blocks until completion
            return self.runner.run_test(test)
        else:
            raise Exception("no runner")
Beispiel #3
0
class ROSTestLaunchParent(roslaunch.parent.ROSLaunchParent):

    def __init__(self, config, roslaunch_files, port=0):
        if config is None:
            raise Exception("config not initialized")
        # we generate a run_id for each test
        run_id = roslaunch.core.generate_run_id()
        super(ROSTestLaunchParent, self).__init__(run_id, roslaunch_files, is_core=False, is_rostest=True)
        self.config = config
        self.port = port
        self.master = None
        
    def _load_config(self):
        # disable super, just in case, though this shouldn't get called
        pass

    def setUp(self):
        """
        initializes self.config and xmlrpc infrastructure
        """
        self._start_infrastructure()
        self.master = Master(port=self.port)
        self.master.start()
        self.config.master.uri = self.master.uri
        self._init_runner()

    def tearDown(self):
        if self.runner is not None:
            runner = self.runner
            runner.stop()
        if self.master is not None:
            self.master.stop()
            self.master = None
        self._stop_infrastructure()

    def launch(self):
        """
        perform launch of nodes, does not launch tests.  rostest_parent
        follows a different pattern of init/run than the normal
        roslaunch, which is why it does not reuse start()/spin()
        """
        if self.runner is not None:
            return self.runner.launch()
        else:
            raise Exception("no runner to launch")

    def run_test(self, test):
        """
        run the test, blocks until completion 
        """
        if self.runner is not None:
            # run the test, blocks until completion            
            return self.runner.run_test(test)
        else:
            raise Exception("no runner")
Beispiel #4
0
 def setUp(self):
     """
     initializes self.config and xmlrpc infrastructure
     """
     self._start_infrastructure()
     self.master = Master(port=self.port)
     self.master.start()
     self.config.master.uri = self.master.uri
     self._init_runner()
Beispiel #5
0
class ROSTestLaunchParent(roslaunch.parent.ROSLaunchParent):

    def __init__(self, config, roslaunch_files, port=0, reuse_master=False, clear=False):
        if config is None:
            raise Exception("config not initialized")
        # we generate a run_id for each test
        if reuse_master:
            param_server = rosgraph.Master('/roslaunch')
            try:
                run_id = param_server.getParam('/run_id')
            except Exception as e:
                # The user asked us to connect to an existing ROS master, and
                # we can't. Throw an exception and die
                raise Exception("Could not connect to existing ROS master. "
                                + "Original exception was: %s" % str(e))
            except:
                # oh boy; we got something that wasn't an exception.
                # Throw an exception and die
                raise Exception("Could not connect to existing ROS master.")

            if clear:
                params = param_server.getParamNames()
                # whitelist of parameters to keep
                whitelist = ['/run_id', '/rosversion', '/rosdistro']
                for i in reversed(range(len(params))):
                    param = params[i]
                    if param in whitelist:
                        del params[i]
                    elif param.startswith('/roslaunch/'):
                        del params[i]
                for param in params:
                    param_server.deleteParam(param)
        else:
            run_id = roslaunch.core.generate_run_id()
        super(ROSTestLaunchParent, self).__init__(run_id, roslaunch_files, is_core=False, is_rostest=True)
        self.config = config
        self.port = port
        self.reuse_master = reuse_master
        self.master = None
        
    def _load_config(self):
        # disable super, just in case, though this shouldn't get called
        pass

    def setUp(self):
        """
        initializes self.config and xmlrpc infrastructure
        """
        self._start_infrastructure()
        if not self.reuse_master:
            self.master = Master(port=self.port)
            self.master.start()
            self.config.master.uri = self.master.uri
        self._init_runner()

    def tearDown(self):
        if self.runner is not None:
            runner = self.runner
            runner.stop()
        if self.master is not None:
            self.master.stop()
            self.master = None
        self._stop_infrastructure()

    def launch(self):
        """
        perform launch of nodes, does not launch tests.  rostest_parent
        follows a different pattern of init/run than the normal
        roslaunch, which is why it does not reuse start()/spin()
        """
        if self.runner is not None:
            return self.runner.launch()
        else:
            raise Exception("no runner to launch")

    def run_test(self, test):
        """
        run the test, blocks until completion 
        """
        if self.runner is not None:
            # run the test, blocks until completion            
            return self.runner.run_test(test)
        else:
            raise Exception("no runner")