videotest_checksum.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* All tests need to include test.h for GRUB testing framework. */
  19. #include <grub/test.h>
  20. #include <grub/dl.h>
  21. #include <grub/video.h>
  22. #include <grub/video_fb.h>
  23. #include <grub/command.h>
  24. #include <grub/font.h>
  25. GRUB_MOD_LICENSE ("GPLv3+");
  26. #define FONT_NAME "Unknown Regular 16"
  27. /* Functional test main method. */
  28. static void
  29. videotest_checksum (void)
  30. {
  31. unsigned i;
  32. grub_font_t font;
  33. font = grub_font_get (FONT_NAME);
  34. if (font && grub_strcmp (font->name, FONT_NAME) != 0)
  35. font = 0;
  36. if (!font)
  37. font = grub_font_load ("unicode");
  38. if (!font)
  39. {
  40. grub_test_assert (0, "unicode font not found: %s", grub_errmsg);
  41. return;
  42. }
  43. for (i = 0; i < ARRAY_SIZE (grub_test_video_modes); i++)
  44. {
  45. grub_err_t err;
  46. #if defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_IEEE1275)
  47. if (grub_test_video_modes[i].width > 1024)
  48. continue;
  49. #endif
  50. err = grub_video_capture_start (&grub_test_video_modes[i],
  51. grub_video_fbstd_colors,
  52. grub_test_video_modes[i].number_of_colors);
  53. if (err)
  54. {
  55. grub_test_assert (0, "can't start capture: %s", grub_errmsg);
  56. grub_print_error ();
  57. continue;
  58. }
  59. grub_terminal_input_fake_sequence ((int []) { '\n' }, 1);
  60. grub_video_checksum ("videotest");
  61. char *args[] = { 0 };
  62. grub_command_execute ("videotest", 0, args);
  63. grub_terminal_input_fake_sequence_end ();
  64. grub_video_checksum_end ();
  65. grub_video_capture_end ();
  66. }
  67. }
  68. /* Register example_test method as a functional test. */
  69. GRUB_FUNCTIONAL_TEST (videotest_checksum, videotest_checksum);