1# SPDX-License-Identifier: GPL-2.0
2# Copyright (c) 2015 Stephen Warren
3# Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
4
5import pytest
6
7@pytest.mark.buildconfigspec('cmd_help')
8def test_help(ubman):
9    """Test that the "help" command can be executed."""
10
11    lines = ubman.run_command('help')
12    if ubman.config.buildconfig.get('config_cmd_2048', 'n') == 'y':
13        assert lines.splitlines()[0] == "2048      - The 2048 game"
14    else:
15        assert lines.splitlines()[0] == "?         - alias for 'help'"
16
17@pytest.mark.boardspec('sandbox')
18def test_help_no_devicetree(ubman):
19    try:
20        ubman.restart_uboot_with_flags([], use_dtb=False)
21        ubman.run_command('help')
22        output = ubman.get_spawn_output().replace('\r', '')
23        assert 'print command description/usage' in output
24    finally:
25        # Restart afterward to get the normal device tree back
26        ubman.restart_uboot()
27
28@pytest.mark.boardspec('sandbox_vpl')
29def test_vpl_help(ubman):
30    try:
31        ubman.restart_uboot()
32        ubman.run_command('help')
33        output = ubman.get_spawn_output().replace('\r', '')
34        assert 'print command description/usage' in output
35    finally:
36        # Restart afterward to get the normal device tree back
37        ubman.restart_uboot()
38