diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-10-05 15:09:28 +0200 |
commit | c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch) | |
tree | cac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/testbed/test_testbed_api_hosts.c | |
parent | fbb71d527c7d6babf269a8fefce1db291b9f7068 (diff) | |
download | gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip |
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/testbed/test_testbed_api_hosts.c')
-rw-r--r-- | src/testbed/test_testbed_api_hosts.c | 147 |
1 files changed, 74 insertions, 73 deletions
diff --git a/src/testbed/test_testbed_api_hosts.c b/src/testbed/test_testbed_api_hosts.c index f9656d17f..9c2a96fb7 100644 --- a/src/testbed/test_testbed_api_hosts.c +++ b/src/testbed/test_testbed_api_hosts.c | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | #define TIME_REL_SECS(sec) \ | 33 | #define TIME_REL_SECS(sec) \ |
34 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, sec) | 34 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * configuration handle to use as template configuration while creating hosts | 37 | * configuration handle to use as template configuration while creating hosts |
@@ -65,20 +65,20 @@ static int status; | |||
65 | * @param cls NULL | 65 | * @param cls NULL |
66 | */ | 66 | */ |
67 | static void | 67 | static void |
68 | do_shutdown(void *cls) | 68 | do_shutdown (void *cls) |
69 | { | 69 | { |
70 | GNUNET_TESTBED_host_destroy(host); | 70 | GNUNET_TESTBED_host_destroy (host); |
71 | while (0 != num_hosts) | 71 | while (0 != num_hosts) |
72 | { | 72 | { |
73 | GNUNET_TESTBED_host_destroy(hosts[num_hosts - 1]); | 73 | GNUNET_TESTBED_host_destroy (hosts[num_hosts - 1]); |
74 | num_hosts--; | 74 | num_hosts--; |
75 | } | 75 | } |
76 | GNUNET_free(hosts); | 76 | GNUNET_free (hosts); |
77 | if (NULL != cfg) | 77 | if (NULL != cfg) |
78 | { | 78 | { |
79 | GNUNET_CONFIGURATION_destroy(cfg); | 79 | GNUNET_CONFIGURATION_destroy (cfg); |
80 | cfg = NULL; | 80 | cfg = NULL; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
@@ -91,76 +91,77 @@ do_shutdown(void *cls) | |||
91 | * @param cfg the configuration file handle | 91 | * @param cfg the configuration file handle |
92 | */ | 92 | */ |
93 | static void | 93 | static void |
94 | run(void *cls, char *const *args, const char *cfgfile, | 94 | run (void *cls, char *const *args, const char *cfgfile, |
95 | const struct GNUNET_CONFIGURATION_Handle *config) | 95 | const struct GNUNET_CONFIGURATION_Handle *config) |
96 | { | 96 | { |
97 | unsigned int cnt; | 97 | unsigned int cnt; |
98 | 98 | ||
99 | cfg = GNUNET_CONFIGURATION_dup(config); | 99 | cfg = GNUNET_CONFIGURATION_dup (config); |
100 | host = GNUNET_TESTBED_host_create("localhost", NULL, cfg, 0); | 100 | host = GNUNET_TESTBED_host_create ("localhost", NULL, cfg, 0); |
101 | GNUNET_assert(NULL != host); | 101 | GNUNET_assert (NULL != host); |
102 | GNUNET_assert(0 != GNUNET_TESTBED_host_get_id_(host)); | 102 | GNUNET_assert (0 != GNUNET_TESTBED_host_get_id_ (host)); |
103 | GNUNET_TESTBED_host_destroy(host); | 103 | GNUNET_TESTBED_host_destroy (host); |
104 | host = GNUNET_TESTBED_host_create(NULL, NULL, cfg, 0); | 104 | host = GNUNET_TESTBED_host_create (NULL, NULL, cfg, 0); |
105 | GNUNET_assert(NULL != host); | 105 | GNUNET_assert (NULL != host); |
106 | GNUNET_assert(0 == GNUNET_TESTBED_host_get_id_(host)); | 106 | GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); |
107 | GNUNET_assert(host == GNUNET_TESTBED_host_lookup_by_id_(0)); | 107 | GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); |
108 | hosts = NULL; | 108 | hosts = NULL; |
109 | num_hosts = GNUNET_TESTBED_hosts_load_from_file("sample_hosts.txt", cfg, &hosts); | 109 | num_hosts = GNUNET_TESTBED_hosts_load_from_file ("sample_hosts.txt", cfg, |
110 | GNUNET_assert(7 == num_hosts); | 110 | &hosts); |
111 | GNUNET_assert(NULL != hosts); | 111 | GNUNET_assert (7 == num_hosts); |
112 | GNUNET_assert (NULL != hosts); | ||
112 | for (cnt = 0; cnt < num_hosts; cnt++) | 113 | for (cnt = 0; cnt < num_hosts; cnt++) |
114 | { | ||
115 | if (cnt < 3) | ||
116 | { | ||
117 | GNUNET_assert (0 == strcmp ("totakura", | ||
118 | GNUNET_TESTBED_host_get_username_ | ||
119 | (hosts[cnt]))); | ||
120 | GNUNET_assert (NULL != GNUNET_TESTBED_host_get_hostname (hosts[cnt])); | ||
121 | GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); | ||
122 | } | ||
123 | if (3 == cnt) | ||
124 | { | ||
125 | GNUNET_assert (0 == strcmp ("totakura", | ||
126 | GNUNET_TESTBED_host_get_username_ | ||
127 | (hosts[cnt]))); | ||
128 | GNUNET_assert (NULL != GNUNET_TESTBED_host_get_hostname (hosts[cnt])); | ||
129 | GNUNET_assert (2022 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); | ||
130 | } | ||
131 | if (4 == cnt) | ||
132 | { | ||
133 | GNUNET_assert (0 == strcmp ("totakura", | ||
134 | GNUNET_TESTBED_host_get_username_ | ||
135 | (hosts[cnt]))); | ||
136 | GNUNET_assert (0 == strcmp ("asgard.realm", | ||
137 | GNUNET_TESTBED_host_get_hostname | ||
138 | (hosts[cnt]))); | ||
139 | GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); | ||
140 | } | ||
141 | if (5 == cnt) | ||
142 | { | ||
143 | GNUNET_assert (NULL == GNUNET_TESTBED_host_get_username_ (hosts[cnt])); | ||
144 | GNUNET_assert (0 == strcmp ("rivendal", | ||
145 | GNUNET_TESTBED_host_get_hostname | ||
146 | (hosts[cnt]))); | ||
147 | GNUNET_assert (22 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); | ||
148 | } | ||
149 | if (6 == cnt) | ||
113 | { | 150 | { |
114 | if (cnt < 3) | 151 | GNUNET_assert (NULL == GNUNET_TESTBED_host_get_username_ (hosts[cnt])); |
115 | { | 152 | GNUNET_assert (0 == strcmp ("rohan", |
116 | GNUNET_assert(0 == strcmp("totakura", | 153 | GNUNET_TESTBED_host_get_hostname |
117 | GNUNET_TESTBED_host_get_username_ | 154 | (hosts[cnt]))); |
118 | (hosts[cnt]))); | 155 | GNUNET_assert (561 == GNUNET_TESTBED_host_get_ssh_port_ (hosts[cnt])); |
119 | GNUNET_assert(NULL != GNUNET_TESTBED_host_get_hostname(hosts[cnt])); | ||
120 | GNUNET_assert(22 == GNUNET_TESTBED_host_get_ssh_port_(hosts[cnt])); | ||
121 | } | ||
122 | if (3 == cnt) | ||
123 | { | ||
124 | GNUNET_assert(0 == strcmp("totakura", | ||
125 | GNUNET_TESTBED_host_get_username_ | ||
126 | (hosts[cnt]))); | ||
127 | GNUNET_assert(NULL != GNUNET_TESTBED_host_get_hostname(hosts[cnt])); | ||
128 | GNUNET_assert(2022 == GNUNET_TESTBED_host_get_ssh_port_(hosts[cnt])); | ||
129 | } | ||
130 | if (4 == cnt) | ||
131 | { | ||
132 | GNUNET_assert(0 == strcmp("totakura", | ||
133 | GNUNET_TESTBED_host_get_username_ | ||
134 | (hosts[cnt]))); | ||
135 | GNUNET_assert(0 == strcmp("asgard.realm", | ||
136 | GNUNET_TESTBED_host_get_hostname | ||
137 | (hosts[cnt]))); | ||
138 | GNUNET_assert(22 == GNUNET_TESTBED_host_get_ssh_port_(hosts[cnt])); | ||
139 | } | ||
140 | if (5 == cnt) | ||
141 | { | ||
142 | GNUNET_assert(NULL == GNUNET_TESTBED_host_get_username_(hosts[cnt])); | ||
143 | GNUNET_assert(0 == strcmp("rivendal", | ||
144 | GNUNET_TESTBED_host_get_hostname | ||
145 | (hosts[cnt]))); | ||
146 | GNUNET_assert(22 == GNUNET_TESTBED_host_get_ssh_port_(hosts[cnt])); | ||
147 | } | ||
148 | if (6 == cnt) | ||
149 | { | ||
150 | GNUNET_assert(NULL == GNUNET_TESTBED_host_get_username_(hosts[cnt])); | ||
151 | GNUNET_assert(0 == strcmp("rohan", | ||
152 | GNUNET_TESTBED_host_get_hostname | ||
153 | (hosts[cnt]))); | ||
154 | GNUNET_assert(561 == GNUNET_TESTBED_host_get_ssh_port_(hosts[cnt])); | ||
155 | } | ||
156 | } | 156 | } |
157 | } | ||
157 | status = GNUNET_YES; | 158 | status = GNUNET_YES; |
158 | GNUNET_SCHEDULER_add_now(&do_shutdown, NULL); | 159 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
159 | } | 160 | } |
160 | 161 | ||
161 | 162 | ||
162 | int | 163 | int |
163 | main(int argc, char **argv) | 164 | main (int argc, char **argv) |
164 | { | 165 | { |
165 | char *const argv2[] = { "test_testbed_api_hosts", | 166 | char *const argv2[] = { "test_testbed_api_hosts", |
166 | "-c", "test_testbed_api.conf", | 167 | "-c", "test_testbed_api.conf", |
@@ -171,9 +172,9 @@ main(int argc, char **argv) | |||
171 | 172 | ||
172 | status = GNUNET_SYSERR; | 173 | status = GNUNET_SYSERR; |
173 | if (GNUNET_OK != | 174 | if (GNUNET_OK != |
174 | GNUNET_PROGRAM_run((sizeof(argv2) / sizeof(char *)) - 1, argv2, | 175 | GNUNET_PROGRAM_run ((sizeof(argv2) / sizeof(char *)) - 1, argv2, |
175 | "test_testbed_api_hosts", "nohelp", options, &run, | 176 | "test_testbed_api_hosts", "nohelp", options, &run, |
176 | NULL)) | 177 | NULL)) |
177 | return 1; | 178 | return 1; |
178 | return (GNUNET_OK == status) ? 0 : 1; | 179 | return (GNUNET_OK == status) ? 0 : 1; |
179 | } | 180 | } |