Example #1
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')
Example #2
0
 def stopTest(self, test):
     super().stopTest(test)
     sys.stderr = self.stderr
     sys.stdout = self.stdout
     log.end()
Example #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()