# SPDX-License-Identifier:  GPL-2.0+
#
# Copyright (c) 2021 Adarsh Babu Kalepalli <opensource.kab@gmail.com>
# Copyright (c) 2020 Alex Kiernan <alex.kiernan@gmail.com>

import pytest
import time
import u_boot_utils

"""
	test_gpio_input is intended to test the fix 4dbc107f4683.
	4dbc107f4683:"cmd: gpio: Correct do_gpio() return value"
"""

@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_input(u_boot_console):
    """Test that gpio input correctly returns the value of a gpio pin."""

    response = u_boot_console.run_command('gpio input 0; echo rc:$?')
    expected_response = 'rc:0'
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio toggle 0; gpio input 0; echo rc:$?')
    expected_response = 'rc:1'
    assert(expected_response in response)

@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_exit_statuses(u_boot_console):
    """Test that non-input gpio commands correctly return the command
    success/failure status."""

    expected_response = 'rc:0'
    response = u_boot_console.run_command('gpio clear 0; echo rc:$?')
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio set 0; echo rc:$?')
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio toggle 0; echo rc:$?')
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio status -a; echo rc:$?')
    assert(expected_response in response)

    expected_response = 'rc:1'
    response = u_boot_console.run_command('gpio nonexistent-command; echo rc:$?')
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio input 200; echo rc:$?')
    assert(expected_response in response)

@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_read(u_boot_console):
    """Test that gpio read correctly sets the variable to the value of a gpio pin."""

    u_boot_console.run_command('gpio clear 0')
    response = u_boot_console.run_command('gpio read var 0; echo val:$var,rc:$?')
    expected_response = 'val:0,rc:0'
    assert(expected_response in response)
    response = u_boot_console.run_command('gpio toggle 0; gpio read var 0; echo val:$var,rc:$?')
    expected_response = 'val:1,rc:0'
    assert(expected_response in response)
    response = u_boot_console.run_command('setenv var; gpio read var nonexistent-gpio; echo val:$var,rc:$?')
    expected_response = 'val:,rc:1'
    assert(expected_response in response)

"""
Generic Tests for 'gpio' command on sandbox and real hardware.
The below sequence of tests rely on env__gpio_dev_config for configuration values of gpio pins.

 Configuration data for gpio command.
 The  set,clear,toggle ,input and status options of 'gpio' command are verified.
 For sake of verification,A  LED/buzzer could be connected to GPIO pins configured as O/P.
 Logic level '1'/'0' can be applied onto GPIO pins configured as I/P


env__gpio_dev_config = {
        #the number of 'gpio_str_x' strings should equal to
        #'gpio_str_count' value
        'gpio_str_count':4 ,
        'gpio_str_1': '0',
        'gpio_str_2': '31',
        'gpio_str_3': '63',
        'gpio_str_4': '127',
        'gpio_op_pin': '64',
        'gpio_ip_pin_set':'65',
        'gpio_ip_pin_clear':'66',
        'gpio_clear_value': 'value is 0',
        'gpio_set_value': 'value is 1',
}
"""


@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_status_all_generic(u_boot_console):
    """Test the 'gpio status' command.

	Displays all gpio pins available on the Board.
	To verify if the status of pins is displayed or not,
        the user can configure (gpio_str_count) and verify existence of certain
	pins.The details of these can be configured in 'gpio_str_n'.
        of boardenv_* (example above).User can configure any
        number of such pins and mention that count in 'gpio_str_count'.
    """

    f = u_boot_console.config.env.get('env__gpio_dev_config',False)
    if not f:
        pytest.skip("gpio not configured")

    gpio_str_count = f['gpio_str_count']

    #Display all the GPIO ports
    cmd = 'gpio status -a'
    response = u_boot_console.run_command(cmd)

    for str_value in range(1,gpio_str_count + 1):
        assert f["gpio_str_%d" %(str_value)] in response


@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_set_generic(u_boot_console):
    """Test the 'gpio set' command.

	A specific gpio pin configured by user as output
        (mentioned in gpio_op_pin) is verified for
	'set' option

    """

    f = u_boot_console.config.env.get('env__gpio_dev_config',False)
    if not f:
        pytest.skip("gpio not configured")

    gpio_pin_adr = f['gpio_op_pin'];
    gpio_set_value = f['gpio_set_value'];


    cmd = 'gpio set ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_set_value
    assert good_response in response



@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_clear_generic(u_boot_console):
    """Test the 'gpio clear' command.

	A specific gpio pin configured by user as output
        (mentioned in gpio_op_pin) is verified for
	'clear' option
    """

    f = u_boot_console.config.env.get('env__gpio_dev_config',False)
    if not f:
        pytest.skip("gpio not configured")

    gpio_pin_adr = f['gpio_op_pin'];
    gpio_clear_value = f['gpio_clear_value'];


    cmd = 'gpio clear ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_clear_value
    assert good_response in response


@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_toggle_generic(u_boot_console):
    """Test the 'gpio toggle' command.

	A specific gpio pin configured by user as output
        (mentioned in gpio_op_pin) is verified for
	'toggle' option
    """


    f = u_boot_console.config.env.get('env__gpio_dev_config',False)
    if not f:
        pytest.skip("gpio not configured")

    gpio_pin_adr = f['gpio_op_pin'];
    gpio_set_value = f['gpio_set_value'];
    gpio_clear_value = f['gpio_clear_value'];

    cmd = 'gpio set ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_set_value
    assert good_response in response

    cmd = 'gpio toggle ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_clear_value
    assert good_response in response


@pytest.mark.buildconfigspec('cmd_gpio')
def test_gpio_input_generic(u_boot_console):
    """Test the 'gpio input' command.

	Specific gpio pins configured by user as input
        (mentioned in gpio_ip_pin_set and gpio_ip_pin_clear)
	is verified for logic '1' and logic '0' states
    """

    f = u_boot_console.config.env.get('env__gpio_dev_config',False)
    if not f:
        pytest.skip("gpio not configured")

    gpio_pin_adr = f['gpio_ip_pin_clear'];
    gpio_clear_value = f['gpio_clear_value'];


    cmd = 'gpio input ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_clear_value
    assert good_response in response


    gpio_pin_adr = f['gpio_ip_pin_set'];
    gpio_set_value = f['gpio_set_value'];


    cmd = 'gpio input ' + gpio_pin_adr
    response = u_boot_console.run_command(cmd)
    good_response = gpio_set_value
    assert good_response in response
