diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-06-19 12:40:27 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-06-19 12:40:27 +0000 |
commit | e02cb36c96f1745b357fe723b2990753247acb46 (patch) | |
tree | 829621e972f040992c633b5f7636096597bf6f36 | |
parent | 72d6a013072770ba7e2426346f962a8ade446b8c (diff) | |
download | gnunet-e02cb36c96f1745b357fe723b2990753247acb46.tar.gz gnunet-e02cb36c96f1745b357fe723b2990753247acb46.zip |
testbed_api_hosts test cases
-rw-r--r-- | src/testbed/Makefile.am | 12 | ||||
-rw-r--r-- | src/testbed/test_testbed_api.conf | 67 | ||||
-rw-r--r-- | src/testbed/test_testbed_api_hosts.c | 105 | ||||
-rw-r--r-- | src/testbed/testbed_api_hosts.c | 12 |
4 files changed, 193 insertions, 3 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index 75ca9d567..96f354474 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am | |||
@@ -50,3 +50,15 @@ libgnunettestbed_la_LDFLAGS = \ | |||
50 | $(GN_LIB_LDFLAGS) \ | 50 | $(GN_LIB_LDFLAGS) \ |
51 | -version-info 0:0:0 | 51 | -version-info 0:0:0 |
52 | 52 | ||
53 | check_PROGRAMS = \ | ||
54 | test_testbed_api_hosts | ||
55 | |||
56 | if ENABLE_TEST_RUN | ||
57 | TESTS = $(check_PROGRAMS) | ||
58 | endif | ||
59 | |||
60 | test_testbed_api_hosts_SOURCES = \ | ||
61 | test_testbed_api_hosts.c | ||
62 | test_testbed_api_hosts_LDADD = \ | ||
63 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
64 | libgnunettestbed.la \ No newline at end of file | ||
diff --git a/src/testbed/test_testbed_api.conf b/src/testbed/test_testbed_api.conf new file mode 100644 index 000000000..c41ee9539 --- /dev/null +++ b/src/testbed/test_testbed_api.conf | |||
@@ -0,0 +1,67 @@ | |||
1 | [lockmanager] | ||
2 | AUTOSTART = NO | ||
3 | |||
4 | [fs] | ||
5 | AUTOSTART = NO | ||
6 | |||
7 | [resolver] | ||
8 | AUTOSTART = NO | ||
9 | |||
10 | [mesh] | ||
11 | AUTOSTART = NO | ||
12 | |||
13 | [dht] | ||
14 | AUTOSTART = NO | ||
15 | |||
16 | [block] | ||
17 | plugins = dht test | ||
18 | |||
19 | [dhtcache] | ||
20 | QUOTA = 1 MB | ||
21 | DATABASE = sqlite | ||
22 | |||
23 | [transport] | ||
24 | PLUGINS = tcp | ||
25 | DEBUG = NO | ||
26 | ACCEPT_FROM6 = ::1; | ||
27 | ACCEPT_FROM = 127.0.0.1; | ||
28 | NEIGHBOUR_LIMIT = 50 | ||
29 | PORT = 12365 | ||
30 | |||
31 | [ats] | ||
32 | WAN_QUOTA_OUT = 3932160 | ||
33 | WAN_QUOTA_IN = 3932160 | ||
34 | |||
35 | [core] | ||
36 | PORT = 12092 | ||
37 | |||
38 | [arm] | ||
39 | DEFAULTSERVICES = | ||
40 | PORT = 12366 | ||
41 | DEBUG = NO | ||
42 | |||
43 | [transport-tcp] | ||
44 | TIMEOUT = 300 s | ||
45 | PORT = 12368 | ||
46 | |||
47 | [TESTING] | ||
48 | NUM_PEERS = 5 | ||
49 | WEAKRANDOM = YES | ||
50 | DEBUG = YES | ||
51 | HOSTKEYSFILE = ../../contrib/testing_hostkeys.dat | ||
52 | MAX_CONCURRENT_SSH = 10 | ||
53 | USE_PROGRESSBARS = YES | ||
54 | PEERGROUP_TIMEOUT = 2400 s | ||
55 | |||
56 | [gnunetd] | ||
57 | HOSTKEY = $SERVICEHOME/.hostkey | ||
58 | |||
59 | [PATHS] | ||
60 | DEFAULTCONFIG = test_testbed_api.conf | ||
61 | SERVICEHOME = /tmp/test-testbed/ | ||
62 | |||
63 | [dns] | ||
64 | AUTOSTART = NO | ||
65 | |||
66 | [nse] | ||
67 | AUTOSTART = NO | ||
diff --git a/src/testbed/test_testbed_api_hosts.c b/src/testbed/test_testbed_api_hosts.c new file mode 100644 index 000000000..91002f10e --- /dev/null +++ b/src/testbed/test_testbed_api_hosts.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2008--2012 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 | /** | ||
22 | * @file testbed/test_testbed_api_hosts.c | ||
23 | * @brief tests cases for testbed_api_hosts.c | ||
24 | * @author Sree Harsha Totakura | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_testbed_service.h" | ||
30 | #include "testbed_api_hosts.h" | ||
31 | |||
32 | |||
33 | #define TIME_REL_SECS(sec) \ | ||
34 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) | ||
35 | |||
36 | /** | ||
37 | * Host we are creating and using | ||
38 | */ | ||
39 | static struct GNUNET_TESTBED_Host *host; | ||
40 | |||
41 | /** | ||
42 | * The host helper handle | ||
43 | */ | ||
44 | static struct GNUNET_TESTBED_HelperHandle *helper_handle; | ||
45 | |||
46 | |||
47 | /** | ||
48 | * The shutdown task | ||
49 | * | ||
50 | * @param cls NULL | ||
51 | * @param tc the task context | ||
52 | */ | ||
53 | static void | ||
54 | do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
55 | { | ||
56 | GNUNET_TESTBED_host_stop_ (helper_handle); | ||
57 | GNUNET_TESTBED_host_destroy (host); | ||
58 | } | ||
59 | |||
60 | |||
61 | /** | ||
62 | * Main run function. | ||
63 | * | ||
64 | * @param cls NULL | ||
65 | * @param args arguments passed to GNUNET_PROGRAM_run | ||
66 | * @param cfgfile the path to configuration file | ||
67 | * @param cfg the configuration file handle | ||
68 | */ | ||
69 | static void | ||
70 | run (void *cls, char *const *args, const char *cfgfile, | ||
71 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
72 | { | ||
73 | char *const binary_args[] = {NULL}; | ||
74 | |||
75 | host = GNUNET_TESTBED_host_create ("localhost", NULL, 0); | ||
76 | GNUNET_assert (NULL != host); | ||
77 | GNUNET_assert (0 != GNUNET_TESTBED_host_get_id_ (host)); | ||
78 | GNUNET_TESTBED_host_destroy (host); | ||
79 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | ||
80 | GNUNET_assert (NULL != host); | ||
81 | GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); | ||
82 | GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); | ||
83 | helper_handle = GNUNET_TESTBED_host_run_ (host, binary_args); | ||
84 | GNUNET_assert (NULL != helper_handle); | ||
85 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (2), &do_shutdown, NULL); | ||
86 | } | ||
87 | |||
88 | |||
89 | int main (int argc, char **argv) | ||
90 | { | ||
91 | int ret; | ||
92 | |||
93 | char *const argv2[] = { "test_lockmanager_api_hosts", | ||
94 | "-c", "test_testbed_api.conf", | ||
95 | NULL | ||
96 | }; | ||
97 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
98 | GNUNET_GETOPT_OPTION_END | ||
99 | }; | ||
100 | |||
101 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | ||
102 | "test_testbed_api_hosts", "nohelp", options, &run, NULL); | ||
103 | |||
104 | return GNUNET_OK == ret ? 0 : 1; | ||
105 | } | ||
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index c4dfcf3c9..ca3afb29a 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -117,8 +117,11 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id) | |||
117 | struct GNUNET_TESTBED_Host * | 117 | struct GNUNET_TESTBED_Host * |
118 | GNUNET_TESTBED_host_create_by_id_ (uint32_t id) | 118 | GNUNET_TESTBED_host_create_by_id_ (uint32_t id) |
119 | { | 119 | { |
120 | GNUNET_break (0); | 120 | struct GNUNET_TESTBED_Host *host; |
121 | return NULL; | 121 | |
122 | host = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Host)); | ||
123 | host->unique_id = id; | ||
124 | return host; | ||
122 | } | 125 | } |
123 | 126 | ||
124 | 127 | ||
@@ -280,7 +283,10 @@ GNUNET_TESTBED_host_run_ (const struct GNUNET_TESTBED_Host *host, | |||
280 | unsigned int argp; | 283 | unsigned int argp; |
281 | 284 | ||
282 | GNUNET_asprintf (&h->port, "%d", host->port); | 285 | GNUNET_asprintf (&h->port, "%d", host->port); |
283 | GNUNET_asprintf (&h->dst, "%s@%s", host->hostname, host->username); | 286 | if (NULL == host->username) |
287 | GNUNET_asprintf (&h->dst, "%s", host->hostname); | ||
288 | else | ||
289 | GNUNET_asprintf (&h->dst, "%s@%s", host->hostname, host->username); | ||
284 | argp = 0; | 290 | argp = 0; |
285 | remote_args[argp++] = "ssh"; | 291 | remote_args[argp++] = "ssh"; |
286 | remote_args[argp++] = "-p"; | 292 | remote_args[argp++] = "-p"; |