Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch master updated: 5e9ae922f961ce558878ad261b34db3dd7a99b6d
by metan 14 Sep '12
by metan 14 Sep '12
14 Sep '12
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 5e9ae922f961ce558878ad261b34db3dd7a99b6d (commit)
from ed37d412a80d1a2032cc49f00a4e505ac297f7cc (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/5e9ae922f961ce558878ad261b34db3dd7a9…
commit 5e9ae922f961ce558878ad261b34db3dd7a99b6d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 9 10:56:49 2012 +0200
libs: Several small fixes.
Notable Changes:
* Change GP_DEBUG(0, ...) to GP_WARN(...)
* Fix unmapped X11 key 'grave'
* Whitespace fixes
diff --git a/include/filters/GP_Blur.h b/include/filters/GP_Blur.h
index fb0ac26..c008774 100644
--- a/include/filters/GP_Blur.h
+++ b/include/filters/GP_Blur.h
@@ -42,15 +42,15 @@ int GP_FilterGaussianBlurEx(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
- GP_Coord x_dst, GP_Coord y_dst,
- float x_sigma, float y_sigma,
- GP_ProgressCallback *callback);
+ GP_Coord x_dst, GP_Coord y_dst,
+ float x_sigma, float y_sigma,
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
- float x_sigma, float y_sigma,
- GP_ProgressCallback *callback);
+ float x_sigma, float y_sigma,
+ GP_ProgressCallback *callback);
static inline int GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst,
float x_sigma, float y_sigma,
diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h
index 858ead6..8c158ff 100644
--- a/include/filters/GP_Convolution.h
+++ b/include/filters/GP_Convolution.h
@@ -100,8 +100,8 @@ static inline int GP_FilterConvolution(const GP_Context *src, GP_Context *dst,
}
static inline GP_Context *GP_FilterConvolutionAlloc(const GP_Context *src,
- const GP_FilterKernel2D *kernel,
- GP_ProgressCallback *callback)
+ const GP_FilterKernel2D *kernel,
+ GP_ProgressCallback *callback)
{
return GP_FilterConvolutionExAlloc(src, 0, 0, src->w, src->h,
kernel, callback);
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h
index 55a950c..2c4d321 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_Dither.h
@@ -53,8 +53,8 @@
* Semi internal raw version, use at your own risk.
*/
int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
/*
* Converts RGB888 24bit image to any RGB or Grayscale bitmap.
@@ -75,7 +75,7 @@ int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
*/
GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
GP_PixelType pixel_type,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Hilbert-Peano space filling curve based dithering.
diff --git a/include/filters/GP_GaussianNoise.h b/include/filters/GP_GaussianNoise.h
index 59d9d35..9e9274e 100644
--- a/include/filters/GP_GaussianNoise.h
+++ b/include/filters/GP_GaussianNoise.h
@@ -40,7 +40,7 @@ int GP_FilterGaussianNoiseAddEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- float sigma, float mu,
+ float sigma, float mu,
GP_ProgressCallback *callback);
GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src,
diff --git a/include/filters/GP_Median.h b/include/filters/GP_Median.h
index 0547793..4a479cf 100644
--- a/include/filters/GP_Median.h
+++ b/include/filters/GP_Median.h
@@ -41,7 +41,7 @@ int GP_FilterMedianEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- int xmed, int ymed,
+ int xmed, int ymed,
GP_ProgressCallback *callback);
GP_Context *GP_FilterMedianExAlloc(const GP_Context *src,
@@ -52,7 +52,7 @@ GP_Context *GP_FilterMedianExAlloc(const GP_Context *src,
static inline int GP_FilterMedian(const GP_Context *src,
GP_Context *dst,
- int xmed, int ymed,
+ int xmed, int ymed,
GP_ProgressCallback *callback)
{
return GP_FilterMedianEx(src, 0, 0, src->w, src->h,
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 31e9747..7032af3 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -42,7 +42,7 @@ int GP_FilterBrightness_Raw(const GP_Context *src, GP_Context *dst,
GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Contrast filter.
@@ -54,11 +54,11 @@ GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
*/
int GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Invert filter.
@@ -87,7 +87,7 @@ GP_Context *GP_FilterNoise(const GP_Context *src, GP_Context *dst,
*/
GP_Context *GP_FilterPoint(const GP_Context *src, GP_Context *dst,
GP_FilterParam filter_callback[],
- GP_FilterParam priv[],
- GP_ProgressCallback *callback);
+ GP_FilterParam priv[],
+ GP_ProgressCallback *callback);
#endif /* FILTERS_GP_POINT_H */
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
index 7c39ced..bafc37a 100644
--- a/include/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -170,7 +170,7 @@ int GP_FilterSymmetryByName(const char *symmetry);
int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst,
GP_FilterSymmetries symmetry,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterSymmetry_Alloc(const GP_Context *src,
GP_FilterSymmetries symmetry,
diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h
index 1660e5b..18275f0 100644
--- a/include/filters/GP_Sigma.h
+++ b/include/filters/GP_Sigma.h
@@ -48,7 +48,7 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
int xrad, int yrad, int min, float sigma,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -62,7 +62,7 @@ static inline int GP_FilterSigma(const GP_Context *src,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaEx(src, 0, 0, src->w, src->h,
- dst, 0, 0, xrad, yrad, min, sigma, callback);
+ dst, 0, 0, xrad, yrad, min, sigma, callback);
}
static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src,
@@ -71,7 +71,7 @@ static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaExAlloc(src, 0, 0, src->w, src->h,
- xrad, yrad, min, sigma, callback);
+ xrad, yrad, min, sigma, callback);
}
#endif /* GP_FILTERS_SIGMA_H */
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index d95e2de..8e08476 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -536,7 +536,7 @@ GP_Backend *GP_BackendX11Init(const char *GP_UNUSED(display),
unsigned int GP_UNUSED(h),
const char *GP_UNUSED(caption))
{
- GP_DEBUG(0, "FATAL: X11 support not compiled in");
+ GP_WARN("FATAL: X11 support not compiled in");
return NULL;
}
diff --git a/libs/input/GP_InputDriverKBD.c b/libs/input/GP_InputDriverKBD.c
index c598c37..9530fca 100644
--- a/libs/input/GP_InputDriverKBD.c
+++ b/libs/input/GP_InputDriverKBD.c
@@ -75,5 +75,5 @@ void GP_InputDriverKBDEventPut(unsigned char ev)
}
}
- GP_DEBUG(0, "Unmapped key %i", keycode);
+ GP_WARN("Unmapped key %i", keycode);
}
diff --git a/libs/input/GP_InputDriverSDL.c b/libs/input/GP_InputDriverSDL.c
index 207cfca..04cf416 100644
--- a/libs/input/GP_InputDriverSDL.c
+++ b/libs/input/GP_InputDriverSDL.c
@@ -120,7 +120,7 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev)
GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, -1, NULL);
return;
default:
- GP_DEBUG(0, "Unmapped SDL Mouse button %02x",
+ GP_WARN("Unmapped SDL Mouse button %02x",
ev->button.button);
return;
}
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 656c232..5caae39 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.c
@@ -41,7 +41,7 @@ static uint16_t keycode_table[] = {
GP_KEY_LEFT_CTRL, GP_KEY_A, GP_KEY_S, GP_KEY_D,
GP_KEY_F, GP_KEY_G, GP_KEY_H, GP_KEY_J,
GP_KEY_K, GP_KEY_L, GP_KEY_SEMICOLON, GP_KEY_APOSTROPHE,
- 0, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
+ GP_KEY_GRAVE, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
GP_KEY_X, GP_KEY_C, GP_KEY_V, GP_KEY_B,
GP_KEY_N, GP_KEY_M, GP_KEY_COMMA, GP_KEY_DOT,
GP_KEY_SLASH, GP_KEY_RIGHT_SHIFT, 0, GP_KEY_LEFT_ALT,
@@ -93,8 +93,8 @@ void GP_InputDriverX11EventPut(XEvent *ev)
}
if (key == 0) {
- GP_DEBUG(0, "Unmapped X11 button %02x",
- ev->xbutton.button);
+ GP_WARN("Unmapped X11 button %02x",
+ ev->xbutton.button);
return;
}
@@ -117,14 +117,14 @@ void GP_InputDriverX11EventPut(XEvent *ev)
key = keycode_table[keycode - 9];
if (key == 0) {
- GP_DEBUG(0, "Unmapped X11 keycode %02x", keycode);
+ GP_WARN("Unmapped X11 keycode %02x", keycode);
return;
}
GP_EventPushKey(key, press, NULL);
break;
default:
- GP_DEBUG(0, "Unhandled X11 event type %u", ev->type);
+ GP_WARN("Unhandled X11 event type %u", ev->type);
}
}
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Blur.h | 10 +++++-----
include/filters/GP_Convolution.h | 4 ++--
include/filters/GP_Dither.h | 6 +++---
include/filters/GP_GaussianNoise.h | 2 +-
include/filters/GP_Median.h | 4 ++--
include/filters/GP_Point.h | 10 +++++-----
include/filters/GP_Rotate.h | 2 +-
include/filters/GP_Sigma.h | 6 +++---
libs/backends/GP_X11.c | 2 +-
libs/input/GP_InputDriverKBD.c | 2 +-
libs/input/GP_InputDriverSDL.c | 2 +-
libs/input/GP_InputDriverX11.c | 10 +++++-----
12 files changed, 30 insertions(+), 30 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: ed37d412a80d1a2032cc49f00a4e505ac297f7cc
by metan 02 Sep '12
by metan 02 Sep '12
02 Sep '12
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 ed37d412a80d1a2032cc49f00a4e505ac297f7cc (commit)
from 971eefd1c614dfb8969187f90dc32829889a874d (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/ed37d412a80d1a2032cc49f00a4e505ac297…
commit ed37d412a80d1a2032cc49f00a4e505ac297f7cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 2 17:36:17 2012 +0200
tests: loaders: Add linker path to GFXprim libs.
This fixes build on machines where GFXprim is not installed.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 5222d6b..8fb8b15 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-LDFLAGS+=-L../framework/
+LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
LDLIBS+=-ltst_preload -ldl -ltst
CFLAGS+=-I../framework/
-----------------------------------------------------------------------
Summary of changes:
tests/loaders/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 971eefd1c614dfb8969187f90dc32829889a874d
by metan 27 Aug '12
by metan 27 Aug '12
27 Aug '12
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 971eefd1c614dfb8969187f90dc32829889a874d (commit)
via 4329359915f47fe2b4946869fc59e51a7b7da4a0 (commit)
via fb0fefa324ac7b26f40cac96b49758551466bfaf (commit)
via 89f6534f6c917d672c3312e15be3d2e74358f343 (commit)
via 92bbfc390d6fb4b924e0b7f94626d981d794320a (commit)
from b2c5eaa7e3f80fd1b2f3e45f70790d6440465e8f (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/971eefd1c614dfb8969187f90dc32829889a…
commit 971eefd1c614dfb8969187f90dc32829889a874d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Aug 27 12:41:45 2012 +0200
tests: loaders: Add missing dependency on libtst.a
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 9a5aff5..5222d6b 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -10,6 +10,8 @@ CFLAGS+=-I../framework/
APPS=loaders_suite
+$(APPS): ../framework/libtst.a
+
CLEAN+=libtst_preload.so log.html log.json
include $(TOPDIR)/app.mk
http://repo.or.cz/w/gfxprim.git/commit/4329359915f47fe2b4946869fc59e51a7b7d…
commit 4329359915f47fe2b4946869fc59e51a7b7da4a0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Aug 27 12:40:12 2012 +0200
tests: Add max stats to malloc check.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index dcdaced..6535ae8 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -77,6 +77,26 @@ static const char *ret_to_str(enum tst_ret ret)
return "Unknown";
}
+static void bytes_human_readable(FILE *f, size_t bytes)
+{
+ if (bytes < 512) {
+ fprintf(f, "%zuB", bytes);
+ return;
+ }
+
+ if (bytes < 1024 * 512) {
+ fprintf(f, "%.2fkB", (float)bytes / 1024);
+ return;
+ }
+
+ if (bytes < 1024 * 1024 * 512) {
+ fprintf(f, "%.2fMB", (float)bytes / 1024 / 1024);
+ return;
+ }
+
+ fprintf(f, "%.2fGB", (float)bytes / 1024 / 1024 / 1024);
+}
+
static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd)
{
/* Create innter table */
@@ -97,6 +117,14 @@ static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd)
fprintf(f, "%s </td>n", padd);
fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
+ fprintf(f, "%s <small>Max size</small>n", padd);
+ fprintf(f, "%s </td>n", padd);
+
+ fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
+ fprintf(f, "%s <small>Max chunks</small>n", padd);
+ fprintf(f, "%s </td>n", padd);
+
+ fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
fprintf(f, "%s <small>Lost size</small>n", padd);
fprintf(f, "%s </td>n", padd);
@@ -110,8 +138,9 @@ static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd)
fprintf(f, "%s <tr>n", padd);
fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
- fprintf(f, "%s <center><small>%zu</small></center>n",
- padd, job->malloc_stats.total_size);
+ fprintf(f, "%s <center><small>", padd);
+ bytes_human_readable(f, job->malloc_stats.total_size);
+ fprintf(f, "</small></center>n");
fprintf(f, "%s </td>n", padd);
fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
@@ -120,8 +149,20 @@ static void malloc_stats_html(struct tst_job *job, FILE *f, const char *padd)
fprintf(f, "%s </td>n", padd);
fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
- fprintf(f, "%s <center><small>%zu</small></center>n",
- padd, job->malloc_stats.lost_size);
+ fprintf(f, "%s <center><small>", padd);
+ bytes_human_readable(f, job->malloc_stats.max_size);
+ fprintf(f, "</small></center>n");
+ fprintf(f, "%s </td>n", padd);
+
+ fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
+ fprintf(f, "%s <center><small>%u</small></center>n",
+ padd, job->malloc_stats.max_chunks);
+ fprintf(f, "%s </td>n", padd);
+
+ fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
+ fprintf(f, "%s <center><small>", padd);
+ bytes_human_readable(f, job->malloc_stats.lost_size);
+ fprintf(f, "</small></center>n");
fprintf(f, "%s </td>n", padd);
fprintf(f, "%s <td bgcolor="#ffffaa">n", padd);
@@ -147,7 +188,7 @@ static int append_html(struct tst_job *job, FILE *f)
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 <small><font color="#222">%i.%03is %i.%03is</font></small>",
+ 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);
fprintf(f, "%s <td bgcolor="%s"><center><font color="white"> %s </td></center>n", padd,
@@ -197,6 +238,10 @@ static int append_malloc_stats_json(struct tst_job *job, FILE *f)
job->malloc_stats.total_size);
fprintf(f, "tttt"Total Chunks": %u,n",
job->malloc_stats.total_chunks);
+ fprintf(f, "tttt"Max Size": %zi,n",
+ job->malloc_stats.max_size);
+ fprintf(f, "tttt"Max Chunks": %u,n",
+ job->malloc_stats.max_chunks);
fprintf(f, "tttt"Lost Size": %zi,n",
job->malloc_stats.lost_size);
fprintf(f, "tttt"Lost Chunks": %un",
diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c
index 86927aa..7241926 100644
--- a/tests/framework/tst_preload.c
+++ b/tests/framework/tst_preload.c
@@ -44,14 +44,20 @@ static size_t cur_size = 0;
static unsigned int cur_chunks = 0;
static size_t total_size = 0;
static unsigned int total_chunks = 0;
-
+/* Maximal allocated size at a time */
+static size_t max_size = 0;
+static unsigned int max_chunks = 0;
void tst_malloc_check_report(struct malloc_stats *stats)
{
- stats->lost_size = cur_size;
- stats->lost_chunks = cur_chunks;
stats->total_size = total_size;
stats->total_chunks = total_chunks;
+
+ stats->max_size = max_size;
+ stats->max_chunks = max_chunks;
+
+ stats->lost_size = cur_size;
+ stats->lost_chunks = cur_chunks;
}
#define MAX_CHUNKS 100
@@ -83,6 +89,12 @@ static void add_chunk(size_t size, void *ptr)
cur_chunks++;
total_size += size;
total_chunks++;
+
+ if (cur_size > max_size)
+ max_size = cur_size;
+
+ if (cur_chunks > max_chunks)
+ max_chunks = cur_chunks;
}
static void rem_chunk(void *ptr)
diff --git a/tests/framework/tst_preload.h b/tests/framework/tst_preload.h
index 36bb41a..d103e8c 100644
--- a/tests/framework/tst_preload.h
+++ b/tests/framework/tst_preload.h
@@ -34,9 +34,21 @@ void tst_malloc_check_start(void);
void tst_malloc_check_stop(void);
struct malloc_stats {
+ /*
+ * Sum of all alocated chunks.
+ */
size_t total_size;
unsigned int total_chunks;
+ /*
+ * Maximal allocated size and number of chunks at any time.
+ */
+ size_t max_size;
+ unsigned int max_chunks;
+
+ /*
+ * Memory that was allocated but not freed
+ */
size_t lost_size;
unsigned int lost_chunks;
};
http://repo.or.cz/w/gfxprim.git/commit/fb0fefa324ac7b26f40cac96b49758551466…
commit fb0fefa324ac7b26f40cac96b49758551466bfaf
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Aug 27 12:14:46 2012 +0200
tests: loaders: Add more tests.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index 1f05961..cb7f398 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -120,6 +120,107 @@ static int test_JPG_Load_fail(void)
return TST_SUCCESS;
}
+static int abort_callback(GP_ProgressCallback *self __attribute__((unused)))
+{
+ return 1;
+}
+
+/*
+ * We test that a correct cleanup is done after aborting the image load from a
+ * callback.
+ */
+static int test_PNG_Save_abort(void)
+{
+ GP_Context *img;
+
+ img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
+
+ GP_ProgressCallback callback = {.callback = abort_callback};
+
+ if (GP_SavePNG(img, "test.png", &callback) == 0) {
+ tst_report(0, "Failed to save PNG saving");
+ return TST_FAILED;
+ }
+
+ int saved_errno = errno;
+
+ if (saved_errno != ECANCELED) {
+ tst_report(0, "Expected errno = ECANCELED, have %s",
+ strerror(saved_errno));
+ return TST_FAILED;
+ }
+
+ GP_ContextFree(img);
+
+ return TST_SUCCESS;
+}
+
+static int test_PNG_Load_abort(void)
+{
+ GP_Context *img;
+
+ img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
+
+ if (GP_SavePNG(img, "test.png", NULL)) {
+ tst_report(0, "Failed to save PNG: %s", strerror(errno));
+ return TST_FAILED;
+ }
+
+ GP_ContextFree(img);
+
+ GP_ProgressCallback callback = {.callback = abort_callback};
+
+ img = GP_LoadPNG("test.png", &callback);
+
+ int saved_errno = errno;
+
+ if (img != NULL) {
+ tst_report(0, "Failed to abort PNG loading");
+ return TST_FAILED;
+ }
+
+ if (saved_errno != ECANCELED) {
+ tst_report(0, "Expected errno = ECANCELED, have %s",
+ strerror(saved_errno));
+ return TST_FAILED;
+ }
+
+ 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;
+}
+
const struct tst_suite tst_suite = {
.suite_name = "Image Loaders testsuite",
.tests = {
@@ -131,6 +232,12 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR},
{.name = "JPG Load fail", .tst_fn = test_JPG_Load_fail,
.flags = TST_TMPDIR},
+ {.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 = "PNG stress", .tst_fn = test_PNG_stress,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = NULL},
}
};
http://repo.or.cz/w/gfxprim.git/commit/89f6534f6c917d672c3312e15be3d2e74358…
commit 89f6534f6c917d672c3312e15be3d2e74358f343
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Aug 27 12:14:22 2012 +0200
tests: Further edhance test job output.
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 469f22d..652b038 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -58,6 +58,8 @@ void tst_diff_timespec(int *sec, int *nsec, struct timespec *start,
}
}
+#define NAME_PADD 24
+
static void stop_test(struct tst_job *job)
{
const char *name = job->test->name;
@@ -68,33 +70,39 @@ static void stop_test(struct tst_job *job)
switch (job->result) {
case TST_SUCCESS:
- result = "e[1;32mSUCCESSe[0m";
+ result = "[ e[1;32mSUCCESSe[0m ]";
break;
case TST_INTERR:
- result = "e[1;31mINTERNAL ERRORe[0m";
+ result = "[ e[1;31mINTERNAL ERRORe[0m ]";
break;
case TST_SIGSEGV:
- result = "e[1;31mSEGFAULTe[0m";
+ result = "[ e[1;31mSEGFAULTe[0m ]";
break;
case TST_TIMEOUT:
- result = "e[1;35mTIMEOUTe[0m";
+ result = "[ e[1;35mTIMEOUTe[0m ]";
break;
case TST_ABORTED:
- result = "e[1;31mABORTEDe[0m";
+ result = "[ e[1;31mABORTEDe[0m ]";
break;
case TST_MEMLEAK:
- result = "e[1;33mMEMLEAKe[0m";
+ result = "[ e[1;33mMEMLEAKe[0m ]";
break;
case TST_FAILED:
- result = "e[1;31mFAILUREe[0m";
+ result = "[ e[1;31mFAILUREe[0m ]";
break;
case TST_MAX:
break;
}
- fprintf(stderr, "e[1;37m%se[0m finished "
- "(Time %i.%03is, CPU %i.%03is) %sn",
- name, sec, nsec/1000000,
+ fprintf(stderr, "e[1;37m%se[0m", name);
+
+ int i;
+
+ for (i = strlen(name); i < NAME_PADD; i++)
+ fprintf(stderr, " ");
+
+ fprintf(stderr, " finished (Time %i.%03is, CPU %i.%03is) %sn",
+ sec, nsec/1000000,
(int)job->cpu_time.tv_sec,
(int)job->cpu_time.tv_nsec/1000000,
result);
@@ -104,6 +112,8 @@ static void stop_test(struct tst_job *job)
/* Now print test message store */
tst_msg_print(&job->store);
+
+ fprintf(stderr, "------------------------------------------------------------------------------- n");
}
/*
@@ -267,11 +277,11 @@ void tst_job_run(struct tst_job *job)
}
/* Redirect stderr/stdout TODO: catch its output */
-// if (freopen("/dev/null", "w", stderr))
-// tst_warn("freopen(stderr) failed: %s", strerror(errno));
+ if (freopen("/dev/null", "w", stderr))
+ 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))
+ tst_warn("freopen(stderr) failed: %s", strerror(errno));
/* Create directory in /tmp/ and chdir into it. */
if (job->test->flags & TST_TMPDIR)
http://repo.or.cz/w/gfxprim.git/commit/92bbfc390d6fb4b924e0b7f94626d981d794…
commit 92bbfc390d6fb4b924e0b7f94626d981d794320a
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Aug 27 11:14:17 2012 +0200
doc: Fix typos.
diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt
index a7f65c9..75b6aa2 100644
--- a/doc/drawing_api.txt
+++ b/doc/drawing_api.txt
@@ -253,7 +253,7 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
Draws text at the position x and y; the alignment of the text in relation
to the point is specified by alignment flags.
-If the 'style' argument is NULL, a default style is used.
+If the 'style' argument is 'NULL', a default style is used.
The text size can be computed by following functions:
diff --git a/doc/environment_variables.txt b/doc/environment_variables.txt
index 71e3b91..dec32e7 100644
--- a/doc/environment_variables.txt
+++ b/doc/environment_variables.txt
@@ -25,6 +25,6 @@ GP_DEBUG
~~~~~~~~
The 'GP_DEBUG' environment variable may be used to set library debug level.
-The variable and its value is used only once a the time first debug message is
-about to be printed.
+The variable and its value is used only once at the time first debug message
+is about to be printed.
-----------------------------------------------------------------------
Summary of changes:
doc/drawing_api.txt | 2 +-
doc/environment_variables.txt | 4 +-
tests/framework/tst_job.c | 38 +++++++++-----
tests/framework/tst_log.c | 55 +++++++++++++++++++--
tests/framework/tst_preload.c | 18 ++++++-
tests/framework/tst_preload.h | 12 +++++
tests/loaders/Makefile | 2 +
tests/loaders/loaders_suite.c | 107 +++++++++++++++++++++++++++++++++++++++++
8 files changed, 213 insertions(+), 25 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: b2c5eaa7e3f80fd1b2f3e45f70790d6440465e8f
by metan 26 Aug '12
by metan 26 Aug '12
26 Aug '12
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 b2c5eaa7e3f80fd1b2f3e45f70790d6440465e8f (commit)
via a87bf60f6d8d3d43074195e38fdb352e7fbbb99c (commit)
from dbcccdb698055de18b0adb88101bb0d450cb4d43 (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/b2c5eaa7e3f80fd1b2f3e45f70790d644046…
commit b2c5eaa7e3f80fd1b2f3e45f70790d6440465e8f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 16:38:09 2012 +0200
loaders: JPG: Fix memleak when saving JPEG image.
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index 2c40f47..fbf57c6 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -196,7 +196,6 @@ GP_Context *GP_LoadJPG(const char *src_path, GP_ProgressCallback *callback)
if (GP_OpenJPG(src_path, &f))
return NULL;
-
res = GP_ReadJPG(f, callback);
@@ -322,6 +321,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
if (setjmp(my_err.setjmp_buf)) {
err = EIO;
+ //TODO: is cinfo allocated?
goto err2;
}
@@ -366,11 +366,12 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
if (GP_ProgressCallbackReport(callback, y, src->h, src->w)) {
GP_DEBUG(1, "Operation aborted");
err = ECANCELED;
- goto err2;
+ goto err3;
}
}
jpeg_finish_compress(&cinfo);
+ jpeg_destroy_compress(&cinfo);
if (fclose(f)) {
err = errno;
@@ -378,12 +379,12 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
dst_path, strerror(errno));
goto err1;
}
-
+
GP_ProgressCallbackDone(callback);
return 0;
-//TODO: is cinfo allocated?
-err2:
+err3:
jpeg_destroy_compress(&cinfo);
+err2:
fclose(f);
err1:
unlink(dst_path);
http://repo.or.cz/w/gfxprim.git/commit/a87bf60f6d8d3d43074195e38fdb352e7fbb…
commit a87bf60f6d8d3d43074195e38fdb352e7fbbb99c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 16:36:42 2012 +0200
tests: Run loaders testsuite using build/* libraries.
diff --git a/tests/loaders/runtest.sh b/tests/loaders/runtest.sh
index acd4771..0c6d722 100755
--- a/tests/loaders/runtest.sh
+++ b/tests/loaders/runtest.sh
@@ -9,4 +9,4 @@
#
export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders_suite "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so LD_LIBRARY_PATH=../../build/ ./loaders_suite "$@"
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_JPG.c | 11 ++++++-----
tests/loaders/runtest.sh | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: dbcccdb698055de18b0adb88101bb0d450cb4d43
by metan 26 Aug '12
by metan 26 Aug '12
26 Aug '12
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 dbcccdb698055de18b0adb88101bb0d450cb4d43 (commit)
via 2cbfeef63486a89fd16bf49e21280b1d8fa36ca9 (commit)
via ac1ca3c9ac663de025c756572016f59c3da732e1 (commit)
via 91a95ef7accb991b8c35c573d946fec625fabf6e (commit)
from 929e7070a0d18580bbf3eeb17b02803099acbb5f (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/dbcccdb698055de18b0adb88101bb0d450cb…
commit dbcccdb698055de18b0adb88101bb0d450cb4d43
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 15:52:53 2012 +0200
tests: Add sample loaders tests.
Ah, looks like we found a memleak allready.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 7b1285a..9a5aff5 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -4,6 +4,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
LDFLAGS+=-L../framework/
+LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
LDLIBS+=-ltst_preload -ldl -ltst
CFLAGS+=-I../framework/
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index 50fab55..1f05961 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -20,28 +20,117 @@
* *
*****************************************************************************/
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
#include <string.h>
+#include <errno.h>
+
+#include <core/GP_Context.h>
+#include <loaders/GP_Loaders.h>
#include "tst_test.h"
-#include "tst_alloc_barriers.h"
-#include "tst_preload_FILE.h"
-int success_fn(void)
+static int test_PNG_Load_Save(void)
{
- tst_report(0, "This test does nothing");
- tst_report(0, "But successfully");
-
+ GP_Context *img, *res;
+
+ img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
+
+ if (GP_SavePNG(img, "test.png", NULL)) {
+ tst_report(0, "Failed to save PNG: %s", strerror(errno));
+ return TST_FAILED;
+ }
+
+ res = GP_LoadPNG("test.png", NULL);
+
+ if (res == NULL) {
+ tst_report(0, "Failed to load PNG: %s", strerror(errno));
+ return TST_FAILED;
+ }
+
+ 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));
+ return TST_FAILED;
+ }
+
+ res = GP_LoadJPG("test.jpg", NULL);
+
+ if (res == NULL) {
+ tst_report(0, "Failed to load JPG: %s", strerror(errno));
+ return TST_FAILED;
+ }
+
+ GP_ContextFree(img);
+ GP_ContextFree(res);
+
+ return TST_SUCCESS;
+}
+
+static int test_PNG_Load_fail(void)
+{
+ GP_Context *img;
+
+ img = GP_LoadPNG("nonexistent.png", NULL);
+
+ int saved_errno = errno;
+
+ if (img != NULL) {
+ tst_report(0, "Test succedded unexpectedly");
+ return TST_FAILED;
+ }
+
+ if (saved_errno != ENOENT) {
+ tst_report(0, "Expected errno = ENOENT, have %s",
+ strerror(errno));
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_JPG_Load_fail(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;
+ }
+
+ if (saved_errno != ENOENT) {
+ tst_report(0, "Expected errno = ENOENT, have %s",
+ strerror(errno));
+ return TST_FAILED;
+ }
+
return TST_SUCCESS;
}
const struct tst_suite tst_suite = {
.suite_name = "Image Loaders testsuite",
.tests = {
- {.name = "Success test", .tst_fn = success_fn},
+ {.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},
+ {.name = "PNG Load fail", .tst_fn = test_PNG_Load_fail,
+ .flags = TST_TMPDIR},
+ {.name = "JPG Load fail", .tst_fn = test_JPG_Load_fail,
+ .flags = TST_TMPDIR},
{.name = NULL},
}
};
diff --git a/tests/loaders/runtest.sh b/tests/loaders/runtest.sh
index 707cc20..acd4771 100755
--- a/tests/loaders/runtest.sh
+++ b/tests/loaders/runtest.sh
@@ -9,4 +9,4 @@
#
export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders "$@"
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders_suite "$@"
http://repo.or.cz/w/gfxprim.git/commit/2cbfeef63486a89fd16bf49e21280b1d8fa3…
commit 2cbfeef63486a89fd16bf49e21280b1d8fa36ca9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 15:43:13 2012 +0200
tests: Fix / in test name bug && constant rename.
diff --git a/tests/framework/test.c b/tests/framework/test.c
index 1174d14..914f2d2 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -195,8 +195,8 @@ const struct tst_suite tst_suite = {
{.name = "Stack overflow test", .tst_fn = stack_overflow_fn},
{.name = "Timeout test", .tst_fn = timeout_fn, .timeout = 1},
{.name = "Tempdir test", .tst_fn = temp_dir_fn, .flags = TST_TMPDIR},
- {.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_MALLOC_CHECK},
- {.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_MALLOC_CHECK},
+ {.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_CHECK_MALLOC},
+ {.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_CHECK_MALLOC},
{.name = "Double free()", .tst_fn = double_free},
{.name = "Barrier allocation", .tst_fn = barrier_allocation},
{.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR},
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 2eda133..469f22d 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -131,18 +131,23 @@ static void remove_tmpdir(const char *path)
*/
static void create_tmpdir(const char *name, char *template, size_t size)
{
- /* Create template from test name */
- snprintf(template, size, "/tmp/ctest_%s_XXXXXX", name);
+ char safe_name[256];
/* Fix any funny characters in test name */
- char *s = template;
+ snprintf(safe_name, sizeof(safe_name), "%s", name);
+
+ char *s = safe_name;
while (*s != '0') {
- if (!isalnum(*s) && *s != '/')
+ if (!isalnum(*s))
*s = '_';
s++;
}
+ /* Create template from test name */
+ snprintf(template, size, "/tmp/ctest_%s_XXXXXX", safe_name);
+
+
if (mkdtemp(template) == NULL) {
tst_warn("mkdtemp(%s) failed: %s", template, strerror(errno));
exit(TST_INTERR);
@@ -262,11 +267,11 @@ void tst_job_run(struct tst_job *job)
}
/* Redirect stderr/stdout TODO: catch its output */
- if (freopen("/dev/null", "w", stderr))
- tst_warn("freopen(stderr) failed: %s", strerror(errno));
+// if (freopen("/dev/null", "w", stderr))
+// 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))
+// tst_warn("freopen(stderr) failed: %s", strerror(errno));
/* Create directory in /tmp/ and chdir into it. */
if (job->test->flags & TST_TMPDIR)
@@ -284,13 +289,13 @@ void tst_job_run(struct tst_job *job)
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &job->cpu_time);
write_timespec(job, 'c', &job->cpu_time);
- if (job->test->flags & TST_MALLOC_CHECK)
+ if (job->test->flags & TST_CHECK_MALLOC)
tst_malloc_check_start();
/* Run test */
ret = job->test->tst_fn();
- if (job->test->flags & TST_MALLOC_CHECK) {
+ if (job->test->flags & TST_CHECK_MALLOC) {
tst_malloc_check_stop();
tst_malloc_check_report(&job->malloc_stats);
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 57234e3..dcdaced 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -156,7 +156,7 @@ static int append_html(struct tst_job *job, FILE *f)
struct tst_msg *msg;
/* If calculated include malloc report */
- if (job->test->flags & TST_MALLOC_CHECK)
+ if (job->test->flags & TST_CHECK_MALLOC)
malloc_stats_html(job, f, padd);
for (msg = job->store.first; msg != NULL; msg = msg->next) {
@@ -223,7 +223,7 @@ static int append_json(struct tst_job *job, FILE *f)
append_msg_json(job, f);
/* If calculated include malloc report */
- if (job->test->flags & TST_MALLOC_CHECK)
+ if (job->test->flags & TST_CHECK_MALLOC)
append_malloc_stats_json(job, f);
/* Time statistics */
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index e38b92f..27eaff5 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -44,7 +44,7 @@ enum tst_flags {
/*
* Check malloc for memory leaks.
*/
- TST_MALLOC_CHECK = 0x02,
+ TST_CHECK_MALLOC = 0x02,
};
struct tst_test {
http://repo.or.cz/w/gfxprim.git/commit/ac1ca3c9ac663de025c756572016f59c3da7…
commit ac1ca3c9ac663de025c756572016f59c3da732e1
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 15:41:55 2012 +0200
tests: Add test framework build as default target.
diff --git a/tests/Makefile b/tests/Makefile
index d7405d2..f965da6 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,8 @@
TOPDIR=..
-SUBDIRS=core SDL drivers
+include $(TOPDIR)/pre.mk
+
+SUBDIRS=core SDL drivers framework loaders
+
+loaders: framework
+
include $(TOPDIR)/post.mk
http://repo.or.cz/w/gfxprim.git/commit/91a95ef7accb991b8c35c573d946fec625fa…
commit 91a95ef7accb991b8c35c573d946fec625fabf6e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Aug 26 15:22:33 2012 +0200
tests: Add global test main.
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 9482807..709f907 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -5,19 +5,22 @@ CSOURCES=$(shell echo *.c)
INCLUDE=
LDFLAGS+=-L.
-LDLIBS+=-ltst_preload -ldl
+LDLIBS+=-ltst_preload -ldl -ltst
CFLAGS+=
-test: tst_test.o tst_job.o tst_msg.o tst_log.o
+test: libtst.a
APPS=test
-ALL+=libtst_preload.so
+ALL+=libtst_preload.so libtst.a
libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o
gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
-CLEAN+=libtst_preload.so
+libtst.a: tst_test.o tst_job.o tst_msg.o tst_log.o tst_main.o
+ ar rcs $@ $^
+
+CLEAN+=libtst_preload.so libtst.a log.html log.json
include $(TOPDIR)/app.mk
include $(TOPDIR)/post.mk
diff --git a/tests/framework/runtest.sh b/tests/framework/runtest.sh
index e38592d..03e99b8 100755
--- a/tests/framework/runtest.sh
+++ b/tests/framework/runtest.sh
@@ -9,4 +9,4 @@
#
export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/libtst_preload.so ./test
+LD_PRELOAD=`pwd`/libtst_preload.so ./test "$@"
diff --git a/tests/framework/test.c b/tests/framework/test.c
index f10d404..1174d14 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -186,7 +186,7 @@ int fail_FILE(void)
return TST_SUCCESS;
}
-const struct tst_suite suite = {
+const struct tst_suite tst_suite = {
.suite_name = "Testing Framework Example",
.tests = {
{.name = "Success test", .tst_fn = success_fn},
@@ -203,17 +203,3 @@ const struct tst_suite suite = {
{.name = NULL},
}
};
-
-int main(void)
-{
- fprintf(stderr, "(Listing testsuite tests)n");
- tst_list_suite(&suite);
-
- fprintf(stderr, "n(Running selected test)n");
- tst_run_suite(&suite, "Sigsegv test");
-
- fprintf(stderr, "n(Running whole suite)n");
- tst_run_suite(&suite, NULL);
-
- return 0;
-}
diff --git a/tests/framework/tst_main.c b/tests/framework/tst_main.c
new file mode 100644
index 0000000..28020a0
--- /dev/null
+++ b/tests/framework/tst_main.c
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "tst_test.h"
+
+extern const struct tst_suite tst_suite;
+
+void print_help(void)
+{
+ fprintf(stderr, "Test suite '%s' Usage:nn", tst_suite.suite_name);
+ fprintf(stderr, "-h prints this helpn");
+ fprintf(stderr, "-l list all testsn");
+ fprintf(stderr, "-t name runs single test by namen");
+ fprintf(stderr, "without any option, all tests are executedn");
+}
+
+int main(int argc, char *argv[])
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "hlt:")) != -1) {
+ switch (opt) {
+ case 'l':
+ tst_list_suite(&tst_suite);
+ return 0;
+ break;
+ case 't':
+ tst_run_suite(&tst_suite, optarg);
+ return 0;
+ break;
+ case 'h':
+ print_help();
+ return 0;
+ break;
+ default:
+ print_help();
+ return 1;
+ }
+ }
+
+ tst_run_suite(&tst_suite, NULL);
+
+ return 0;
+}
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
new file mode 100644
index 0000000..7b1285a
--- /dev/null
+++ b/tests/loaders/Makefile
@@ -0,0 +1,15 @@
+TOPDIR=../..
+include $(TOPDIR)/pre.mk
+
+CSOURCES=$(shell echo *.c)
+
+LDFLAGS+=-L../framework/
+LDLIBS+=-ltst_preload -ldl -ltst
+CFLAGS+=-I../framework/
+
+APPS=loaders_suite
+
+CLEAN+=libtst_preload.so log.html log.json
+
+include $(TOPDIR)/app.mk
+include $(TOPDIR)/post.mk
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
new file mode 100644
index 0000000..50fab55
--- /dev/null
+++ b/tests/loaders/loaders_suite.c
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include "tst_test.h"
+#include "tst_alloc_barriers.h"
+#include "tst_preload_FILE.h"
+
+int success_fn(void)
+{
+ tst_report(0, "This test does nothing");
+ tst_report(0, "But successfully");
+
+ return TST_SUCCESS;
+}
+
+const struct tst_suite tst_suite = {
+ .suite_name = "Image Loaders testsuite",
+ .tests = {
+ {.name = "Success test", .tst_fn = success_fn},
+ {.name = NULL},
+ }
+};
diff --git a/tests/framework/runtest.sh b/tests/loaders/runtest.sh
similarity index 83%
copy from tests/framework/runtest.sh
copy to tests/loaders/runtest.sh
index e38592d..707cc20 100755
--- a/tests/framework/runtest.sh
+++ b/tests/loaders/runtest.sh
@@ -9,4 +9,4 @@
#
export LIBC_FATAL_STDERR_=1
-LD_PRELOAD=`pwd`/libtst_preload.so ./test
+LD_PRELOAD=`pwd`/../framework/libtst_preload.so ./loaders "$@"
-----------------------------------------------------------------------
Summary of changes:
tests/Makefile | 7 +-
tests/framework/Makefile | 11 +-
tests/framework/runtest.sh | 2 +-
tests/framework/test.c | 20 +---
tests/framework/tst_job.c | 25 ++--
tests/framework/tst_log.c | 4 +-
.../meta_data_dump.c => tests/framework/tst_main.c | 64 +++++-----
tests/framework/tst_test.h | 2 +-
tests/loaders/Makefile | 16 +++
tests/loaders/loaders_suite.c | 136 ++++++++++++++++++++
tests/{framework => loaders}/runtest.sh | 2 +-
11 files changed, 220 insertions(+), 69 deletions(-)
copy demos/c_simple/meta_data_dump.c => tests/framework/tst_main.c (69%)
create mode 100644 tests/loaders/Makefile
create mode 100644 tests/loaders/loaders_suite.c
copy tests/{framework => loaders}/runtest.sh (82%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 929e7070a0d18580bbf3eeb17b02803099acbb5f
by metan 24 Aug '12
by metan 24 Aug '12
24 Aug '12
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 929e7070a0d18580bbf3eeb17b02803099acbb5f (commit)
from 1883d7d07231829d270253b3f97fc8562047a12c (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/929e7070a0d18580bbf3eeb17b02803099ac…
commit 929e7070a0d18580bbf3eeb17b02803099acbb5f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Aug 24 18:51:07 2012 +0200
tests: Add code to fail fclose() and fopen() libcalls.
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 529919e..9482807 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -14,7 +14,7 @@ APPS=test
ALL+=libtst_preload.so
-libtst_preload.so: tst_preload.o tst_alloc_barriers.o
+libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o
gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
CLEAN+=libtst_preload.so
diff --git a/tests/framework/test.c b/tests/framework/test.c
index 0c908f5..f10d404 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -23,9 +23,12 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <errno.h>
+#include <string.h>
#include "tst_test.h"
#include "tst_alloc_barriers.h"
+#include "tst_preload_FILE.h"
int success_fn(void)
{
@@ -135,6 +138,54 @@ int barrier_allocation(void)
return TST_SUCCESS;
}
+int fail_FILE(void)
+{
+ struct tst_fail_FILE failures[] = {
+ {.path = "test_fail_fopen", .call = TST_FAIL_FOPEN, .err = EPERM},
+ {.path = "test_fail_fclose", .call = TST_FAIL_FCLOSE, .err = ENOSPC},
+ {.path = NULL}
+ };
+
+ tst_fail_FILE_register(failures);
+
+ int fail = 0;
+ FILE *f;
+
+ f = fopen("test_fail_fclose", "w");
+
+ if (f == NULL) {
+ tst_report(0, "Failed to open 'test_fail_fclose' for writing: %s",
+ strerror(errno));
+ fail = 1;
+ }
+
+ tst_report(0, "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'");
+ fail = 1;
+ }
+
+ tst_report(0, "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'");
+ fclose(f);
+ fail = 1;
+ }
+
+ tst_report(0, "Correctly failed to open 'test_fail_fopen'");
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
const struct tst_suite suite = {
.suite_name = "Testing Framework Example",
.tests = {
@@ -148,6 +199,7 @@ const struct tst_suite suite = {
{.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_MALLOC_CHECK},
{.name = "Double free()", .tst_fn = double_free},
{.name = "Barrier allocation", .tst_fn = barrier_allocation},
+ {.name = "Failed FILE", .tst_fn = fail_FILE, .flags = TST_TMPDIR},
{.name = NULL},
}
};
diff --git a/tests/framework/tst_preload_FILE.c b/tests/framework/tst_preload_FILE.c
new file mode 100644
index 0000000..2365b6b
--- /dev/null
+++ b/tests/framework/tst_preload_FILE.c
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <string.h>
+
+#include "tst_test.h"
+#include "tst_preload_FILE.h"
+
+struct tst_fail_FILE *failures = NULL;
+
+void tst_fail_FILE_register(struct tst_fail_FILE *self)
+{
+ failures = self;
+}
+
+static struct tst_fail_FILE *failure_by_path(const char *path,
+ enum tst_file_call call)
+{
+ unsigned int i;
+
+ if (failures == NULL)
+ return NULL;
+
+ for (i = 0; failures[i].path != NULL; i++)
+ if (failures[i].call == call &&
+ !strcmp(path, failures[i].path))
+ return &failures[i];
+
+ return NULL;
+}
+
+void failures_init_FILE(const char *path, FILE *f)
+{
+ unsigned int i;
+
+ if (failures == NULL)
+ return;
+
+ //TODO: warn on f not NULL
+ for (i = 0; failures[i].path != NULL; i++)
+ if (!strcmp(path, failures[i].path))
+ failures[i].f = f;
+}
+
+static struct tst_fail_FILE *failure_by_FILE(FILE *f, enum tst_file_call call)
+{
+ unsigned int i;
+
+ if (failures == NULL)
+ return NULL;
+
+ for (i = 0; failures[i].path != NULL; i++)
+ if (failures[i].call == call && f == failures[i].f)
+ return &failures[i];
+
+ return NULL;
+}
+
+FILE *fopen(const char *path, const char *mode)
+{
+ static FILE *(*real_fopen)(const char *, const char *);
+
+ if (!real_fopen)
+ real_fopen = dlsym(RTLD_NEXT, "fopen");
+
+ struct tst_fail_FILE *failure = failure_by_path(path, TST_FAIL_FOPEN);
+
+ if (failure) {
+ if (failure->err)
+ errno = failure->err;
+
+ return NULL;
+ }
+
+
+ FILE *f = real_fopen(path, mode);
+
+ failures_init_FILE(path, f);
+
+ return f;
+}
+
+int fclose(FILE *fp)
+{
+ static int (*real_fclose)(FILE *);
+
+ if (!real_fclose)
+ real_fclose = dlsym(RTLD_NEXT, "fclose");
+
+ struct tst_fail_FILE *failure = failure_by_FILE(fp, TST_FAIL_FCLOSE);
+
+ /*
+ * We close the file here correctly, we can because when fclose() has
+ * failed any further access results in undefined behavior.
+ */
+ if (failure) {
+ real_fclose(fp);
+
+ if (failure->err)
+ errno = failure->err;
+
+ return EOF;
+ }
+
+ return real_fclose(fp);
+}
diff --git a/tests/framework/tst_preload_FILE.h b/tests/framework/tst_preload_FILE.h
new file mode 100644
index 0000000..0c1da0a
--- /dev/null
+++ b/tests/framework/tst_preload_FILE.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef TST_PRELOAD_FILE_H
+#define TST_PRELOAD_FILE_H
+
+enum tst_file_call {
+ TST_FAIL_FOPEN = 0x01,
+ TST_FAIL_FCLOSE = 0x02,
+};
+
+/*
+ * Describes which call on which file and how should fail.
+ */
+struct tst_fail_FILE {
+ /*
+ * File path to be failed, this is matched exactly against the path
+ * passed to fopen().
+ *
+ * TODO: should we support regexps?
+ */
+ const char *path;
+
+ /* pointer to opened file, don't touch */
+ FILE *f;
+
+ /* if not zero, errno is set to this */
+ int err;
+
+ /*
+ * Which call should be failed.
+ */
+ enum tst_file_call call;
+};
+
+/*
+ * Registers NULL-terminated FILE fail table, NULL == no table.
+ */
+void tst_fail_FILE_register(struct tst_fail_FILE *self);
+
+#endif /* TST_PRELOAD_FILE_H */
-----------------------------------------------------------------------
Summary of changes:
tests/framework/Makefile | 2 +-
tests/framework/test.c | 52 ++++++++
tests/framework/tst_preload_FILE.c | 129 ++++++++++++++++++++
.../framework/tst_preload_FILE.h | 42 ++++---
4 files changed, 209 insertions(+), 16 deletions(-)
create mode 100644 tests/framework/tst_preload_FILE.c
copy include/backends/GP_BackendVirtual.h => tests/framework/tst_preload_FILE.h (71%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 1883d7d07231829d270253b3f97fc8562047a12c
by metan 23 Aug '12
by metan 23 Aug '12
23 Aug '12
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 1883d7d07231829d270253b3f97fc8562047a12c (commit)
via 7c67e75801ee1f749d80db0d8fdf67a6808b347e (commit)
from 2d7e9bb328d9e81fed96350d419f367b3fb01961 (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/1883d7d07231829d270253b3f97fc8562047…
commit 1883d7d07231829d270253b3f97fc8562047a12c
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Aug 23 22:16:37 2012 +0200
tests: Added example pyton JSON log parser.
diff --git a/tests/framework/json_parse.py b/tests/framework/json_parse.py
new file mode 100755
index 0000000..b3e0833
--- /dev/null
+++ b/tests/framework/json_parse.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+#
+# Sample python code to print testsuite name and test results from the JSON logfile
+#
+
+import json
+
+#
+# Create classes from JSON dictionary
+#
+class TestResult:
+ def __init__(self, test_result):
+ self.name = test_result["Test Name"]
+ self.result = test_result["Test Result"]
+ self.reports = test_result["Test Reports"]
+ self.cpu_time = test_result["CPU Time"]
+ self.run_time = test_result["Run Time"]
+
+ if ("Malloc Stats" in test_result):
+ self.malloc_stats = 1
+
+ def __str__(self):
+ return "Test '%s' ended with '%s' (CPU %is) (TIME %is)" % + (self.name, self.result, self.cpu_time, self.run_time)
+
+
+class TestSuite:
+ def __init__(self, testsuite_result):
+ self.name = testsuite_result["Suite Name"]
+ self.test_results = []
+
+ for test_result in testsuite_result["Test Results"]:
+ self.test_results.append(TestResult(test_result))
+
+ def __str__(self):
+ ret = 'tt' + self.name + 'nn'
+
+ max_len = 0
+ for i in self.test_results:
+ max_len = max(max_len, len(i.name))
+
+ for i in self.test_results:
+ ret += i.name
+
+ padds = (max_len - len(i.name))
+
+ while padds > 0:
+ ret += ' '
+ padds-=1
+
+ ret += " | %.3fs/%.3fs | %sn" % + (i.cpu_time, i.run_time, i.result)
+
+ for j in i.reports:
+ ret += " (%s)n" % j
+
+ return ret
+
+def main():
+ # parse JSON
+ f = open('log.json')
+ data = json.load(f)
+ f.close()
+
+ # convert to python objects
+ test_suite = TestSuite(data)
+
+ print(test_suite)
+
+if __name__ == '__main__':
+ main()
http://repo.or.cz/w/gfxprim.git/commit/7c67e75801ee1f749d80db0d8fdf67a6808b…
commit 7c67e75801ee1f749d80db0d8fdf67a6808b347e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Aug 23 16:38:25 2012 +0200
tests: Silence the job output.
This prepares to capture the messages.
diff --git a/tests/framework/runtest.sh b/tests/framework/runtest.sh
index bdefd45..e38592d 100755
--- a/tests/framework/runtest.sh
+++ b/tests/framework/runtest.sh
@@ -1,3 +1,12 @@
#!/bin/sh
+#
+# By default the glibc __libc_message() writes to /dev/tty before calling
+# the abort(). Exporting this macro makes it to use stderr instead.
+#
+# The main usage of the function are malloc assertions, so this makes us catch
+# the malloc error message by catching stderr output.
+#
+export LIBC_FATAL_STDERR_=1
+
LD_PRELOAD=`pwd`/libtst_preload.so ./test
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 150011d..2eda133 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -261,6 +261,13 @@ void tst_job_run(struct tst_job *job)
return;
}
+ /* Redirect stderr/stdout TODO: catch its output */
+ if (freopen("/dev/null", "w", stderr))
+ tst_warn("freopen(stderr) failed: %s", strerror(errno));
+
+ if (freopen("/dev/null", "w", stdout))
+ tst_warn("freopen(stderr) failed: %s", strerror(errno));
+
/* Create directory in /tmp/ and chdir into it. */
if (job->test->flags & TST_TMPDIR)
create_tmpdir(job->test->name, template, sizeof(template));
-----------------------------------------------------------------------
Summary of changes:
tests/framework/json_parse.py | 72 +++++++++++++++++++++++++++++++++++++++++
tests/framework/runtest.sh | 9 +++++
tests/framework/tst_job.c | 7 ++++
3 files changed, 88 insertions(+), 0 deletions(-)
create mode 100755 tests/framework/json_parse.py
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 2d7e9bb328d9e81fed96350d419f367b3fb01961
by metan 22 Aug '12
by metan 22 Aug '12
22 Aug '12
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 2d7e9bb328d9e81fed96350d419f367b3fb01961 (commit)
via 7402c552f2c82fd3574b90cd95e720e2865fc8b6 (commit)
via 7b51e7842889c3eb0ecf06dc9586d1acb4bfbce6 (commit)
from 14e8e751a6d78a0376951b09eff2a51c577d96ea (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/2d7e9bb328d9e81fed96350d419f367b3fb0…
commit 2d7e9bb328d9e81fed96350d419f367b3fb01961
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Aug 22 19:23:51 2012 +0200
tests: Add JSON output.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index cc063e4..57234e3 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -20,6 +20,9 @@
* *
*****************************************************************************/
+#include <sys/utsname.h>
+#include <stdio.h>
+
#include "tst_test.h"
#include "tst_job.h"
#include "tst_msg.h"
@@ -169,12 +172,84 @@ static int append_html(struct tst_job *job, FILE *f)
return 0;
}
+static int append_msg_json(struct tst_job *job, FILE *f)
+{
+ struct tst_msg *msg;
+
+ fprintf(f, "ttt"Test Reports": [n");
+
+ for (msg = job->store.first; msg != NULL; msg = msg->next) {
+ fprintf(f, "tttt"%s"", msg->msg);
+
+ if (msg->next != NULL)
+ fprintf(f, ",n");
+ }
+
+ fprintf(f, "nttt],n");
+
+ return 0;
+}
+
+static int append_malloc_stats_json(struct tst_job *job, FILE *f)
+{
+ fprintf(f, "ttt"Malloc Stats": {n");
+ fprintf(f, "tttt"Total Size": %zi,n",
+ job->malloc_stats.total_size);
+ fprintf(f, "tttt"Total Chunks": %u,n",
+ job->malloc_stats.total_chunks);
+ fprintf(f, "tttt"Lost Size": %zi,n",
+ job->malloc_stats.lost_size);
+ fprintf(f, "tttt"Lost Chunks": %un",
+ job->malloc_stats.lost_chunks);
+ fprintf(f, "ttt},n");
+
+ return 0;
+}
+
+static int hack_json_start = 0;
+
+static int append_json(struct tst_job *job, FILE *f)
+{
+ if (hack_json_start)
+ hack_json_start = 0;
+ else
+ fprintf(f, ",n");
+
+ fprintf(f, "tt{n");
+ fprintf(f, "ttt"Test Name": "%s",n", job->test->name);
+ fprintf(f, "ttt"Test Result": "%s",n", ret_to_str(job->result));
+
+ /* Append any test reports */
+ append_msg_json(job, f);
+
+ /* If calculated include malloc report */
+ if (job->test->flags & TST_MALLOC_CHECK)
+ append_malloc_stats_json(job, f);
+
+ /* Time statistics */
+ int sec, nsec;
+
+ tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time);
+
+ fprintf(f, "ttt"CPU Time": %i.%09i,n",
+ (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec);
+
+ fprintf(f, "ttt"Run Time": %i.%09in", sec, nsec);
+
+ fprintf(f, "tt}");
+
+ return 0;
+}
+
int tst_log_append(struct tst_job *job, FILE *f, enum tst_log_fmt format)
{
switch (format) {
case TST_LOG_HTML:
return append_html(job, f);
break;
+ case TST_LOG_JSON:
+ return append_json(job, f);
+ break;
default:
return 1;
}
@@ -205,6 +280,61 @@ FILE *open_html(const struct tst_suite *suite, const char *path)
return f;
}
+static void write_system_info_json(FILE *f)
+{
+ struct utsname buf;
+
+ uname(&buf);
+
+ fprintf(f, "t"System Info": {n");
+
+ fprintf(f, "tt"OS": "%s",n", buf.sysname);
+ fprintf(f, "tt"Hostname": "%s",n", buf.nodename);
+ fprintf(f, "tt"Release": "%s",n", buf.release);
+
+ /* CPU related info */
+ fprintf(f, "tt"CPU": {");
+
+ /* lscpu is part of reasonably new util-linux */
+ FILE *cmd = popen("lscpu", "r");
+
+ if (cmd != NULL) {
+ char id[256], val[1024];
+ char *del = "n";
+
+ while (fscanf(cmd, "%[^:]%*c %[^n]n", id, val) == 2) {
+ fprintf(f, "%sttt"%s": "%s"", del, id, val);
+ del = ",n";
+ }
+
+ fclose(cmd);
+ fprintf(f, "n");
+ }
+
+ fprintf(f, "tt}n");
+
+ fprintf(f, "t},n");
+}
+
+FILE *open_json(const struct tst_suite *suite, const char *path)
+{
+ FILE *f;
+
+ f = fopen(path, "w");
+
+ if (f == NULL)
+ return NULL;
+
+ fprintf(f, "{n");
+ fprintf(f, "t"Suite Name": "%s",n", suite->suite_name);
+ write_system_info_json(f);
+ fprintf(f, "t"Test Results": [n");
+
+ hack_json_start = 1;
+
+ return f;
+}
+
FILE *tst_log_open(const struct tst_suite *suite, const char *path,
enum tst_log_fmt format)
{
@@ -212,6 +342,9 @@ FILE *tst_log_open(const struct tst_suite *suite, const char *path,
case TST_LOG_HTML:
return open_html(suite, path);
break;
+ case TST_LOG_JSON:
+ return open_json(suite, path);
+ break;
default:
return NULL;
}
@@ -222,8 +355,13 @@ FILE *tst_log_open(const struct tst_suite *suite, const char *path,
static int close_html(FILE *f)
{
fprintf(f, " </table>n </body>n</html>n");
- fclose(f);
- return 0;
+ return fclose(f);
+}
+
+static int close_json(FILE *f)
+{
+ fprintf(f, "nt]n}n");
+ return fclose(f);
}
int tst_log_close(FILE *f, enum tst_log_fmt format)
@@ -232,6 +370,9 @@ int tst_log_close(FILE *f, enum tst_log_fmt format)
case TST_LOG_HTML:
return close_html(f);
break;
+ case TST_LOG_JSON:
+ return close_json(f);
+ break;
default:
return 1;
}
diff --git a/tests/framework/tst_test.c b/tests/framework/tst_test.c
index f45a582..2cc94a5 100644
--- a/tests/framework/tst_test.c
+++ b/tests/framework/tst_test.c
@@ -43,8 +43,7 @@ int tst_warn(const char *fmt, ...)
return ret;
}
-static int run_test(const struct tst_test *test, FILE *f,
- enum tst_log_fmt format)
+static int run_test(const struct tst_test *test, FILE *html, FILE *json)
{
struct tst_job job;
@@ -56,12 +55,14 @@ static int run_test(const struct tst_test *test, FILE *f,
* child and parent and the lines in the resulting
* file would be repeated several times.
*/
- fflush(f);
+ fflush(html);
+ fflush(json);
tst_job_run(&job);
tst_job_wait(&job);
- tst_log_append(&job, f, format);
+ tst_log_append(&job, html, TST_LOG_HTML);
+ tst_log_append(&job, json, TST_LOG_JSON);
/* Free the test message store */
tst_msg_clear(&job.store);
@@ -79,17 +80,19 @@ void tst_run_suite(const struct tst_suite *suite, const char *tst_name)
fprintf(stderr, "Running e[1;37m%se[0mnn", suite->suite_name);
//TODO:
- FILE *f = tst_log_open(suite, "log.html", TST_LOG_HTML);
+ FILE *html = tst_log_open(suite, "log.html", TST_LOG_HTML);
+ FILE *json = tst_log_open(suite, "log.json", TST_LOG_JSON);
for (i = 0; suite->tests[i].name != NULL; i++) {
if (tst_name == NULL || !strcmp(tst_name, suite->tests[i].name)) {
- ret = run_test(&suite->tests[i], f, TST_LOG_HTML);
+ ret = run_test(&suite->tests[i], html, json);
counters[ret]++;
counter++;
}
}
- tst_log_close(f, TST_LOG_HTML);
+ tst_log_close(html, TST_LOG_HTML);
+ tst_log_close(json, TST_LOG_JSON);
fprintf(stderr, "nSummary: succedded %u out of %u (%.2f%%)n",
counters[0], counter, 100.00 * counters[0] / counter);
http://repo.or.cz/w/gfxprim.git/commit/7402c552f2c82fd3574b90cd95e720e2865f…
commit 7402c552f2c82fd3574b90cd95e720e2865fc8b6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Aug 22 16:08:20 2012 +0200
tests: Simplify malloc tracing logick.
diff --git a/tests/framework/test.c b/tests/framework/test.c
index f460139..0c908f5 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -72,12 +72,16 @@ int temp_dir_fn(void)
int malloc_leak_fn(void)
{
- void *p;
-
+ void *p, *q, *r;
+
+ q = malloc(100);
p = malloc(4);
p = malloc(3);
+ r = malloc(20);
free(p);
+ free(q);
+ free(r);
tst_report(0, "Leaking 1 chunks 4 bytes total");
@@ -86,10 +90,19 @@ int malloc_leak_fn(void)
int malloc_ok_fn(void)
{
- void *p;
+ unsigned int perm[20] = {
+ 1, 3, 2, 6, 4, 5, 0, 9, 8, 14,
+ 7, 11, 13, 10, 12, 19, 17, 16, 15, 18,
+ };
- p = malloc(100);
- free(p);
+ unsigned int i;
+ void *p[20];
+
+ for (i = 0; i < 20; i++)
+ p[i] = malloc((7 * i) % 127);
+
+ for (i = 0; i < 20; i++)
+ free(p[perm[i]]);
return TST_SUCCESS;
}
diff --git a/tests/framework/tst_preload.c b/tests/framework/tst_preload.c
index 1ba320e..86927aa 100644
--- a/tests/framework/tst_preload.c
+++ b/tests/framework/tst_preload.c
@@ -40,20 +40,12 @@ void tst_malloc_check_stop(void)
check_malloc = 0;
}
-#define MAX_CHUNKS 100
-
-struct chunk {
- void *ptr;
- size_t size;
- int cont;
-};
-
-struct chunk chunks[MAX_CHUNKS + 1];
static size_t cur_size = 0;
static unsigned int cur_chunks = 0;
static size_t total_size = 0;
static unsigned int total_chunks = 0;
+
void tst_malloc_check_report(struct malloc_stats *stats)
{
stats->lost_size = cur_size;
@@ -62,43 +54,51 @@ void tst_malloc_check_report(struct malloc_stats *stats)
stats->total_chunks = total_chunks;
}
+#define MAX_CHUNKS 100
+
+struct chunk {
+ void *ptr;
+ size_t size;
+ int cont;
+};
+
+static struct chunk chunks[MAX_CHUNKS];
+static unsigned int chunks_top = 0;
+
static void add_chunk(size_t size, void *ptr)
{
- int i;
-
- for (i = 0; i < MAX_CHUNKS; i++) {
- if (chunks[i].size == 0) {
- chunks[i].size = size;
- chunks[i].ptr = ptr;
- cur_size += size;
- cur_chunks++;
- total_size += size;
- total_chunks++;
- return;
- }
+ if (chunks_top >= MAX_CHUNKS) {
+ tst_warn("Not enough chunks (%i) for malloc() tracing",
+ MAX_CHUNKS);
+ return;
}
- tst_warn("Not enough chunks (%i) for malloc() tracing", MAX_CHUNKS);
+ /* Store chunk */
+ chunks[chunks_top].size = size;
+ chunks[chunks_top].ptr = ptr;
+ chunks_top++;
+
+ /* Update global stats */
+ cur_size += size;
+ cur_chunks++;
+ total_size += size;
+ total_chunks++;
}
static void rem_chunk(void *ptr)
{
- int i;
-
- for (i = 0; i < MAX_CHUNKS; i++) {
- /* Nothing interesting in the rest of the array */
- if (chunks[i].size == 0 && chunks[i].cont == 0)
- break;
+ unsigned int i;
+ for (i = 0; i < chunks_top; i++) {
if (chunks[i].ptr == ptr) {
+
+ /* Update global stats */
cur_size -= chunks[i].size;
cur_chunks--;
- chunks[i].size = 0;
- chunks[i].ptr = NULL;
+ /* Replace found chunk with top one */
+ chunks[i] = chunks[--chunks_top];
- if (chunks[i+1].size != 0 || chunks[i+1].cont != 0)
- chunks[i].cont = 1;
return;
}
}
http://repo.or.cz/w/gfxprim.git/commit/7b51e7842889c3eb0ecf06dc9586d1acb4bf…
commit 7b51e7842889c3eb0ecf06dc9586d1acb4bfbce6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Aug 22 13:46:08 2012 +0200
tests: Add allocation with barriers.
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index 64186ca..529919e 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -14,8 +14,8 @@ APPS=test
ALL+=libtst_preload.so
-libtst_preload.so: tst_preload.o
- gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $< -o $@
+libtst_preload.so: tst_preload.o tst_alloc_barriers.o
+ gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
CLEAN+=libtst_preload.so
diff --git a/tests/framework/test.c b/tests/framework/test.c
index 69e50eb..f460139 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -25,6 +25,7 @@
#include <stdio.h>
#include "tst_test.h"
+#include "tst_alloc_barriers.h"
int success_fn(void)
{
@@ -103,6 +104,24 @@ int double_free(void)
return TST_SUCCESS;
}
+int barrier_allocation(void)
+{
+ char *buf = tst_alloc_barrier_right(31);
+
+ int i;
+
+ for (i = 0; i < 31; i++)
+ buf[i] = 0;
+
+ tst_report(0, "About to use address after the buffer with barrier");
+
+ buf[31] = 0;
+
+ tst_report(0, "This is not printed at all");
+
+ return TST_SUCCESS;
+}
+
const struct tst_suite suite = {
.suite_name = "Testing Framework Example",
.tests = {
@@ -115,6 +134,7 @@ const struct tst_suite suite = {
{.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_MALLOC_CHECK},
{.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_MALLOC_CHECK},
{.name = "Double free()", .tst_fn = double_free},
+ {.name = "Barrier allocation", .tst_fn = barrier_allocation},
{.name = NULL},
}
};
diff --git a/tests/framework/tst_alloc_barriers.c b/tests/framework/tst_alloc_barriers.c
new file mode 100644
index 0000000..c5aa7ad
--- /dev/null
+++ b/tests/framework/tst_alloc_barriers.c
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <sys/mman.h>
+#include <malloc.h>
+#include <unistd.h>
+
+#include "tst_alloc_barriers.h"
+
+void *tst_alloc_barrier_right(size_t size)
+{
+ size_t pagesize = sysconf(_SC_PAGESIZE);
+ size_t pages = size/pagesize + !!(size%pagesize) + 1;
+
+ char *buf = memalign(pagesize, pages * pagesize);
+
+ if (buf == NULL)
+ return NULL;
+
+ /*
+ * Turn off read/write acces on the last page. The buffer starts
+ * somewhere in the first page so that the end is exactly before the
+ * start of the last page.
+ */
+ if (mprotect(buf + pagesize * (pages - 1), pagesize, PROT_NONE)) {
+ perror("mprotect");
+ free(buf);
+ return NULL;
+ }
+
+ return buf + (pagesize - size%pagesize);
+}
+
+void tst_free_barrier_right(void *ptr, size_t size)
+{
+ size_t pagesize = sysconf(_SC_PAGESIZE);
+ size_t pages = size/pagesize + !!(size%pagesize);
+ void *start = (char*)ptr - (pagesize - size%pagesize);
+
+ /* Reset the memory protection back to RW */
+ if (mprotect(start + pagesize * pages, pagesize, PROT_READ | PROT_WRITE)) {
+ perror("mprotect");
+ }
+
+ free(start);
+}
+
+void *tst_alloc_barrier_left(size_t size)
+{
+ size_t pagesize = sysconf(_SC_PAGESIZE);
+ size_t pages = size/pagesize + !!(size%pagesize) + 1;
+
+ char *buf = memalign(pagesize, pages * pagesize);
+
+ if (buf == NULL)
+ return NULL;
+
+ /*
+ * Turn off read/write acces on the first page, the buffer starts right
+ * after it.
+ */
+ if (mprotect(buf, pagesize, PROT_NONE)) {
+ perror("mprotect");
+ free(buf);
+ return NULL;
+ }
+
+ return buf + pagesize;
+}
+
+void tst_free_barrier_left(void *ptr, size_t size __attribute__((unused)))
+{
+ size_t pagesize = sysconf(_SC_PAGESIZE);
+ void *start = ptr - pagesize;
+
+ /* Reset the memory protection back to RW */
+ if (mprotect(start, pagesize, PROT_READ | PROT_WRITE)) {
+ perror("mprotect");
+ }
+
+ free(start);
+}
diff --git a/tests/framework/tst_alloc_barriers.h b/tests/framework/tst_alloc_barriers.h
new file mode 100644
index 0000000..dc6b12d
--- /dev/null
+++ b/tests/framework/tst_alloc_barriers.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * 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-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ This code could create a buffer with either left or right barrier. Barrier is
+ a page that exists right before respectively right after the buffer and is
+ set to PROT_NONE (reading or writing at adresses in such page causes
+ Segmentation Fault).
+
+ */
+
+#ifndef TST_ALLOC_BARRIERS_H
+#define TST_ALLOC_BARRIERS_H
+
+/*
+ * Allocate memory with a barrier page at the right side of the buffer
+ * (right == higher addresses).
+ *
+ * Returns NULL in case allocation or mprotect has failed.
+ */
+void *tst_alloc_barrier_right(size_t size);
+
+/*
+ * Free allocated buffer.
+ */
+void tst_free_barrier_right(void *ptr, size_t size);
+
+/*
+ * Allocate memory with barrier page at the left side of the buffer.
+ *
+ * Returns NULL in case allocation or mprotect has failed.
+ */
+void *tst_alloc_barrier_left(size_t size);
+
+/*
+ * Free allocated buffer.
+ */
+void tst_free_barrier_left(void *ptr, size_t size);
+
+#endif /* TST_ALLOC_BARRIERS_H */
-----------------------------------------------------------------------
Summary of changes:
tests/framework/Makefile | 4 +-
tests/framework/test.c | 43 +++++-
.../framework/tst_alloc_barriers.c | 95 ++++++++------
.../framework/tst_alloc_barriers.h | 43 +++---
tests/framework/tst_log.c | 145 +++++++++++++++++++-
tests/framework/tst_preload.c | 64 +++++-----
tests/framework/tst_test.c | 17 ++-
7 files changed, 302 insertions(+), 109 deletions(-)
copy libs/filters/GP_Dither.c => tests/framework/tst_alloc_barriers.c (50%)
copy include/loaders/GP_GIF.h => tests/framework/tst_alloc_barriers.h (65%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 14e8e751a6d78a0376951b09eff2a51c577d96ea
by metan 21 Aug '12
by metan 21 Aug '12
21 Aug '12
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 14e8e751a6d78a0376951b09eff2a51c577d96ea (commit)
via 0724917c736951cddddaca643b5afb079fe8841d (commit)
from 1a72b271726b22e8eb7424a49e8d85084455eaa5 (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/14e8e751a6d78a0376951b09eff2a51c577d…
commit 14e8e751a6d78a0376951b09eff2a51c577d96ea
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Aug 21 16:04:41 2012 +0200
doc: Small fixes in grabbers docs.
diff --git a/doc/grabbers.txt b/doc/grabbers.txt
index e7112cc..93af01b 100644
--- a/doc/grabbers.txt
+++ b/doc/grabbers.txt
@@ -122,5 +122,6 @@ The height and width are preferred values, you will most likely get frame by
that width and height, but the driver may return different values if chosen
width and height are not supported.
-Returns either pointer to the initialized grabber or, in case of failure, NULL
-and errno is filled.
+Returns either pointer to the initialized grabber or, in case of failure,
+'NULL' and 'errno' is set.
+
http://repo.or.cz/w/gfxprim.git/commit/0724917c736951cddddaca643b5afb079fe8…
commit 0724917c736951cddddaca643b5afb079fe8841d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Aug 21 15:02:26 2012 +0200
tests: Catch SIGABRT too.
diff --git a/tests/framework/test.c b/tests/framework/test.c
index ddc1573..69e50eb 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -93,6 +93,16 @@ int malloc_ok_fn(void)
return TST_SUCCESS;
}
+int double_free(void)
+{
+ void *p = malloc(100);
+
+ free(p);
+ free(p);
+
+ return TST_SUCCESS;
+}
+
const struct tst_suite suite = {
.suite_name = "Testing Framework Example",
.tests = {
@@ -104,6 +114,7 @@ const struct tst_suite suite = {
{.name = "Tempdir test", .tst_fn = temp_dir_fn, .flags = TST_TMPDIR},
{.name = "Mem Leak test", .tst_fn = malloc_leak_fn, .flags = TST_MALLOC_CHECK},
{.name = "Mem Ok test", .tst_fn = malloc_ok_fn, .flags = TST_MALLOC_CHECK},
+ {.name = "Double free()", .tst_fn = double_free},
{.name = NULL},
}
};
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 241e0fe..150011d 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -79,12 +79,17 @@ static void stop_test(struct tst_job *job)
case TST_TIMEOUT:
result = "e[1;35mTIMEOUTe[0m";
break;
+ case TST_ABORTED:
+ result = "e[1;31mABORTEDe[0m";
+ break;
case TST_MEMLEAK:
result = "e[1;33mMEMLEAKe[0m";
break;
case TST_FAILED:
result = "e[1;31mFAILUREe[0m";
break;
+ case TST_MAX:
+ break;
}
fprintf(stderr, "e[1;37m%se[0m finished "
@@ -272,7 +277,6 @@ void tst_job_run(struct tst_job *job)
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &job->cpu_time);
write_timespec(job, 'c', &job->cpu_time);
-
if (job->test->flags & TST_MALLOC_CHECK)
tst_malloc_check_start();
@@ -399,7 +403,15 @@ void tst_job_wait(struct tst_job *job)
case SIGALRM:
job->result = TST_TIMEOUT;
break;
+ /*
+ * abort() called most likely double free or malloc data
+ * corruption
+ */
+ case SIGABRT:
+ job->result = TST_ABORTED;
+ break;
default:
+ printf("%in", WTERMSIG(status));
job->result = TST_INTERR;
}
}
diff --git a/tests/framework/tst_job.h b/tests/framework/tst_job.h
index bdc9ed8..2e74a7d 100644
--- a/tests/framework/tst_job.h
+++ b/tests/framework/tst_job.h
@@ -33,8 +33,7 @@
#include "tst_msg.h"
#include "tst_preload.h"
-
-struct tst_test;
+#include "tst_test.h"
struct tst_job {
const struct tst_test *test;
@@ -63,7 +62,7 @@ struct tst_job {
int pid;
/* test result */
- int result;
+ enum tst_ret result;
/*
* test malloc statistics, filled if TST_MALLOC_CHECK was set.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 578c960..cc063e4 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -37,6 +37,8 @@ static const char *ret_to_bg_color(enum tst_ret ret)
return "#e00000";
case TST_TIMEOUT:
return "#800080";
+ case TST_ABORTED:
+ return "#e00000";
case TST_MEMLEAK:
return "#a0a000";
case TST_FAILED:
@@ -59,6 +61,8 @@ static const char *ret_to_str(enum tst_ret ret)
return "Segmentation Fault";
case TST_TIMEOUT:
return "Timeout";
+ case TST_ABORTED:
+ return "Aborted";
case TST_MEMLEAK:
return "Memory Leak";
case TST_FAILED:
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index 50ba271..e38b92f 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -24,12 +24,13 @@
#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_MEMLEAK, /* Memory leak was detected */
- TST_FAILED, /* Test failed */
+ 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_MAX = TST_FAILED+1,
};
-----------------------------------------------------------------------
Summary of changes:
doc/grabbers.txt | 5 +++--
tests/framework/test.c | 11 +++++++++++
tests/framework/tst_job.c | 14 +++++++++++++-
tests/framework/tst_job.h | 5 ++---
tests/framework/tst_log.c | 4 ++++
tests/framework/tst_test.h | 13 +++++++------
6 files changed, 40 insertions(+), 12 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 1a72b271726b22e8eb7424a49e8d85084455eaa5
by metan 15 Aug '12
by metan 15 Aug '12
15 Aug '12
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 1a72b271726b22e8eb7424a49e8d85084455eaa5 (commit)
from 4c3c5c53d86f3703ae383dd8ca9d500836018e91 (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/1a72b271726b22e8eb7424a49e8d85084455…
commit 1a72b271726b22e8eb7424a49e8d85084455eaa5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Aug 15 20:22:23 2012 +0200
build: Reorder object files and LDLIBS.
This fixes linking failure on Ubuntu.
diff --git a/app.mk b/app.mk
index 556f9fd..c5aef12 100644
--- a/app.mk
+++ b/app.mk
@@ -5,8 +5,8 @@ CLEAN+=$(APPS)
%: %.o
ifdef VERBOSE
- $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
+ $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group -o $@
else
@echo "LD $@"
- @$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $(LDLIBS) $^ -Wl,--end-group -o $@
+ @$(CC) $(CFLAGS) $(LDFLAGS) -Wl,--start-group $^ $(LDLIBS) -Wl,--end-group -o $@
endif
diff --git a/configure b/configure
index 9721a42..0919ff2 100755
--- a/configure
+++ b/configure
@@ -120,14 +120,14 @@ class libraries:
f.write("n")
#
- # Writes LDFLAGS and CFLAGS into passed file
+ # Writes LDLIBS and CFLAGS into passed file
#
def write_config_mk(self, f):
for i in self.libraries:
f.write("# %s - %sn" % (i[0], i[1]))
if self.results[i[0]]:
f.write("HAVE_%s=yesn" % i[0].upper())
- f.write("CFLAGS+=%snLDFLAGS+=%sn" % (i[3], i[4]))
+ f.write("CFLAGS+=%snLDLIBS+=%sn" % (i[3], i[4]))
else:
f.write("HAVE_%s=non" % i[0].upper())
@@ -228,7 +228,7 @@ if __name__ == '__main__':
# Dictionary for default configuration parameters
#
cfg = {'CC' : ['gcc', 'Path/name of the C compiler'],
- 'CFLAGS' : ['-W -Wall -Wextra -fPIC -O2 -ggdb -D_FORTIFY_SOURCE=2', 'C compiler flags'],
+ 'CFLAGS' : ['-pthread -W -Wall -Wextra -fPIC -O2 -ggdb -D_FORTIFY_SOURCE=2', 'C compiler flags'],
'PYTHON_BIN' : ['python', 'Path/name of python interpreter'],
'SWIG' : ['swig', 'Simplified Wrapper and Interface Generator'],
'include_path': ['/usr/include', 'Path to the system headers']}
diff --git a/demos/grinder/Makefile b/demos/grinder/Makefile
index 2ea815c..4df5ea8 100644
--- a/demos/grinder/Makefile
+++ b/demos/grinder/Makefile
@@ -4,7 +4,7 @@ CSOURCES=$(shell echo *.c)
INCLUDE=core gfx
LDFLAGS+=-L$(TOPDIR)/build/
-LDLIBS+=-lrt `$(TOPDIR)/gfxprim-config --libs --libs-backends`
+LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-backends) -lrt
APPS=grinder
-----------------------------------------------------------------------
Summary of changes:
app.mk | 4 ++--
configure | 6 +++---
demos/grinder/Makefile | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0