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 2370df5de0e544ff861f5c18a9ddb430d306301e (commit) via 62334a32c731a5452fb460a76373c7ee7e241d8b (commit) via 78a4c679dd65e8dca7ffedc1e58357036baf9917 (commit) via 9134135c2343714cde81a93c58cee3111d80aa48 (commit) via ea25d6c8a8b8ecb3a1f874d05a2c5705de7b8837 (commit) via 8fa145ac2bca9ebb15fd25965c6d9afe5b2de7a0 (commit) via 94aa52632f9ade7a52a8e419b9e2d1b6309e57a2 (commit) via f8b2d14ae8aa2c8fb6f64ccae23cc8298eea3381 (commit) via e4a59032ce9295e40e84c5003d5e813553b52f2e (commit) via c643ecb4b3d832e7b3afeff095c3f453ee3d573f (commit) via b3b68550f6431afd3dd5a441e38212d09b22bdda (commit) via 3095a596cffe0dca94e5a773828af6fc0365f9d4 (commit) from f7abc056071b6987bd8ddf3b3e21b76fb2faa593 (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/2370df5de0e544ff861f5c18a9ddb430d3063...
commit 2370df5de0e544ff861f5c18a9ddb430d306301e Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 14:10:53 2012 +0200
doc: Cleaned up loaders docs, more to come.
diff --git a/doc/loaders.txt b/doc/loaders.txt index 0f31498..99ed35d 100644 --- a/doc/loaders.txt +++ b/doc/loaders.txt @@ -1,18 +1,26 @@ Context loaders --------------- -This part of gfxprim library aims to create API to load/save images from/to -common image file formats. +This part of GFXprim library aims to create API to load and save images +from/to common image file formats.
All loading functions returns a pointer to allocated and loaded image or upon -a failure 'NULL' is returned and 'errno' is set. +a failure 'NULL' and 'errno' is set.
-The possible errno values are: +All saving functions returns zero on success and non-zero on failure and +'errno' is set. If image saving is aborted by a callback, the opened file is +closed and removed from a filesystem before the call returns.
-* anything returned by fopen(), fclose(), fseek(), ... -* 'ENOSYS' if library wasn't compiled with particular library support -* 'ENOMEM' as returned by malloc() -* 'EIO'/'EILSEQ' invalid image data -* 'ECANCELED' loading canceled from callback +The possible 'errno' values (for both loading and saving) are: + +* anything returned by +open()+, +close()+, +lseek()+, +read()+, +write()+, ... + - 'ENOENT' if file doesn't exist + - 'EACCES' if process doesn't have rights + - etc. + +* 'ENOSYS' if GFXprim wasn't compiled with particular library support +* 'ENOMEM' if returned by +malloc()+ +* 'EIO' invalid image data (wrong signature, header or image data) +* 'ECANCELED' action canceled by returning non-zero from within a callback
Common Loader ~~~~~~~~~~~~~ @@ -27,7 +35,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback); -------------------------------------------------------------------------------
Loads image from a file. The format is now matched by an image file extension. -File signature loading method is on the TODO. +Fallback to file signature if file content doesn't match it's extension is on +the TODO.
[source,c] ------------------------------------------------------------------------------- @@ -44,16 +53,11 @@ file extension, if extension is invalid or if support for requested image format wasn't compiled in, non-zero is returned and 'errno' is set to 'ENOSYS'.
-Returns zero on success and non-zero on failure and 'errno' is set. The -possible errno values are 'ENOSYS' for unknown format and anything that could -be returned by 'fopen()', 'open()', 'fwrite()', 'write()', 'seek()', etc... - PNG ~~~ -The 'PNG' loading support is optionally implemented by libpng. +The 'PNG' image support is implemented by the libpng library.
-Just now, the 'PNG' support is not fully finished. Images with alpha channel -are not supported yet. +WARNING: PNG images with alpha channel are not supported yet.
[source,c] ------------------------------------------------------------------------------- @@ -68,8 +72,6 @@ Opens file and checks for 'PNG' signature. Returns zero on success (file could be opened, signature matches), the opened file is returned and the file position points right after the end of the 'PNG' signature.
-Upon failure 'errno' is filled. - This function is semi-internal, you should rather use functions listed below.
[source,c] @@ -108,17 +110,13 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path, GP_ProgressCallback *callback); -------------------------------------------------------------------------------
-Writes a Context into a 'PNG' image. If aborted by a callback, the opened file -is closed and removed before the call returns non-zero and 'errno' is set to -'ECANCELED'. - Currently only 'RGB888' format is supported, you should convert the 'GP_Context' to 'RGB888' before calling this function otherwise non-zero is returned and 'errno' is set to 'ENOSYS'.
JPEG ~~~~ -The 'JPEG' loading support is optionally implemented by jpeg library. +The 'JPEG' image support is implemented by the jpeg library.
[source,c] ------------------------------------------------------------------------------- @@ -185,7 +183,7 @@ convert the context into one of them before this functions is called. GIF ~~~
-The 'GIF' format is supported optionally by giflib library. +The 'GIF' image support is implemented by the giflib library.
[source,c] -------------------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/62334a32c731a5452fb460a76373c7ee7e241...
commit 62334a32c731a5452fb460a76373c7ee7e241d8b Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 13:31:13 2012 +0200
tests: framework: slight change in html output.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 7c6a82c..5ab46a6 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -186,12 +186,19 @@ static int append_html(struct tst_job *job, FILE *f) { const char *padd = " "; int sec, nsec; + static int hack_counter = 0; + const char *bgcol;
tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time);
+ if (hack_counter) + bgcol = "#ccccee"; + else + bgcol = "#ddddee"; + fprintf(f, "%s<tr>n", padd); - fprintf(f, "%s <td bgcolor="#ccccee">%s </td>n", padd, job->test->name); - fprintf(f, "%s <td bgcolor="#ccccee">n", padd); + fprintf(f, "%s <td bgcolor="%s">%s </td>n", padd, bgcol, job->test->name); + fprintf(f, "%s <td bgcolor="%s">n", padd, bgcol); fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is</font></small></center>", padd, sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000); fprintf(f, "%s </td>n", padd); @@ -213,7 +220,9 @@ static int append_html(struct tst_job *job, FILE *f) }
fprintf(f, "%s</tr>n", padd); - + + hack_counter = !hack_counter; + return 0; }
http://repo.or.cz/w/gfxprim.git/commit/78a4c679dd65e8dca7ffedc1e58357036baf9...
commit 78a4c679dd65e8dca7ffedc1e58357036baf9917 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 13:18:45 2012 +0200
loaders: bmp: Fix errno on invalid signature.
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c index d7ac6c5..0b1f7f5 100644 --- a/libs/loaders/GP_BMP.c +++ b/libs/loaders/GP_BMP.c @@ -535,7 +535,7 @@ int GP_OpenBMP(const char *src_path, FILE **f, GP_DEBUG(1, "Unexpected bitmap header 0x%02x (%c) 0x%02x (%c)", ch1, isascii(ch1) ? ch1 : ' ', ch2, isascii(ch2) ? ch2 : ' '); - err = EILSEQ; + err = EIO; goto err1; }
http://repo.or.cz/w/gfxprim.git/commit/9134135c2343714cde81a93c58cee3111d80a...
commit 9134135c2343714cde81a93c58cee3111d80aa48 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 13:18:04 2012 +0200
tests: loaders: Add tests for EIO.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index b35b855..aa2fa92 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -58,8 +58,6 @@ static int save_img(enum fmt fmt, const GP_Context *img, const char *name)
snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt));
- tst_report(0, "Saving %s", buf); - switch (fmt) { case PNG: return GP_SavePNG(img, buf, NULL); @@ -257,6 +255,63 @@ static int test_BMP_Load_EACCES(void) return load_eacces(BMP); }
+static int load_eio(enum fmt fmt) +{ + char buf[256]; + GP_Context *img; + + snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); + + FILE *f = fopen(buf, "w"); + + if (f == NULL) { + tst_report(0, "Failed to create file 'test'"); + return TST_INTERR; + } + + fclose(f); + + img = load(fmt, "test"); + + if (img != NULL) { + tst_report(0, "Test succedded unexpectedly"); + return TST_FAILED; + } + + if (errno == ENOSYS) { + tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + return TST_SKIPPED; + } + + if (errno != EIO) { + tst_report(0, "Expected errno = EIO, have %s", + strerror(errno)); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int test_PNG_Load_EIO(void) +{ + return load_eio(PNG); +} + +static int test_JPG_Load_EIO(void) +{ + return load_eio(JPG); +} + +static int test_GIF_Load_EIO(void) +{ + return load_eio(GIF); +} + +static int test_BMP_Load_EIO(void) +{ + return load_eio(BMP); +} + /* * We test that a correct cleanup is done after aborting the image load from a * callback. @@ -460,6 +515,15 @@ const struct tst_suite tst_suite = { {.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, + .flags = TST_TMPDIR}, + {.name = "GIF Load EIO", .tst_fn = test_GIF_Load_EIO, + .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},
http://repo.or.cz/w/gfxprim.git/commit/ea25d6c8a8b8ecb3a1f874d05a2c5705de7b8...
commit ea25d6c8a8b8ecb3a1f874d05a2c5705de7b8837 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 13:11:16 2012 +0200
loaders: gif: Fix errno handling.
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c index 15e0c44..262e5d9 100644 --- a/libs/loaders/GP_GIF.c +++ b/libs/loaders/GP_GIF.c @@ -48,11 +48,21 @@ int GP_OpenGIF(const char *src_path, void **f) { GifFileType *gf;
+ errno = 0; + gf = DGifOpenFileName(src_path);
if (gf == NULL) { - //TODO: error handling - errno = EIO; + /* + * The giflib uses open() so when we got a failure and errno + * is set => open() has failed. + * + * When errno is not set the file content was not valid so we + * set errno to EIO. + */ + if (errno == 0) + errno = EIO; + return 1; }
http://repo.or.cz/w/gfxprim.git/commit/8fa145ac2bca9ebb15fd25965c6d9afe5b2de...
commit 8fa145ac2bca9ebb15fd25965c6d9afe5b2de7a0 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 12:58:39 2012 +0200
tests: loaders: Add tests for EACCES + cleanup.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 5736829..b35b855 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -22,6 +22,7 @@
#include <string.h> #include <errno.h> +#include <sys/stat.h>
#include <core/GP_Context.h> #include <loaders/GP_Loaders.h> @@ -32,6 +33,7 @@ enum fmt { PNG, JPG, GIF, + BMP, };
static const char *strfmt(enum fmt fmt) @@ -43,35 +45,66 @@ static const char *strfmt(enum fmt fmt) return "JPG"; case GIF: return "GIF"; + case BMP: + return "BMP"; };
return "INVALID"; }
-static int load_save(enum fmt fmt, GP_Size w, GP_Size h) +static int save_img(enum fmt fmt, const GP_Context *img, const char *name) { - GP_Context *img, *res = NULL; + char buf[256];
- img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); - - if (img == NULL) { - tst_report(0, "GP_ContextAlloc failed"); - return TST_FAILED; + snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt)); + + tst_report(0, "Saving %s", buf); + + switch (fmt) { + case PNG: + return GP_SavePNG(img, buf, NULL); + case JPG: + return GP_SaveJPG(img, buf, NULL); + default: + tst_report(0, "WARNING: trying to save %s", strfmt(fmt)); + exit(TST_INTERR); } +} + +static GP_Context *load(enum fmt fmt, const char *name) +{ + char buf[256];
- int ret = 1; + snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt));
switch (fmt) { case PNG: - ret = GP_SavePNG(img, "test.png", NULL); - break; + return GP_LoadPNG(buf, NULL); case JPG: - ret = GP_SaveJPG(img, "test.jpg", NULL); - break; + return GP_LoadJPG(buf, NULL); + case GIF: + return GP_LoadGIF(buf, NULL); + case BMP: + return GP_LoadBMP(buf, NULL); default: + tst_report(0, "WARNING: trying to load %s", strfmt(fmt)); + exit(TST_INTERR); + } +} + +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_report(0, "GP_ContextAlloc failed"); return TST_INTERR; }
+ int ret = save_img(fmt, img, "test"); + if (ret) { if (errno == ENOSYS) { tst_report(0, "Save %s: ENOSYS", strfmt(fmt)); @@ -83,16 +116,7 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h) return TST_FAILED; }
- switch (fmt) { - case PNG: - res = GP_LoadPNG("test.png", NULL); - break; - case JPG: - res = GP_LoadJPG("test.jpg", NULL); - break; - default: - return TST_INTERR; - } + res = load(fmt, "test");
if (res == NULL) { tst_report(0, "Failed to load %s: %s", @@ -106,41 +130,31 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h) return TST_SUCCESS; }
-static int test_PNG_Load_Save(void) +static int test_PNG_Save_Load(void) { - return load_save(PNG, 100, 100); + return save_load(PNG, 100, 100); }
-static int test_JPG_Load_Save(void) +static int test_JPG_Save_Load(void) { - return load_save(JPG, 100, 100); + return save_load(JPG, 100, 100); }
static int test_PNG_stress(void) { - return load_save(PNG, 2000, 2000); + return save_load(PNG, 2000, 2000); }
static int test_JPG_stress(void) { - return load_save(JPG, 2000, 2000); + return save_load(JPG, 2000, 2000); }
static int load_enoent(enum fmt fmt) { - GP_Context *img = NULL; - - switch (fmt) { - case PNG: - img = GP_LoadPNG("nonexistent.png", NULL); - break; - case JPG: - img = GP_LoadJPG("nonexistent.jpg", NULL); - break; - case GIF: - img = GP_LoadGIF("nonexistent.gif", NULL); - break; - } + GP_Context *img; + + img = load(fmt, "nonexistent"); if (img != NULL) { tst_report(0, "Test succedded unexpectedly"); @@ -176,15 +190,82 @@ static int test_GIF_Load_ENOENT(void) return load_enoent(GIF); }
-static int abort_callback(GP_ProgressCallback *self __attribute__((unused))) +static int test_BMP_Load_ENOENT(void) { - return 1; + return load_enoent(BMP); +} + +static int load_eacces(enum fmt fmt) +{ + char buf[256]; + GP_Context *img; + + snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt)); + + FILE *f = fopen(buf, "w"); + + if (f == NULL) { + tst_report(0, "Failed to create file 'test'"); + return TST_INTERR; + } + + fclose(f); + + if (chmod(buf, 200)) { + tst_report(0, "chmod failed: %s", strerror(errno)); + return TST_INTERR; + } + + img = load(fmt, "test"); + + if (img != NULL) { + tst_report(0, "Test succedded unexpectedly"); + return TST_FAILED; + } + + if (errno == ENOSYS) { + tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + return TST_SKIPPED; + } + + if (errno != EACCES) { + tst_report(0, "Expected errno = EACCES, have %s", + strerror(errno)); + return TST_FAILED; + } + + return TST_SUCCESS; +} + +static int test_PNG_Load_EACCES(void) +{ + return load_eacces(PNG); +} + +static int test_JPG_Load_EACCES(void) +{ + return load_eacces(JPG); +} + +static int test_GIF_Load_EACCES(void) +{ + return load_eacces(GIF); +} + +static int test_BMP_Load_EACCES(void) +{ + return load_eacces(BMP); }
/* * We test that a correct cleanup is done after aborting the image load from a * callback. */ +static int abort_callback(GP_ProgressCallback *self __attribute__((unused))) +{ + return 1; +} + static int test_PNG_Save_abort(void) { GP_Context *img; @@ -291,7 +372,7 @@ static struct file_testcase file_testcases[] = {
{"not_here.jpg", 0, ENOENT},
- //TODO: EPERM + //TODO: EACCES
{NULL, 0, 0} }; @@ -328,7 +409,7 @@ static int test_Load(void) continue; }
- if (errno == ENOSYS) { + if (file_testcases[i].expected_errno != ENOSYS && errno == ENOSYS) { tst_report(0, "Load Image '%s': ENOSYS", file_testcases[i].filename); continue; @@ -360,26 +441,47 @@ static int test_Load(void) const struct tst_suite tst_suite = { .suite_name = "Image Loaders testsuite", .tests = { - {.name = "PNG Load/Save", .tst_fn = test_PNG_Load_Save, - .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "JPG Load/Save", .tst_fn = test_JPG_Load_Save, - .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + /* Correct errno tests */ {.name = "PNG Load ENOENT", .tst_fn = test_PNG_Load_ENOENT, .flags = TST_TMPDIR}, {.name = "JPG Load ENOENT", .tst_fn = test_JPG_Load_ENOENT, .flags = TST_TMPDIR}, {.name = "GIF Load ENOENT", .tst_fn = test_GIF_Load_ENOENT, .flags = TST_TMPDIR}, + {.name = "BMP Load ENOENT", .tst_fn = test_BMP_Load_ENOENT, + .flags = TST_TMPDIR}, + + {.name = "PNG Load EACCES", .tst_fn = test_PNG_Load_EACCES, + .flags = TST_TMPDIR}, + {.name = "JPG Load EACCES", .tst_fn = test_JPG_Load_EACCES, + .flags = TST_TMPDIR}, + {.name = "GIF Load EACCES", .tst_fn = test_GIF_Load_EACCES, + .flags = TST_TMPDIR}, + {.name = "BMP Load EACCES", .tst_fn = test_BMP_Load_EACCES, + .flags = TST_TMPDIR}, + + /* Generic GP_LoadImage test */ + {.name = "Image Load", .tst_fn = test_Load, + .flags = TST_TMPDIR}, + + /* 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}, - {.name = "Image Load", .tst_fn = test_Load, - .flags = TST_TMPDIR}, - {.name = "PNG stress", .tst_fn = test_PNG_stress, + + /* Basic Save Load tests */ + {.name = "PNG Save Load", .tst_fn = test_PNG_Save_Load, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = "JPG Save Load", .tst_fn = test_JPG_Save_Load, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "JPG stress", .tst_fn = test_JPG_stress, + + /* Stress Save Load tests */ + {.name = "PNG Stress", .tst_fn = test_PNG_stress, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = "JPG Stress", .tst_fn = test_JPG_stress, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = NULL}, } };
http://repo.or.cz/w/gfxprim.git/commit/94aa52632f9ade7a52a8e419b9e2d1b6309e5...
commit 94aa52632f9ade7a52a8e419b9e2d1b6309e57a2 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 12:57:42 2012 +0200
loaders: Fix typo that misidentified BMP as GIF.
diff --git a/libs/loaders/GP_Loaders.c b/libs/loaders/GP_Loaders.c index 4e3c3d6..b142e93 100644 --- a/libs/loaders/GP_Loaders.c +++ b/libs/loaders/GP_Loaders.c @@ -158,7 +158,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) case GP_FMT_GIF: return GP_LoadGIF(src_path, callback); case GP_FMT_BMP: - return GP_LoadGIF(src_path, callback); + return GP_LoadBMP(src_path, callback); case GP_FMT_PBM: return GP_LoadPBM(src_path, callback); case GP_FMT_PGM:
http://repo.or.cz/w/gfxprim.git/commit/f8b2d14ae8aa2c8fb6f64ccae23cc8298eea3...
commit f8b2d14ae8aa2c8fb6f64ccae23cc8298eea3381 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 11:56:54 2012 +0200
tests: loaders: Skip tests on ENOSYS.
Fix the tests to return SKIPPED status when particular library is not compiled in.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 1308737..5736829 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -31,6 +31,7 @@ enum fmt { PNG, JPG, + GIF, };
static const char *strfmt(enum fmt fmt) @@ -40,6 +41,8 @@ static const char *strfmt(enum fmt fmt) return "PNG"; case JPG: return "JPG"; + case GIF: + return "GIF"; };
return "INVALID"; @@ -65,9 +68,16 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h) case JPG: ret = GP_SaveJPG(img, "test.jpg", NULL); break; + default: + return TST_INTERR; }
if (ret) { + if (errno == ENOSYS) { + tst_report(0, "Save %s: ENOSYS", strfmt(fmt)); + return TST_SKIPPED; + } + tst_report(0, "Failed to save %s: %s", strfmt(fmt), strerror(errno)); return TST_FAILED; @@ -80,6 +90,8 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h) case JPG: res = GP_LoadJPG("test.jpg", NULL); break; + default: + return TST_INTERR; }
if (res == NULL) { @@ -114,20 +126,33 @@ static int test_JPG_stress(void) return load_save(JPG, 2000, 2000); }
-static int test_PNG_Load_fail(void) +static int load_enoent(enum fmt fmt) { - GP_Context *img; - - img = GP_LoadPNG("nonexistent.png", NULL); - - int saved_errno = errno; + GP_Context *img = NULL;
+ switch (fmt) { + case PNG: + img = GP_LoadPNG("nonexistent.png", NULL); + break; + case JPG: + img = GP_LoadJPG("nonexistent.jpg", NULL); + break; + case GIF: + img = GP_LoadGIF("nonexistent.gif", NULL); + break; + } + if (img != NULL) { tst_report(0, "Test succedded unexpectedly"); return TST_FAILED; } + + if (errno == ENOSYS) { + tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + return TST_SKIPPED; + }
- if (saved_errno != ENOENT) { + if (errno != ENOENT) { tst_report(0, "Expected errno = ENOENT, have %s", strerror(errno)); return TST_FAILED; @@ -136,26 +161,19 @@ static int test_PNG_Load_fail(void) return TST_SUCCESS; }
-static int test_JPG_Load_fail(void) +static int test_PNG_Load_ENOENT(void) { - GP_Context *img; - - img = GP_LoadJPG("nonexistent.png", NULL); - - int saved_errno = errno; - - if (img != NULL) { - tst_report(0, "Test succedded unexpectedly"); - return TST_FAILED; - } + return load_enoent(PNG); +}
- if (saved_errno != ENOENT) { - tst_report(0, "Expected errno = ENOENT, have %s", - strerror(errno)); - return TST_FAILED; - } +static int test_JPG_Load_ENOENT(void) +{ + return load_enoent(JPG); +}
- return TST_SUCCESS; +static int test_GIF_Load_ENOENT(void) +{ + return load_enoent(GIF); }
static int abort_callback(GP_ProgressCallback *self __attribute__((unused))) @@ -180,11 +198,14 @@ static int test_PNG_Save_abort(void) return TST_FAILED; } - int saved_errno = errno; - - if (saved_errno != ECANCELED) { + if (errno == ENOSYS) { + tst_report(0, "Load PNG: ENOSYS"); + return TST_SKIPPED; + } + + if (errno != ECANCELED) { tst_report(0, "Expected errno = ECANCELED, have %s", - strerror(saved_errno)); + strerror(errno)); return TST_FAILED; }
@@ -200,6 +221,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_report(0, "Save PNG: ENOSYS"); + return TST_SKIPPED; + } + tst_report(0, "Failed to save PNG: %s", strerror(errno)); return TST_FAILED; } @@ -271,7 +298,7 @@ static struct file_testcase file_testcases[] = {
static int test_Load(void) { - unsigned int i, fail = 0; + unsigned int i, fail = 0, success = 0;
/* Create empty files */ for (i = 0; file_testcases[i].filename != NULL; i++) { @@ -298,9 +325,16 @@ static int test_Load(void) tst_report(0, "GP_LoadImage('%s') succeeded " "unexpectedly", file_testcases[i].filename); fail++; + continue; + } + + if (errno == ENOSYS) { + tst_report(0, "Load Image '%s': ENOSYS", + file_testcases[i].filename); + continue; } - if (ret == NULL && file_testcases[i].expected_errno != errno) { + if (file_testcases[i].expected_errno != errno) { tst_report(0, "Expected errno %i (%s) got %i (%s) on '%s'", file_testcases[i].expected_errno, strerror(file_testcases[i].expected_errno), @@ -308,13 +342,19 @@ static int test_Load(void) strerror(saved_errno), file_testcases[i].filename); fail++; + continue; } + + success++; }
if (fail) return TST_FAILED;
- return TST_SUCCESS; + if (success) + return TST_SUCCESS; + + return TST_SKIPPED; }
const struct tst_suite tst_suite = { @@ -324,9 +364,11 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "JPG Load/Save", .tst_fn = test_JPG_Load_Save, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG Load fail", .tst_fn = test_PNG_Load_fail, + {.name = "PNG Load ENOENT", .tst_fn = test_PNG_Load_ENOENT, + .flags = TST_TMPDIR}, + {.name = "JPG Load ENOENT", .tst_fn = test_JPG_Load_ENOENT, .flags = TST_TMPDIR}, - {.name = "JPG Load fail", .tst_fn = test_JPG_Load_fail, + {.name = "GIF Load ENOENT", .tst_fn = test_GIF_Load_ENOENT, .flags = TST_TMPDIR}, {.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC},
http://repo.or.cz/w/gfxprim.git/commit/e4a59032ce9295e40e84c5003d5e813553b52...
commit e4a59032ce9295e40e84c5003d5e813553b52f2e Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 11:55:39 2012 +0200
loaders: jpg: Fix ENOSYS stubs.
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c index fbf57c6..bece7d5 100644 --- a/libs/loaders/GP_JPG.c +++ b/libs/loaders/GP_JPG.c @@ -418,14 +418,14 @@ GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path), int GP_ReadJPGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; - return NULL; + return 1; }
int GP_LoadJPGMetaData(const char GP_UNUSED(*src_path), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; - return NULL; + return 1; }
int GP_SaveJPG(const GP_Context GP_UNUSED(*src),
http://repo.or.cz/w/gfxprim.git/commit/c643ecb4b3d832e7b3afeff095c3f453ee3d5...
commit c643ecb4b3d832e7b3afeff095c3f453ee3d573f Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 11:35:58 2012 +0200
tests: framework: Introduce SKIPPED test result.
The SKIPPED test result is intended for situations where current configuration doesn't allow the test to run (i.e. ENOSYS from libcall, not enough RAM, etc.).
diff --git a/tests/framework/test.c b/tests/framework/test.c index 914f2d2..0e9e9df 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -186,10 +186,16 @@ int fail_FILE(void) return TST_SUCCESS; }
+static int skipped_fn(void) +{ + return TST_SKIPPED; +} + const struct tst_suite tst_suite = { .suite_name = "Testing Framework Example", .tests = { {.name = "Success test", .tst_fn = success_fn}, + {.name = "Skipped test", .tst_fn = skipped_fn}, {.name = "Sigsegv test", .tst_fn = sigsegv_fn}, {.name = "Failed test", .tst_fn = failed_fn}, {.name = "Stack overflow test", .tst_fn = stack_overflow_fn}, diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 652b038..f483578 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -72,6 +72,9 @@ static void stop_test(struct tst_job *job) case TST_SUCCESS: result = "[ e[1;32mSUCCESSe[0m ]"; break; + case TST_SKIPPED: + result = "[ e[1;30mSKIPPEDe[0m ]"; + break; case TST_INTERR: result = "[ e[1;31mINTERNAL ERRORe[0m ]"; break; diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c index 6535ae8..7c6a82c 100644 --- a/tests/framework/tst_log.c +++ b/tests/framework/tst_log.c @@ -34,6 +34,8 @@ static const char *ret_to_bg_color(enum tst_ret ret) switch (ret) { case TST_SUCCESS: return "#008000"; + case TST_SKIPPED: + return "#888888"; case TST_INTERR: return "#800000"; case TST_SIGSEGV: @@ -58,6 +60,8 @@ static const char *ret_to_str(enum tst_ret ret) switch (ret) { case TST_SUCCESS: return "Success"; + case TST_SKIPPED: + return "Skipped"; case TST_INTERR: return "Internal Error"; case TST_SIGSEGV: diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index 27eaff5..4eb97e0 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -24,13 +24,14 @@ #define TST_TEST_H
enum tst_ret { - TST_SUCCESS, /* Test succedded */ - TST_INTERR, /* Test framework error */ - TST_SIGSEGV, /* Test ended with SIGSEGV */ - TST_TIMEOUT, /* Test hasn't finished in time */ - TST_ABORTED, /* The abort() was called (possible double free) */ - TST_MEMLEAK, /* Memory leak was detected */ - TST_FAILED, /* Test failed */ + TST_SUCCESS, /* Test succedded */ + TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */ + TST_INTERR, /* Test framework error */ + TST_SIGSEGV, /* Test ended with SIGSEGV */ + TST_TIMEOUT, /* Test hasn't finished in time */ + TST_ABORTED, /* The abort() was called (possible double free) */ + TST_MEMLEAK, /* Memory leak was detected */ + TST_FAILED, /* Test failed */ TST_MAX = TST_FAILED+1, };
http://repo.or.cz/w/gfxprim.git/commit/b3b68550f6431afd3dd5a441e38212d09b22b...
commit b3b68550f6431afd3dd5a441e38212d09b22bdda Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 11:27:14 2012 +0200
loaders: png: Fix ENOSYS stubs.
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 73b129a..7cf7441 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -570,13 +570,13 @@ GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path), int GP_ReadPNGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; - return NULL; + return 1; }
int GP_LoadPNGMetaData(const char GP_UNUSED(*src_path), GP_MetaData GP_UNUSED(*data)) { errno = ENOSYS; - return NULL; + return 1; }
int GP_SavePNG(const GP_Context GP_UNUSED(*src),
http://repo.or.cz/w/gfxprim.git/commit/3095a596cffe0dca94e5a773828af6fc0365f...
commit 3095a596cffe0dca94e5a773828af6fc0365f9d4 Author: Cyril Hrubis metan@ucw.cz Date: Thu Sep 27 11:24:43 2012 +0200
tests: loaders: Simplify tests code.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index 918b139..1308737 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -28,45 +28,63 @@
#include "tst_test.h"
-static int test_PNG_Load_Save(void) +enum fmt { + PNG, + JPG, +}; + +static const char *strfmt(enum fmt fmt) { - GP_Context *img, *res; + switch (fmt) { + case PNG: + return "PNG"; + case JPG: + return "JPG"; + }; + + return "INVALID"; +}
- img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); +static int load_save(enum fmt fmt, GP_Size w, GP_Size h) +{ + GP_Context *img, *res = NULL;
- if (GP_SavePNG(img, "test.png", NULL)) { - tst_report(0, "Failed to save PNG: %s", strerror(errno)); + img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); + + if (img == NULL) { + tst_report(0, "GP_ContextAlloc failed"); return TST_FAILED; }
- res = GP_LoadPNG("test.png", NULL); + int ret = 1;
- if (res == NULL) { - tst_report(0, "Failed to load PNG: %s", strerror(errno)); - return TST_FAILED; + switch (fmt) { + case PNG: + ret = GP_SavePNG(img, "test.png", NULL); + break; + case JPG: + ret = GP_SaveJPG(img, "test.jpg", NULL); + break; }
- GP_ContextFree(img); - GP_ContextFree(res); - - return TST_SUCCESS; -} - -static int test_JPG_Load_Save(void) -{ - GP_Context *img, *res; - - img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888); - - if (GP_SaveJPG(img, "test.jpg", NULL)) { - tst_report(0, "Failed to save JPG: %s", strerror(errno)); + if (ret) { + tst_report(0, "Failed to save %s: %s", + strfmt(fmt), strerror(errno)); return TST_FAILED; }
- res = GP_LoadJPG("test.jpg", NULL); + switch (fmt) { + case PNG: + res = GP_LoadPNG("test.png", NULL); + break; + case JPG: + res = GP_LoadJPG("test.jpg", NULL); + break; + }
if (res == NULL) { - tst_report(0, "Failed to load JPG: %s", strerror(errno)); + tst_report(0, "Failed to load %s: %s", + strfmt(fmt), strerror(errno)); return TST_FAILED; }
@@ -76,6 +94,26 @@ static int test_JPG_Load_Save(void) return TST_SUCCESS; }
+static int test_PNG_Load_Save(void) +{ + return load_save(PNG, 100, 100); +} + +static int test_JPG_Load_Save(void) +{ + return load_save(JPG, 100, 100); +} + +static int test_PNG_stress(void) +{ + return load_save(PNG, 2000, 2000); +} + +static int test_JPG_stress(void) +{ + return load_save(JPG, 2000, 2000); +} + static int test_PNG_Load_fail(void) { GP_Context *img; @@ -188,38 +226,6 @@ static int test_PNG_Load_abort(void) return TST_SUCCESS; }
-/* - * PNG stress test, let it save and load 10MB image. - */ -static int test_PNG_stress(void) -{ - GP_Context *img; - - img = GP_ContextAlloc(2000, 2000, GP_PIXEL_RGB888); - - if (img == NULL) { - tst_report(0, "GP_ContextAlloc failed"); - return TST_FAILED; - } - - if (GP_SavePNG(img, "test.png", NULL)) { - tst_report(0, "GP_SavePNG failed with: %s", strerror(errno)); - return TST_FAILED; - } - - GP_ContextFree(img); - - img = GP_LoadPNG("test.png", NULL); - - if (img == NULL) { - tst_report(0, "GP_LoadPNG failed with: %s", strerror(errno)); - return TST_FAILED; - } - - GP_ContextFree(img); - - return TST_SUCCESS; -}
/* * Loaders test. Hammers the GP_LoadImage() interface with plenty of @@ -242,6 +248,7 @@ static struct file_testcase file_testcases[] = { {"jpg.", 1, ENOSYS}, {"gif.", 1, ENOSYS}, {"jpeg.", 1, ENOSYS}, + {"bmp.", 1, ENOSYS}, {".jpg", 1, EIO}, {"img.jpg", 1, EIO}, @@ -249,12 +256,16 @@ static struct file_testcase file_testcases[] = { {"img.png", 1, EIO}, {".gif", 1, EIO}, {"img.gif", 1, EIO}, + {".bmp", 1, EIO}, + {"img.bmp", 1, EIO}, {".pbm", 1, EIO}, {".pgm", 1, EIO}, {".ppm", 1, EIO},
{"not_here.jpg", 0, ENOENT},
+ //TODO: EPERM + {NULL, 0, 0} };
@@ -321,10 +332,12 @@ const struct tst_suite tst_suite = { .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "PNG Save abort", .tst_fn = test_PNG_Save_abort, .flags = TST_TMPDIR | TST_CHECK_MALLOC}, - {.name = "PNG stress", .tst_fn = test_PNG_stress, - .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = "Image Load", .tst_fn = test_Load, .flags = TST_TMPDIR}, + {.name = "PNG stress", .tst_fn = test_PNG_stress, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, + {.name = "JPG stress", .tst_fn = test_JPG_stress, + .flags = TST_TMPDIR | TST_CHECK_MALLOC}, {.name = NULL}, } };
-----------------------------------------------------------------------
Summary of changes: doc/loaders.txt | 48 +++--- libs/loaders/GP_BMP.c | 2 +- libs/loaders/GP_GIF.c | 14 ++- libs/loaders/GP_JPG.c | 4 +- libs/loaders/GP_Loaders.c | 2 +- libs/loaders/GP_PNG.c | 4 +- tests/framework/test.c | 6 + tests/framework/tst_job.c | 3 + tests/framework/tst_log.c | 19 ++- tests/framework/tst_test.h | 15 +- tests/loaders/loaders_suite.c | 379 ++++++++++++++++++++++++++++++++--------- 11 files changed, 374 insertions(+), 122 deletions(-)
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.