seama.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Executes tests for SEAMA (SEAttle iMAge) command
  4. *
  5. * Copyright (C) 2021 Linus Walleij <linus.walleij@linaro.org>
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <dm.h>
  10. #include <test/suites.h>
  11. #include <test/test.h>
  12. #include <test/ut.h>
  13. #define SEAMA_TEST(_name, _flags) UNIT_TEST(_name, _flags, seama_test)
  14. static int seama_test_noargs(struct unit_test_state *uts)
  15. {
  16. /* Test that 'seama' with no arguments fails gracefully */
  17. console_record_reset();
  18. run_command("seama", 0);
  19. ut_assert_nextlinen("seama - Load the SEAMA image and sets envs");
  20. ut_assert_skipline();
  21. ut_assert_skipline();
  22. ut_assert_skipline();
  23. ut_assert_skipline();
  24. ut_assert_console_end();
  25. return 0;
  26. }
  27. SEAMA_TEST(seama_test_noargs, UT_TESTF_CONSOLE_REC);
  28. static int seama_test_addr(struct unit_test_state *uts)
  29. {
  30. /* Test that loads SEAMA image 0 to address 0x01000000 */
  31. console_record_reset();
  32. run_command("seama 0x01000000", 0);
  33. ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
  34. ut_assert_nextlinen("SEMA IMAGE:");
  35. ut_assert_nextlinen(" metadata size ");
  36. ut_assert_nextlinen(" image size ");
  37. ut_assert_nextlinen(" checksum ");
  38. ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
  39. ut_assert_console_end();
  40. return 0;
  41. }
  42. SEAMA_TEST(seama_test_addr, UT_TESTF_CONSOLE_REC);
  43. static int seama_test_index(struct unit_test_state *uts)
  44. {
  45. /* Test that loads SEAMA image 0 exlicitly specified */
  46. console_record_reset();
  47. run_command("seama 0x01000000 0", 0);
  48. ut_assert_nextlinen("Loading SEAMA image 0 from nand0");
  49. ut_assert_nextlinen("SEMA IMAGE:");
  50. ut_assert_nextlinen(" metadata size ");
  51. ut_assert_nextlinen(" image size ");
  52. ut_assert_nextlinen(" checksum ");
  53. ut_assert_nextlinen("Decoding SEAMA image 0x01000040..");
  54. ut_assert_console_end();
  55. return 0;
  56. }
  57. SEAMA_TEST(seama_test_index, UT_TESTF_CONSOLE_REC);
  58. int do_ut_seama(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  59. {
  60. struct unit_test *tests = UNIT_TEST_SUITE_START(seama_test);
  61. const int n_ents = UNIT_TEST_SUITE_COUNT(seama_test);
  62. return cmd_ut_category("seama", "seama_test_", tests, n_ents, argc,
  63. argv);
  64. }