Exemplo n.º 1
0
    def __call__(self, log, *args, **kwargs):
        board = boards.detect()

        if not hasattr(board, 'eeproms'):
            raise runner.Error()

        if 'module' in board.eeproms:
            device = board.eeproms['module']
            buf = io.StringIO()

            eeprom = system.EEPROM(device.sysfs)

            log.debug('module ID EEPROM:')
            eeprom.dump(output = buf)
            buf.seek(0, io.SEEK_SET)

            for line in buf:
                log.debug('  %s' % line.rstrip())

        if 'system' in board.eeproms:
            device = board.eeproms['system']
            buf = io.StringIO()

            try:
                eeprom = system.EEPROM(device.sysfs)
            except Exception as e:
                log.info('ERROR:', e)

            log.debug('system ID EEPROM:')
            eeprom.dump(output = buf)
            buf.seek(0, io.SEEK_SET)

            for line in buf:
                log.debug('  %s' % line.rstrip())
Exemplo n.º 2
0
    def __call__(self, log, *args, **kwargs):
        fbcon = None

        for console in sysfs.enumerate(subsystem='vtconsole'):
            with console.open('name', 'r') as f:
                for line in f:
                    line = line.strip()
                    if line.endswith('frame buffer device'):
                        log.debug('found:', console.path)
                        fbcon = console
                        break

            if fbcon:
                break
        else:
            raise runner.Error('framebuffer console not found')

        log.debug('framebuffer console found:', console.path)

        time.sleep(1)

        with console.open('bind', 'w') as f:
            log.debug('unbinding %s...' % console.path)
            f.write('0')

        time.sleep(1)

        with console.open('bind', 'w') as f:
            log.debug('binding %s...' % console.path)
            f.write('1')
Exemplo n.º 3
0
    def __call__(self, log, *args, **kwargs):
        board = boards.detect()
        kernel = system.Kernel()
        count = 0

        if hasattr(board, 'allowlist'):
            allowlist = util.AllowList(board.allowlist)
        else:
            allowlist = None

        with kmsg.open('/dev/kmsg') as dmesg:
            for entry in dmesg:
                if entry.header.facility == kmsg.LOG_KERN and \
                   entry.header.level <= kmsg.LOG_WARNING:
                    if not allowlist or entry not in allowlist:
                        log.debug(entry)
                        count += 1

        if allowlist:
            unmatched = allowlist.unmatched()

            for pattern in unmatched:
                log.debug('pattern \'%s\' had no matches' % pattern)

        if count > 0:
            andor = 'and/or' if count > 1 else 'or'
            plural = 's' if count > 1 else ''

            raise runner.Error(
                '%u warning%s %s error%s found in the kernel log' %
                (count, plural, andor, plural))
Exemplo n.º 4
0
    def __call__(self, log, *args, **kwargs):
        board = boards.detect()
        kernel = system.Kernel()
        count = 0

        if hasattr(board, 'whitelist'):
            whitelist = util.WhiteList(board.whitelist)
        else:
            whitelist = None

        with kmsg.open('/dev/kmsg') as dmesg:
            for entry in dmesg:
                if entry.header.facility == kmsg.LOG_KERN and \
                   entry.header.level <= kmsg.LOG_WARNING:
                    if not whitelist or entry not in whitelist:
                        log.debug(entry)
                        count += 1

        if count > 0:
            andor = 'and/or' if count > 1 else 'or'
            plural = 's' if count > 1 else ''

            raise runner.Error(
                '%u warning%s %s error%s found in the kernel log' %
                (count, plural, andor, plural))
Exemplo n.º 5
0
def emc_legacy(log, *args, **kwargs):
    def set_rate(rate):
        with debugfs.open('emc/rate', 'w') as f:
            f.write(rate)

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

    supported_rates = []
    errors = 0

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

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

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

    log.debug('- supported rates: (* = current)')

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

    log.debug('- testing:')

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

        actual = set_rate(rate)
        if actual != rate:
            log.cont('reported %s' % actual)
            errors += 1
        else:
            log.cont('done')

    log.debug('- resetting to old rate: %s...' % current, end='')

    actual = set_rate(current)
    if actual != current:
        log.cont('reported %s' % actual)
    else:
        log.cont()

    if errors != 0:
        raise runner.Error('not all rate changes succeeded')
Exemplo n.º 6
0
    def __call__(self, log, *args, **kwargs):
        board = boards.detect()
        failed = False

        log.debug('board:', board.name)

        for device in board.devices:
            path = os.path.join('/sys', 'bus', device.bus, 'devices',
                                device.name)

            log.debug('  device: %s ... ' % path, end='', flush=True)

            if os.path.exists(path):
                log.cont('exists')
            else:
                log.cont('failed')
                failed = True
                continue

            path = os.path.join(path, 'driver')

            if os.path.exists(path):
                path = os.path.realpath(path)
                driver = os.path.basename(path)

                log.debug('    bound: %s ... ' % driver, end='', flush=True)

                if driver != device.driver:
                    log.cont('failed')
                    failed = True
                else:
                    log.cont('done')
            else:
                log.debug('unbound')

                if device.driver:
                    failed = True

        if failed:
            raise runner.Error()
Exemplo n.º 7
0
def emc_modern(log, *args, **kwargs):
    def get_rate():
        with debugfs.open('clk/emc/clk_rate', 'r') as fobj:
            current = int(fobj.read().strip())

        with debugfs.open('emc/min_rate', 'r') as fobj:
            min_rate = int(fobj.read().strip())

        with debugfs.open('emc/max_rate', 'r') as fobj:
            max_rate = int(fobj.read().strip())

        return current, min_rate, max_rate

    def set_rate(min_rate, max_rate):
        current, lower, upper = get_rate()

        #
        # If an attempt is made to set the minimum rate higher than the
        # currently configured maximum rate, the common clock framework will
        # return an error because the new range would be invalid.
        #
        # Fix this by updating the maximum rate before the minimum rate in
        # that case.
        #
        if min_rate > upper:
            with debugfs.open('emc/max_rate', 'w') as fobj:
                fobj.write('%u' % max_rate)

        with debugfs.open('emc/min_rate', 'w') as fobj:
            fobj.write('%u' % min_rate)

        #
        # If the new minimum rate is lower than the currently configured
        # maximum rate, it's safe to write the maximum rate second.
        #
        if min_rate <= upper:
            with debugfs.open('emc/max_rate', 'w') as fobj:
                fobj.write('%u' % max_rate)

        #
        # Read the actual clock rate from the standard debugfs files. This
        # should always be within the range given by the minimum and maximum
        # rates.
        #
        with debugfs.open('clk/emc/clk_rate', 'r') as fobj:
            rate = int(fobj.read().strip())

        return rate

    available_rates = []
    errors = 0

    with debugfs.open('emc/available_rates', 'r') as fobj:
        for line in fobj:
            rates = [int(rate) for rate in line.strip().split()]
            available_rates.extend(rates)

    width = max([len(str(x)) for x in available_rates])

    current, min_rate, max_rate = get_rate()

    log.debug('- available rates: (* = current)')

    for rate in available_rates:
        if rate == current:
            log.debug('  - %*u' % (width, rate), '*')
        else:
            log.debug('  - %*u' % (width, rate))

    log.debug('- testing:')

    for rate in available_rates:
        log.debug('  - %*u...' % (width, rate), end='')

        actual = set_rate(rate, rate)
        if actual != rate:
            log.cont('reported %u' % actual)
            errors += 1
        else:
            log.cont('done')

    log.debug('- resetting rate: %u...' % current, end='')

    actual = set_rate(current, current)
    if actual != current:
        log.cont('reported %u' % actual)
    else:
        log.cont('done')

    log.debug('- resetting range: %u-%u...' % (min_rate, max_rate), end='')

    actual = set_rate(min_rate, max_rate)
    if actual != current:
        log.cont('reported %u' % actual)
    else:
        log.cont('done')

    if errors != 0:
        raise runner.Error('not all rate changes succeeded')
Exemplo n.º 8
0
    def __call__(self, log, *args, **kwargs):
        failures = 0

        try:
            v4l2_ctl = find_executable('v4l2-ctl')
        except FileNotFoundError as e:
            raise runner.Skip(e.message)

        # XXX parameterize stream index
        bus = sysfs.Bus('host1x')
        dev = bus.device('tegra-video')
        cls = dev.child('video4linux')

        for child in cls:
            path = os.path.join(os.path.sep, 'dev', child.uevent['DEVNAME'])
            device = V4L2Device(path)

            log.debug('testing device %s:' % path)

            for (width, height,
                 pixelformat), checksum in sanity.formats.items():
                fmt = 'width=%u,height=%u,pixelformat=%s' % (width, height,
                                                             pixelformat)

                log.debug('  - capturing frame at %ux%u (%s)...' %
                          (width, height, pixelformat),
                          end='',
                          flush=True)

                filename = 'tpg-%ux%u-%s.raw' % (width, height,
                                                 pixelformat.lower())

                command = [
                    v4l2_ctl,
                    '--set-fmt-video=%s' % fmt, '--set-ctrl', 'test_pattern=1',
                    '--stream-count=1', '--stream-mmap',
                    '--device=%s' % device.path,
                    '--stream-to=%s' % filename
                ]

                proc = subprocess.run(command, capture_output=True)
                if proc.returncode != 0:
                    log.cont('failed')
                    log.debug('proc:', proc)
                    failures += 1
                    continue

                log.cont('done')

                log.debug('    - %u bytes captured' %
                          os.path.getsize(filename))
                log.debug('    - checksum...', end='', flush=True)

                digest = hashlib.md5()

                with open(filename, 'rb') as fobj:
                    digest.update(fobj.read())

                if digest.hexdigest() != checksum:
                    log.cont('failed')
                    failures += 1
                else:
                    log.cont('okay')

        if failures > 0:
            raise runner.Error()
Exemplo n.º 9
0
    def __call__(self, log, *args, **kwargs):
        cpuset = system.CPUSet()
        failed = False

        # output supported governors and frequencies
        for cpu in cpuset:
            log.debug('- CPU#%u:' % cpu.num)

            cpu = cpufreq.CPU(cpu.num)

            log.debug('  - supported governors:')

            for governor in cpu.supported_governors:
                if governor == cpu.governor:
                    log.debug('    - %s *' % governor)
                else:
                    log.debug('    - %s' % governor)

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

            log.debug('  - supported rates:')

            for rate in cpu.supported_rates:
                if rate == cpu.rate:
                    log.debug('    - %*s' % (width, rate), '*')
                else:
                    log.debug('    - %*s' % (width, rate))

        # test each frequency on each CPU
        for cpu in cpuset:
            log.debug('- CPU#%u' % cpu.num)
            cpu = cpufreq.CPU(cpu.num)

            log.debug('  - switching to userspace governor...', end='')

            if 'userspace' not in cpu.supported_governors:
                log.cont('skip')
                continue

            governor = cpu.governor

            try:
                cpu.governor = 'userspace'
            except Exception as e:
                log.cont('fail (%s)' % e)
                failed = True
                continue
            else:
                log.cont('done')

            for rate in cpu.supported_rates:
                log.debug('  - setting rate %s...' % rate, end='')

                try:
                    cpu.rate = rate
                except Exception as e:
                    log.cont('fail (%s)' % e)
                    failed = True
                else:
                    log.cont('done')

            log.debug('  - restoring %s governor...' % governor, end='')

            try:
                cpu.governor = governor
            except Exception as e:
                log.cont('fail (%s)' % e)
                failed = True
            else:
                log.cont('done')

        if failed:
            raise runner.Error()
Exemplo n.º 10
0
    def __call__(self, log, *args, **kwargs):
        board = boards.detect()
        failed = False

        log.debug('board:', board.name)

        for device in board.devices:
            path = os.path.join('/sys', 'bus', device.bus, 'devices',
                                device.name)

            log.debug('  device: %s ... ' % path, end='', flush=True)

            if os.path.exists(path):
                log.cont('exists')
            else:
                log.cont('failed')
                failed = True
                continue

            path = os.path.join(path, 'driver')

            if os.path.exists(path):
                path = os.path.realpath(path)
                driver = os.path.basename(path)

                log.debug('    bound: %s ... ' % driver, end='', flush=True)

                if isinstance(device.driver, str):
                    drivers = [device.driver]
                else:
                    drivers = device.driver

                for match in drivers:
                    if driver == match:
                        log.cont('done')
                        break
                else:
                    log.cont('failed')
                    failed = True
            else:
                log.debug('    unbound')

                if device.driver:
                    failed = True

        # no devices should be left in the deferred probe pending list
        if debugfs.exists('devices_deferred'):
            count = 0

            log.debug('deferred:')

            with debugfs.open('devices_deferred', 'r') as devices:
                for line in devices:
                    log.debug('  deferred: %s' % line.strip())
                    count += 1

            if count == 0:
                log.debug('  none')
            else:
                failed = True

        if failed:
            raise runner.Error()