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.")
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.")
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.")