vbe_fixup.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. #include <common.h>
  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. * Basic test of reading nvdata and updating a fwupd node in the device tree
  16. * This test works when called from test_vbe.py and it must use the flat tree,
  17. * since device tree fix-ups do not yet support live tree.
  18. */
  19. static int vbe_test_fixup_norun(struct unit_test_state *uts)
  20. {
  21. ofnode chosen, node;
  22. const char *data;
  23. oftree tree;
  24. int size;
  25. tree = oftree_from_fdt(working_fdt);
  26. ut_assert(oftree_valid(tree));
  27. chosen = oftree_path(tree, "/chosen");
  28. ut_assert(ofnode_valid(chosen));
  29. /* check the things set up for the FIT in test_vbe.py */
  30. node = ofnode_find_subnode(chosen, "random");
  31. /* ignore if this test is run on its own */
  32. if (!ofnode_valid(node))
  33. return 0;
  34. data = ofnode_read_prop(node, "data", &size);
  35. ut_asserteq(0x40, size);
  36. node = ofnode_find_subnode(chosen, "aslr2");
  37. ut_assert(ofnode_valid(node));
  38. data = ofnode_read_prop(node, "data", &size);
  39. ut_asserteq(4, size);
  40. node = ofnode_find_subnode(chosen, "efi-runtime");
  41. ut_assert(ofnode_valid(node));
  42. data = ofnode_read_prop(node, "data", &size);
  43. ut_asserteq(4, size);
  44. return 0;
  45. }
  46. BOOTSTD_TEST(vbe_test_fixup_norun, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
  47. UT_TESTF_FLAT_TREE | UT_TESTF_MANUAL);