1# SPDX-License-Identifier: GPL-2.0
2# Copyright (C) 2020 Sean Anderson
3
4import pytest
5
6@pytest.mark.buildconfigspec('cmd_dm')
7def test_dm_compat(u_boot_console):
8    """Test that each driver in `dm tree` is also listed in `dm compat`."""
9    response = u_boot_console.run_command('dm tree')
10    driver_index = response.find('Driver')
11    assert driver_index != -1
12    drivers = (line[driver_index:].split()[0]
13               for line in response[:-1].split('\n')[2:])
14
15    response = u_boot_console.run_command('dm compat')
16    for driver in drivers:
17        assert driver in response
18
19@pytest.mark.buildconfigspec('cmd_dm')
20def test_dm_drivers(u_boot_console):
21    """Test that each driver in `dm compat` is also listed in `dm drivers`."""
22    response = u_boot_console.run_command('dm compat')
23    drivers = (line[:20].rstrip() for line in response[:-1].split('\n')[2:])
24    response = u_boot_console.run_command('dm drivers')
25    for driver in drivers:
26        assert driver in response
27
28@pytest.mark.buildconfigspec('cmd_dm')
29def test_dm_static(u_boot_console):
30    """Test that each driver in `dm static` is also listed in `dm drivers`."""
31    response = u_boot_console.run_command('dm static')
32    drivers = (line[:25].rstrip() for line in response[:-1].split('\n')[2:])
33    response = u_boot_console.run_command('dm drivers')
34    for driver in drivers:
35        assert driver in response
36