Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

pixbuf_test.c 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. /** @file
  21. *
  22. * Pixel buffer self-tests
  23. *
  24. */
  25. /* Forcibly enable assertions */
  26. #undef NDEBUG
  27. #include <assert.h>
  28. #include <ipxe/image.h>
  29. #include <ipxe/pixbuf.h>
  30. #include <ipxe/test.h>
  31. #include "pixbuf_test.h"
  32. /**
  33. * Report pixel buffer test result
  34. *
  35. * @v test Pixel buffer test
  36. * @v file Test code file
  37. * @v line Test code line
  38. */
  39. void pixbuf_okx ( struct pixel_buffer_test *test, const char *file,
  40. unsigned int line ) {
  41. struct pixel_buffer *pixbuf;
  42. int rc;
  43. /* Sanity check */
  44. assert ( ( test->width * test->height * sizeof ( test->data[0] ) )
  45. == test->len );
  46. /* Correct image data pointer */
  47. test->image->data = virt_to_user ( ( void * ) test->image->data );
  48. /* Check that image is detected as PNM */
  49. okx ( image_probe ( test->image ) == 0, file, line );
  50. okx ( test->image->type == test->type, file, line );
  51. /* Check that a pixel buffer can be created from the image */
  52. okx ( ( rc = image_pixbuf ( test->image, &pixbuf ) ) == 0, file, line );
  53. if ( rc == 0 ) {
  54. /* Check pixel buffer dimensions */
  55. okx ( pixbuf->width == test->width, file, line );
  56. okx ( pixbuf->height == test->height, file, line );
  57. /* Check pixel buffer data */
  58. okx ( pixbuf->len == test->len, file, line );
  59. okx ( memcmp_user ( pixbuf->data, 0,
  60. virt_to_user ( test->data ), 0,
  61. test->len ) == 0, file, line );
  62. pixbuf_put ( pixbuf );
  63. }
  64. }