Пример #1
0
    def run(self, env, json_writer):
        '''
        Schedule all tests in profile for execution.

        See ``Test.schedule`` and ``Test.run``.
        '''
        self.prepare_test_list(env)

        self.pre_run_hook()
        framework.exectest.Test.ENV = env

        chunksize = 1

        self.prepare_test_list(env)
        log = Log(len(self.test_list), env.verbose)

        def test(pair):
            """ Function to call test.execute from .map

            adds env and json_writer which are needed by Test.execute()

            """
            name, test = pair
            test.execute(name, log, json_writer, self.dmesg)

        def run_threads(pool, testlist):
            """ Open a pool, close it, and join it """
            pool.imap(test, testlist, chunksize)
            pool.close()
            pool.join()

        # Multiprocessing.dummy is a wrapper around Threading that provides a
        # multiprocessing compatible API
        #
        # The default value of pool is the number of virtual processor cores
        single = multiprocessing.dummy.Pool(1)
        multi = multiprocessing.dummy.Pool()

        if env.concurrent == "all":
            run_threads(multi, self.test_list.iteritems())
        elif env.concurrent == "none":
            run_threads(single, self.test_list.iteritems())
        else:
            # Filter and return only thread safe tests to the threaded pool
            run_threads(
                multi,
                (x for x in self.test_list.iteritems() if x[1].run_concurrent))
            # Filter and return the non thread safe tests to the single pool
            run_threads(single, (x for x in self.test_list.iteritems()
                                 if not x[1].run_concurrent))

        log.summary()

        self.post_run_hook()
Пример #2
0
    def run(self, env, json_writer):
        """
        Schedule all tests in profile for execution.

        See ``Test.schedule`` and ``Test.run``.
        """
        self.prepare_test_list(env)

        self.pre_run_hook()
        framework.exectest.Test.ENV = env

        chunksize = 1

        self.prepare_test_list(env)
        log = Log(len(self.test_list), env.verbose)

        def test(pair):
            """ Function to call test.execute from .map

            adds env and json_writer which are needed by Test.execute()

            """
            name, test = pair
            test.execute(name, log, json_writer, self.dmesg)

        def run_threads(pool, testlist):
            """ Open a pool, close it, and join it """
            pool.imap(test, testlist, chunksize)
            pool.close()
            pool.join()

        # Multiprocessing.dummy is a wrapper around Threading that provides a
        # multiprocessing compatible API
        #
        # The default value of pool is the number of virtual processor cores
        single = multiprocessing.dummy.Pool(1)
        multi = multiprocessing.dummy.Pool()

        if env.concurrent == "all":
            run_threads(multi, self.test_list.iteritems())
        elif env.concurrent == "none":
            run_threads(single, self.test_list.iteritems())
        else:
            # Filter and return only thread safe tests to the threaded pool
            run_threads(multi, (x for x in self.test_list.iteritems() if x[1].run_concurrent))
            # Filter and return the non thread safe tests to the single pool
            run_threads(single, (x for x in self.test_list.iteritems() if not x[1].run_concurrent))

        log.summary()

        self.post_run_hook()
Пример #3
0
    def run(self, opts, backend):
        """ Runs all tests using Thread pool

        When called this method will flatten out self.tests into
        self.test_list, then will prepare a logger, pass opts to the Test
        class, and begin executing tests through it's Thread pools.

        Based on the value of opts.concurrent it will either run all the tests
        concurrently, all serially, or first the thread safe tests then the
        serial tests.

        Finally it will print a final summary of the tests

        Arguments:
        opts -- a core.Options instance
        backend -- a results.Backend derived instance
        

        """

        self._pre_run_hook()
        framework.exectest.Test.OPTS = opts

        chunksize = 1

        self._prepare_test_list(opts)
        log = Log(len(self.test_list), opts.verbose)

        def test(pair):
            """ Function to call test.execute from .map

            Adds opts which are needed by Test.execute()

            """
            name, test = pair
            test.execute(name, log, self.dmesg)
            backend.write_test(name, test.result)

        def run_threads(pool, testlist):
            """ Open a pool, close it, and join it """
            pool.imap(test, testlist, chunksize)
            pool.close()
            pool.join()

        # Multiprocessing.dummy is a wrapper around Threading that provides a
        # multiprocessing compatible API
        #
        # The default value of pool is the number of virtual processor cores
        single = multiprocessing.dummy.Pool(1)
        multi = multiprocessing.dummy.Pool()

        if opts.concurrent == "all":
            run_threads(multi, self.test_list.iteritems())
        elif opts.concurrent == "none":
            run_threads(single, self.test_list.iteritems())
        else:
            # Filter and return only thread safe tests to the threaded pool
            run_threads(multi, (x for x in self.test_list.iteritems()
                                if x[1].run_concurrent))
            # Filter and return the non thread safe tests to the single pool
            run_threads(single, (x for x in self.test_list.iteritems()
                                 if not x[1].run_concurrent))

        log.summary()

        self._post_run_hook()
Пример #4
0
    def run(self, opts, json_writer):
        """ Runs all tests using Thread pool

        When called this method will flatten out self.tests into
        self.test_list, then will prepare a logger, pass opts to the Test
        class, and begin executing tests through it's Thread pools.

        Based on the value of opts.concurrent it will either run all the tests
        concurrently, all serially, or first the thread safe tests then the
        serial tests.

        Finally it will print a final summary of the tests

        Arguments:
        opts -- a core.Options instance
        json_writer -- a core.JSONWriter instance

        """

        self._pre_run_hook()
        framework.exectest.Test.OPTS = opts

        chunksize = 1

        self._prepare_test_list(opts)
        log = Log(len(self.test_list), opts.verbose)

        def test(pair):
            """ Function to call test.execute from .map

            Adds opts and json_writer which are needed by Test.execute()

            """
            name, test = pair
            test.execute(name, log, json_writer, self.dmesg)

        def run_threads(pool, testlist):
            """ Open a pool, close it, and join it """
            pool.imap(test, testlist, chunksize)
            pool.close()
            pool.join()

        # Multiprocessing.dummy is a wrapper around Threading that provides a
        # multiprocessing compatible API
        #
        # The default value of pool is the number of virtual processor cores
        single = multiprocessing.dummy.Pool(1)
        multi = multiprocessing.dummy.Pool()

        if opts.concurrent == "all":
            run_threads(multi, self.test_list.iteritems())
        elif opts.concurrent == "none":
            run_threads(single, self.test_list.iteritems())
        else:
            # Filter and return only thread safe tests to the threaded pool
            run_threads(
                multi,
                (x for x in self.test_list.iteritems() if x[1].run_concurrent))
            # Filter and return the non thread safe tests to the single pool
            run_threads(single, (x for x in self.test_list.iteritems()
                                 if not x[1].run_concurrent))

        log.summary()

        self._post_run_hook()