import os
import subprocess

NODE = '/dev/dri/renderD128'


def udev_props(path):
    out = subprocess.check_output(['udevadm', 'info', '-qproperty', path]).decode('utf-8')
    props = {}
    for line in out.split('\n'):
        if not line.strip():
            continue
        k, v = line.strip().split('=', 1)
        props[k] = v
    return props


def test_render_node():
    "Test if we have a render node"
    assert(os.path.exists(NODE))


def test_etnaviv_node():
    "Test if the render node is etnaviv"
    props = udev_props(NODE)
    assert(props['ID_PATH'] == 'platform-etnaviv')
