コード例 #1
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_post_log_removes_complete():
    """ Test that Log.post_log() removes finished tests from __running """
    log = Log(100, False)
    ret = log.pre_log()
    log.post_log(ret, 'pass')
    nt.assert_not_in(ret, log._Log__running,
                     msg="Running tests not removed from running list")
コード例 #2
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_pre_log_return():
    """ Test that pre_log returns a number """
    log = Log(100, False)

    ret = log.pre_log()
    nt.assert_true(isinstance(ret, (IntType, FloatType, LongType)),
                   msg="Log.pre_log() didn't return a numeric type!")
コード例 #3
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_post_log_increment_complete():
    """ Tests that Log.post_log() increments self.__complete """
    log = Log(100, False)
    ret = log.pre_log()
    log.post_log(ret, 'pass')
    nt.assert_equal(log._Log__complete, 1,
                    msg="Log.post_log() did not properly incremented "
                        "Log.__current")
コード例 #4
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def check_post_log_increment_summary(stat):
    """ Test that passing a result to post_log works correctly """
    log = Log(100, False)
    ret = log.pre_log()
    log.post_log(ret, stat)
    print log._Log__summary
    nt.assert_equal(log._Log__summary[stat], 1,
                    msg="Log.__summary[{}] was not properly "
                        "incremented".format(stat))
コード例 #5
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()
コード例 #6
0
ファイル: profile.py プロジェクト: Zoxc/piglit
    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()
コード例 #7
0
def log(global_config, logging_level):
    """
    Returns a logger that extends `logging` with the ability to take screenshots on error, a Slack integration, and a
    formatting helper.
    """
    slack_integration = Slack(global_config.urls.slack_webhook)
    return Log(slack_integration=slack_integration, level=logging_level)
コード例 #8
0
ファイル: profile.py プロジェクト: groleo/piglit
    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()
コード例 #9
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_post_log_increment_summary_bad():
    """ Only statuses in self.__summary_keys are valid for post_log """
    log = Log(100, False)
    ret = log.pre_log()
    log.post_log(ret, 'fails')
コード例 #10
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_initialize_log_verbose():
    """ Test that Log initializes with verbose=True """
    log = Log(100, True)
    assert log
コード例 #11
0
ファイル: log_tests.py プロジェクト: rafalmiel/piglit
def test_initialize_log_terse():
    """ Test that Log initializes with verbose=False """
    log = Log(100, False)
    assert log
コード例 #12
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()