Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pixbuf_test.c 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. *
  19. * You can also choose to distribute this program under the terms of
  20. * the Unmodified Binary Distribution Licence (as given in the file
  21. * COPYING.UBDL), provided that you have satisfied its requirements.
  22. */
  23. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  24. /** @file
  25. *
  26. * Pixel buffer self-tests
  27. *
  28. */
  29. /* Forcibly enable assertions */
  30. #undef NDEBUG
  31. #include <assert.h>
  32. #include <ipxe/image.h>
  33. #include <ipxe/pixbuf.h>
  34. #include <ipxe/test.h>
  35. #include "pixbuf_test.h"
  36. /**
  37. * Report pixel buffer test result
  38. *
  39. * @v test Pixel buffer test
  40. * @v file Test code file
  41. * @v line Test code line
  42. */
  43. void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
  44. unsigned int line ) {
  45. struct pixel_buffer *pixbuf;
  46. int rc;
  47. /* Sanity check */
  48. assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
  49. == test->len );
  50. /* Correct image data pointer */
  51. test->image->data = virt_to_user ( ( void * ) test->image->data );
  52. /* Check that image is detected as correct type */
  53. okx ( register_image ( test->image ) == 0, file, line );
  54. okx ( test->image->type == test->type, file, line );
  55. /* Check that a pixel buffer can be created from the image */
  56. okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
  57. if ( rc == 0 ) {
  58. /* Check pixel buffer dimensions */
  59. okx ( pixbuf->width == test->width, file, line );
  60. okx ( pixbuf->height == test->height, file, line );
  61. /* Check pixel buffer data */
  62. okx ( pixbuf->len == test->len, file, line );
  63. okx ( memcmp_user ( pixbuf->data, 0,
  64. virt_to_user ( test->data ), 0,
  65. test->len ) == 0, file, line );
  66. pixbuf_put ( pixbuf );
  67. }
  68. /* Unregister image */
  69. unregister_image ( test->image );
  70. }