2
0

hexloader-test.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * QTest testcase for the Intel Hexadecimal Object File Loader
  3. *
  4. * Authors:
  5. * Su Hang <suhang16@mails.ucas.ac.cn> 2018
  6. *
  7. * This work is licensed under the terms of the GNU GPL, version 2 or later.
  8. * See the COPYING file in the top-level directory.
  9. *
  10. */
  11. #include "qemu/osdep.h"
  12. #include "libqtest.h"
  13. /* Load 'test.hex' and verify that the in-memory contents are as expected.
  14. * 'test.hex' is a memory test pattern stored in Hexadecimal Object
  15. * format. It loads at 0x10000 in RAM and contains values from 0 through
  16. * 255.
  17. */
  18. static void hex_loader_test(void)
  19. {
  20. unsigned int i;
  21. const unsigned int base_addr = 0x00010000;
  22. QTestState *s = qtest_initf(
  23. "-M vexpress-a9 -device loader,file=tests/data/hex-loader/test.hex");
  24. for (i = 0; i < 256; ++i) {
  25. uint8_t val = qtest_readb(s, base_addr + i);
  26. g_assert_cmpuint(i, ==, val);
  27. }
  28. qtest_quit(s);
  29. }
  30. int main(int argc, char **argv)
  31. {
  32. int ret;
  33. g_test_init(&argc, &argv, NULL);
  34. qtest_add_func("/tmp/hex_loader", hex_loader_test);
  35. ret = g_test_run();
  36. return ret;
  37. }