From af7bfd6fa7b42ef77c8086c3d44423c958b12a69 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 04:31:06 +0200 Subject: [PATCH 01/17] just a scratch --- src/lib/error.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/lib/error.h diff --git a/src/lib/error.h b/src/lib/error.h new file mode 100644 index 000000000..09cd31c8d --- /dev/null +++ b/src/lib/error.h @@ -0,0 +1,34 @@ +/* + error.h - Cinelerra Error handling + + Copyright (C) CinelerraCV + 2007, Christian Thaeter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ +#ifndef CINELERRA_ERROR_H +#define CINELERRA_ERROR_H + +#include +#include + +#define CINELERRA_DIE(message) do { NOBUG_ERROR(NOBUG_ON, message); abort(); } while(0) + +#define CINELERRA_ERROR_DECLARE(err) extern const cinelerra_error err +#define CINELERRA_ERROR_DEFINE(err, msg) const cinelerra_error err = #err ":" msg + +typedef const char* cinelerra_error; + +#endif /* CINELERRA_ERROR_H */ From 471148b7db2e41f2c081760cc367710ce6999da9 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 05:10:14 +0200 Subject: [PATCH 02/17] basic automake setup --- Makefile.am | 36 ++++++++++++++++++++++ configure.ac | 73 +++++++++++++++++++++++++++++++++++++++++++++ src/lib/Makefile.am | 24 +++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 Makefile.am create mode 100644 configure.ac create mode 100644 src/lib/Makefile.am diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..72d0dcb43 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,36 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +bin_PROGRAMS = +lib_LTLIBRARIES = +noinst_PROGRAMS = +noinst_LIBRARIES = +noinst_LTLIBRARIES = +noinst_HEADERS = +BUILT_SOURCES = +EXTRA_DIST = +SUBDIRS = + +#SUBDIRS += + +include $(top_srcdir)/src/lib/Makefile.am + +#EXTRA_DIST += admin debian doc depcomp README.BUILD LICENSE \ +# cinelerra-cvs-current.spec +AUTOMAKE_OPTIONS=foreign +#ACLOCAL_AMFLAGS = -I m4 + diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..5d7b42d8b --- /dev/null +++ b/configure.ac @@ -0,0 +1,73 @@ +AC_INIT(cinelerra, 3.0pre) +AC_CONFIG_SRCDIR(src/lib/plugin.c) +AC_CONFIG_AUX_DIR(scripts) +AM_INIT_AUTOMAKE +AC_PREREQ(2.59) + +AC_COPYRIGHT([ + Copyright (C) CinelerraCV + 2007, Christian Thaeter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +]) + +# +# Required programs +# +AC_PROG_CC +AC_PROG_CPP +AC_PROG_CXX +AC_PROG_RANLIB + +# +# test for headers +# +AC_STDC_HEADERS +AC_CHECK_HEADER([pthread.h], AC_DEFINE(HAVE_PTHREAD_H)) +AC_CHECK_HEADER([nobug.h], AC_DEFINE(HAVE_NOBUG_H)) +AC_CHECK_HEADER([execinfo.h], AC_DEFINE(HAVE_EXECINFO_H)) +AC_CHECK_HEADER([valgrind/valgrind.h], AC_DEFINE(HAVE_VALGRIND_VALGRIND_H)) + +# +# user options +# + + +############## NoBug build levels +AH_TEMPLATE(EBUG_ALPHA, [Define to 1 for selecting NoBug ALPHA build level]) +AH_TEMPLATE(EBUG_BETA, [Define to 1 for selecting NoBug BETA build level]) +AH_TEMPLATE(NDEBUG, [Define to 1 for selecting NoBug RELEASE build level]) +AC_ARG_ENABLE(alpha, AC_HELP_STRING([--enable-alpha], [select NoBug ALPHA build level]), + nobug_level=alpha + AC_DEFINE(EBUG_ALPHA), +[ +AC_ARG_ENABLE(beta, AC_HELP_STRING([--enable-beta], [select NoBug BETA build level]), + nobug_level=beta + AC_DEFINE(EBUG_BETA), +[ +AC_ARG_ENABLE(release, AC_HELP_STRING([--enable-release], [select NoBug RELEASE build level]), + nobug_level=release + AC_DEFINE(NDEBUG), + +# default to ALPHA + nobug_level=alpha + AC_DEFINE(EBUG_ALPHA) +)])]) +AC_MSG_RESULT([NoBug build level: $nobug_level]) +# END NoBug + + +AC_CONFIG_FILES(Makefile) +AC_OUTPUT diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 000000000..236b916a7 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,24 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +libcin3_a_srcdir = $(top_srcdir)/src/lib +noinst_LIBRARIES += libcin3.a + +#libcin3_a_CFLAGS = $(CFLAGS) + +libcin3_a_SOURCES = $(libcin3_a_srcdir)/plugin.c +noinst_HEADERS += $(libcin3_a_srcdir)/plugin.h From c0a0c08ab12a600c6bbc0199d22b808280cdacef Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 05:47:10 +0200 Subject: [PATCH 03/17] new scripts/DIR_INFO, add autotools stuff to gitignore --- .gitignore | 8 +++++++- scripts/DIR_INFO | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 scripts/DIR_INFO diff --git a/.gitignore b/.gitignore index ed690f89c..01c32fa89 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,10 @@ .sconsign.dblite Buildhelper.pyc optcache - +Makefile.in +build/* +autom4te.cache/* +scripts/* +configure +aclocal.m4 +semantic.cache diff --git a/scripts/DIR_INFO b/scripts/DIR_INFO new file mode 100644 index 000000000..265ca57ac --- /dev/null +++ b/scripts/DIR_INFO @@ -0,0 +1 @@ +autotools helper scripts From e1a072a6d31d55afd6aa0f54ea18e2566ab7a8b1 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 05:48:23 +0200 Subject: [PATCH 04/17] config update, small problem with NoBug which shows a warning when valgrind is enabled, dont use valgrind support until this is fixed --- configure.ac | 2 +- src/lib/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5d7b42d8b..872275791 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,7 @@ AC_STDC_HEADERS AC_CHECK_HEADER([pthread.h], AC_DEFINE(HAVE_PTHREAD_H)) AC_CHECK_HEADER([nobug.h], AC_DEFINE(HAVE_NOBUG_H)) AC_CHECK_HEADER([execinfo.h], AC_DEFINE(HAVE_EXECINFO_H)) -AC_CHECK_HEADER([valgrind/valgrind.h], AC_DEFINE(HAVE_VALGRIND_VALGRIND_H)) +# there is a warning in nobug, disabled til fixed AC_CHECK_HEADER([valgrind/valgrind.h], AC_DEFINE(HAVE_VALGRIND_VALGRIND_H)) # # user options diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 236b916a7..b6c493a18 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -18,7 +18,7 @@ libcin3_a_srcdir = $(top_srcdir)/src/lib noinst_LIBRARIES += libcin3.a -#libcin3_a_CFLAGS = $(CFLAGS) +libcin3_a_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror libcin3_a_SOURCES = $(libcin3_a_srcdir)/plugin.c noinst_HEADERS += $(libcin3_a_srcdir)/plugin.h From 5946d6961d44e7defe277822bfffea313c9f1469 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 05:49:02 +0200 Subject: [PATCH 05/17] some small fixes to make it compile (first try) --- src/lib/plugin.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/plugin.c b/src/lib/plugin.c index 6876674f4..92149ad51 100644 --- a/src/lib/plugin.c +++ b/src/lib/plugin.c @@ -19,6 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include +#include #include #include #include @@ -33,7 +34,7 @@ TODO move CINELERRA_DIE elsewhere (cinlib.h?) */ -#define CINELERRA_DIE do{NOBUG_ERROR(NOBUG_ON, LOG_EMERG, "aborting due fatal error"); abort();}while(0) +#define CINELERRA_DIE do{NOBUG_LOG(NOBUG_ON, LOG_EMERG, "aborting due fatal error"); abort();}while(0) /* TODO should be set by the build system to the actual plugin path */ #define CINELERRA_PLUGIN_PATH "~/.cinelerra3/plugins:/usr/local/lib/cinelerra3/plugins" @@ -62,15 +63,15 @@ enum cinelerra_plugin_type static const struct { const char* const ext; - enum cinelerra_plugin_type; + enum cinelerra_plugin_type type; } cinelerra_plugin_extensions [] = { - "plugin", CINELERRA_PLUGIN_DYNLIB, - "so", CINELERRA_PLUGIN_DYNLIB, - "tcc", CINELERRA_PLUGIN_CSOURCE, - "c", CINELERRA_PLUGIN_CSOURCE, + {"plugin", CINELERRA_PLUGIN_DYNLIB}, + {"so", CINELERRA_PLUGIN_DYNLIB}, + {"tcc", CINELERRA_PLUGIN_CSOURCE}, + {"c", CINELERRA_PLUGIN_CSOURCE}, /* extend here */ - NULL, CINELERRA_PLUGIN_NULL + {NULL, CINELERRA_PLUGIN_NULL} }; @@ -153,7 +154,7 @@ cinelerra_plugin_lookup (struct cinelerra_plugin* self, const char* path) strcpy(tpath, path); /*for each in path*/ - for (char* tok = strtok(tpath, ":", &tmp); tok; tok = strtok(NULL, ":", &tmp)) + for (char* tok = strtok_r (tpath, ":", &tmp); tok; tok = strtok_r (NULL, ":", &tmp)) { /*for each extension*/ for (int i = 0; cinelerra_plugin_extensions[i].ext; ++i) @@ -181,7 +182,7 @@ cinelerra_plugin_lookup (struct cinelerra_plugin* self, const char* path) struct cinelerra_interface* cinelerra_interface_open (const char* name, const char* interface, size_t min_revision) { - REQUIRE (min_revision > sizeof(cinelerra_interface), "try to use an empty interface eh?"); + //REQUIRE (min_revision > sizeof(struct cinelerra_interface), "try to use an empty interface eh?"); REQUIRE (interface, "interface name must be given"); pthread_once (&cinelerra_plugin_initialized, cinelerra_plugin_tls_init); @@ -208,7 +209,7 @@ cinelerra_interface_open (const char* name, const char* interface, size_t min_re { /*lookup for $CINELERRA_PLUGIN_PATH*/ (*found)->name = strdup (name); - if (!(*found)->name) CINELERA_DIE; + if (!(*found)->name) CINELERRA_DIE; if (!cinelerra_plugin_lookup (*found, getenv("CINELERRA_PLUGIN_PATH")) #ifdef CINELERRA_PLUGIN_PATH @@ -225,15 +226,14 @@ cinelerra_interface_open (const char* name, const char* interface, size_t min_re { (*found)->name = NULL; (*found)->pathname = NULL; - (*found)->ext = NULL; } (*found)->use_count = 0; PLANNED("if .so like then dlopen; else if .c like tcc compile"); - TODO("factor dlopen and dlsym out") + TODO("factor dlopen and dlsym out"); - (*found)->handle = dlopen (pathname, RTLD_NOW|RTLD_LOCAL); + (*found)->handle = dlopen ((*found)->pathname, RTLD_NOW|RTLD_LOCAL); if (!(*found)->handle) { ERROR (cinelerra_plugin, "dlopen failed: %s", dlerror()); From fdb691398d8f1f92866bd911f7e4e33b9a9c5448 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Thu, 19 Jul 2007 06:15:55 +0200 Subject: [PATCH 06/17] compiles example, segfaults by intention (disabled error handling, no plugin yet) --- Makefile.am | 8 ++++++++ src/lib/plugin.c | 8 +++++--- src/lib/plugin.h | 2 +- tests/examples/Makefile.am | 26 ++++++++++++++++++++++++++ tests/examples/hello_interface.h | 4 ++-- tests/examples/plugin_main.c | 20 +++++++++++--------- 6 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 tests/examples/Makefile.am diff --git a/Makefile.am b/Makefile.am index 72d0dcb43..fbaecd794 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,10 +25,18 @@ BUILT_SOURCES = EXTRA_DIST = SUBDIRS = +# Only use subdirs if really needed, prefer the include scheme below #SUBDIRS += +# core include $(top_srcdir)/src/lib/Makefile.am +# plugins +#include $(top_srcdir)/src... + +# tests +include $(top_srcdir)/tests/examples/Makefile.am + #EXTRA_DIST += admin debian doc depcomp README.BUILD LICENSE \ # cinelerra-cvs-current.spec AUTOMAKE_OPTIONS=foreign diff --git a/src/lib/plugin.c b/src/lib/plugin.c index 92149ad51..ec7b3f0a6 100644 --- a/src/lib/plugin.c +++ b/src/lib/plugin.c @@ -44,7 +44,7 @@ NOBUG_DEFINE_FLAG (cinelerra_plugin); /* errors */ const char* CINELERRA_PLUGIN_SUCCESS = NULL; const char* CINELERRA_PLUGIN_EDLOPEN = "Could not open plugin"; -const char* CINELERRA_PLUGIN_EDHOOK = "Hook function failed"; +const char* CINELERRA_PLUGIN_EHOOK = "Hook function failed"; const char* CINELERRA_PLUGIN_ENFOUND = "No such plugin"; const char* CINELERRA_PLUGIN_ENIFACE = "No such interface"; const char* CINELERRA_PLUGIN_EREVISION = "Interface revision too old"; @@ -304,11 +304,13 @@ cinelerra_interface_open (const char* name, const char* interface, size_t min_re } void -cinelerra_interface_close (struct cinelerra_interface* self) +cinelerra_interface_close (void* ptr) { - if(!self) + if(!ptr) return; + struct cinelerra_interface* self = (struct cinelerra_interface*) ptr; + pthread_mutex_lock (&cinelerra_plugin_mutex); struct cinelerra_plugin* plugin = self->plugin; diff --git a/src/lib/plugin.h b/src/lib/plugin.h index 605da329c..74ab964b3 100644 --- a/src/lib/plugin.h +++ b/src/lib/plugin.h @@ -109,7 +109,7 @@ cinelerra_interface_open (const char* plugin, const char* name, size_t min_revis * @param self interface to be closed */ void -cinelerra_interface_close (struct cinelerra_interface* self); +cinelerra_interface_close (void* self); /** * Tries to unload a plugin. diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am new file mode 100644 index 000000000..c3ee8e033 --- /dev/null +++ b/tests/examples/Makefile.am @@ -0,0 +1,26 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +examples_srcdir = $(top_srcdir)/tests/examples +noinst_PROGRAMS += plugin_example + +plugin_example_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror +plugin_example_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ +plugin_example_LDADD = -lnobugmt -lpthread -ldl $(builddir)/libcin3.a + +plugin_example_SOURCES = $(examples_srcdir)/plugin_main.c +noinst_HEADERS += $(examples_srcdir)/hello_interface.h diff --git a/tests/examples/hello_interface.h b/tests/examples/hello_interface.h index 58483e6ff..183a22c54 100644 --- a/tests/examples/hello_interface.h +++ b/tests/examples/hello_interface.h @@ -1,6 +1,6 @@ #include "plugin.h" CINELERRA_INTERFACE(hello, 1, - CINELERRA_INTERFACE_PROTO(void, hello, (void)), - CINELERRA_INTERFACE_PROTO(void, goodbye, (const char*)), + CINELERRA_INTERFACE_PROTO(void, hello, (void)) + CINELERRA_INTERFACE_PROTO(void, goodbye, (const char*)) ); diff --git a/tests/examples/plugin_main.c b/tests/examples/plugin_main.c index 1902fc5fe..427f88655 100644 --- a/tests/examples/plugin_main.c +++ b/tests/examples/plugin_main.c @@ -12,20 +12,22 @@ main(int argc, char** argv) open both try them, close them. */ - struct hello_interface_1* hello_de = - cinelerra_interface_open ("hello_1", "german_1", sizeof(struct hello_interface_1)); - if (!hello_de) CINELERRA_DIE; + TODO("macros, doing casting and typing"); - hello_de->say_hello(); + CINELERRA_INTERFACE_TYPE(hello, 1)* hello_de = (CINELERRA_INTERFACE_TYPE(hello, 1)*) + cinelerra_interface_open ("hello_1", "german_1", sizeof(CINELERRA_INTERFACE_TYPE(hello, 1))); + TODO("new error handling, when finished if (!hello_de) CINELERRA_DIE"); + + hello_de->hello(); - struct hello_interface_1* hello_en = - cinelerra_interface_open ("hello_1", "english_1", sizeof(struct hello_interface_1)); - if (!hello_en) CINELERRA_DIE; + // struct hello_interface_1* hello_en = + // cinelerra_interface_open ("hello_1", "english_1", sizeof(struct hello_interface_1)); + // TODO if (!hello_en) CINELERRA_DIE; - hello_en->say_hello(); + //hello_en->hello(); - cinelerra_interface_close (hello_en); + //cinelerra_interface_close (hello_en); cinelerra_interface_close (hello_de); #if 0 From dd276a90578d5bcdfd242f9e6c39e03e63177cbe Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Sun, 12 Aug 2007 14:51:33 +0200 Subject: [PATCH 07/17] little hook improvement --- admin/git_hooks/post-commit | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/git_hooks/post-commit b/admin/git_hooks/post-commit index cf0dd5ec1..34b182a81 100755 --- a/admin/git_hooks/post-commit +++ b/admin/git_hooks/post-commit @@ -7,6 +7,8 @@ # see wiki/index.html#GitNotes%20GitAliases for information -git tag -s -f -m "signature generated by $(git config user.email)" "$(git config user.email)/$(git-symbolic-ref HEAD | cut -d/ -f 3-)_signature" +user_email="$(git config user.email)" + +git tag -s -f -m "signature generated by $user_email" "$user_email/$(git-symbolic-ref HEAD | cut -d/ -f 3-)_signature" git push --all public -git push public "refs/tags/$(git config user.email)/*" +git push public "refs/tags/$user_email/*" From 4374fc4b1fb6adbc29618a98e16eebd86bb18c79 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Sun, 12 Aug 2007 21:28:21 +0200 Subject: [PATCH 08/17] just put tests in place, will not work yet --- Makefile.am | 1 + tests/00test.tests | 8 +++ tests/Makefile.am | 23 +++++++ tests/test.sh | 146 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 tests/00test.tests create mode 100644 tests/Makefile.am create mode 100755 tests/test.sh diff --git a/Makefile.am b/Makefile.am index fbaecd794..df66c2437 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,7 @@ include $(top_srcdir)/src/lib/Makefile.am #include $(top_srcdir)/src... # tests +include $(top_srcdir)/tests/Makefile.am include $(top_srcdir)/tests/examples/Makefile.am #EXTRA_DIST += admin debian doc depcomp README.BUILD LICENSE \ diff --git a/tests/00test.tests b/tests/00test.tests new file mode 100644 index 000000000..a0c4c9761 --- /dev/null +++ b/tests/00test.tests @@ -0,0 +1,8 @@ + +TESTING "test system selftest" cat + +TEST "test" < +# Hermann Vosseler +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +tests_srcdir = $(top_srcdir)/tests + +noinst_PROGRAMS += + +TESTS = $(tests_srcdir)/test.sh diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 000000000..c27d0b1e7 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,146 @@ +#!/bin/bash +# Copyright (C) 2004, Christian Thaeter +# +# This file is part of the MaLa extension Language. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, contact me. + +# TESTMODE=FULL yet unimplemented +# run all tests, PLANNED which fail count as error +# +# TESTMODE=FAST +# run only tests which recently failed + +arg0="$0" +srcdir=$(dirname "$arg0") + +ulimit -S -t 1 -v 524288 +valgrind="" +if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then + echo "valgrind explicit disabled" +else + if [ "$(which valgrind)" ]; then + valgrind="$(which valgrind) --suppressions=$srcdir/../valgrind.sup --leak-check=yes --show-reachable=yes -q $VALGRINDFLAGS" + ulimit -S -t 10 + else + echo "no valgrind found, go without it" + fi +fi + +echo +echo ================ $0 ================ + +TESTCNT=0 +SKIPCNT=0 +FAILCNT=0 + +if test -f ,testlog; then + mv ,testlog ,testlog.pre +else + touch ,testlog.pre +fi + +date >,testlog + +function TEST() +{ + name="$1" + shift + cat >,cmp + echo -n "" >,out + echo -n "TEST $name: " + echo -en "\nTEST $name: $* " >>,testlog + + case $TESTMODE in + *FAST*) + if grep "^TEST $name: .* FAILED" ,testlog.pre >&/dev/null; then + MSGOK=" (fixed)" + MSGFAIL=" (still broken)" + elif grep "^TEST $name: .* \\(SKIPPED (ok)\\|OK\\)" ,testlog.pre >&/dev/null; then + echo ".. SKIPPED (ok)" + echo ".. SKIPPED (ok)" >>,testlog + SKIPCNT=$(($SKIPCNT + 1)) + TESTCNT=$(($TESTCNT + 1)) + return + else + MSGOK=" (new)" + MSGFAIL=" (new)" + fi + ;; + *) + MSGOK="" + MSGFAIL="" + ;; + esac + + TESTCNT=$(($TESTCNT + 1)) + if $valgrind $TESTBIN "$@" 2>&1 | tee ,tmp | grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' | cmp ,cmp - &>/dev/null; then + echo ".. OK$MSGOK" + echo ".. OK$MSGOK" >>,testlog + else + echo ".. FAILED$MSGFAIL"; + echo ".. FAILED$MSGFAIL" >>,testlog + grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,tmp >,out + diff -ua ,cmp ,out >>,testlog + # grep 'DEBUG:\|==.*==' <,tmp >>,testlog + cat ,tmp >>,testlog + echo END >>,testlog + FAILCNT=$(($FAILCNT + 1)) + case $TESTMODE in + *FIRSTFAIL*) + break 2 + ;; + esac + fi +} + +function PLANNED() +{ + echo -n "PLANNED $1: " + echo -en "\nPLANNED $* " >>,testlog + echo ".. SKIPPED (planned)" + echo ".. SKIPPED (planned)" >>,testlog + SKIPCNT=$(($SKIPCNT + 1)) + TESTCNT=$(($TESTCNT + 1)) +} + +function RUNTESTS() +{ + for i in $srcdir/*.tests; do + source $i + done + echo + rm ,cmp ,out ,tmp + if [ $FAILCNT = 0 ]; then + echo " ... PASSED $(($TESTCNT - $SKIPCNT)) TESTS, $SKIPCNT SKIPPED" + #rm ,testlog + else + echo " ... SUCCEDED $(($TESTCNT - $FAILCNT - $SKIPCNT)) TESTS" + echo " ... FAILED $FAILCNT TESTS" + echo " ... SKIPPED $SKIPCNT TESTS" + echo " see ',testlog' for details" + exit 1 + fi +} + +function TESTING() +{ + echo + echo "$1" + TESTBIN=$2 +} + +RUNTESTS + +# arch-tag: f4d06a47-6e17-40de-bba8-17240ae3f435 + From 9404b5d1f1d6fc6d179aa4944018b4763a09bb67 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Sun, 12 Aug 2007 21:51:24 +0200 Subject: [PATCH 09/17] cosmetics, copyright header --- tests/test.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index c27d0b1e7..401bdac48 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,19 +1,22 @@ #!/bin/bash -# Copyright (C) 2004, Christian Thaeter + +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# Hermann Vosseler # -# This file is part of the MaLa extension Language. +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. # -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. +# This program 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 General Public License for more details. # -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, contact me. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # TESTMODE=FULL yet unimplemented # run all tests, PLANNED which fail count as error @@ -30,7 +33,7 @@ if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then echo "valgrind explicit disabled" else if [ "$(which valgrind)" ]; then - valgrind="$(which valgrind) --suppressions=$srcdir/../valgrind.sup --leak-check=yes --show-reachable=yes -q $VALGRINDFLAGS" + valgrind="$(which valgrind) --leak-check=yes --show-reachable=yes -q $VALGRINDFLAGS" ulimit -S -t 10 else echo "no valgrind found, go without it" @@ -38,7 +41,7 @@ else fi echo -echo ================ $0 ================ +echo ================ ${0##*/} ================ TESTCNT=0 SKIPCNT=0 @@ -141,6 +144,3 @@ function TESTING() } RUNTESTS - -# arch-tag: f4d06a47-6e17-40de-bba8-17240ae3f435 - From ce3eb42131b0f8f809b00ef9a7759eb885e684d3 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 13 Aug 2007 17:22:07 +0200 Subject: [PATCH 10/17] test suite works now basically --- tests/00test.tests | 13 ++++--- tests/test.sh | 84 +++++++++++++++++++++++++++++++++++++++++----- wiki/index.html | 38 ++++++++++++++++++++- 3 files changed, 121 insertions(+), 14 deletions(-) diff --git a/tests/00test.tests b/tests/00test.tests index a0c4c9761..0b894982b 100644 --- a/tests/00test.tests +++ b/tests/00test.tests @@ -1,8 +1,13 @@ - TESTING "test system selftest" cat -TEST "test" < # Hermann Vosseler @@ -23,6 +22,11 @@ # # TESTMODE=FAST # run only tests which recently failed +# +# TESTMODE=FIRSTFAIL +# stop testing on the first failure + +export LC_ALL=C arg0="$0" srcdir=$(dirname "$arg0") @@ -47,6 +51,7 @@ TESTCNT=0 SKIPCNT=0 FAILCNT=0 +# the old testlog if existing will be used to check for previous test states if test -f ,testlog; then mv ,testlog ,testlog.pre else @@ -59,8 +64,34 @@ function TEST() { name="$1" shift - cat >,cmp - echo -n "" >,out + rm -f ,send_stdin + rm -f ,expect_stdout + rm -f ,expect_stderr + + while read -r line; do + cmd="${line%%:*}" + arg="${line#*: }" + expect_return=0 + + case $cmd in + 'in') + echo "$arg" >>,send_stdin + ;; + 'out') + echo "$arg" >>,expect_stdout + ;; + 'err') + echo "$arg" >>,expect_stderr + ;; + 'return') + expect_return=$arg + ;; + *) + echo "UNKOWN TEST COMMAND '$cmd'" 1>&2 + exit + ;; + esac + done echo -n "TEST $name: " echo -en "\nTEST $name: $* " >>,testlog @@ -87,16 +118,52 @@ function TEST() esac TESTCNT=$(($TESTCNT + 1)) - if $valgrind $TESTBIN "$@" 2>&1 | tee ,tmp | grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' | cmp ,cmp - &>/dev/null; then + + fails=0 + + if test -f ,send_stdin; then + cat ,send_stdin | $valgrind $TESTBIN "$@" 2>,stderr >,stdout + return=$? + else + $valgrind $TESTBIN "$@" 2>,stderr >,stdout + return=$? + fi + + echo -n >,testtmp + + if test -f ,expect_stdout; then + if ! cmp ,expect_stdout ,stdout &>/dev/null; then + echo "unexpected data on stdout" >>,testtmp + grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stdout >,tmp + diff -ua ,expect_stdout ,tmp >>,testtmp + rm ,tmp + ((fails+=1)) + fi + fi + + if test -f ,expect_stderr; then + if ! cmp ,expect_stderr ,stderr &>/dev/null; then + echo "unexpected data on stderr" >>,testtmp + grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stderr >,tmp + diff -ua ,expect_stderr ,tmp >>,testtmp + rm ,tmp + ((fails+=1)) + fi + fi + + if test $expect_return != $return; then + echo "unexpected return value $return" >>,testtmp + ((fails+=1)) + fi + + if test $fails -eq 0; then echo ".. OK$MSGOK" echo ".. OK$MSGOK" >>,testlog else echo ".. FAILED$MSGFAIL"; echo ".. FAILED$MSGFAIL" >>,testlog - grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,tmp >,out - diff -ua ,cmp ,out >>,testlog - # grep 'DEBUG:\|==.*==' <,tmp >>,testlog - cat ,tmp >>,testlog + cat ,testtmp >>,testlog + rm ,testtmp echo END >>,testlog FAILCNT=$(($FAILCNT + 1)) case $TESTMODE in @@ -123,7 +190,6 @@ function RUNTESTS() source $i done echo - rm ,cmp ,out ,tmp if [ $FAILCNT = 0 ]; then echo " ... PASSED $(($TESTCNT - $SKIPCNT)) TESTS, $SKIPCNT SKIPPED" #rm ,testlog diff --git a/wiki/index.html b/wiki/index.html index 51da7bc71..5e9b52bef 100755 --- a/wiki/index.html +++ b/wiki/index.html @@ -795,7 +795,7 @@ This distributed wiki might be used instead the pipapo.org wiki, investigate tha Wiki works. It is simple to use and just flexible enough to handle the task. I don't go to install any other software for such tasks on my server. While the design progresses I'd propose to move our work into git repositories and eventually phase this wiki pages out anyways. I'd rather like to start out distributed/git right away .. but git gives us only a fine storage layer, for a design process we need some good presentation layer (later when using git and starting the implementation everyones favorite editor serves for that) I have no better ideas yet to solve the presentation problem other than using this wiki (or maybe Bouml). -
+
This 'index.html' becomes the entry point of some tiddlywikis managed under git. There is a 'empty.html' in the same folder serving as template for generating new wikis. Please refrain from editing it.
 
 * I started a GitNotes where we will collect some information about git, howto and special setups
@@ -812,6 +812,7 @@ to get started, we create design drafts emphasizing different aspects and region
 * Ichthyo focuses mainly on the Render Engine and its interconnection to the EDL, [[see this separate page|renderengine.html]]
 * cehteh works on the data backend draft, see [[this page|backend.html]]
 * Some tools which don't fit somewhere else and are used everywhere are put into a [[Support Library|support_library.html]]
+* [[Description of the Test System|TestSh]]
 
 !Coding Structures
 next we should //start thinking// on how to organize several aspects of the practical coding...
@@ -3452,6 +3453,41 @@ Portions written by Luke Blanshard are hereby released into the public domain.
 <div macro="tasksum end"></div>
 <div class="tagglyTagging" macro="tagglyListWithSort"></div>
 <!--}}}-->
+
+
+
+
! The Test Script
+There is a simple test script in tests which will be used to drive various tests. All tests are run under valgrind control if available unless {{{VALGRINDFLAGS=DISABLE}}} is defined. This test script is integrated in the automake build and will be used when {{{make check}}} is called.
+
+! Options for running the Test Suite
+One may define {{{TESTMODE}}} containing any one of the following strings:
+* {{{FAST}}} only run tests which failed recently
+* {{{FIRSTFAIL}}} abort the tests at the first failure
+
+putting this together a very fast check (when using automake) while hacking on the source would look like:
+{{{
+VALGRINDFLAGS=DISABLE TESTMODE=FAST+FIRSTFAIL make check
+}}}
+This doesnt catch all errors, notably not regressions, but is useful to do coarse checks.
+
+Running the testsuite with everything enabled is just:
+{{{
+make check
+}}}
+
+! Writing Tests
+Tests are written in files named {{{NNname.tests}}} in the {{{tests}}} dir, where NN is a number defining the order of the various test files, 'name' should be a descriptive name about whats going to be tested.
+
+In a .tests file one has to define following:
+* {{{TESTING <description> <binary>}}} set the program binary to be tested to <binary>, <description> should be a string which is displayed as header before running following tests
+* {{{TEST <description> [optargs] <<END}}} run the previously set binary with [optargs], <description> is displayed when running this test. A detailed test spec must follow this command and be terminated with {{{END}}} on a single line. Test specs can contain following statements:
+** {{{in: <line>}}} send <line> to stdin of the test program
+** {{{out: <line>}}} expect <line> at the stdout of the test program
+** {{{err: <line>}}} expect <line> at the stderr of the test program
+** {{{return: <status>}}} expect <status> as exit status of the program
+
+If no {{{out:}}} or {{{err:}}} is given, stdout and stderr are not considered as part of the test. If no {{{return:}}} is given, then 0 is expected.
+
 
From 7470a6d07365c860f03699e10941b424a122212a Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 13 Aug 2007 17:45:43 +0200 Subject: [PATCH 11/17] cleanup and add stderr to testlog when test failed --- tests/test.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test.sh b/tests/test.sh index 9f2ef6a8f..ed8d6a35b 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -121,13 +121,13 @@ function TEST() fails=0 + if test -f ,send_stdin; then cat ,send_stdin | $valgrind $TESTBIN "$@" 2>,stderr >,stdout - return=$? else $valgrind $TESTBIN "$@" 2>,stderr >,stdout - return=$? - fi + fi &>/dev/null + return=$? echo -n >,testtmp @@ -164,6 +164,8 @@ function TEST() echo ".. FAILED$MSGFAIL" >>,testlog cat ,testtmp >>,testlog rm ,testtmp + echo "stderr was:" >>,testlog + cat ,stderr >>,testlog echo END >>,testlog FAILCNT=$(($FAILCNT + 1)) case $TESTMODE in From 69c62152773c8dd90d0df84a30cb9c641dce1719 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 13 Aug 2007 21:30:41 +0200 Subject: [PATCH 12/17] more automake merges --- configure.ac | 73 ++++++++++++++++++++++++++++++++++++++ tests/examples/Makefile.am | 31 ++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 configure.ac create mode 100644 tests/examples/Makefile.am diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..5b2512122 --- /dev/null +++ b/configure.ac @@ -0,0 +1,73 @@ +AC_INIT(cinelerra, 3.0pre) +AC_CONFIG_SRCDIR(src/lib/plugin.c) +AC_CONFIG_AUX_DIR(scripts) +AM_INIT_AUTOMAKE +AC_PREREQ(2.59) + +AC_COPYRIGHT([ + Copyright (C) CinelerraCV + 2007, Christian Thaeter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +]) + +# +# Required programs +# +AC_PROG_CC +AC_PROG_CPP +AC_PROG_CXX +AC_PROG_LIBTOOL + +# +# test for headers +# +AC_STDC_HEADERS +AC_CHECK_HEADER([pthread.h], AC_DEFINE(HAVE_PTHREAD_H)) +AC_CHECK_HEADER([nobug.h], AC_DEFINE(HAVE_NOBUG_H)) +AC_CHECK_HEADER([execinfo.h], AC_DEFINE(HAVE_EXECINFO_H)) +# there is a warning in nobug, disabled til fixed AC_CHECK_HEADER([valgrind/valgrind.h], AC_DEFINE(HAVE_VALGRIND_VALGRIND_H)) + +# +# user options +# + + +############## NoBug build levels +AH_TEMPLATE(EBUG_ALPHA, [Define to 1 for selecting NoBug ALPHA build level]) +AH_TEMPLATE(EBUG_BETA, [Define to 1 for selecting NoBug BETA build level]) +AH_TEMPLATE(NDEBUG, [Define to 1 for selecting NoBug RELEASE build level]) +AC_ARG_ENABLE(alpha, AC_HELP_STRING([--enable-alpha], [select NoBug ALPHA build level]), + nobug_level=alpha + AC_DEFINE(EBUG_ALPHA), +[ +AC_ARG_ENABLE(beta, AC_HELP_STRING([--enable-beta], [select NoBug BETA build level]), + nobug_level=beta + AC_DEFINE(EBUG_BETA), +[ +AC_ARG_ENABLE(release, AC_HELP_STRING([--enable-release], [select NoBug RELEASE build level]), + nobug_level=release + AC_DEFINE(NDEBUG), + +# default to ALPHA + nobug_level=alpha + AC_DEFINE(EBUG_ALPHA) +)])]) +AC_MSG_RESULT([NoBug build level: $nobug_level]) +# END NoBug + + +AC_CONFIG_FILES(Makefile) +AC_OUTPUT diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am new file mode 100644 index 000000000..b63b4c821 --- /dev/null +++ b/tests/examples/Makefile.am @@ -0,0 +1,31 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +examples_srcdir = $(top_srcdir)/tests/examples +noinst_PROGRAMS += plugin_example + +plugin_example_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror +plugin_example_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ +plugin_example_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl + +plugin_example_SOURCES = $(examples_srcdir)/plugin_main.c +noinst_HEADERS += $(examples_srcdir)/hello_interface.h + +noinst_LTLIBRARIES += example_plugin.la +example_plugin_la_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ +example_plugin_la_SOURCES = $(examples_srcdir)/example_plugin.c + From ed2427c653d9e5b15f0cb367c212f96fa590756e Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 13 Aug 2007 21:34:51 +0200 Subject: [PATCH 13/17] Merge branch 'automake' Conflicts: configure.ac tests/examples/Makefile.am --- .gitignore | 8 +++++++- configure.ac | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ed690f89c..01c32fa89 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,10 @@ .sconsign.dblite Buildhelper.pyc optcache - +Makefile.in +build/* +autom4te.cache/* +scripts/* +configure +aclocal.m4 +semantic.cache diff --git a/configure.ac b/configure.ac index 5b2512122..88ff7e908 100644 --- a/configure.ac +++ b/configure.ac @@ -30,6 +30,7 @@ AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_LIBTOOL +AC_PROG_RANLIB # # test for headers From 42b3e12180b230caf5c0fecb2cb21a8e7b1c7077 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Mon, 13 Aug 2007 21:36:22 +0200 Subject: [PATCH 14/17] merge in progress, some files left out --- Makefile.am | 44 ++++++++++++++++++++++++++++++++++++++++++ src/lib/Makefile.am | 24 +++++++++++++++++++++++ tests/99examples.tests | 5 +++++ 3 files changed, 73 insertions(+) create mode 100644 Makefile.am create mode 100644 src/lib/Makefile.am create mode 100644 tests/99examples.tests diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..fbaecd794 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,44 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +bin_PROGRAMS = +lib_LTLIBRARIES = +noinst_PROGRAMS = +noinst_LIBRARIES = +noinst_LTLIBRARIES = +noinst_HEADERS = +BUILT_SOURCES = +EXTRA_DIST = +SUBDIRS = + +# Only use subdirs if really needed, prefer the include scheme below +#SUBDIRS += + +# core +include $(top_srcdir)/src/lib/Makefile.am + +# plugins +#include $(top_srcdir)/src... + +# tests +include $(top_srcdir)/tests/examples/Makefile.am + +#EXTRA_DIST += admin debian doc depcomp README.BUILD LICENSE \ +# cinelerra-cvs-current.spec +AUTOMAKE_OPTIONS=foreign +#ACLOCAL_AMFLAGS = -I m4 + diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am new file mode 100644 index 000000000..b6c493a18 --- /dev/null +++ b/src/lib/Makefile.am @@ -0,0 +1,24 @@ +# Copyright (C) CinelerraCV +# 2007, Christian Thaeter +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +libcin3_a_srcdir = $(top_srcdir)/src/lib +noinst_LIBRARIES += libcin3.a + +libcin3_a_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror + +libcin3_a_SOURCES = $(libcin3_a_srcdir)/plugin.c +noinst_HEADERS += $(libcin3_a_srcdir)/plugin.h diff --git a/tests/99examples.tests b/tests/99examples.tests new file mode 100644 index 000000000..ef7cb1aff --- /dev/null +++ b/tests/99examples.tests @@ -0,0 +1,5 @@ +TESTING "test plugin example code" ./plugin_example + +TEST "plugin example" < Date: Mon, 13 Aug 2007 21:37:51 +0200 Subject: [PATCH 15/17] add DIR_INFO in otherwise ignored scripts dir --- scripts/DIR_INFO | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/DIR_INFO diff --git a/scripts/DIR_INFO b/scripts/DIR_INFO new file mode 100644 index 000000000..265ca57ac --- /dev/null +++ b/scripts/DIR_INFO @@ -0,0 +1 @@ +autotools helper scripts From d2c13807bbeb0213fab05f18a1fb91da176ac207 Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Tue, 14 Aug 2007 04:21:47 +0200 Subject: [PATCH 16/17] disable (non finished) plugin test, fix some bugs --- tests/examples/Makefile.am | 6 +++--- tests/examples/example_plugin.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/examples/Makefile.am b/tests/examples/Makefile.am index a28e4b087..5ca03150a 100644 --- a/tests/examples/Makefile.am +++ b/tests/examples/Makefile.am @@ -25,6 +25,6 @@ plugin_example_LDADD = $(builddir)/libcin3.a -lnobugmt -lpthread -ldl plugin_example_SOURCES = $(examples_srcdir)/plugin_main.c noinst_HEADERS += $(examples_srcdir)/hello_interface.h -noinst_LTLIBRARIES += example_plugin.la -example_plugin_la_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ -example_plugin_la_SOURCES = $(examples_srcdir)/example_plugin.c +#noinst_LTLIBRARIES += example_plugin.la +#example_plugin_la_CPPFLAGS = $(CPPFLAGS) -std=gnu99 -Wall -Werror -I$(top_srcdir)/src/lib/ +#example_plugin_la_SOURCES = $(examples_srcdir)/example_plugin.c diff --git a/tests/examples/example_plugin.c b/tests/examples/example_plugin.c index 1a294b8bf..2f4e96a6c 100644 --- a/tests/examples/example_plugin.c +++ b/tests/examples/example_plugin.c @@ -5,40 +5,41 @@ int myopen(void) { printf("opened\n"); + return 0; } -int myclose(void); +int myclose(void) { printf("closed\n"); + return 0; } -int hallo(void) +void hallo(void) { printf("Hallo Welt!\n"); } -int tschuess(const char* m) +void tschuess(const char* m) { printf("Tschues %s\n", m); } -int hello(void); +void hello(void) { printf("Hello world!\n"); } -int bye(const char* m) +void bye(const char* m) { printf("bye %s\n", m); - } CINELERRA_INTERFACE_IMPLEMENT(hello, 1, german, myopen, myclose, - CINELERRA_INTERFACE_FUNC(hello, hallo), - CINELERRA_INTERFACE_FUNC(goodbye, tschuess) + //CINELERRA_INTERFACE_FUNC(hello, hallo), + //CINELERRA_INTERFACE_FUNC(goodbye, tschuess) ); CINELERRA_INTERFACE_IMPLEMENT(hello, 1, english, myopen, myclose, - CINELERRA_INTERFACE_FUNC(hello, hello), - CINELERRA_INTERFACE_FUNC(goodbye, bye) + //CINELERRA_INTERFACE_FUNC(hello, hello), + //CINELERRA_INTERFACE_FUNC(goodbye, bye) ); From d36a38a56eeacc7f7130b304638bc5c23fefd6ac Mon Sep 17 00:00:00 2001 From: Christian Thaeter Date: Tue, 14 Aug 2007 04:40:13 +0200 Subject: [PATCH 17/17] errorhandling finished for now, as proposed --- Makefile.am | 1 + src/lib/Makefile.am | 4 +-- src/lib/error.c | 56 ++++++++++++++++++++++++++++++++ src/lib/error.h | 14 ++++++-- tests/10errorhandling.tests | 27 +++++++++++++++ tests/Makefile.am | 6 +++- tests/errortest.c | 65 +++++++++++++++++++++++++++++++++++++ 7 files changed, 167 insertions(+), 6 deletions(-) create mode 100644 src/lib/error.c create mode 100644 tests/10errorhandling.tests create mode 100644 tests/errortest.c diff --git a/Makefile.am b/Makefile.am index df66c2437..09e1593c9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,7 @@ bin_PROGRAMS = lib_LTLIBRARIES = noinst_PROGRAMS = +check_PROGRAMS = noinst_LIBRARIES = noinst_LTLIBRARIES = noinst_HEADERS = diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index b6c493a18..7419bedf9 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -20,5 +20,5 @@ noinst_LIBRARIES += libcin3.a libcin3_a_CFLAGS = $(CFLAGS) -std=gnu99 -Wall -Werror -libcin3_a_SOURCES = $(libcin3_a_srcdir)/plugin.c -noinst_HEADERS += $(libcin3_a_srcdir)/plugin.h +libcin3_a_SOURCES = $(libcin3_a_srcdir)/plugin.c $(libcin3_a_srcdir)/error.c +noinst_HEADERS += $(libcin3_a_srcdir)/plugin.h $(libcin3_a_srcdir)/error.h diff --git a/src/lib/error.c b/src/lib/error.c new file mode 100644 index 000000000..d05696c06 --- /dev/null +++ b/src/lib/error.c @@ -0,0 +1,56 @@ +/* + error.c - Cinelerra Error handling + + Copyright (C) CinelerraCV + 2007, Christian Thaeter + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include + +/* Thread local storage */ +static pthread_key_t cinelerra_error_tls; +static pthread_once_t cinelerra_error_initialized = PTHREAD_ONCE_INIT; + +static void +cinelerra_error_tls_init (void) +{ + pthread_key_create (&cinelerra_error_tls, NULL); +} + +const char* +cinelerra_error_set (const char * nerr) +{ + pthread_once (&cinelerra_error_initialized, cinelerra_error_tls_init); + + const char* err = pthread_getspecific (cinelerra_error_tls); + if (!err) + pthread_setspecific (cinelerra_error_tls, nerr); + + return err; +} + + +const char* +cinelerra_error () +{ + pthread_once (&cinelerra_error_initialized, cinelerra_error_tls_init); + + const char* err = pthread_getspecific (cinelerra_error_tls); + if (err) + pthread_setspecific (cinelerra_error_tls, NULL); + return err; +} diff --git a/src/lib/error.h b/src/lib/error.h index 09cd31c8d..6b8aaf753 100644 --- a/src/lib/error.h +++ b/src/lib/error.h @@ -26,9 +26,17 @@ #define CINELERRA_DIE(message) do { NOBUG_ERROR(NOBUG_ON, message); abort(); } while(0) -#define CINELERRA_ERROR_DECLARE(err) extern const cinelerra_error err -#define CINELERRA_ERROR_DEFINE(err, msg) const cinelerra_error err = #err ":" msg +#define CINELERRA_ERROR_DECLARE(err) \ +extern const char* CINELERRA_ERROR_##err + +#define CINELERRA_ERROR_DEFINE(err, msg) \ +const char* CINELERRA_ERROR_##err = "CINELERRA_ERROR_" #err ":" msg + +const char* +cinelerra_error_set (const char * err); + +const char* +cinelerra_error (); -typedef const char* cinelerra_error; #endif /* CINELERRA_ERROR_H */ diff --git a/tests/10errorhandling.tests b/tests/10errorhandling.tests new file mode 100644 index 000000000..220e1da3d --- /dev/null +++ b/tests/10errorhandling.tests @@ -0,0 +1,27 @@ + +TESTING "Error handling" ./errortest + +TEST "no error" < + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include +#include +#include + +CINELERRA_ERROR_DEFINE(TEST, "test error"); + +int +main (int argc, char** argv) +{ + if (argc == 1) + return 0; + + if (!strcmp(argv[1], "set")) + { + cinelerra_error_set (CINELERRA_ERROR_TEST); + } + + if (!strcmp(argv[1], "get_no")) + { + const char* err; + err = cinelerra_error (); + printf ("%p\n", err); + } + + if (!strcmp(argv[1], "get")) + { + cinelerra_error_set (CINELERRA_ERROR_TEST); + const char* err; + err = cinelerra_error (); + printf ("%s\n", err); + } + + if (!strcmp(argv[1], "get2")) + { + cinelerra_error_set (CINELERRA_ERROR_TEST); + const char* err; + err = cinelerra_error (); + printf ("%s\n", err); + err = cinelerra_error (); + printf ("%p\n", err); + } + + return 0; +}