1# SPDX-License-Identifier: GPL-2.0+
2# Copyright 2024 Google LLC
3#
4# Test addition of Universal Payload
5
6import os
7
8import pytest
9import utils
10
11@pytest.mark.boardspec('sandbox_vpl')
12def test_upl_handoff(ubman):
13    """Test of UPL handoff
14
15    This works by starting up U-Boot VPL, which gets to SPL and then sets up a
16    UPL handoff using the FIT containing U-Boot proper. It then jumps to U-Boot
17    proper and runs a test to check that the parameters are correct.
18
19    The entire FIT is loaded into memory in SPL (in upl_load_from_image()) so
20    that it can be inspected in upl_test_info_norun
21    """
22    ram = os.path.join(ubman.config.build_dir, 'ram.bin')
23    fdt = os.path.join(ubman.config.build_dir, 'u-boot.dtb')
24
25    # Remove any existing RAM file, so we don't have old data present
26    if os.path.exists(ram):
27        os.remove(ram)
28    flags = ['-m', ram, '-d', fdt, '--upl']
29    ubman.restart_uboot_with_flags(flags, use_dtb=False)
30
31    # Make sure that Universal Payload is detected in U-Boot proper
32    output = ubman.run_command('upl info')
33    assert 'UPL state: active' == output
34
35    # Check the FIT offsets look correct
36    output = ubman.run_command('ut upl -f upl_test_info_norun')
37    assert 'failures: 0' in output
38