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, generate has been updated via 1e00e08031c90d4f8d1b987d4908c9d2c938671a (commit) via 0dc22c99f6f5c323d4d623e57edce53324d7caeb (commit) via 8484734afb7ec336d7cf4399064b785e8a3d99d4 (commit) via daa6ed769550d82191a853913d329d4881a9ab85 (commit) via 9d50a7192a8d4620a221c571092015891182f63a (commit) via 57eae77c4371c555ba66b24e739bd2aab83732a9 (commit) via a31120b664ac415df88655407937f2e9c0fea489 (commit) via 3eca4f4778eee54992fcd133978419cefd9135b0 (commit) via 34f8b640d9ce81505a024b745b03a9d179eb9b27 (commit) via ecb50dd5415f6b8079e3dda4e2cd0a4f9d8043d3 (commit) from 46a94e8b7af27012503eca96f3d5a1395d75bb10 (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/1e00e08031c90d4f8d1b987d4908c9d2c9386...
commit 1e00e08031c90d4f8d1b987d4908c9d2c938671a Author: Tomas Gavenciak gavento@ucw.cz Date: Thu Jun 2 19:16:20 2011 +0200
Update .gitignore (.dep, library)
diff --git a/.gitignore b/.gitignore index 6126da2..1d500c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ *.o +*.dep *.pyc *.gen.c *.gen.h *.swp -libGP_core.so* -libGP_core.a +libGP.so* +libGP.a
http://repo.or.cz/w/gfxprim.git/commit/0dc22c99f6f5c323d4d623e57edce53324d7c...
commit 0dc22c99f6f5c323d4d623e57edce53324d7caeb Author: Tomas Gavenciak gavento@ucw.cz Date: Thu Jun 2 19:15:23 2011 +0200
Fix a typo in GP_Get/PutPixel name
diff --git a/include/core/GP_Pixel_Access.h b/include/core/GP_Pixel_Access.h index 3513d61..331d7eb 100644 --- a/include/core/GP_Pixel_Access.h +++ b/include/core/GP_Pixel_Access.h @@ -36,7 +36,7 @@ * GetPixel with context transformations and clipping. * Returns 0 for clipped pixels or pixels outside bitmap. */ -GP_Pixel GP_GetPixel_(GP_Context *context, int x, int y); +GP_Pixel GP_GetPixel(GP_Context *context, int x, int y);
/* * Version of GetPixel without transformations nor border checking. @@ -51,7 +51,7 @@ static inline GP_Pixel GP_GetPixel_Raw(GP_Context *context, int x, int y) * PutPixel with context transformations and clipping. * NOP for clipped pixels or pixels outside bitmap. */ -void GP_PutPixel_(GP_Context *context, int x, int y, GP_Pixel p); +void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p);
/* * Version of PutPixel without transformations nor border checking. diff --git a/libs/core/GP_Pixel_Access.c b/libs/core/GP_Pixel_Access.c index 4f9b579..f2b8924 100644 --- a/libs/core/GP_Pixel_Access.c +++ b/libs/core/GP_Pixel_Access.c @@ -23,7 +23,7 @@ #include "GP_Pixel_Access.h" #include "GP_Transform.h"
-GP_Pixel GP_GetPixel_(GP_Context *context, int x, int y) +GP_Pixel GP_GetPixel(GP_Context *context, int x, int y) { GP_TRANSFORM_POINT(context, x, y); if (GP_PIXEL_IS_CLIPPED(context, x, y)) @@ -31,7 +31,7 @@ GP_Pixel GP_GetPixel_(GP_Context *context, int x, int y) return GP_GetPixel_Raw(context, x, y); }
-void GP_PutPixel_(GP_Context *context, int x, int y, GP_Pixel p) +void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p) { GP_TRANSFORM_POINT(context, x, y); if (! GP_PIXEL_IS_CLIPPED(context, x, y))
http://repo.or.cz/w/gfxprim.git/commit/8484734afb7ec336d7cf4399064b785e8a3d9...
commit 8484734afb7ec336d7cf4399064b785e8a3d99d4 Author: Tomas Gavenciak gavento@ucw.cz Date: Thu Jun 2 19:12:27 2011 +0200
Testing framework refactoring and move, new tests.mk
Test collection now part of code generation Testing should be now accessible from any module
diff --git a/gen.mk b/gen.mk index ba375c0..5df5588 100644 --- a/gen.mk +++ b/gen.mk @@ -5,6 +5,14 @@ ifndef LIBNAME $(error LIBNAME not defined, fix your library Makefile) endif
+ifndef GENHEADERS +GENHEADERS= +endif + +ifndef GENSOURCES +GENSOURCES= +endif + # # Headers goes into include/core/ # diff --git a/include.mk b/include.mk index 2a103a9..c8f8b18 100644 --- a/include.mk +++ b/include.mk @@ -1,3 +1,10 @@ +# +# Make no subdirs by default +# +ifndef SUBDIRS +SUBDIRS= +endif + .PHONY: $(SUBDIRS) all clean help
all: $(SUBDIRS) diff --git a/pylib/gfxprim/generators/make_collected_tests.py b/pylib/gfxprim/generators/make_collected_tests.py new file mode 100644 index 0000000..ca117ec --- /dev/null +++ b/pylib/gfxprim/generators/make_collected_tests.py @@ -0,0 +1,140 @@ +#!/usr/bin/python +# +# Script generating collected_tests.gen.c +# +# Scrapes the target directory for .test.c files, looks for +# GP_TEST and GP_SUITE macros and generates code creating all the +# tests and the suite +# +# 2011 - Tomas Gavenciak gavento@ucw.cz +# + +# Also fixed in tests.mk +collected_tests_file = 'collected_tests.gen.c' + +import os, re, glob +from gfxprim.generators.generator import * + +def warn(msg_s, fname=None, line=None): + msg('W', msg_s, fname, line) + +def msg(prefix, msg_s, fname=None, line=None): + s = '[' + prefix + if fname: + s += ' ' + fname + if line: + s += ':%d'%line + s += '] ' + sys.stderr.write(s + msg_s + 'n') + +testfile_pattern = '*.test.c' + +suites = {} # {"suitename":["testname":{test_parameters}]} + +suite_re = re.compile("A\s*GP_SUITE((.*))\s*Z") +test_re = re.compile("A\s*GP_TEST((.*))\s*Z") + +@generator(CHeaderGenerator(name = collected_tests_file), + descr = 'Code creating the tests and suites for tests collected ' + 'from .test.c files', + authors = ["2011 - Tomas Gavenciak gavento@ucw.cz"]) +def tests_collected_tests(c): + fnames = glob.fnmatch.filter(os.listdir(c.fdir or '.'), testfile_pattern) + print fnames + for fn in fnames: + dirfn = os.path.join(c.fdir, fn) + with open(dirfn, 'rt') as f: + find_tests(f, fn) + if not fnames: + warn('No .test.c files found in "%s".' % c.fdir) + if not suites: + warn('No suites found, generating empty testsuite.') + + c.rhead("#include <check.h>nn") + + for suite, tests in suites.iteritems(): + c.rbody( + "/****************************************************************n" + " * Suite {{ suite }}n" + " */nn", suite=suite) + for t in tests: + assert ('loop_start' in t) == ('loop_end' in t) + c.rbody( + "/*n" + " * Test {{ suite }}/{{ t['name'] }} defined in {{ t['fname'] }}:{{ t['line'] }}n" + " */nn" + "void GP_TEST_{{ t['name'] }}(int);nn" + "TCase *GP_TC_{{ suite }}_{{ t['name'] }}() {n" + " TCase *tc = tcase_create("{{ t['name'] }}");n" + " _tcase_add_test(tc, GP_TEST_{{ t['name'] }}, "{{ t['name'] }}", " + "{{ t.get('expect_signal', 0) }}, {{ t.get('expect_exit', 0) }}, " + "{{ t.get('loop_start', 0) }}, {{ t.get('loop_end', 1) }});n" + " return tc;n}nn", t=t, suite=suite) + # TODO: Handle special test requirements (timing, fixture, ...) + + c.rbody( + "Suite *GP_TS_{{ suite }}() {n" + " Suite *s = suite_create("{{ suite }}");n" + "{% for t in tests %}" + " suite_add_tcase(s, GP_TC_{{ suite }}_{{ t['name'] }}());n" + "{% endfor %}" + " return s;n}nn", tests=tests, suite=suite) + + # Once for all suites + c.rbody( + "/****************************************************************n" + " * Create and add all suites to a SRunnern" + " */nn" + "void GP_AddSuitesToSRunner(SRunner *sr) {n" + "{% for s in suites %}" + " srunner_add_suite(sr, GP_TS_{{ s }}());n" + "{% endfor %}" + "}nn", suites=suites) + +def find_GP_directive(name, regexp, l, fname='unknown', line=0): + "Looks for a given GP_* directive, parses args if any, " + "retuns (name, dict_of_args) or (None, None) if not found." + if name in l: + m = regexp.search(l) + if not m: + warn("found unsuitable %s directive, ignoring." % name, fname, line) + else: + d = m.groups()[0].split(',', 1) + args = {} + if len(d)>1: + try: + s = 'dict( ' + d[1].strip(" tn"") + ' )' + args = eval(s) + except: + die("error parsing arguments: %r" % s, fname, line) + return d[0].strip(), args + return None, None + +def find_tests(f, fname): + "Finds all tests in a file." + suite = None + ls = f.readlines() + for i in range(len(ls)): + l = ls[i] + # Look for suite declaration + name, args = find_GP_directive("GP_SUITE", suite_re, l, fname=fname, line=i) + if name: + suite = name + if args: + warn("suite should have no arguments other than name.", fname, i) + suites.setdefault(name, []) + # Look for suite declaration + name, args = find_GP_directive("GP_TEST", test_re, l, fname=fname, line=i) + if name: + test_suite = suite + if 'suite' in args: + test_suite = args['suite'] + if not test_suite: + test_suite = 'default' + warn("no suite defined before test %s, using %r." % (name, test_suite), fname, i) + args['name'] = name + args['fname'] = fname + args['line'] = i + suites.setdefault(test_suite, []) + suites[test_suite].append(args) + diff --git a/pylib/gfxprim/generators/utils.py b/pylib/gfxprim/generators/utils.py index 28c1891..3ddc7ad 100644 --- a/pylib/gfxprim/generators/utils.py +++ b/pylib/gfxprim/generators/utils.py @@ -16,6 +16,7 @@ def j2render(tmpl, **kw): def load_generators(): "Load all modules containig generators to allow them to register" # TODO: write proper discovery + import gfxprim.generators.make_collected_tests import gfxprim.generators.core.make_GP_Pixel import gfxprim.generators.core.make_GP_Blit pass diff --git a/tests.mk b/tests.mk new file mode 100644 index 0000000..5dbcc80 --- /dev/null +++ b/tests.mk @@ -0,0 +1,46 @@ +.PHONY: tests runtests + +# +# List of test targets (testsuite incl. automatically) +# +ifndef TESTS +TESTS= +endif + +# +# Testsuite with automated collection of tests +# All .test.c files are scraped for GP_TEST definitions +# + +ifdef TESTSUITE +# a bit crude way to link with test minilibrary +GP_TESTLIB_SRCS=${TOPDIR}/tests/common/GP_Tests.c +CSOURCES+=${GP_TESTLIB_SRCS} + +# generated suite creation code +TESTSUITE_GEN=collected_tests.gen.c # also fixed in the code generator +GENSOURCES+=${TESTSUITE_GEN} + +TESTSUITE_SRCS=$(wildcard *.test.c) ${TESTSUITE_GEN} ${GP_TESTLIB_SRCS} +INCLUDE+=../tests/common +TESTSUITE_OBJS=$(patsubst %.c,%.o,$(TESTSUITE_SRCS)) +CLEAN+=${TESTSUITE} +TESTS+=${TESTSUITE} + +${TESTSUITE}: ${TESTSUITE_OBJS} +ifdef VERBOSE + $(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 $@ +endif # VERBOSE + +endif # TESTSUITE + +tests: $(TESTS) + +runtests: tests + for test in $(TESTS); do LD_LIBRARY_PATH=../../build ./"$$test" -v ; done + +# WARN: avoid double includion? +include $(TOPDIR)/gen.mk diff --git a/tests/core/core_tests.c b/tests/common/GP_Tests.c similarity index 100% rename from tests/core/core_tests.c rename to tests/common/GP_Tests.c diff --git a/tests/core/GP_Tests.h b/tests/common/GP_Tests.h similarity index 100% rename from tests/core/GP_Tests.h rename to tests/common/GP_Tests.h diff --git a/tests/core/GP_Comon.test.c b/tests/core/GP_Common.test.c similarity index 100% rename from tests/core/GP_Comon.test.c rename to tests/core/GP_Common.test.c diff --git a/tests/core/Makefile b/tests/core/Makefile index 2911629..929a30c 100644 --- a/tests/core/Makefile +++ b/tests/core/Makefile @@ -1,31 +1,10 @@ TOPDIR=../..
-CSOURCES=$(shell echo *.test.c) core_tests.gen.c - -INCLUDE=core +LIBNAME=core +TESTSUITE=core LDLIBS+=-lGP -L$(TOPDIR)/build/ -lcheck
-APPS=core_tests - include $(TOPDIR)/include.mk -include $(TOPDIR)/app.mk - -.PHONY: run - -TEST_SRCS=$(wildcard *.test.c) -TEST_OBJS=$(patsubst %.c,%.o,$(TEST_SRCS)) -TESTS=core_tests -CLEAN+=core_tests.gen.c - -run: $(TESTS) - for test in $(TESTS); do LD_LIBRARY_PATH=../../build ./"$$test" -v ; done +include $(TOPDIR)/tests.mk
-core_tests.gen.c: $(TEST_SRCS) find_tests.py -ifdef VERBOSE - python find_tests.py -c $@ $(TEST_SRCS) -else - @echo "GEN (python) $@" - @python find_tests.py -c $@ $(TEST_SRCS) -endif
-core_tests: $(TEST_OBJS) core_tests.gen.o diff --git a/tests/core/find_tests.py b/tests/core/find_tests.py deleted file mode 100644 index 7ddc7fb..0000000 --- a/tests/core/find_tests.py +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/python - -import sys, re, getopt - -# Helpers - -def die(msg_s, fname=None, line=None): - msg('E', msg_s, fname, line) - sys.exit(1) - -def warn(msg_s, fname=None, line=None): - msg('W', msg_s, fname, line) - -def msg(prefix, msg_s, fname=None, line=None): - s = '[' + prefix - if fname: - s += ' ' + fname - if line: - s += ':%d'%line - s += '] ' - sys.stderr.write(s + msg_s + 'n') - -# Globals - -suites = {} # {"suitename":["testname":{test_parameters}]} - -suite_re = re.compile("A\s*GP_SUITE((.*))\s*Z") -test_re = re.compile("A\s*GP_TEST((.*))\s*Z") - - -def find_GP_directive(name, regexp, l, fname='unknown', line=0): - "Looks for a given GP_* directive, parses args if any, " - "retuns (name, dict_of_args) or (None, None) if not found." - if name in l: - m = regexp.search(l) - if not m: - warn("found unsuitable %s directive, ignoring." % name, fname, line) - else: - d = m.groups()[0].split(',', 1) - args = {} - if len(d)>1: - try: - s = 'dict( ' + d[1].strip(" tn"") + ' )' - args = eval(s) - except: - die("error parsing arguments: %r" % s, fname, line) - return d[0].strip(), args - return None, None - -def find_tests(f, fname): - "Finds all tests in a file." - suite = None - ls = f.readlines() - for i in range(len(ls)): - l = ls[i] - # Look for suite declaration - name, args = find_GP_directive("GP_SUITE", suite_re, l, fname=fname, line=i) - if name: - suite = name - if args: - warn("suite should have no arguments other than name.", fname, i) - suites.setdefault(name, []) - # Look for suite declaration - name, args = find_GP_directive("GP_TEST", test_re, l, fname=fname, line=i) - if name: - test_suite = suite - if 'suite' in args: - test_suite = args['suite'] - if not test_suite: - test_suite = 'default' - warn("no suite defined before test %s, using %r." % (name, test_suite), fname, i) - args['name'] = name - args['fname'] = fname - args['line'] = i - suites.setdefault(test_suite, []) - suites[test_suite].append(args) - -def gen_tests(f): - f.write("/*n" - " * This GENERATED file is part of GfxPrim. See LICENSE for legal stuff.n" - " * Do not modify this file directly!n" - " */nn" - "#include <check.h>nn") - - for suite, tests in suites.iteritems(): - f.write("/****************************************************************n" - " * Suite %sn" - " */nn" % suite) - for t in tests: - f.write("/*n" - " * Test %s/%s defined in %s:%dn" - " */nn" % (suite, t['name'], t['fname'], t['line'])) - f.write("void GP_TEST_%s(int);nn" - "TCase *GP_TC_%s_%s()n" - "{n" - " TCase *tc = tcase_create("%s");n" % - (t['name'], suite, t['name'], t['name'])) - signal = t.get('expect_signal', 0) - exitval = t.get('expect_exit', 0) - assert ('loop_start' in t) == ('loop_end' in t) - loop_start = t.get('loop_start', 0) - loop_end = t.get('loop_end', 1) - f.write(" _tcase_add_test(tc, GP_TEST_%s, "%s", %d, %d, %d, %d);n" % - (t['name'], t['name'], signal, exitval, loop_start, loop_end)) - f.write(" return tc;n}nn") - # TODO: Handle special test requirements (timing, fixture, ...) - - f.write("Suite *GP_TS_%s()n" - "{n" - " Suite *s = suite_create("%s");n" % (suite, suite)) - for t in tests: - f.write(" suite_add_tcase(s, GP_TC_%s_%s());n" % (suite, t['name'])) - f.write(" return s;n" - "}nn") - - f.write("/****************************************************************n" - " * Create and add all suites to a SRunnern" - " */nn" - "void GP_AddSuitesToSRunner(SRunner *sr)n" - "{n") - for suite in suites: - f.write(" srunner_add_suite(sr, GP_TS_%s());n" % suite) - f.write("}nn") - - -def main(): - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], "c:") - except: - die("Invalid arguments") - cfile = None - for opt, val in opts: - if opt == '-c': - cfile = val - if not cfile: - die("You must specify: -c <output.c>") - - for fn in args: - try: - f = open(fn, 'rt') - except: - die("Unable to open '%s'" % fn) - find_tests(f, fn) - f.close() - - try: - f = open(cfile, 'wt') - except: - die("Unable to open '%s'" % cfile) - gen_tests(f) - f.close() - -if __name__ == '__main__': - main() diff --git a/tests/core/font.test.c b/tests/text/font.test.c similarity index 100% rename from tests/core/font.test.c rename to tests/text/font.test.c
http://repo.or.cz/w/gfxprim.git/commit/daa6ed769550d82191a853913d329d4881a9a...
commit daa6ed769550d82191a853913d329d4881a9ab85 Merge: 46a94e8 9d50a71 Author: Tomas Gavenciak gavento@ucw.cz Date: Thu Jun 2 17:40:59 2011 +0200
Merge remote branch 'origin/master' into generate
Conflicts: libs/core/Makefile
-----------------------------------------------------------------------
Summary of changes: .gitignore | 5 +- Makefile | 22 +--- build/Makefile | 4 + gen.mk | 8 + include.mk | 7 + include/{sdl => SDL}/GP_SDL.h | 0 include/{sdl => SDL}/GP_SDL_Context.h | 0 include/{sdl => SDL}/GP_SDL_VideoInit.h | 0 include/{sdl => SDL}/README | 0 include/core/GP_Pixel_Access.h | 4 +- install.sh | 24 ++++ lib.mk | 39 ++++++- libs/Makefile | 2 +- libs/{sdl => SDL}/GP_SDL_Context.c | 0 libs/{sdl => SDL}/GP_SDL_VideoInit.c | 0 libs/{backends => SDL}/Makefile | 3 +- libs/core/GP_Pixel_Access.c | 4 +- libs/core/Makefile | 1 - libs/sdl/Makefile | 5 - pylib/gfxprim/generators/make_collected_tests.py | 140 ++++++++++++++++++++ pylib/gfxprim/generators/utils.py | 1 + tests.mk | 46 +++++++ tests/Makefile | 2 +- tests/{sdl => SDL}/Makefile | 10 +- tests/{sdl => SDL}/fileview.c | 0 tests/{sdl => SDL}/fonttest.c | 0 tests/{sdl => SDL}/linetest.c | 0 tests/{sdl => SDL}/pixeltest.c | 0 tests/{sdl => SDL}/randomshapetest.c | 0 tests/{sdl => SDL}/runtest.sh | 0 tests/{sdl => SDL}/shapetest.c | 0 tests/{sdl => SDL}/sierpinsky.c | 0 tests/{sdl => SDL}/symbolstest.c | 0 tests/{sdl => SDL}/textaligntest.c | 0 tests/{sdl => SDL}/trianglefps.c | 0 tests/{core/core_tests.c => common/GP_Tests.c} | 0 tests/{core => common}/GP_Tests.h | 0 tests/core/{GP_Comon.test.c => GP_Common.test.c} | 0 tests/core/Makefile | 27 +---- tests/core/find_tests.py | 154 ---------------------- tests/sdl/old.dddd | 19 --- tests/{core => text}/font.test.c | 0 42 files changed, 291 insertions(+), 236 deletions(-) rename include/{sdl => SDL}/GP_SDL.h (100%) rename include/{sdl => SDL}/GP_SDL_Context.h (100%) rename include/{sdl => SDL}/GP_SDL_VideoInit.h (100%) rename include/{sdl => SDL}/README (100%) create mode 100755 install.sh rename libs/{sdl => SDL}/GP_SDL_Context.c (100%) rename libs/{sdl => SDL}/GP_SDL_VideoInit.c (100%) copy libs/{backends => SDL}/Makefile (78%) delete mode 100644 libs/sdl/Makefile create mode 100644 pylib/gfxprim/generators/make_collected_tests.py create mode 100644 tests.mk rename tests/{sdl => SDL}/Makefile (55%) rename tests/{sdl => SDL}/fileview.c (100%) rename tests/{sdl => SDL}/fonttest.c (100%) rename tests/{sdl => SDL}/linetest.c (100%) rename tests/{sdl => SDL}/pixeltest.c (100%) rename tests/{sdl => SDL}/randomshapetest.c (100%) rename tests/{sdl => SDL}/runtest.sh (100%) rename tests/{sdl => SDL}/shapetest.c (100%) rename tests/{sdl => SDL}/sierpinsky.c (100%) rename tests/{sdl => SDL}/symbolstest.c (100%) rename tests/{sdl => SDL}/textaligntest.c (100%) rename tests/{sdl => SDL}/trianglefps.c (100%) rename tests/{core/core_tests.c => common/GP_Tests.c} (100%) rename tests/{core => common}/GP_Tests.h (100%) rename tests/core/{GP_Comon.test.c => GP_Common.test.c} (100%) delete mode 100644 tests/core/find_tests.py delete mode 100644 tests/sdl/old.dddd rename tests/{core => text}/font.test.c (100%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.