]> Git Repo - u-boot.git/blame - test/boot/vbe_simple.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[u-boot.git] / test / boot / vbe_simple.c
CommitLineData
5fe76d46
SG
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Test for vbe-simple bootmeth. All start with 'vbe_simple'
4 *
5 * Copyright 2023 Google LLC
6 * Written by Simon Glass <[email protected]>
7 */
8
d678a59d 9#include <common.h>
5fe76d46
SG
10#include <bootmeth.h>
11#include <dm.h>
12#include <image.h>
5fe76d46
SG
13#include <of_live.h>
14#include <vbe.h>
5fe76d46
SG
15#include <test/suites.h>
16#include <test/ut.h>
5fe76d46
SG
17#include "bootstd_common.h"
18
a56f663f
SG
19/*
20 * Basic test of reading nvdata and updating a fwupd node in the device tree
21 *
22 * This sets up its own VBE info in the device, using bootstd_setup_for_tests()
23 * then does a VBE fixup and checks that everything is present.
24 */
5fe76d46
SG
25static int vbe_simple_test_base(struct unit_test_state *uts)
26{
5fe76d46
SG
27 const char *version, *bl_version;
28 struct event_ft_fixup fixup;
bfdfc5d8 29 struct udevice *dev;
5fe76d46 30 struct device_node *np;
5fe76d46
SG
31 char fdt_buf[0x400];
32 char info[100];
33 int node_ofs;
34 ofnode node;
35 u32 vernum;
36
bfdfc5d8
SG
37 /* Set up the VBE info */
38 ut_assertok(bootstd_setup_for_tests());
5fe76d46
SG
39
40 /* Read the version back */
41 ut_assertok(vbe_find_by_any("firmware0", &dev));
42 ut_assertok(bootmeth_get_state_desc(dev, info, sizeof(info)));
43 ut_asserteq_str("Version: " TEST_VERSION "\nVernum: 1/2", info);
44
45 ut_assertok(fdt_create_empty_tree(fdt_buf, sizeof(fdt_buf)));
46 node_ofs = fdt_add_subnode(fdt_buf, 0, "chosen");
47 ut_assert(node_ofs > 0);
48
49 node_ofs = fdt_add_subnode(fdt_buf, node_ofs, "fwupd");
50 ut_assert(node_ofs > 0);
51
52 node_ofs = fdt_add_subnode(fdt_buf, node_ofs, "firmware0");
53 ut_assert(node_ofs > 0);
54
0d63213c
SG
55 if (of_live_active()) {
56 ut_assertok(unflatten_device_tree(fdt_buf, &np));
57 fixup.tree = oftree_from_np(np);
58 } else {
59 fixup.tree = oftree_from_fdt(fdt_buf);
60 }
5fe76d46
SG
61
62 /*
63 * It would be better to call image_setup_libfdt() here, but that
64 * function does not allow passing an ofnode. We can pass fdt_buf but
0d63213c 65 * when it comes to send the event, it creates an ofnode that uses the
5fe76d46
SG
66 * control FDT, since it has no way of accessing the live tree created
67 * here.
68 *
0d63213c 69 * Two fix this we need image_setup_libfdt() is updated to use ofnode
5fe76d46 70 */
bfdfc5d8 71 fixup.images = NULL;
5fe76d46
SG
72 ut_assertok(event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup)));
73
b7bd94f1 74 node = oftree_path(fixup.tree, "/chosen/fwupd/firmware0");
5fe76d46
SG
75
76 version = ofnode_read_string(node, "cur-version");
77 ut_assertnonnull(version);
78 ut_asserteq_str(TEST_VERSION, version);
79
80 ut_assertok(ofnode_read_u32(node, "cur-vernum", &vernum));
81 ut_asserteq(TEST_VERNUM, vernum);
82
83 bl_version = ofnode_read_string(node, "bootloader-version");
84 ut_assertnonnull(bl_version);
e45d2265 85 ut_asserteq_str(version_string + 7, bl_version);
5fe76d46
SG
86
87 return 0;
88}
0d63213c 89BOOTSTD_TEST(vbe_simple_test_base, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
This page took 0.078798 seconds and 4 git commands to generate.