blob: 5bc026dbb59cc00080428f12dbe3ee6fab10b582 [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
Simon Glass49efb062022-10-11 09:47:20 -06009#include <dm/ofnode.h>
10#include <linux/libfdt.h>
11#include <test/test.h>
12#include <test/ut.h>
13#include "bootstd_common.h"
14
Simon Glass54905482022-10-20 18:23:17 -060015/*
16 * Basic test of reading nvdata and updating a fwupd node in the device tree
17 * This test works when called from test_vbe.py and it must use the flat tree,
18 * since device tree fix-ups do not yet support live tree.
19 */
20static int vbe_test_fixup_norun(struct unit_test_state *uts)
Simon Glass49efb062022-10-11 09:47:20 -060021{
22 ofnode chosen, node;
23 const char *data;
24 oftree tree;
25 int size;
26
Simon Glass49efb062022-10-11 09:47:20 -060027 tree = oftree_from_fdt(working_fdt);
28 ut_assert(oftree_valid(tree));
29
30 chosen = oftree_path(tree, "/chosen");
31 ut_assert(ofnode_valid(chosen));
32
33 /* check the things set up for the FIT in test_vbe.py */
34 node = ofnode_find_subnode(chosen, "random");
35
36 /* ignore if this test is run on its own */
37 if (!ofnode_valid(node))
38 return 0;
39 data = ofnode_read_prop(node, "data", &size);
40 ut_asserteq(0x40, size);
41
42 node = ofnode_find_subnode(chosen, "aslr2");
43 ut_assert(ofnode_valid(node));
44 data = ofnode_read_prop(node, "data", &size);
45 ut_asserteq(4, size);
46
47 node = ofnode_find_subnode(chosen, "efi-runtime");
48 ut_assert(ofnode_valid(node));
49 data = ofnode_read_prop(node, "data", &size);
50 ut_asserteq(4, size);
51
52 return 0;
53}
Simon Glass1a92f832024-08-22 07:57:48 -060054BOOTSTD_TEST(vbe_test_fixup_norun, UTF_DM | UTF_SCAN_FDT | UTF_FLAT_TREE |
55 UTF_MANUAL);