diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-01 15:42:42 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-09-01 15:42:42 +0000 |
commit | 768cf4d37944fceb336ceb09aa85e2ae87e7a612 (patch) | |
tree | cf680d1b5306c3a066ec2f269f51c5754f3898e8 /src/testbed/test_testbed_api_test.c | |
parent | 427cbfbb202128ea8017c8da75f1a22b376ab2b0 (diff) | |
download | gnunet-768cf4d37944fceb336ceb09aa85e2ae87e7a612.tar.gz gnunet-768cf4d37944fceb336ceb09aa85e2ae87e7a612.zip |
tests for testbed_test_run and some fixes
Diffstat (limited to 'src/testbed/test_testbed_api_test.c')
-rw-r--r-- | src/testbed/test_testbed_api_test.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/testbed/test_testbed_api_test.c b/src/testbed/test_testbed_api_test.c new file mode 100644 index 000000000..83d18ce0c --- /dev/null +++ b/src/testbed/test_testbed_api_test.c | |||
@@ -0,0 +1,93 @@ | |||
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 src/testbed/test_testbed_api_test.c | ||
23 | * @brief testing cases for testing high level testbed api helper functions | ||
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | ||
25 | */ | ||
26 | |||
27 | #include "platform.h" | ||
28 | #include "gnunet_common.h" | ||
29 | #include "gnunet_testbed_service.h" | ||
30 | |||
31 | /** | ||
32 | * Number of peers we want to start | ||
33 | */ | ||
34 | #define NUM_PEERS 25 | ||
35 | |||
36 | /** | ||
37 | * Testing result | ||
38 | */ | ||
39 | static int result; | ||
40 | |||
41 | |||
42 | /** | ||
43 | * Shutdown nicely | ||
44 | * | ||
45 | * @param cls NULL | ||
46 | * @param tc the task context | ||
47 | */ | ||
48 | static void | ||
49 | do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
50 | { | ||
51 | GNUNET_SCHEDULER_shutdown (); | ||
52 | } | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Signature of a main function for a testcase. | ||
57 | * | ||
58 | * @param cls closure | ||
59 | * @param num_peers number of peers in 'peers' | ||
60 | * @param peers handle to peers run in the testbed | ||
61 | */ | ||
62 | static void | ||
63 | test_master (void *cls, unsigned int num_peers, | ||
64 | struct GNUNET_TESTBED_Peer **peers) | ||
65 | { | ||
66 | unsigned int peer; | ||
67 | |||
68 | GNUNET_assert (NULL == cls); | ||
69 | GNUNET_assert (NUM_PEERS == num_peers); | ||
70 | GNUNET_assert (NULL != peers); | ||
71 | for (peer = 0; peer < num_peers; peer++) | ||
72 | GNUNET_assert (NULL != peers[peer]); | ||
73 | result = GNUNET_OK; | ||
74 | /* Artificial delay for shutdown */ | ||
75 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown, NULL); | ||
76 | } | ||
77 | |||
78 | |||
79 | /** | ||
80 | * Main function | ||
81 | */ | ||
82 | int | ||
83 | main (int argc, char **argv) | ||
84 | { | ||
85 | result = GNUNET_SYSERR; | ||
86 | GNUNET_TESTBED_test_run ("test_testbed_api_test", "test_testbed_api.conf", | ||
87 | NUM_PEERS, &test_master, NULL); | ||
88 | if (GNUNET_OK != result) | ||
89 | return 1; | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | /* end of test_testbed_api_test.c */ | ||