From: Matthias Wachs Date: Tue, 21 Feb 2012 11:05:50 +0000 (+0000) Subject: - adding namestore api test X-Git-Tag: initial-import-from-subversion-38251~14779 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6efad6059c8d41a2d6ad0d74c4804eb27baa0295;p=oweals%2Fgnunet.git - adding namestore api test --- diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 3dead06dc..5e7f1cbfd 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am @@ -17,29 +17,31 @@ if USE_COVERAGE endif -#lib_LTLIBRARIES = \ -# libgnunetnamestore.la -# -#libgnunetnamestore_la_SOURCES = \ -# namestore_api.c namestore.h -#libgnunetnamestore_la_LIBADD = \ -# $(top_builddir)/src/statistics/libgnunetstatistics.la \ -# $(top_builddir)/src/util/libgnunetutil.la \ -# $(GN_LIBINTL) -#libgnunetnamestore_la_LDFLAGS = \ -# $(GN_LIB_LDFLAGS) $(WINFLAGS) \ -# -version-info 0:0:0 -# - -#bin_PROGRAMS = \ -# gnunet-service-namestore -# -#gnunet_service_namestore_SOURCES = \ -# gnunet-service-namestore.c -#gnunet_service_namestore_LDADD = \ -# $(top_builddir)/src/statistics/libgnunetstatistics.la \ -# $(top_builddir)/src/util/libgnunetutil.la \ -# $(GN_LIBINTL) +check_PROGRAMS = \ + test_namestore_api + +lib_LTLIBRARIES = \ + libgnunetnamestore.la + +libgnunetnamestore_la_SOURCES = \ + namestore_api.c namestore.h +libgnunetnamestore_la_LIBADD = \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) +libgnunetnamestore_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) $(WINFLAGS) \ + -version-info 0:0:0 + +bin_PROGRAMS = \ + gnunet-service-namestore + +gnunet_service_namestore_SOURCES = \ + gnunet-service-namestore.c +gnunet_service_namestore_LDADD = \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(GN_LIBINTL) if HAVE_SQLITE SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la @@ -56,3 +58,14 @@ libgnunet_plugin_namestore_sqlite_la_LIBADD = \ libgnunet_plugin_namestore_sqlite_la_LDFLAGS = \ $(GN_PLUGIN_LDFLAGS) + +test_namestore_api_SOURCES = \ + test_namestore_api.c +test_namestore_api_LDADD = \ + $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/namestore/libgnunetnamestore.la + +EXTRADIST = \ + test_namestore_api.conf + + \ No newline at end of file diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index b04154f04..8e7946246 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c @@ -28,6 +28,7 @@ #include "gnunet_service_lib.h" #include "gnunet_namestore_service.h" + /** * Task run during shutdown. * @@ -56,7 +57,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, /* FIXME: add handlers here! */ {NULL, NULL, 0, 0} }; - /* FIXME: do setup here */ + GNUNET_SERVER_add_handlers (server, handlers); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, NULL); diff --git a/src/namestore/test_namestore_api.c b/src/namestore/test_namestore_api.c new file mode 100644 index 000000000..c15a4e7d1 --- /dev/null +++ b/src/namestore/test_namestore_api.c @@ -0,0 +1,72 @@ +/* + This file is part of GNUnet. + (C) 2009 Christian Grothoff (and other contributing authors) + + GNUnet 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 3, or (at your + option) any later version. + + GNUnet 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 GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ +/** + * @file namestore/test_namestore_api.c + * @brief testcase for namestore_api.c + */ +#include "platform.h" +#include "gnunet_common.h" +#include "gnunet_namestore_service.h" + +#define VERBOSE GNUNET_EXTRA_LOGGING + +static int res; + +static void +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + + res = 0; +} + +static int +check () +{ + static char *const argv[] = { "test-namestore-api", + "-c", + "test_namestore_api.conf", +#if VERBOSE + "-L", "DEBUG", +#endif + NULL + }; + static struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_END + }; + + res = 1; + GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", + "nohelp", options, &run, &res); + return res; +} + +int +main (int argc, char *argv[]) +{ + int ret; + + + ret = check (); + + return ret; +} + +/* end of test_namestore_api.c */ diff --git a/src/namestore/test_namestore_api.conf b/src/namestore/test_namestore_api.conf new file mode 100644 index 000000000..c73a15498 --- /dev/null +++ b/src/namestore/test_namestore_api.conf @@ -0,0 +1,30 @@ +[namestore] +AUTOSTART = YES +UNIXPATH = /tmp/gnunet-service-namestore.sock +UNIX_MATCH_UID = YES +UNIX_MATCH_GID = YES +# PORT = 2099 +HOSTNAME = localhost +HOME = $SERVICEHOME +CONFIG = $DEFAULTCONFIG +BINARY = gnunet-service-namestore +ACCEPT_FROM = 127.0.0.1; +ACCEPT_FROM6 = ::1; +DATABASE = sqlite + +[namestore-sqlite] +FILENAME = $SERVICEHOME/namestore/sqlite.db + +[namestore-postgres] +CONFIG = connect_timeout=10; dbname=gnunet + +[namestore-mysql] +DATABASE = gnunet +CONFIG = ~/.my.cnf +# USER = gnunet +# PASSWORD = +# HOST = localhost +# PORT = 3306 + + +