This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 285f37259943b8777104bf7e34e45cd1da2706a9 (commit) via d838051917f95c332c457eadba72c5369147678f (commit) via 4d6e63045fabb823aeb543122fd4c26697117bbe (commit) via 28d21ca42de6b4e894b677f49f30a0b9849902eb (commit) via eb664a99edb339aba95731b9a437dd8a30ef31b5 (commit) via 98452c22c9737ea12fa14cfb1f9551886ee320a2 (commit) via 5f8f0740414d5bc5e5fd4cf51824ed75057681ea (commit) via 9eda828f0117515f5698c1101e632fff823830fd (commit) from 8d2ecb32294836112e300b456b2d620f1b033b31 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/285f37259943b8777104bf7e34e45cd1da270...
commit 285f37259943b8777104bf7e34e45cd1da2706a9 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 23:36:58 2013 +0200
loaders: BMP, JPG: Simplify LineConvert usage.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index b6f3a50..3a56413 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -780,20 +780,15 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea { GP_PixelType out_pix;
- switch (src->pixel_type) { - case GP_PIXEL_RGB888: - header->bpp = 24; - break; - default: - out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); + out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types);
- if (out_pix == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unsupported pixel type %s", - GP_PixelTypeName(src->pixel_type)); - return ENOSYS; - } + if (out_pix == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unsupported pixel type %s", + GP_PixelTypeName(src->pixel_type)); + return ENOSYS; }
+ header->bpp = 24; header->w = src->w; header->h = src->h;
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index 3b52821..aa6b1c4 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -410,20 +410,13 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
GP_DEBUG(1, "Saving JPG Image '%s'", dst_path);
- switch (src->pixel_type) { - case GP_PIXEL_BGR888: - case GP_PIXEL_G8: - out_pix = src->pixel_type; - break; - default: - out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types); + out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types);
- if (out_pix == GP_PIXEL_UNKNOWN) { - GP_DEBUG(1, "Unsupported pixel type %s", - GP_PixelTypeName(src->pixel_type)); - errno = ENOSYS; - return 1; - } + if (out_pix == GP_PIXEL_UNKNOWN) { + GP_DEBUG(1, "Unsupported pixel type %s", + GP_PixelTypeName(src->pixel_type)); + errno = ENOSYS; + return 1; }
f = fopen(dst_path, "wb");
http://repo.or.cz/w/gfxprim.git/commit/d838051917f95c332c457eadba72c53691476...
commit d838051917f95c332c457eadba72c5369147678f Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 23:31:15 2013 +0200
tests: loaders: Add simple pixelcheck to save_load.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/Loader.h b/tests/loaders/Loader.h index d1a81b2..36b20ef 100644 --- a/tests/loaders/Loader.h +++ b/tests/loaders/Loader.h @@ -115,6 +115,7 @@ struct testcase_save_load { static int test_save_load(struct testcase_save_load *test) { GP_Context *img, *img2; + unsigned int x, y;
img = GP_ContextAlloc(test->w, test->h, test->pixel_type);
@@ -124,6 +125,10 @@ static int test_save_load(struct testcase_save_load *test) return TST_FAILED; }
+ for (x = 0; x < img->w; x++) + for (y = 0; y < img->w; y++) + GP_PutPixel(img, x, y, 0); + errno = 0;
if (SAVE(img, "testfile", NULL)) { @@ -168,12 +173,18 @@ static int test_save_load(struct testcase_save_load *test) tst_msg("Source pixel type %s and loaded type %s differs", GP_PixelTypeName(img->pixel_type), GP_PixelTypeName(img2->pixel_type)); + return TST_FAILED; + } + + if (GP_GetPixel(img2, 0, 0) != 0) { + tst_msg("Pixel value is wrong %x", GP_GetPixel(img2, 0, 0)); + GP_ContextFree(img); + GP_ContextFree(img2); + return TST_FAILED; }
GP_ContextFree(img); GP_ContextFree(img2);
- //TODO: Check pixels - return TST_SUCCESS; }
http://repo.or.cz/w/gfxprim.git/commit/4d6e63045fabb823aeb543122fd4c26697117...
commit 4d6e63045fabb823aeb543122fd4c26697117bbe Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 23:30:11 2013 +0200
loaders: PNM: Fix SavePBM.
Inverse the value on SavePBM.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index 7100fb8..027dae2 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -551,15 +551,20 @@ static int load_bin_rgb888(FILE *f, GP_Context *ctx, GP_ProgressCallback *cb) return 0; }
-static int save_ascii(FILE *f, const GP_Context *ctx, GP_ProgressCallback *cb) +static int save_ascii(FILE *f, const GP_Context *ctx, + GP_ProgressCallback *cb, int inv) { uint32_t x, y; int err;
for (y = 0; y < ctx->h; y++) { for (x = 0; x < ctx->w; x++) { + int val = GP_GetPixel_Raw(ctx, x, y);
- if (fprintf(f, "%i ", GP_GetPixel_Raw(ctx, x, y)) < 0) { + if (inv) + val = !val; + + if (fprintf(f, "%i ", val) < 0) { err = errno; GP_DEBUG(1, "Failed to write data"); return err; @@ -674,7 +679,7 @@ int GP_SavePBM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h) < 0) goto err;
- if (save_ascii(f, src, callback)) + if (save_ascii(f, src, callback, 1)) goto err;
if (fclose(f)) @@ -847,7 +852,7 @@ int GP_SavePGM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h, depth) < 0) goto err1;
- if ((err = save_ascii(f, src, callback))) + if ((err = save_ascii(f, src, callback, 0))) goto err1;
if (fclose(f)) {
http://repo.or.cz/w/gfxprim.git/commit/28d21ca42de6b4e894b677f49f30a0b984990...
commit 28d21ca42de6b4e894b677f49f30a0b9849902eb Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 23:20:48 2013 +0200
loaders: PNM: Make use of LineConvert.
So far only for PNM and PPM.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c index dc29a7c..7100fb8 100644 --- a/libs/loaders/GP_PNM.c +++ b/libs/loaders/GP_PNM.c @@ -57,6 +57,7 @@ #include "core/GP_Debug.h" #include "core/GP_Context.h" #include "core/GP_GetPutPixel.h" +#include "loaders/GP_LineConvert.h"
#include "loaders/GP_PNM.h"
@@ -947,14 +948,23 @@ static int write_binary_ppm(FILE *f, GP_Context *src) }
static int save_ascii_rgb888(FILE *f, const GP_Context *ctx, - GP_ProgressCallback *cb) + GP_LineConvert Convert, GP_ProgressCallback *cb) { uint32_t x, y; int ret; + uint8_t buf[3 * ctx->w], *addr;
for (y = 0; y < ctx->h; y++) { + + addr = GP_PIXEL_ADDR(ctx, 0, y); + + if (Convert) { + Convert(addr, buf, ctx->w); + addr = buf; + } + for (x = 0; x < ctx->w; x++) { - GP_Pixel pix = GP_GetPixel_Raw_24BPP(ctx, x, y); + GP_Pixel pix = *(addr+=3);
ret = fprintf(f, "%u %u %u ", GP_Pixel_GET_R_RGB888(pix), @@ -978,16 +988,25 @@ static int save_ascii_rgb888(FILE *f, const GP_Context *ctx, return 0; }
+static GP_PixelType ppm_save_pixels[] = { + GP_PIXEL_RGB888, + GP_PIXEL_UNKNOWN, +}; + int GP_SavePPM(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback) { + GP_Pixel out_pix; + GP_LineConvert Convert; FILE *f; int err = EIO;
GP_DEBUG(1, "Saving context %ux%u %s to '%s'", src->w, src->h, GP_PixelTypeName(src->pixel_type), dst_path);
- if (src->pixel_type != GP_PIXEL_RGB888) { + out_pix = GP_LineConvertible(src->pixel_type, ppm_save_pixels); + + if (out_pix == GP_PIXEL_UNKNOWN) { GP_DEBUG(1, "Invalid pixel type '%s'", GP_PixelTypeName(src->pixel_type)); errno = EINVAL; @@ -1007,7 +1026,9 @@ int GP_SavePPM(const GP_Context *src, const char *dst_path, (unsigned int) src->w, (unsigned int) src->h) < 0) goto err1;
- if ((err = save_ascii_rgb888(f, src, callback))) + Convert = GP_LineConvertGet(src->pixel_type, out_pix); + + if ((err = save_ascii_rgb888(f, src, Convert, callback))) goto err1;
if (fclose(f)) { @@ -1075,6 +1096,9 @@ int GP_SavePNM(const GP_Context *src, const char *dst_path, case GP_PIXEL_RGB888: return GP_SavePPM(src, dst_path, callback); default: + if (GP_LineConvertible(src->pixel_type, ppm_save_pixels)) + return GP_SavePPM(src, dst_path, callback); + errno = EINVAL; return 1; }
http://repo.or.cz/w/gfxprim.git/commit/eb664a99edb339aba95731b9a437dd8a30ef3...
commit eb664a99edb339aba95731b9a437dd8a30ef31b5 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 23:14:49 2013 +0200
loaders: LineConvert: Add more conversions.
Add match for identity (returns NULL convert functions).
Add conversions between xRGB888 and RGB888 and BGR888.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_LineConvert.c b/libs/loaders/GP_LineConvert.c index 9f3b70c..18655bc 100644 --- a/libs/loaders/GP_LineConvert.c +++ b/libs/loaders/GP_LineConvert.c @@ -23,7 +23,8 @@ #include "core/GP_Debug.h" #include "GP_LineConvert.h"
-static void xyz888_to_zyx888(const uint8_t *inbuf, uint8_t *outbuf, unsigned int len) +static void ABC888_to_CBA888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) { unsigned int i;
@@ -37,13 +38,43 @@ static void xyz888_to_zyx888(const uint8_t *inbuf, uint8_t *outbuf, unsigned int } }
+static void xABC8888_to_ABC888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + outbuf[0] = inbuf[1]; + outbuf[1] = inbuf[2]; + outbuf[2] = inbuf[3]; + + outbuf+=3; + inbuf+=4; + } +} + +static void xABC8888_to_CBA888(const uint8_t *inbuf, uint8_t *outbuf, + unsigned int len) +{ + unsigned int i; + + for (i = 0; i < len; i++) { + outbuf[0] = inbuf[3]; + outbuf[1] = inbuf[2]; + outbuf[2] = inbuf[1]; + + outbuf+=3; + inbuf+=4; + } +} + GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out) { switch (in) { case GP_PIXEL_RGB888: switch (out) { case GP_PIXEL_BGR888: - return xyz888_to_zyx888; + return ABC888_to_CBA888; break; default: break; @@ -52,7 +83,19 @@ GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out) case GP_PIXEL_BGR888: switch (out) { case GP_PIXEL_RGB888: - return xyz888_to_zyx888; + return ABC888_to_CBA888; + break; + default: + break; + } + break; + case GP_PIXEL_xRGB8888: + switch (out) { + case GP_PIXEL_RGB888: + return xABC8888_to_ABC888; + break; + case GP_PIXEL_BGR888: + return xABC8888_to_CBA888; break; default: break; @@ -71,6 +114,14 @@ GP_PixelType GP_LineConvertible(GP_PixelType in, GP_PixelType out[])
GP_DEBUG(1, "Trying to find conversion for %s", GP_PixelTypeName(in));
+ + for (i = 0; out[i] != GP_PIXEL_UNKNOWN; i++) { + if (out[i] == in) { + GP_DEBUG(1, "Found identity for %s", GP_PixelTypeName(in)); + return in; + } + } + for (i = 0; out[i] != GP_PIXEL_UNKNOWN; i++) { if (GP_LineConvertGet(in, out[i])) { GP_DEBUG(1, "Found %s -> %s", GP_PixelTypeName(in),
http://repo.or.cz/w/gfxprim.git/commit/98452c22c9737ea12fa14cfb1f9551886ee32...
commit 98452c22c9737ea12fa14cfb1f9551886ee320a2 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 22:46:47 2013 +0200
loaders: TIFF: Handle correctly on unsuppored pixeltypes.
Make the saver exit with ENOSYS on unsupported pixeltypes.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c index 160a85a..3a7b422 100644 --- a/libs/loaders/GP_TIFF.c +++ b/libs/loaders/GP_TIFF.c @@ -621,6 +621,11 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, }
switch (src->pixel_type) { + case GP_PIXEL_G1: + case GP_PIXEL_G2: + case GP_PIXEL_G4: + case GP_PIXEL_G8: + break; case GP_PIXEL_RGB888: case GP_PIXEL_BGR888: case GP_PIXEL_xRGB8888: @@ -628,6 +633,8 @@ int GP_SaveTIFF(const GP_Context *src, const char *dst_path, default: GP_DEBUG(1, "Unsupported pixel type %s", GP_PixelTypeName(src->pixel_type)); + errno = ENOSYS; + return 1; }
/* Open TIFF image */
http://repo.or.cz/w/gfxprim.git/commit/5f8f0740414d5bc5e5fd4cf51824ed7505768...
commit 5f8f0740414d5bc5e5fd4cf51824ed75057681ea Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 22:31:12 2013 +0200
tests: loaders: New SaveLoad test.
The test calls for each format and each pixel corresponding save function. The expected behavior is either failure with ENOSYS or success. In case of success the image is loaded back and checked.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile index 1d8cc2e..24cd1e4 100644 --- a/tests/loaders/Makefile +++ b/tests/loaders/Makefile @@ -1,11 +1,13 @@ TOPDIR=../.. include $(TOPDIR)/pre.mk
-CSOURCES=$(shell echo *.c) +CSOURCES=loaders_suite.c PNG.c PBM.c PGM.c PPM.c +GENSOURCES=SaveLoad.gen.c
-APPS=loaders_suite PNG PBM PGM PPM +APPS=loaders_suite PNG PBM PGM PPM SaveLoad.gen
include ../tests.mk
+include $(TOPDIR)/gen.mk include $(TOPDIR)/app.mk include $(TOPDIR)/post.mk diff --git a/tests/loaders/SaveLoad.gen.c.t b/tests/loaders/SaveLoad.gen.c.t new file mode 100644 index 0000000..df2767f --- /dev/null +++ b/tests/loaders/SaveLoad.gen.c.t @@ -0,0 +1,136 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +%% extends "base.test.c.t" + +%% block descr +Iterate over all pixel types, try to save and load back context. +%% endblock descr + +%% block body + +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +#include <core/GP_Context.h> +#include <core/GP_GetPutPixel.h> +#include <loaders/GP_Loaders.h> + +#include "tst_test.h" + +%% set fmts = ['PNG', 'JPG', 'TIFF', 'BMP', 'PBM', 'PGM', 'PPM', 'PNM'] + +typedef int (*Save)(const GP_Context *src, const char *path, GP_ProgressCallback *callback); +typedef GP_Context *(*Load)(const char *path, GP_ProgressCallback *callback); + +static int test(Save Saver, Load Loader, GP_PixelType pixel_type) +{ + GP_Context *src; + GP_Context *res; + unsigned int x, y; + int ret = TST_SUCCESS; + + src = GP_ContextAlloc(100, 100, pixel_type); + + if (!src) { + tst_msg("Malloc failed"); + return TST_UNTESTED; + } + + for (x = 0; x < src->w; x++) + for (y = 0; y < src->w; y++) + GP_PutPixel(src, x, y, 0); + + if (Saver(src, "testfile", NULL)) { + if (errno == ENOSYS) { + tst_msg("Unimplemented pixel value"); + ret = TST_SKIPPED; + goto err; + } + + if (errno == EINVAL) { + tst_msg("Invalid pixel value for the format"); + ret = TST_SKIPPED; + goto err; + } + + tst_msg("Saver failed with %s", strerror(errno)); + ret = TST_FAILED; + goto err; + } + + res = Loader("testfile", NULL); + + if (!res) { + tst_msg("Failed to load saved image"); + ret = TST_FAILED; + goto err; + } + + tst_msg("Loaded back as %s", GP_PixelTypeName(res->pixel_type)); + + if (res->w != src->w || res->h != src->h) { + tst_msg("Invalid loaded image size %ux%u", res->w, res->h); + ret = TST_FAILED; + } + + if (GP_GetPixel(res, 0, 0) != 0) { + tst_msg("Pixel value is wrong %x", GP_GetPixel(res, 0, 0)); + ret = TST_FAILED; + } + + GP_ContextFree(res); +err: + GP_ContextFree(src); + return ret; +} + +%% for fmt in fmts +%% for pt in pixeltypes +%% if not pt.is_unknown() +static int test_{{ fmt }}_{{ pt.name }}(void) +{ + return test(GP_Save{{ fmt }}, GP_Load{{ fmt }}, GP_PIXEL_{{ pt.name }}); +} + +%% endif +%% endfor +%% endfor + +const struct tst_suite tst_suite = { + .suite_name = "SaveLoad", + .tests = { +%% for fmt in fmts +%% for pt in pixeltypes +%% if not pt.is_unknown() + {.name = "{{ fmt }} {{ pt.name }}", + .tst_fn = test_{{ fmt }}_{{ pt.name }}, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, +%% endif +%% endfor +%% endfor + {.name = NULL}, + } +}; + +%% endblock body diff --git a/tests/loaders/test_list.txt b/tests/loaders/test_list.txt index 1593ff6..e9fdf3d 100644 --- a/tests/loaders/test_list.txt +++ b/tests/loaders/test_list.txt @@ -4,3 +4,4 @@ PNG PBM PGM PPM +SaveLoad.gen
http://repo.or.cz/w/gfxprim.git/commit/9eda828f0117515f5698c1101e632fff82383...
commit 9eda828f0117515f5698c1101e632fff823830fd Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 19 21:18:43 2013 +0200
test: loaders: Fix whitespaces.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/tests/loaders/Loader.h b/tests/loaders/Loader.h index d8a916d..d1a81b2 100644 --- a/tests/loaders/Loader.h +++ b/tests/loaders/Loader.h @@ -58,7 +58,7 @@ static int test_load(struct testcase *test) for (y = 0; y < img->h; y++) {
GP_Pixel pix = GP_GetPixel(img, x, y); - + if (pix != test->pix) { if (err < 5) tst_msg("%08x instead of %08x (%ux%u)", diff --git a/tests/loaders/PBM.c b/tests/loaders/PBM.c index ac87f25..86a20a5 100644 --- a/tests/loaders/PBM.c +++ b/tests/loaders/PBM.c @@ -141,31 +141,31 @@ const struct tst_suite tst_suite = { .res_path = "data/pbm/valid/black_2x2_bin.pbm", .data = &black_2x2_bin, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load 3x9 (black) Raw", .tst_fn = test_load, .res_path = "data/pbm/valid/black_3x9_bin.pbm", .data = &black_3x9_bin, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load corrupt", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/short.pbm", .data = "short.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load wrong header", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/wrong_header.pbm", .data = "wrong_header.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Load empty", .tst_fn = test_load_fail, .res_path = "data/pbm/corrupt/empty.pbm", .data = "empty.pbm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PBM Save Load", .tst_fn = test_save_load, .data = &save_load, diff --git a/tests/loaders/PGM.c b/tests/loaders/PGM.c index f914a8e..6bac05a 100644 --- a/tests/loaders/PGM.c +++ b/tests/loaders/PGM.c @@ -94,7 +94,7 @@ const struct tst_suite tst_suite = { .res_path = "data/pgm/valid/black_1x1_1bpp.pgm", .data = &black_1x1_1bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load 1x1 2bpp (black)", .tst_fn = test_load, .res_path = "data/pgm/valid/black_1x1_2bpp.pgm", @@ -106,7 +106,7 @@ const struct tst_suite tst_suite = { .res_path = "data/pgm/valid/black_1x1_4bpp.pgm", .data = &black_1x1_4bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load 1x1 8bpp (black)", .tst_fn = test_load, .res_path = "data/pgm/valid/black_1x1_8bpp.pgm", @@ -132,13 +132,13 @@ const struct tst_suite tst_suite = { .tst_fn = test_save_load, .data = &save_load_8bpp, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load wrong header", .tst_fn = test_load_fail, .res_path = "data/pgm/corrupt/wrong_header.pgm", .data = "wrong_header.pgm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PGM Load incomplete", .tst_fn = test_load_fail, .res_path = "data/pgm/corrupt/incomplete.pgm", diff --git a/tests/loaders/PNG.c b/tests/loaders/PNG.c index 540e492..0803e98 100644 --- a/tests/loaders/PNG.c +++ b/tests/loaders/PNG.c @@ -134,7 +134,7 @@ static int test_save_PNG(GP_PixelType pixel_type) tst_msg("Failed to allocate context"); return TST_UNTESTED; } - + errno = 0;
ret = GP_SavePNG(ctx, "/dev/null", NULL); @@ -166,53 +166,53 @@ const struct tst_suite tst_suite = { .res_path = "data/png/valid/100x100-red.png", .data = &red, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 RGB 50% alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-alpha.png", .data = "100x100-red-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 8 bit Grayscale", .tst_fn = test_load_PNG_check_color, .res_path = "data/png/valid/100x100-black-grayscale.png", .data = &black_grayscale, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 8 bit Grayscale + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-black-grayscale-alpha.png", .data = "100x100-black-grayscale-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 Palette + alpha", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-palette-alpha.png", .data = "100x100-palette-alpha.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 Palette", .tst_fn = test_load_PNG, .res_path = "data/png/valid/100x100-red-palette.png", .data = "100x100-red-palette.png", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Load 100x100 RGB Adam7", .tst_fn = test_load_PNG_check_color, .res_path = "data/png/valid/100x100-white-adam7.png", .data = &white_adam7, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G1", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G1, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G2", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G2, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 G4", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G4, @@ -222,12 +222,12 @@ const struct tst_suite tst_suite = { .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_G8, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 RGB888", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_RGB888, .flags = TST_CHECK_MALLOC}, - + {.name = "PNG Save 100x100 BGR888", .tst_fn = test_save_PNG, .data = (void*)GP_PIXEL_BGR888, diff --git a/tests/loaders/PPM.c b/tests/loaders/PPM.c index b4790cf..3082ce4 100644 --- a/tests/loaders/PPM.c +++ b/tests/loaders/PPM.c @@ -55,7 +55,7 @@ const struct tst_suite tst_suite = { .res_path = "data/ppm/valid/black_1x1.ppm", .data = &black_1x1, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PPM Save Load", .tst_fn = test_save_load, .data = &save_load, @@ -66,7 +66,7 @@ const struct tst_suite tst_suite = { .res_path = "data/ppm/corrupt/wrong_header.ppm", .data = "wrong_header.ppm", .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + {.name = "PPM Load incomplete", .tst_fn = test_load_fail, .res_path = "data/ppm/corrupt/incomplete.ppm", diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 8b378dd..333eccd 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -97,7 +97,7 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) GP_Context *img, *res;
img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); - + if (img == NULL) { tst_warn("GP_ContextAlloc failed"); return TST_UNTESTED; @@ -110,7 +110,7 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) tst_msg("Save %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; } - + tst_msg("Failed to save %s: %s", strfmt(fmt), strerror(errno)); return TST_FAILED; @@ -163,14 +163,14 @@ static int test_BMP_stress(void) static int load_enoent(enum fmt fmt) { GP_Context *img; - - img = load(fmt, "nonexistent"); - + + img = load(fmt, "nonexistent"); + if (img != NULL) { tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -210,7 +210,7 @@ static int load_eacces(enum fmt fmt) GP_Context *img;
snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); - + FILE *f = fopen(buf, "w");
if (f == NULL) { @@ -231,7 +231,7 @@ static int load_eacces(enum fmt fmt) tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -272,7 +272,7 @@ static int load_eio(enum fmt fmt) GP_Context *img;
snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); - + FILE *f = fopen(buf, "w");
if (f == NULL) { @@ -288,7 +288,7 @@ static int load_eio(enum fmt fmt) tst_msg("Test succedded unexpectedly"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; @@ -299,7 +299,7 @@ static int load_eio(enum fmt fmt) strerror(errno)); return TST_FAILED; } - + return TST_SUCCESS; }
@@ -344,7 +344,7 @@ static int test_PNG_Save_abort(void) tst_msg("Failed to save PNG saving"); return TST_FAILED; } - + if (errno == ENOSYS) { tst_msg("Load PNG: ENOSYS"); return TST_SKIPPED; @@ -357,7 +357,7 @@ static int test_PNG_Save_abort(void) }
GP_ContextFree(img); - + return TST_SUCCESS; }
@@ -368,12 +368,12 @@ static int test_PNG_Load_abort(void) img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
if (GP_SavePNG(img, "test.png", NULL)) { - + if (errno == ENOSYS) { tst_msg("Save PNG: ENOSYS"); return TST_SKIPPED; } - + tst_msg("Failed to save PNG: %s", strerror(errno)); return TST_FAILED; } @@ -417,7 +417,7 @@ enum file_flags { };
static struct file_testcase file_testcases[] = { - + /* * Should fail the file signature based loader * as the signature could have been loaded but @@ -443,7 +443,7 @@ static struct file_testcase file_testcases[] = { {"wrong.tif", FILE_CREATE | FILE_FILL, ENOSYS}, {"wrong.tiff", FILE_CREATE | FILE_FILL, ENOSYS},
- /* + /* * Should start signature-based loader and * fail it to read start of the file. */ @@ -453,7 +453,7 @@ static struct file_testcase file_testcases[] = { {".dc", FILE_CREATE, EIO}, {"dc", FILE_CREATE, EIO}, {"cba", FILE_CREATE, EIO}, - + /* * Dtto but for hits the extension based * loader first and fail to read image header @@ -501,8 +501,7 @@ static int test_Load(void) if (file_testcases[i].create & FILE_FILL) { if (fwrite(buf, sizeof(buf), 1, f) != 1) tst_msg("Failed to write to '%s'", - file_testcases[i].filename); - + file_testcases[i].filename); }
fclose(f); @@ -514,7 +513,6 @@ static int test_Load(void)
for (i = 0; file_testcases[i].filename != NULL; i++) { GP_Context *ret; - errno = 0;
ret = GP_LoadImage(file_testcases[i].filename, NULL); @@ -533,7 +531,7 @@ static int test_Load(void) file_testcases[i].filename); continue; } - + if (file_testcases[i].expected_errno != saved_errno) { tst_msg("Expected errno %i (%s) got %i (%s) on '%s'", file_testcases[i].expected_errno, @@ -676,7 +674,7 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR}, {.name = "BMP Load EACCES", .tst_fn = test_BMP_Load_EACCES, .flags = TST_TMPDIR}, - + {.name = "PNG Load EIO", .tst_fn = test_PNG_Load_EIO, .flags = TST_TMPDIR}, {.name = "JPG Load EIO", .tst_fn = test_JPG_Load_EIO, @@ -685,17 +683,17 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR}, {.name = "BMP Load EIO", .tst_fn = test_BMP_Load_EIO, .flags = TST_TMPDIR}, - + /* Generic GP_LoadImage test */ {.name = "Image Load", .tst_fn = test_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Callback abort tests */ {.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "PNG Save abort", .tst_fn = test_PNG_Save_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Basic Save Load tests */ {.name = "PNG Save Load", .tst_fn = test_PNG_Save_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, @@ -703,7 +701,7 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "BMP Save Load", .tst_fn = test_BMP_Save_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - + /* Stress Save Load tests */ {.name = "PNG Stress", .tst_fn = test_PNG_stress, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, @@ -717,37 +715,37 @@ const struct tst_suite tst_suite = { .tst_fn = test_load_BMP_1bpp_1x1, .res_path = "data/bmp/bitmaps/valid/1bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP Load 4bpp 1x1", .tst_fn = test_load_BMP_4bpp_1x1, .res_path = "data/bmp/bitmaps/valid/4bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP Load 8bpp 1x1", .tst_fn = test_load_BMP_8bpp_1x1, .res_path = "data/bmp/bitmaps/valid/8bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 24bpp 1x1", .tst_fn = test_load_BMP_24bpp_1x1, .res_path = "data/bmp/bitmaps/valid/24bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 32bpp 1x1", .tst_fn = test_load_BMP_32bpp_1x1, .res_path = "data/bmp/bitmaps/valid/32bpp-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 555 1x1", .tst_fn = test_load_BMP_555_1x1, .res_path = "data/bmp/bitmaps/valid/555-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 565 1x1", .tst_fn = test_load_BMP_565_1x1, .res_path = "data/bmp/bitmaps/valid/565-1x1.bmp", .flags = TST_TMPDIR}, - + {.name = "BMP 8bpp 1x64000", .tst_fn = test_load_BMP_8bpp_1x64000, .res_path = "data/bmp/bitmaps/valid/8bpp-1x64000.bmp",
-----------------------------------------------------------------------
Summary of changes: libs/loaders/GP_BMP.c | 17 ++--- libs/loaders/GP_JPG.c | 19 ++---- libs/loaders/GP_LineConvert.c | 57 ++++++++++++++++- libs/loaders/GP_PNM.c | 45 +++++++++++--- libs/loaders/GP_TIFF.c | 7 ++ tests/loaders/Loader.h | 17 ++++- tests/loaders/Makefile | 6 +- tests/loaders/PBM.c | 10 ++-- tests/loaders/PGM.c | 8 +- tests/loaders/PNG.c | 24 ++++---- tests/loaders/PPM.c | 4 +- tests/loaders/SaveLoad.gen.c.t | 136 ++++++++++++++++++++++++++++++++++++++++ tests/loaders/loaders_suite.c | 66 +++++++++---------- tests/loaders/test_list.txt | 1 + 14 files changed, 320 insertions(+), 97 deletions(-) create mode 100644 tests/loaders/SaveLoad.gen.c.t
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.