Exemplo n.º 1
0
    def startTest(self, test):
        self.stdout = sys.stdout
        self.stderr = sys.stderr

        if self.verbosity > 0:
            log.begin('running: %s (%s)' % (strclass(test.__class__),
                                            test._testMethodName),
                      end = '\n')
            sys.stdout = RedirectOutput(sys.stdout)
            sys.stderr = RedirectOutput(sys.stderr)
        else:
            log.begin('running: %s (%s)' % (strclass(test.__class__),
                                            test._testMethodName))
            sys.stdout = None
            sys.stderr = None

        super().startTest(test)
Exemplo n.º 2
0
    def test_set_rates(self):
        supported_rates = []
        errors = 0

        print('EMC frequency scaling:')
        print('======================')

        with debugfs.open('emc/supported_rates') as f:
            for line in f:
                supported_rates.extend(line.split())

        width = max([len(x) for x in supported_rates])

        with debugfs.open('emc/rate') as f:
            current = f.read().strip()

        print('- supported rates: (* = current)');

        for rate in supported_rates:
            if rate == current:
                print('  - %*s' % (width, rate), '*')
            else:
                print('  - %*s' % (width, rate))

        print('- testing:')

        for rate in supported_rates:
            log.begin('  - %*s...' % (width, rate))

            actual = emc_set_rate(rate)
            if actual != rate:
                log.end('reported %s' % actual)
                errors += 1
            else:
                log.end()

        log.begin('- resetting to old rate: %s...' % current)

        actual = emc_set_rate(current)
        if actual != current:
            log.end('reported %s' % actual)
        else:
            log.end()

        self.longMessage = False
        self.assertEqual(errors, 0, 'not all rate changes succeeded')
Exemplo n.º 3
0
    def test_set_rates(self):
        cpuset = system.CPUSet()

        for cpu in cpuset:
            print('- CPU#%u' % cpu.num)
            cpu = CPU(cpu.num)

            log.begin('  - switching to userspace governor')
            governor = cpu.governor

            try:
                cpu.governor = 'userspace'
            except Exception as e:
                log.end(e)
                continue
            else:
                log.end()

            for rate in cpu.supported_rates:
                log.begin('  - setting rate %s' % rate)

                try:
                    cpu.rate = rate
                except Exception as e:
                    log.end(e)
                else:
                    log.end()

            log.begin('  - restoring %s governor' % governor)

            try:
                cpu.governor = governor
            except Exception as e:
                log.end(e)
            else:
                log.end()