blob: eba5c4ebe6c0355c3576012686a2958e3f297bb5 [file] [log] [blame]
Simon Glass49efb062022-10-11 09:47:20 -06001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Test for VBE device tree fix-ups
4 *
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
Tom Riniabb9a042024-05-18 20:20:43 -06009#include <common.h>
Simon Glass49efb062022-10-11 09:47:20 -060010#include <dm/ofnode.h>
11#include <linux/libfdt.h>
12#include <test/test.h>
13#include <test/ut.h>
14#include "bootstd_common.h"
15
Simon Glass54905482022-10-20 18:23:17 -060016/*
17 * Basic test of reading nvdata and updating a fwupd node in the device tree
18 * This test works when called from test_vbe.py and it must use the flat tree,
19 * since device tree fix-ups do not yet support live tree.
20 */
21static int vbe_test_fixup_norun(struct unit_test_state *uts)
Simon Glass49efb062022-10-11 09:47:20 -060022{
23 ofnode chosen, node;
24 const char *data;
25 oftree tree;
26 int size;
27
Simon Glass49efb062022-10-11 09:47:20 -060028 tree = oftree_from_fdt(working_fdt);
29 ut_assert(oftree_valid(tree));
30
31 chosen = oftree_path(tree, "/chosen");
32 ut_assert(ofnode_valid(chosen));
33
34 /* check the things set up for the FIT in test_vbe.py */
35 node = ofnode_find_subnode(chosen, "random");
36
37 /* ignore if this test is run on its own */
38 if (!ofnode_valid(node))
39 return 0;
40 data = ofnode_read_prop(node, "data", &size);
41 ut_asserteq(0x40, size);
42
43 node = ofnode_find_subnode(chosen, "aslr2");
44 ut_assert(ofnode_valid(node));
45 data = ofnode_read_prop(node, "data", &size);
46 ut_asserteq(4, size);
47
48 node = ofnode_find_subnode(chosen, "efi-runtime");
49 ut_assert(ofnode_valid(node));
50 data = ofnode_read_prop(node, "data", &size);
51 ut_asserteq(4, size);
52
53 return 0;
54}
Simon Glass54905482022-10-20 18:23:17 -060055BOOTSTD_TEST(vbe_test_fixup_norun, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
56 UT_TESTF_FLAT_TREE | UT_TESTF_MANUAL);