diff options
author | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-21 11:53:54 -0700 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2015-05-21 15:10:37 -0700 |
commit | c919883d269703a1c9391af347df390979027f53 (patch) | |
tree | e5c323e0f1167b2d93f8d57d0d6eded8944eb99f | |
parent | 3835d05c638e79f10dee57d0fa825d866122e80b (diff) | |
download | weston-c919883d269703a1c9391af347df390979027f53.tar.gz weston-c919883d269703a1c9391af347df390979027f53.tar.bz2 weston-c919883d269703a1c9391af347df390979027f53.zip |
tests: Check that the PNG file's stride matches our internal assumption
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
-rw-r--r-- | tests/internal-screenshot-test.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c index b5707336..f2e6c16b 100644 --- a/tests/internal-screenshot-test.c +++ b/tests/internal-screenshot-test.c @@ -75,6 +75,7 @@ load_surface_from_png(const char *fname) { cairo_surface_t *reference_cairo_surface; cairo_status_t status; size_t source_data_size; + int bpp; int stride; printf("Loading reference image %s\n", fname); @@ -98,6 +99,15 @@ load_surface_from_png(const char *fname) { stride = cairo_image_surface_get_stride(reference_cairo_surface); source_data_size = stride * reference->height; + /* Check that the file's stride matches our assumption */ + bpp = 4; + if (stride != bpp * reference->width) { + printf("Mismatched stride for screenshot reference image %s\n", fname); + cairo_surface_destroy(reference_cairo_surface); + free(reference); + return NULL; + } + /* Allocate new buffer for our weston reference, and copy the data from the cairo surface so we can destroy it */ reference->data = xzalloc(source_data_size); |