1// 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 9#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 15/* 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) 21{ 22 ofnode chosen, node; 23 const char *data; 24 oftree tree; 25 int size; 26 27 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} 54BOOTSTD_TEST(vbe_test_fixup_norun, UT_TESTF_DM | UT_TESTF_SCAN_FDT | 55 UT_TESTF_FLAT_TREE | UT_TESTF_MANUAL); 56