diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-21 11:05:50 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-02-21 11:05:50 +0000 |
commit | 6efad6059c8d41a2d6ad0d74c4804eb27baa0295 (patch) | |
tree | b23241af06bb9c9ed4f8dfb11522b15a0abb9fd8 /src/namestore | |
parent | 2be63d6e73aa46ed4271cf0cc7e6499c64bfade2 (diff) | |
download | gnunet-6efad6059c8d41a2d6ad0d74c4804eb27baa0295.tar.gz gnunet-6efad6059c8d41a2d6ad0d74c4804eb27baa0295.zip |
- adding namestore api test
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/Makefile.am | 59 | ||||
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 3 | ||||
-rw-r--r-- | src/namestore/test_namestore_api.c | 72 | ||||
-rw-r--r-- | src/namestore/test_namestore_api.conf | 30 |
4 files changed, 140 insertions, 24 deletions
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 | |||
17 | endif | 17 | endif |
18 | 18 | ||
19 | 19 | ||
20 | #lib_LTLIBRARIES = \ | 20 | check_PROGRAMS = \ |
21 | # libgnunetnamestore.la | 21 | test_namestore_api |
22 | # | 22 | |
23 | #libgnunetnamestore_la_SOURCES = \ | 23 | lib_LTLIBRARIES = \ |
24 | # namestore_api.c namestore.h | 24 | libgnunetnamestore.la |
25 | #libgnunetnamestore_la_LIBADD = \ | 25 | |
26 | # $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 26 | libgnunetnamestore_la_SOURCES = \ |
27 | # $(top_builddir)/src/util/libgnunetutil.la \ | 27 | namestore_api.c namestore.h |
28 | # $(GN_LIBINTL) | 28 | libgnunetnamestore_la_LIBADD = \ |
29 | #libgnunetnamestore_la_LDFLAGS = \ | 29 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
30 | # $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 30 | $(top_builddir)/src/util/libgnunetutil.la \ |
31 | # -version-info 0:0:0 | 31 | $(GN_LIBINTL) |
32 | # | 32 | libgnunetnamestore_la_LDFLAGS = \ |
33 | 33 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | |
34 | #bin_PROGRAMS = \ | 34 | -version-info 0:0:0 |
35 | # gnunet-service-namestore | 35 | |
36 | # | 36 | bin_PROGRAMS = \ |
37 | #gnunet_service_namestore_SOURCES = \ | 37 | gnunet-service-namestore |
38 | # gnunet-service-namestore.c | 38 | |
39 | #gnunet_service_namestore_LDADD = \ | 39 | gnunet_service_namestore_SOURCES = \ |
40 | # $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 40 | gnunet-service-namestore.c |
41 | # $(top_builddir)/src/util/libgnunetutil.la \ | 41 | gnunet_service_namestore_LDADD = \ |
42 | # $(GN_LIBINTL) | 42 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
43 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
44 | $(GN_LIBINTL) | ||
43 | 45 | ||
44 | if HAVE_SQLITE | 46 | if HAVE_SQLITE |
45 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la | 47 | SQLITE_PLUGIN = libgnunet_plugin_namestore_sqlite.la |
@@ -56,3 +58,14 @@ libgnunet_plugin_namestore_sqlite_la_LIBADD = \ | |||
56 | libgnunet_plugin_namestore_sqlite_la_LDFLAGS = \ | 58 | libgnunet_plugin_namestore_sqlite_la_LDFLAGS = \ |
57 | $(GN_PLUGIN_LDFLAGS) | 59 | $(GN_PLUGIN_LDFLAGS) |
58 | 60 | ||
61 | |||
62 | test_namestore_api_SOURCES = \ | ||
63 | test_namestore_api.c | ||
64 | test_namestore_api_LDADD = \ | ||
65 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
66 | $(top_builddir)/src/namestore/libgnunetnamestore.la | ||
67 | |||
68 | EXTRADIST = \ | ||
69 | test_namestore_api.conf | ||
70 | |||
71 | \ 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 @@ | |||
28 | #include "gnunet_service_lib.h" | 28 | #include "gnunet_service_lib.h" |
29 | #include "gnunet_namestore_service.h" | 29 | #include "gnunet_namestore_service.h" |
30 | 30 | ||
31 | |||
31 | /** | 32 | /** |
32 | * Task run during shutdown. | 33 | * Task run during shutdown. |
33 | * | 34 | * |
@@ -56,7 +57,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
56 | /* FIXME: add handlers here! */ | 57 | /* FIXME: add handlers here! */ |
57 | {NULL, NULL, 0, 0} | 58 | {NULL, NULL, 0, 0} |
58 | }; | 59 | }; |
59 | /* FIXME: do setup here */ | 60 | |
60 | GNUNET_SERVER_add_handlers (server, handlers); | 61 | GNUNET_SERVER_add_handlers (server, handlers); |
61 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, | 62 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task, |
62 | NULL); | 63 | 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 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file namestore/test_namestore_api.c | ||
22 | * @brief testcase for namestore_api.c | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_common.h" | ||
26 | #include "gnunet_namestore_service.h" | ||
27 | |||
28 | #define VERBOSE GNUNET_EXTRA_LOGGING | ||
29 | |||
30 | static int res; | ||
31 | |||
32 | static void | ||
33 | run (void *cls, char *const *args, const char *cfgfile, | ||
34 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
35 | { | ||
36 | |||
37 | res = 0; | ||
38 | } | ||
39 | |||
40 | static int | ||
41 | check () | ||
42 | { | ||
43 | static char *const argv[] = { "test-namestore-api", | ||
44 | "-c", | ||
45 | "test_namestore_api.conf", | ||
46 | #if VERBOSE | ||
47 | "-L", "DEBUG", | ||
48 | #endif | ||
49 | NULL | ||
50 | }; | ||
51 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
52 | GNUNET_GETOPT_OPTION_END | ||
53 | }; | ||
54 | |||
55 | res = 1; | ||
56 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, "test-namestore-api", | ||
57 | "nohelp", options, &run, &res); | ||
58 | return res; | ||
59 | } | ||
60 | |||
61 | int | ||
62 | main (int argc, char *argv[]) | ||
63 | { | ||
64 | int ret; | ||
65 | |||
66 | |||
67 | ret = check (); | ||
68 | |||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | /* 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 @@ | |||
1 | [namestore] | ||
2 | AUTOSTART = YES | ||
3 | UNIXPATH = /tmp/gnunet-service-namestore.sock | ||
4 | UNIX_MATCH_UID = YES | ||
5 | UNIX_MATCH_GID = YES | ||
6 | # PORT = 2099 | ||
7 | HOSTNAME = localhost | ||
8 | HOME = $SERVICEHOME | ||
9 | CONFIG = $DEFAULTCONFIG | ||
10 | BINARY = gnunet-service-namestore | ||
11 | ACCEPT_FROM = 127.0.0.1; | ||
12 | ACCEPT_FROM6 = ::1; | ||
13 | DATABASE = sqlite | ||
14 | |||
15 | [namestore-sqlite] | ||
16 | FILENAME = $SERVICEHOME/namestore/sqlite.db | ||
17 | |||
18 | [namestore-postgres] | ||
19 | CONFIG = connect_timeout=10; dbname=gnunet | ||
20 | |||
21 | [namestore-mysql] | ||
22 | DATABASE = gnunet | ||
23 | CONFIG = ~/.my.cnf | ||
24 | # USER = gnunet | ||
25 | # PASSWORD = | ||
26 | # HOST = localhost | ||
27 | # PORT = 3306 | ||
28 | |||
29 | |||
30 | |||