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 f7e6f933c737b7904e59d85438747f27785a89ac (commit) via 6bb7181dfe0c836adde74679982b8e66584d4c29 (commit) from 019030bda9e79cde4165d8a9f9ca78be39a5ea28 (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/f7e6f933c737b7904e59d85438747f27785a8...
commit f7e6f933c737b7904e59d85438747f27785a89ac Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 16:01:18 2012 +0100
tests: Fixup messages API and return values.
diff --git a/tests/core/Context.c b/tests/core/Context.c index ec83876..4e05306 100644 --- a/tests/core/Context.c +++ b/tests/core/Context.c @@ -40,50 +40,50 @@ static int Context_Alloc_Free(void) c = GP_ContextAlloc(100, 200, GP_PIXEL_RGB888);
if (c == NULL) { - tst_report(0, "GP_ContextAlloc() failed"); + tst_msg("GP_ContextAlloc() failed"); return TST_FAILED; }
/* Assert context properties */ if (c->bpp != 24) { - tst_report(0, "Context->bpp != 24 (== %i)", c->bpp); + tst_msg("Context->bpp != 24 (== %i)", c->bpp); return TST_FAILED; }
if (c->bytes_per_row != 3 * c->w) { - tst_report(0, "Context->bytes_per_row != %i (== %i)", - 3 * c->w, c->bytes_per_row); + tst_msg("Context->bytes_per_row != %i (== %i)", + 3 * c->w, c->bytes_per_row); return TST_FAILED; }
if (c->w != 100) { - tst_report(0, "Context->w != 100 (== %i)", c->w); + tst_msg("Context->w != 100 (== %i)", c->w); return TST_FAILED; } if (c->h != 200) { - tst_report(0, "Context->h != 200 (== %i)", c->h); + tst_msg("Context->h != 200 (== %i)", c->h); return TST_FAILED; } if (c->offset != 0) { - tst_report(0, "Context->offset != 0"); + tst_msg("Context->offset != 0"); return TST_FAILED; }
if (c->pixel_type != GP_PIXEL_RGB888) { - tst_report(0, "Context->pixel_type != GP_PIXEL_RGB888"); + tst_msg("Context->pixel_type != GP_PIXEL_RGB888"); return TST_FAILED; }
if (c->gamma != NULL) { - tst_report(0, "Context->gamma != NULL"); + tst_msg("Context->gamma != NULL"); return TST_FAILED; }
if (c->axes_swap != 0 || c->x_swap != 0 || c->y_swap != 0) { - tst_report(0, "Wrong default orientation %i %i %i", - c->axes_swap, c->x_swap, c->y_swap); + tst_msg("Wrong default orientation %i %i %i", + c->axes_swap, c->x_swap, c->y_swap); return TST_FAILED; }
@@ -101,7 +101,6 @@ const struct tst_suite tst_suite = { .tests = { {.name = "Context Alloc Free", .tst_fn = Context_Alloc_Free, .flags = TST_CHECK_MALLOC}, - {.name = NULL}, } }; diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t index 5f1354a..05ffbdd 100644 --- a/tests/core/GetPutPixel.gen.c.t +++ b/tests/core/GetPutPixel.gen.c.t @@ -50,7 +50,7 @@ static int check_filled(GP_Context *c) for (x = 0; x < (GP_Coord)c->w; x++) for (y = 0; y < (GP_Coord)c->h; y++) if (p != GP_GetPixel(c, x, y)) { - tst_report(0, "Pixels different %i %i", x, y); + tst_msg("Pixels different %i %i", x, y); return 1; } @@ -61,7 +61,7 @@ static int try_pattern(GP_Context *c, GP_Pixel p) { fill_context(c, p);
- tst_report(0, "Filling pattern 0x%x", p); + tst_msg("Filling pattern 0x%x", p);
if (check_filled(c)) return 1; @@ -79,7 +79,7 @@ static int GetPutPixel_{{ pt.name }}(void) c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }});
if (c == NULL) { - tst_report(0, "GP_ContextAlloc() failed"); + tst_msg("GP_ContextAlloc() failed"); return TST_UNTESTED; }
@@ -114,7 +114,7 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void) c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }});
if (c == NULL) { - tst_report(0, "GP_ContextAlloc() failed"); + tst_msg("GP_ContextAlloc() failed"); return TST_UNTESTED; }
@@ -133,8 +133,8 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void)
/* Must return 0 */ if (GP_GetPixel(c, x, y) != 0) { - tst_report(0, "GP_GetPixel returned non-zero " - "at %i %i", x, y); + tst_msg("GP_GetPixel returned non-zero " + "at %i %i", x, y); err++; } } diff --git a/tests/core/WritePixel_testsuite.gen.c.t b/tests/core/WritePixel_testsuite.gen.c.t index a554e9b..365c247 100644 --- a/tests/core/WritePixel_testsuite.gen.c.t +++ b/tests/core/WritePixel_testsuite.gen.c.t @@ -58,7 +58,7 @@ static void dump_buffer(const char *name, char *buf, unsigned int buf_len) unsigned int i; if (buf1_len != buf2_len) { - tst_report(0, "Invalid buffers"); + tst_msg("Invalid buffers"); return TST_FAILED; } @@ -67,7 +67,7 @@ static void dump_buffer(const char *name, char *buf, unsigned int buf_len) printf("%sn", id); dump_buffer("wrote", buf1, buf1_len); dump_buffer("gen", buf2, buf2_len); - tst_report(0, "Buffers are different"); + tst_msg("Buffers are different"); return TST_FAILED; } diff --git a/tests/filters/LinearConvolution.c b/tests/filters/LinearConvolution.c index 78d1bd4..0264ddd 100644 --- a/tests/filters/LinearConvolution.c +++ b/tests/filters/LinearConvolution.c @@ -37,8 +37,8 @@ static int load_resources(const char *path1, const char *path2, *c2 = GP_LoadImage(path2, NULL);
if (*c1 == NULL || *c2 == NULL) { - tst_report(0, "Failed to load resource"); - return TST_INTERR; + tst_err("Failed to load resource"); + return TST_UNTESTED; }
return TST_SUCCESS; diff --git a/tests/framework/test.c b/tests/framework/test.c index ccef65d..8111855 100644 --- a/tests/framework/test.c +++ b/tests/framework/test.c @@ -32,8 +32,8 @@
int success_fn(void) { - tst_report(0, "This test does nothing"); - tst_report(0, "But successfully"); + tst_msg("This test does nothing"); + tst_msg("But successfully"); return TST_SUCCESS; } @@ -57,7 +57,7 @@ int stack_overflow_fn(void)
int timeout_fn(void) { - tst_report(0, "Sleeping for ten seconds"); + tst_msg("Sleeping for ten seconds"); sleep(10); return TST_SUCCESS; } @@ -68,7 +68,7 @@ int temp_dir_fn(void)
/* log current working directory */ res = getcwd(buf, sizeof(buf)); - tst_report(0, "CWD is '%s'", res); + tst_msg("CWD is '%s'", res);
return TST_SUCCESS; } @@ -86,7 +86,7 @@ int malloc_leak_fn(void) free(q); free(r);
- tst_report(0, "Leaking 1 chunks 4 bytes total"); + tst_msg("Leaking 1 chunks 4 bytes total");
return TST_SUCCESS; } @@ -129,11 +129,11 @@ int barrier_allocation(void) for (i = 0; i < 31; i++) buf[i] = 0;
- tst_report(0, "About to use address after the buffer with barrier"); + tst_msg("About to use address after the buffer with barrier"); buf[31] = 0;
- tst_report(0, "This is not printed at all"); + tst_msg("This is not printed at all");
return TST_SUCCESS; } @@ -154,31 +154,31 @@ int fail_FILE(void) f = fopen("test_fail_fclose", "w");
if (f == NULL) { - tst_report(0, "Failed to open 'test_fail_fclose' for writing: %s", + tst_msg("Failed to open 'test_fail_fclose' for writing: %s", strerror(errno)); fail = 1; }
- tst_report(0, "Correctly opened 'test_fail_fclose'"); + tst_msg("Correctly opened 'test_fail_fclose'");
int ret = fclose(f);
if (ret == 0 || errno != ENOSPC) { - tst_report(0, "Failed to fail to close 'test_fail_fclose'"); + tst_msg("Failed to fail to close 'test_fail_fclose'"); fail = 1; }
- tst_report(0, "Correctly failed to close 'test_fail_fclose'"); + tst_msg("Correctly failed to close 'test_fail_fclose'");
f = fopen("test_fail_fopen", "w");
if (f != NULL && errno != EPERM) { - tst_report(0, "Failed to fail to open 'test_fail_fopen'"); + tst_msg("Failed to fail to open 'test_fail_fopen'"); fclose(f); fail = 1; }
- tst_report(0, "Correctly failed to open 'test_fail_fopen'"); + tst_msg("Correctly failed to open 'test_fail_fopen'");
if (fail) return TST_FAILED; @@ -186,6 +186,19 @@ int fail_FILE(void) return TST_SUCCESS; }
+static int messages_test_fn(void) +{ + /* stdout and stderr capture test */ + printf("This is stdoutn"); + fprintf(stderr, "This is stderrn"); + + tst_msg("This is message"); + tst_warn("This is a warning"); + tst_err("This is an error"); + + return TST_SUCCESS; +} + /* * This status is returned when the could not be started * because of unsufficient configuration @@ -208,7 +221,7 @@ static int untested_fn(void) static int res_fn(void) { if (access("test.c", R_OK) == 0) - tst_report(0, "File correctly copied"); + tst_msg("File correctly copied");
return TST_SUCCESS; } @@ -254,6 +267,7 @@ const struct tst_suite tst_suite = { {.name = "Resource", .tst_fn = res_fn, .flags = TST_TMPDIR, .res_path = "test.c"}, {.name = "FP exception", .tst_fn = fpe_fn}, + {.name = "Messages test", .tst_fn = messages_test_fn}, {.name = "Benchmark test", .tst_fn = benchmark_fn, .bench_iter = 10}, {.name = NULL}, } diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index 889cc45..ce39d41 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -312,6 +312,23 @@ int tst_report(int level, const char *fmt, ...) return ret; }
+int tst_msg(const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + + if (in_child()) + return tst_vreport(TST_MSG, fmt, va); + + fprintf(stderr, "MSG: "); + ret = vfprintf(stderr, fmt, va); + va_end(va); + + return ret; +} + int tst_warn(const char *fmt, ...) { va_list va; @@ -320,8 +337,26 @@ int tst_warn(const char *fmt, ...) va_start(va, fmt);
if (in_child()) - return tst_vreport(-1, fmt, va); + return tst_vreport(TST_WARN, fmt, va); + + fprintf(stderr, "WARN: "); + ret = vfprintf(stderr, fmt, va); + va_end(va); + + return ret; +} + +int tst_err(const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + + if (in_child()) + return tst_vreport(TST_ERR, fmt, va);
+ fprintf(stderr, "ERR: "); ret = vfprintf(stderr, fmt, va); va_end(va);
diff --git a/tests/framework/tst_msg.c b/tests/framework/tst_msg.c index 2d46338..852fb81 100644 --- a/tests/framework/tst_msg.c +++ b/tests/framework/tst_msg.c @@ -71,10 +71,24 @@ int tst_msg_append(struct tst_msg_store *self, int type, const char *msg_text) return 0; }
+static char type_to_char(enum tst_report_type type) +{ + switch (type) { + case TST_MSG: + return 'M'; + case TST_WARN: + return 'W'; + case TST_ERR: + return 'E'; + default: + return '?'; + } +} + void tst_msg_print(struct tst_msg_store *self) { struct tst_msg *msg;
for (msg = self->first; msg != NULL; msg = msg->next) - fprintf(stderr, "%i: %sn", msg->type, msg->msg); + fprintf(stderr, "%c: %sn", type_to_char(msg->type), msg->msg); } diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h index c6ef4fe..186d497 100644 --- a/tests/framework/tst_test.h +++ b/tests/framework/tst_test.h @@ -27,7 +27,7 @@ enum tst_ret { TST_SUCCESS, /* Test succedded */ TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */ TST_UNTESTED, /* Test not finished because of failure */ - TST_INTERR, /* Test framework error */ + TST_INTERR, /* Test framework error, do not use */ TST_SIGSEGV, /* Test ended with SIGSEGV */ TST_TIMEOUT, /* Test hasn't finished in time */ TST_ABORTED, /* The abort() was called (possible double free) */ @@ -91,10 +91,29 @@ void tst_list_suite(const struct tst_suite *suite); /* * Printf-like reporting function. */ +enum tst_report_type { + TST_MSG, + TST_WARN, + TST_ERR, +}; + +/* general report function - do not use */ int tst_report(int level, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
+/* informative message */ +int tst_msg(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +/* + * Warning and Error are used in test framework to distinguish the type of test + * internal problem. You shouldn't use this one unless the test exited with + * TST_UNTESTED. + */ int tst_warn(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+int tst_err(const char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + #endif /* TST_TEST_H */ diff --git a/tests/gfx/Circle.c b/tests/gfx/Circle.c index d159632..34637bc 100644 --- a/tests/gfx/Circle.c +++ b/tests/gfx/Circle.c @@ -110,7 +110,7 @@ static int test_circle(const char *pattern, GP_Size w, GP_Size h, c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
if (c == NULL) { - tst_report(0, "Failed to allocate context"); + tst_err("Failed to allocate context"); return TST_UNTESTED; }
@@ -122,7 +122,7 @@ static int test_circle(const char *pattern, GP_Size w, GP_Size h, err = compare_buffers(pattern, c);
if (err) { - tst_report(0, "Patterns are different"); + tst_msg("Patterns are different"); return TST_FAILED; }
diff --git a/tests/gfx/CircleSeg.c b/tests/gfx/CircleSeg.c index 69767ec..dfb099b 100644 --- a/tests/gfx/CircleSeg.c +++ b/tests/gfx/CircleSeg.c @@ -166,7 +166,7 @@ static int test_circle(const char *pattern, GP_Size w, GP_Size h, c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
if (c == NULL) { - tst_report(0, "Failed to allocate context"); + tst_err("Failed to allocate context"); return TST_UNTESTED; }
@@ -178,7 +178,7 @@ static int test_circle(const char *pattern, GP_Size w, GP_Size h, err = compare_buffers(pattern, c);
if (err) { - tst_report(0, "Patterns are different"); + tst_msg("Patterns are different"); return TST_FAILED; }
diff --git a/tests/gfx/Line.c b/tests/gfx/Line.c index 5821b25..4c15718 100644 --- a/tests/gfx/Line.c +++ b/tests/gfx/Line.c @@ -73,6 +73,20 @@ static const char line_0_0_10_10_11x11[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, };
+static const char line_0_0_11_5_11x11[] = { + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + static int test_line(const char *pattern, GP_Size w, GP_Size h, GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1) { @@ -82,7 +96,7 @@ static int test_line(const char *pattern, GP_Size w, GP_Size h, c = GP_ContextAlloc(w, h, GP_PIXEL_G8);
if (c == NULL) { - tst_report(0, "Failed to allocate context"); + tst_err("Failed to allocate context"); return TST_UNTESTED; }
@@ -94,7 +108,7 @@ static int test_line(const char *pattern, GP_Size w, GP_Size h, err = compare_buffers(pattern, c);
if (err) { - tst_report(0, "Patterns are different"); + tst_msg("Patterns are different"); return TST_FAILED; }
@@ -121,12 +135,18 @@ static int test_line__1__1_11_11(void) return test_line(line_0_0_10_10_11x11, 11, 11, -1, -1, 11, 11); }
+static int test_line_0_0_11_5(void) +{ + return test_line(line_0_0_11_5_11x11, 11, 11, 0, 0, 11, 5); +} + const struct tst_suite tst_suite = { .suite_name = "GFX Line Testsuite", .tests = { {.name = "Line 5x5 - 5x5", .tst_fn = test_line_5_5_5_5}, {.name = "Line 1x5 - 9x5", .tst_fn = test_line_1_5_9_5}, {.name = "Line 0x0 - 10x10", .tst_fn = test_line_0_0_10_10}, + {.name = "Line 0x0 - 11x5", .tst_fn = test_line_0_0_11_5}, {.name = "Line -1x-1 - 11x11", .tst_fn = test_line__1__1_11_11}, {.name = NULL} } diff --git a/tests/gfx/gfx_benchmark.c b/tests/gfx/gfx_benchmark.c index 0ec61c6..c4cff7a 100644 --- a/tests/gfx/gfx_benchmark.c +++ b/tests/gfx/gfx_benchmark.c @@ -30,8 +30,8 @@ static int bench_line(GP_PixelType type) GP_Context *img = GP_ContextAlloc(800, 600, type);
if (img == NULL) { - tst_report(0, "Malloc failed"); - return TST_INTERR; + tst_err("Malloc failed"); + return TST_UNTESTED; }
unsigned int i; @@ -74,8 +74,8 @@ static int bench_circle(GP_PixelType type) GP_Context *img = GP_ContextAlloc(800, 600, type);
if (img == NULL) { - tst_report(0, "Malloc failed"); - return TST_INTERR; + tst_err("Malloc failed"); + return TST_UNTESTED; }
unsigned int i; diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c index c87c6f9..3d9fed4 100644 --- a/tests/loaders/loaders_suite.c +++ b/tests/loaders/loaders_suite.c @@ -64,8 +64,8 @@ static int save_img(enum fmt fmt, const GP_Context *img, const char *name) case JPG: return GP_SaveJPG(img, buf, NULL); default: - tst_report(0, "WARNING: trying to save %s", strfmt(fmt)); - exit(TST_INTERR); + tst_err("Trying to save %s image", strfmt(fmt)); + exit(TST_UNTESTED); } }
@@ -85,8 +85,8 @@ static GP_Context *load(enum fmt fmt, const char *name) case BMP: return GP_LoadBMP(buf, NULL); default: - tst_report(0, "WARNING: trying to load %s", strfmt(fmt)); - exit(TST_INTERR); + tst_err("Trying to load %s image", strfmt(fmt)); + exit(TST_UNTESTED); } }
@@ -97,19 +97,19 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); if (img == NULL) { - tst_report(0, "GP_ContextAlloc failed"); - return TST_INTERR; + tst_warn("GP_ContextAlloc failed"); + return TST_UNTESTED; }
int ret = save_img(fmt, img, "test");
if (ret) { if (errno == ENOSYS) { - tst_report(0, "Save %s: ENOSYS", strfmt(fmt)); + tst_msg("Save %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; } - tst_report(0, "Failed to save %s: %s", + tst_msg("Failed to save %s: %s", strfmt(fmt), strerror(errno)); return TST_FAILED; } @@ -117,7 +117,7 @@ static int save_load(enum fmt fmt, GP_Size w, GP_Size h) res = load(fmt, "test");
if (res == NULL) { - tst_report(0, "Failed to load %s: %s", + tst_msg("Failed to load %s: %s", strfmt(fmt), strerror(errno)); return TST_FAILED; } @@ -155,18 +155,17 @@ static int load_enoent(enum fmt fmt) img = load(fmt, "nonexistent"); if (img != NULL) { - tst_report(0, "Test succedded unexpectedly"); + tst_msg("Test succedded unexpectedly"); return TST_FAILED; } if (errno == ENOSYS) { - tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; }
if (errno != ENOENT) { - tst_report(0, "Expected errno = ENOENT, have %s", - strerror(errno)); + tst_msg("Expected errno = ENOENT, have %s", strerror(errno)); return TST_FAILED; }
@@ -203,31 +202,31 @@ static int load_eacces(enum fmt fmt) FILE *f = fopen(buf, "w");
if (f == NULL) { - tst_report(0, "Failed to create file 'test'"); - return TST_INTERR; + tst_err("Failed to create file 'test': %s", strerror(errno)); + return TST_UNTESTED; }
fclose(f);
if (chmod(buf, 200)) { - tst_report(0, "chmod failed: %s", strerror(errno)); - return TST_INTERR; + tst_err("chmod failed: %s", strerror(errno)); + return TST_UNTESTED; }
img = load(fmt, "test");
if (img != NULL) { - tst_report(0, "Test succedded unexpectedly"); + tst_msg("Test succedded unexpectedly"); return TST_FAILED; } if (errno == ENOSYS) { - tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; }
if (errno != EACCES) { - tst_report(0, "Expected errno = EACCES, have %s", + tst_msg("Expected errno = EACCES, have %s", strerror(errno)); return TST_FAILED; } @@ -265,8 +264,8 @@ static int load_eio(enum fmt fmt) FILE *f = fopen(buf, "w");
if (f == NULL) { - tst_report(0, "Failed to create file 'test'"); - return TST_INTERR; + tst_err("Failed to create file 'test': %s", strerror(errno)); + return TST_UNTESTED; }
fclose(f); @@ -274,17 +273,17 @@ static int load_eio(enum fmt fmt) img = load(fmt, "test");
if (img != NULL) { - tst_report(0, "Test succedded unexpectedly"); + tst_msg("Test succedded unexpectedly"); return TST_FAILED; } if (errno == ENOSYS) { - tst_report(0, "Load %s: ENOSYS", strfmt(fmt)); + tst_msg("Load %s: ENOSYS", strfmt(fmt)); return TST_SKIPPED; }
if (errno != EIO) { - tst_report(0, "Expected errno = EIO, have %s", + tst_msg("Expected errno = EIO, have %s", strerror(errno)); return TST_FAILED; } @@ -330,17 +329,17 @@ static int test_PNG_Save_abort(void) GP_ProgressCallback callback = {.callback = abort_callback};
if (GP_SavePNG(img, "test.png", &callback) == 0) { - tst_report(0, "Failed to save PNG saving"); + tst_msg("Failed to save PNG saving"); return TST_FAILED; } if (errno == ENOSYS) { - tst_report(0, "Load PNG: ENOSYS"); + tst_msg("Load PNG: ENOSYS"); return TST_SKIPPED; }
if (errno != ECANCELED) { - tst_report(0, "Expected errno = ECANCELED, have %s", + tst_msg("Expected errno = ECANCELED, have %s", strerror(errno)); return TST_FAILED; } @@ -359,11 +358,11 @@ static int test_PNG_Load_abort(void) if (GP_SavePNG(img, "test.png", NULL)) { if (errno == ENOSYS) { - tst_report(0, "Save PNG: ENOSYS"); + tst_msg("Save PNG: ENOSYS"); return TST_SKIPPED; } - tst_report(0, "Failed to save PNG: %s", strerror(errno)); + tst_msg("Failed to save PNG: %s", strerror(errno)); return TST_FAILED; }
@@ -376,12 +375,12 @@ static int test_PNG_Load_abort(void) int saved_errno = errno;
if (img != NULL) { - tst_report(0, "Failed to abort PNG loading"); + tst_msg("Failed to abort PNG loading"); return TST_FAILED; }
if (saved_errno != ECANCELED) { - tst_report(0, "Expected errno = ECANCELED, have %s", + tst_msg("Expected errno = ECANCELED, have %s", strerror(saved_errno)); return TST_FAILED; } @@ -458,25 +457,25 @@ static int test_Load(void) int saved_errno = errno;
if (ret != NULL) { - tst_report(0, "GP_LoadImage('%s') succeeded " - "unexpectedly", file_testcases[i].filename); + tst_msg("GP_LoadImage('%s') succeeded unexpectedly", + file_testcases[i].filename); fail++; continue; }
if (file_testcases[i].expected_errno != ENOSYS && errno == ENOSYS) { - tst_report(0, "Load Image '%s': ENOSYS", - file_testcases[i].filename); + tst_msg("Load Image '%s': ENOSYS", + file_testcases[i].filename); continue; } 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), - saved_errno, - strerror(saved_errno), - file_testcases[i].filename); + tst_msg("Expected errno %i (%s) got %i (%s) on '%s'", + file_testcases[i].expected_errno, + strerror(file_testcases[i].expected_errno), + saved_errno, + strerror(saved_errno), + file_testcases[i].filename); fail++; continue; } @@ -502,10 +501,10 @@ static int test_load_BMP(const char *path) if (img == NULL) { switch (errno) { case ENOSYS: - tst_report(0, "Not Implemented"); + tst_msg("Not Implemented"); return TST_SKIPPED; default: - tst_report(0, "Got %s", strerror(errno)); + tst_msg("Got %s", strerror(errno)); return TST_FAILED; } } @@ -570,10 +569,10 @@ static int test_load_PNG(const char *path) if (img == NULL) { switch (errno) { case ENOSYS: - tst_report(0, "Not Implemented"); + tst_msg("Not Implemented"); return TST_SKIPPED; default: - tst_report(0, "Got %s", strerror(errno)); + tst_msg("Got %s", strerror(errno)); return TST_FAILED; } } @@ -605,10 +604,10 @@ static int test_load_JPEG(const char *path) if (img == NULL) { switch (errno) { case ENOSYS: - tst_report(0, "Not Implemented"); + tst_msg("Not Implemented"); return TST_SKIPPED; default: - tst_report(0, "Got %s", strerror(errno)); + tst_msg("Got %s", strerror(errno)); return TST_FAILED; } }
http://repo.or.cz/w/gfxprim.git/commit/6bb7181dfe0c836adde74679982b8e66584d4...
commit 6bb7181dfe0c836adde74679982b8e66584d4c29 Author: Cyril Hrubis metan@ucw.cz Date: Fri Nov 2 15:30:34 2012 +0100
tests: framework: Propagate tst_warn() from child.
This has been broken for quite some time.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c index d208b66..889cc45 100644 --- a/tests/framework/tst_job.c +++ b/tests/framework/tst_job.c @@ -43,6 +43,11 @@ */ static struct tst_job *my_job = NULL;
+static int in_child(void) +{ + return my_job != NULL; +} + static void start_test(struct tst_job *job) { (void)job; @@ -271,15 +276,12 @@ static void child_write(struct tst_job *job, char ch, void *ptr, ssize_t size) } }
-int tst_report(int level, const char *fmt, ...) +static int tst_vreport(int level, const char *fmt, va_list va) { - va_list va; int ret; char buf[258];
- va_start(va, fmt); ret = vsnprintf(buf+3, sizeof(buf) - 3, fmt, va); - va_end(va); ssize_t size = ret > 255 ? 255 : ret + 1;
@@ -287,9 +289,41 @@ int tst_report(int level, const char *fmt, ...) buf[1] = level; ((unsigned char*)buf)[2] = size;
- if (my_job != NULL) + if (in_child()) { if (write(my_job->pipefd, buf, size + 3) != size + 3) tst_warn("Failed to write msg to pipe."); + } else { + tst_warn("tst_report() called from parent, msg: '%s'", + buf + 3); + } + + return ret; +} + +int tst_report(int level, const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + ret = tst_vreport(level, fmt, va); + va_end(va); + + return ret; +} + +int tst_warn(const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + + if (in_child()) + return tst_vreport(-1, fmt, va); + + ret = vfprintf(stderr, fmt, va); + va_end(va);
return ret; } @@ -403,11 +437,11 @@ void tst_job_run(struct tst_job *job) }
/* Redirect stderr/stdout TODO: catch its output */ - if (freopen("/dev/null", "w", stderr)) + if (freopen("/dev/null", "w", stderr) == NULL) tst_warn("freopen(stderr) failed: %s", strerror(errno));
- if (freopen("/dev/null", "w", stdout)) - tst_warn("freopen(stderr) failed: %s", strerror(errno)); + if (freopen("/dev/null", "w", stdout) == NULL) + tst_warn("freopen(stdout) failed: %s", strerror(errno));
/* Create directory in /tmp/ and chdir into it. */ if (job->test->flags & TST_TMPDIR) diff --git a/tests/framework/tst_test.c b/tests/framework/tst_test.c index 4df0ef1..62666da 100644 --- a/tests/framework/tst_test.c +++ b/tests/framework/tst_test.c @@ -31,18 +31,6 @@ #include "tst_job.h" #include "tst_test.h"
-int tst_warn(const char *fmt, ...) -{ - va_list va; - int ret; - - va_start(va, fmt); - ret = vfprintf(stderr, fmt, va); - va_end(va); - - return ret; -} - static int run_test(const struct tst_test *test, FILE *html, FILE *json) { struct tst_job job;
-----------------------------------------------------------------------
Summary of changes: tests/core/Context.c | 23 ++++---- tests/core/GetPutPixel.gen.c.t | 12 ++-- tests/core/WritePixel_testsuite.gen.c.t | 4 +- tests/filters/LinearConvolution.c | 4 +- tests/framework/test.c | 42 +++++++++----- tests/framework/tst_job.c | 85 +++++++++++++++++++++++++--- tests/framework/tst_msg.c | 16 +++++- tests/framework/tst_test.c | 12 ---- tests/framework/tst_test.h | 21 +++++++- tests/gfx/Circle.c | 4 +- tests/gfx/CircleSeg.c | 4 +- tests/gfx/Line.c | 24 +++++++- tests/gfx/gfx_benchmark.c | 8 +- tests/loaders/loaders_suite.c | 95 +++++++++++++++---------------- 14 files changed, 238 insertions(+), 116 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.