Greenbone Vulnerability Management Libraries 22.32.0
hosts_tests.c File Reference
#include "hosts.c"
#include "networking.h"
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
Include dependency graph for hosts_tests.c:

Go to the source code of this file.

Macros

#define TEN   "0123456789"
#define SIXTY   TEN TEN TEN TEN TEN TEN
#define HUNDRED   TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define ASSERT_HOST_EQUALS(hosts, i, string)

Functions

 Describe (hosts)
 BeforeEach (hosts)
 AfterEach (hosts)
 Ensure (hosts, gvm_hosts_new_never_returns_null)
 Ensure (hosts, gvm_get_host_type_returns_host_type_ipv4)
 Ensure (hosts, gvm_get_host_type_returns_host_type_ipv6)
 Ensure (hosts, gvm_get_host_type_returns_host_type_hostname)
 Ensure (hosts, gvm_get_host_type_returns_host_type_cidr_block)
 Ensure (hosts, gvm_get_host_type_returns_host_type_cidr6_block)
 Ensure (hosts, gvm_get_host_type_returns_host_type_range_short)
 Ensure (hosts, gvm_get_host_type_returns_host_type_range6_short)
 Ensure (hosts, gvm_get_host_type_returns_host_type_range_long)
 Ensure (hosts, gvm_get_host_type_returns_host_type_range6_long)
 Ensure (hosts, gvm_get_host_type_returns_error)
 Ensure (hosts, gvm_hosts_new_with_max_returns_success)
 Ensure (hosts, gvm_hosts_new_with_max_returns_error)
static int host_value_eq (gvm_host_t *host, gchar *string)
 Ensure (hosts, gvm_hosts_move_host_to_end)
 Ensure (hosts, gvm_hosts_allowed_only)
int main (int argc, char **argv)

Macro Definition Documentation

◆ ASSERT_HOST_EQUALS

#define ASSERT_HOST_EQUALS ( hosts,
i,
string )
Value:
{ \
gchar *value; \
\
value = gvm_host_value_str (hosts->hosts[i]); \
assert_true_with_message ( \
g_strcmp0 (value, string) == 0, \
"Expected hosts->hosts[%d] to be %s but it was %s", i, string, value); \
g_free (value); \
}
gchar * gvm_host_value_str(const gvm_host_t *host)
Gets a host's value in printable format.
Definition hosts.c:2290

Definition at line 229 of file hosts_tests.c.

229#define ASSERT_HOST_EQUALS(hosts, i, string) \
230 { \
231 gchar *value; \
232 \
233 value = gvm_host_value_str (hosts->hosts[i]); \
234 assert_true_with_message ( \
235 g_strcmp0 (value, string) == 0, \
236 "Expected hosts->hosts[%d] to be %s but it was %s", i, string, value); \
237 g_free (value); \
238 }

Referenced by Ensure().

◆ HUNDRED

#define HUNDRED   TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN

Definition at line 58 of file hosts_tests.c.

◆ SIXTY

#define SIXTY   TEN TEN TEN TEN TEN TEN

Definition at line 57 of file hosts_tests.c.

Referenced by Ensure(), and Ensure().

◆ TEN

#define TEN   "0123456789"

Definition at line 56 of file hosts_tests.c.

Function Documentation

◆ AfterEach()

AfterEach ( hosts )

Definition at line 16 of file hosts_tests.c.

17{
18}

◆ BeforeEach()

BeforeEach ( hosts )

Definition at line 13 of file hosts_tests.c.

14{
15}

◆ Describe()

Describe ( hosts )

◆ Ensure() [1/15]

Ensure ( hosts ,
gvm_get_host_type_returns_error  )

Definition at line 165 of file hosts_tests.c.

166{
167 assert_that (gvm_get_host_type (""), is_equal_to (-1));
168 assert_that (gvm_get_host_type ("."), is_equal_to (-1));
169
170 /* Invalid chars. */
171 assert_that (gvm_get_host_type ("a,b"), is_equal_to (-1));
172 assert_that (gvm_get_host_type ("="), is_equal_to (-1));
173
174 /* Numeric TLD. */
175 assert_that (gvm_get_host_type ("a.123"), is_equal_to (-1));
176
177 /* IP with too many parts. */
178 assert_that (gvm_get_host_type ("192.168.10.1.1"), is_equal_to (-1));
179
180 /* IP with numbers out of bounds. */
181 assert_that (gvm_get_host_type ("256.168.10.1"), is_equal_to (-1));
182 assert_that (gvm_get_host_type ("192.256.10.1"), is_equal_to (-1));
183 assert_that (gvm_get_host_type ("192.168.256.1"), is_equal_to (-1));
184 assert_that (gvm_get_host_type ("192.168.10.256"), is_equal_to (-1));
185 assert_that (gvm_get_host_type ("192.168.10.855"), is_equal_to (-1));
186
187 /* Lengths. */
188 assert_that (gvm_get_host_type (SIXTY "1234.too.long.com"), is_equal_to (-1));
189 assert_that (gvm_get_host_type (SIXTY "." SIXTY "." SIXTY "." SIXTY "."
190 "567890.com"),
191 is_equal_to (-1));
192}
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
Definition hosts.c:813
#define SIXTY
Definition hosts_tests.c:57

References gvm_get_host_type(), and SIXTY.

Here is the call graph for this function:

◆ Ensure() [2/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_cidr6_block  )

Definition at line 94 of file hosts_tests.c.

95{
96 assert_that (gvm_get_host_type ("::ffee:1/64"),
97 is_equal_to (HOST_TYPE_CIDR6_BLOCK));
98 assert_that (gvm_get_host_type ("2001:db8::/78"),
99 is_equal_to (HOST_TYPE_CIDR6_BLOCK));
100 assert_that (gvm_get_host_type ("2001:db8:0000:0000:001f:ffff:ffff:1/1"),
101 is_equal_to (HOST_TYPE_CIDR6_BLOCK));
102}
@ HOST_TYPE_CIDR6_BLOCK
Definition hosts.h:41

References gvm_get_host_type(), and HOST_TYPE_CIDR6_BLOCK.

Here is the call graph for this function:

◆ Ensure() [3/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_cidr_block  )

Definition at line 80 of file hosts_tests.c.

81{
82 assert_that (gvm_get_host_type ("192.168.0.0/24"),
83 is_equal_to (HOST_TYPE_CIDR_BLOCK));
84 assert_that (gvm_get_host_type ("1.1.1.1/8"),
85 is_equal_to (HOST_TYPE_CIDR_BLOCK));
86 assert_that (gvm_get_host_type ("192.168.1.128/25"),
87 is_equal_to (HOST_TYPE_CIDR_BLOCK));
88 assert_that (gvm_get_host_type ("10.0.0.1/16"),
89 is_equal_to (HOST_TYPE_CIDR_BLOCK));
90 assert_that (gvm_get_host_type ("10.1.1.0/30"),
91 is_equal_to (HOST_TYPE_CIDR_BLOCK));
92}
@ HOST_TYPE_CIDR_BLOCK
Definition hosts.h:37

References gvm_get_host_type(), and HOST_TYPE_CIDR_BLOCK.

Here is the call graph for this function:

◆ Ensure() [4/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_hostname  )

Definition at line 60 of file hosts_tests.c.

61{
62 assert_that (gvm_get_host_type ("www.greenbone.net"),
63 is_equal_to (HOST_TYPE_NAME));
64 assert_that (gvm_get_host_type ("www.example_underscore.net"),
65 is_equal_to (HOST_TYPE_NAME));
66 assert_that (gvm_get_host_type ("www.example-dash.net"),
67 is_equal_to (HOST_TYPE_NAME));
68 assert_that (gvm_get_host_type ("greenbone.net"),
69 is_equal_to (HOST_TYPE_NAME));
70 assert_that (gvm_get_host_type ("g"), is_equal_to (HOST_TYPE_NAME));
71 assert_that (gvm_get_host_type ("123.com"), is_equal_to (HOST_TYPE_NAME));
72 /* Lengths. */
73 assert_that (gvm_get_host_type (SIXTY "123.short.enough.com"),
74 is_equal_to (0));
75 assert_that (gvm_get_host_type (SIXTY "." SIXTY "." SIXTY "." SIXTY "."
76 "56789.com"),
77 is_equal_to (0));
78}
@ HOST_TYPE_NAME
Definition hosts.h:35

References gvm_get_host_type(), HOST_TYPE_NAME, and SIXTY.

Here is the call graph for this function:

◆ Ensure() [5/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_ipv4  )

Definition at line 39 of file hosts_tests.c.

40{
41 assert_that (gvm_get_host_type ("192.168.0.4"), is_equal_to (HOST_TYPE_IPV4));
42 assert_that (gvm_get_host_type ("1.1.1.1"), is_equal_to (HOST_TYPE_IPV4));
43 assert_that (gvm_get_host_type ("0.0.0.0"), is_equal_to (HOST_TYPE_IPV4));
44 assert_that (gvm_get_host_type ("255.255.255.255"),
45 is_equal_to (HOST_TYPE_IPV4));
46 assert_that (gvm_get_host_type ("10.1.1.1"), is_equal_to (HOST_TYPE_IPV4));
47}
@ HOST_TYPE_IPV4
Definition hosts.h:36

References gvm_get_host_type(), and HOST_TYPE_IPV4.

Here is the call graph for this function:

◆ Ensure() [6/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_ipv6  )

Definition at line 49 of file hosts_tests.c.

50{
51 assert_that (gvm_get_host_type ("::ffee"), is_equal_to (HOST_TYPE_IPV6));
52 assert_that (gvm_get_host_type ("0001:1:1:1::1"),
53 is_equal_to (HOST_TYPE_IPV6));
54}
@ HOST_TYPE_IPV6
Definition hosts.h:40

References gvm_get_host_type(), and HOST_TYPE_IPV6.

Here is the call graph for this function:

◆ Ensure() [7/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_range6_long  )

Definition at line 156 of file hosts_tests.c.

157{
158 assert_that (
159 gvm_get_host_type ("2001:db0::-2001:0dbf:ffff:ffff:ffff:ffff:ffff:ffff"),
160 is_equal_to (HOST_TYPE_RANGE6_LONG));
161 assert_that (gvm_get_host_type ("::1:200:7-::1:205:500"),
162 is_equal_to (HOST_TYPE_RANGE6_LONG));
163}
@ HOST_TYPE_RANGE6_LONG
Definition hosts.h:42

References gvm_get_host_type(), and HOST_TYPE_RANGE6_LONG.

Here is the call graph for this function:

◆ Ensure() [8/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_range6_short  )

Definition at line 126 of file hosts_tests.c.

127{
128 assert_that (gvm_get_host_type ("::ffee:1-fe50"),
129 is_equal_to (HOST_TYPE_RANGE6_SHORT));
130 assert_that (gvm_get_host_type ("2000::-ffff"),
131 is_equal_to (HOST_TYPE_RANGE6_SHORT));
132}
@ HOST_TYPE_RANGE6_SHORT
Definition hosts.h:43

References gvm_get_host_type(), and HOST_TYPE_RANGE6_SHORT.

Here is the call graph for this function:

◆ Ensure() [9/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_range_long  )

Definition at line 134 of file hosts_tests.c.

135{
136 assert_that (gvm_get_host_type ("192.168.10.1-192.168.10.9"),
137 is_equal_to (HOST_TYPE_RANGE_LONG));
138 assert_that (gvm_get_host_type ("192.168.10.1-192.168.10.50"),
139 is_equal_to (HOST_TYPE_RANGE_LONG));
140 assert_that (gvm_get_host_type ("192.168.10.1-192.168.10.255"),
141 is_equal_to (HOST_TYPE_RANGE_LONG));
142 assert_that (gvm_get_host_type ("1.1.1.1-1.1.1.9"),
143 is_equal_to (HOST_TYPE_RANGE_LONG));
144 assert_that (gvm_get_host_type ("1.1.1.1-1.1.1.50"),
145 is_equal_to (HOST_TYPE_RANGE_LONG));
146 assert_that (gvm_get_host_type ("1.1.1.1-1.1.1.255"),
147 is_equal_to (HOST_TYPE_RANGE_LONG));
148 assert_that (gvm_get_host_type ("255.255.255.1-255.255.255.9"),
149 is_equal_to (HOST_TYPE_RANGE_LONG));
150 assert_that (gvm_get_host_type ("255.255.255.1-255.255.255.50"),
151 is_equal_to (HOST_TYPE_RANGE_LONG));
152 assert_that (gvm_get_host_type ("255.255.255.1-255.255.255.255"),
153 is_equal_to (HOST_TYPE_RANGE_LONG));
154}
@ HOST_TYPE_RANGE_LONG
Definition hosts.h:39

References gvm_get_host_type(), and HOST_TYPE_RANGE_LONG.

Here is the call graph for this function:

◆ Ensure() [10/15]

Ensure ( hosts ,
gvm_get_host_type_returns_host_type_range_short  )

Definition at line 104 of file hosts_tests.c.

105{
106 assert_that (gvm_get_host_type ("192.168.10.1-9"),
107 is_equal_to (HOST_TYPE_RANGE_SHORT));
108 assert_that (gvm_get_host_type ("192.168.10.1-50"),
109 is_equal_to (HOST_TYPE_RANGE_SHORT));
110 assert_that (gvm_get_host_type ("192.168.10.1-255"),
111 is_equal_to (HOST_TYPE_RANGE_SHORT));
112 assert_that (gvm_get_host_type ("1.1.1.1-9"),
113 is_equal_to (HOST_TYPE_RANGE_SHORT));
114 assert_that (gvm_get_host_type ("1.1.1.1-50"),
115 is_equal_to (HOST_TYPE_RANGE_SHORT));
116 assert_that (gvm_get_host_type ("1.1.1.1-255"),
117 is_equal_to (HOST_TYPE_RANGE_SHORT));
118 assert_that (gvm_get_host_type ("255.255.255.1-9"),
119 is_equal_to (HOST_TYPE_RANGE_SHORT));
120 assert_that (gvm_get_host_type ("255.255.255.1-50"),
121 is_equal_to (HOST_TYPE_RANGE_SHORT));
122 assert_that (gvm_get_host_type ("255.255.255.1-255"),
123 is_equal_to (HOST_TYPE_RANGE_SHORT));
124}
@ HOST_TYPE_RANGE_SHORT
Definition hosts.h:38

References gvm_get_host_type(), and HOST_TYPE_RANGE_SHORT.

Here is the call graph for this function:

◆ Ensure() [11/15]

Ensure ( hosts ,
gvm_hosts_allowed_only  )

Definition at line 315 of file hosts_tests.c.

316{
317 gvm_hosts_t *hosts = NULL;
318 gvm_host_t *host = NULL;
319 int totalhosts;
320 GSList *removed = NULL;
321 gchar *value;
322
323 hosts = gvm_hosts_new ("192.168.0.1,192.168.0.2,192.168.0.3");
324
325 removed = gvm_hosts_allowed_only (hosts, NULL, NULL);
326 totalhosts = gvm_hosts_count (hosts);
327 assert_that (totalhosts, is_equal_to (3));
328
329 removed = gvm_hosts_allowed_only (hosts, "192.168.0.2", NULL);
330 totalhosts = gvm_hosts_count (hosts);
331 assert_that (totalhosts, is_equal_to (2));
332 assert_that (g_slist_length (removed), is_equal_to (1));
333 g_slist_free_full (removed, g_free);
334
335 removed = gvm_hosts_allowed_only (hosts, NULL, "192.168.0.3");
336 totalhosts = gvm_hosts_count (hosts);
337 assert_that (totalhosts, is_equal_to (1));
338 assert_that (g_slist_length (removed), is_equal_to (1));
339 g_slist_free_full (removed, g_free);
340
341 host = gvm_hosts_next (hosts);
342 value = gvm_host_value_str (host);
343 assert_that (g_strcmp0 (value, "192.168.0.3"), is_equal_to (0));
344 g_free (value);
345
346 gvm_hosts_free (hosts);
347}
gvm_hosts_t * gvm_hosts_new(const gchar *hosts_str)
Creates a new gvm_hosts_t structure and the associated hosts objects from the provided hosts_str.
Definition hosts.c:1300
gvm_host_t * gvm_hosts_next(gvm_hosts_t *hosts)
Gets the next gvm_host_t from a gvm_hosts_t structure. The state of iteration is kept internally with...
Definition hosts.c:1314
GSList * gvm_hosts_allowed_only(gvm_hosts_t *hosts, const char *deny_hosts_str, const char *allow_hosts_str)
Returns a list of hosts after a host authorization check.
Definition hosts.c:1658
unsigned int gvm_hosts_count(const gvm_hosts_t *hosts)
Gets the count of single hosts objects in a hosts collection.
Definition hosts.c:2106
void gvm_hosts_free(gvm_hosts_t *hosts)
Frees memory occupied by an gvm_hosts_t structure.
Definition hosts.c:1375
struct gvm_host gvm_host_t
Definition hosts.h:48
struct gvm_hosts gvm_hosts_t
Definition hosts.h:50

References gvm_host_value_str(), gvm_hosts_allowed_only(), gvm_hosts_count(), gvm_hosts_free(), gvm_hosts_new(), and gvm_hosts_next().

Here is the call graph for this function:

◆ Ensure() [12/15]

Ensure ( hosts ,
gvm_hosts_move_host_to_end  )

Definition at line 252 of file hosts_tests.c.

253{
254 gvm_hosts_t *hosts = NULL;
255 gvm_host_t *host = NULL;
256 int totalhosts;
257 size_t current;
258
259 hosts = gvm_hosts_new ("192.168.0.0/28");
260
261 ASSERT_HOST_EQUALS (hosts, 0, "192.168.0.1");
262 ASSERT_HOST_EQUALS (hosts, 1, "192.168.0.2");
263 ASSERT_HOST_EQUALS (hosts, 2, "192.168.0.3");
264 ASSERT_HOST_EQUALS (hosts, 3, "192.168.0.4");
265 ASSERT_HOST_EQUALS (hosts, 4, "192.168.0.5");
266 ASSERT_HOST_EQUALS (hosts, 5, "192.168.0.6");
267 ASSERT_HOST_EQUALS (hosts, 6, "192.168.0.7");
268 ASSERT_HOST_EQUALS (hosts, 7, "192.168.0.8");
269 ASSERT_HOST_EQUALS (hosts, 8, "192.168.0.9");
270 ASSERT_HOST_EQUALS (hosts, 9, "192.168.0.10");
271 ASSERT_HOST_EQUALS (hosts, 10, "192.168.0.11");
272 ASSERT_HOST_EQUALS (hosts, 11, "192.168.0.12");
273 ASSERT_HOST_EQUALS (hosts, 12, "192.168.0.13");
274 ASSERT_HOST_EQUALS (hosts, 13, "192.168.0.14");
275
276 // Get first host
277 host = gvm_hosts_next (hosts);
278
279 totalhosts = gvm_hosts_count (hosts);
280 assert_that (totalhosts, is_equal_to (14));
281
282 while (host_value_eq (host, "192.168.0.9"))
283 {
284 host = gvm_hosts_next (hosts);
285 }
286 assert_that (host_value_eq (host, "192.168.0.9"), is_equal_to (0));
287
288 current = hosts->current;
290 assert_that (hosts->current, is_equal_to (current - 1));
291
292 host = gvm_hosts_next (hosts);
293 assert_that (host_value_eq (host, "192.168.0.10"), is_equal_to (0));
294 assert_that (host_value_eq (hosts->hosts[totalhosts - 1], "192.168.0.9"),
295 is_equal_to (0));
296
297 ASSERT_HOST_EQUALS (hosts, 0, "192.168.0.1");
298 ASSERT_HOST_EQUALS (hosts, 1, "192.168.0.2");
299 ASSERT_HOST_EQUALS (hosts, 2, "192.168.0.3");
300 ASSERT_HOST_EQUALS (hosts, 3, "192.168.0.4");
301 ASSERT_HOST_EQUALS (hosts, 4, "192.168.0.5");
302 ASSERT_HOST_EQUALS (hosts, 5, "192.168.0.6");
303 ASSERT_HOST_EQUALS (hosts, 6, "192.168.0.7");
304 ASSERT_HOST_EQUALS (hosts, 7, "192.168.0.8");
305 ASSERT_HOST_EQUALS (hosts, 8, "192.168.0.10");
306 ASSERT_HOST_EQUALS (hosts, 9, "192.168.0.11");
307 ASSERT_HOST_EQUALS (hosts, 10, "192.168.0.12");
308 ASSERT_HOST_EQUALS (hosts, 11, "192.168.0.13");
309 ASSERT_HOST_EQUALS (hosts, 12, "192.168.0.14");
310 ASSERT_HOST_EQUALS (hosts, 13, "192.168.0.9");
311
312 gvm_hosts_free (hosts);
313}
void gvm_hosts_move_current_host_to_end(gvm_hosts_t *hosts)
Move the current gvm_host_t from a gvm_hosts_t structure to the end of the hosts list.
Definition hosts.c:1332
#define ASSERT_HOST_EQUALS(hosts, i, string)
static int host_value_eq(gvm_host_t *host, gchar *string)
size_t current
Definition hosts.h:92
gvm_host_t ** hosts
Definition hosts.h:90

References ASSERT_HOST_EQUALS, gvm_hosts::current, gvm_hosts_count(), gvm_hosts_free(), gvm_hosts_move_current_host_to_end(), gvm_hosts_new(), gvm_hosts_next(), host_value_eq(), and gvm_hosts::hosts.

Here is the call graph for this function:

◆ Ensure() [13/15]

Ensure ( hosts ,
gvm_hosts_new_never_returns_null  )

Definition at line 22 of file hosts_tests.c.

23{
24 gvm_hosts_t *hosts;
25
26 hosts = gvm_hosts_new ("");
27 assert_that (hosts, is_not_null);
28 gvm_hosts_free (hosts);
29
30 hosts = gvm_hosts_new ("172.10.1.1");
31 assert_that (hosts, is_not_null);
32 gvm_hosts_free (hosts);
33
34 hosts = gvm_hosts_new ("172.10.1.1/24");
35 assert_that (hosts, is_not_null);
36 gvm_hosts_free (hosts);
37}

References gvm_hosts_free(), and gvm_hosts_new().

Here is the call graph for this function:

◆ Ensure() [14/15]

Ensure ( hosts ,
gvm_hosts_new_with_max_returns_error  )

Definition at line 215 of file hosts_tests.c.

216{
217 /* Host error. */
218 assert_that (gvm_hosts_new_with_max ("a.123", 2), is_null);
219
220 /* More than max_hosts hosts. */
221 assert_that (gvm_hosts_new_with_max ("127.0.0.1, 127.0.0.2", 1), is_null);
222
223 /* Wrong separator. */
224 assert_that (gvm_hosts_new_with_max ("127.0.0.1 127.0.0.2", 2), is_null);
225 assert_that (gvm_hosts_new_with_max ("127.0.0.1|127.0.0.2", 2), is_null);
226}
gvm_hosts_t * gvm_hosts_new_with_max(const gchar *hosts_str, unsigned int max_hosts)
Creates a new gvm_hosts_t structure and the associated hosts objects from the provided hosts_str.
Definition hosts.c:1103

References gvm_hosts_new_with_max().

Here is the call graph for this function:

◆ Ensure() [15/15]

Ensure ( hosts ,
gvm_hosts_new_with_max_returns_success  )

Definition at line 194 of file hosts_tests.c.

195{
196 gvm_hosts_t *hosts;
197
198 hosts = gvm_hosts_new_with_max ("127.0.0.1", 1);
199 assert_that (hosts, is_not_null);
200 gvm_hosts_free (hosts);
201
202 hosts = gvm_hosts_new_with_max ("127.0.0.1", 2000);
203 assert_that (hosts, is_not_null);
204 gvm_hosts_free (hosts);
205
206 hosts = gvm_hosts_new_with_max ("127.0.0.1,127.0.0.2", 2);
207 assert_that (hosts, is_not_null);
208 gvm_hosts_free (hosts);
209
210 hosts = gvm_hosts_new_with_max ("127.0.0.1, 127.0.0.2", 2);
211 assert_that (hosts, is_not_null);
212 gvm_hosts_free (hosts);
213}

References gvm_hosts_free(), and gvm_hosts_new_with_max().

Here is the call graph for this function:

◆ host_value_eq()

int host_value_eq ( gvm_host_t * host,
gchar * string )
static

Definition at line 241 of file hosts_tests.c.

242{
243 int ret;
244 gchar *value;
245
246 value = gvm_host_value_str (host);
247 ret = g_strcmp0 (value, string);
248 g_free (value);
249 return ret;
250}

References gvm_host_value_str().

Referenced by Ensure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 352 of file hosts_tests.c.

353{
354 int ret;
355 TestSuite *suite;
356
357 suite = create_test_suite ();
358
359 add_test_with_context (suite, hosts, gvm_hosts_new_never_returns_null);
360 add_test_with_context (suite, hosts,
361 gvm_get_host_type_returns_host_type_ipv4);
362 add_test_with_context (suite, hosts,
363 gvm_get_host_type_returns_host_type_ipv6);
364 add_test_with_context (suite, hosts,
365 gvm_get_host_type_returns_host_type_hostname);
366 add_test_with_context (suite, hosts,
367 gvm_get_host_type_returns_host_type_cidr_block);
368 add_test_with_context (suite, hosts,
369 gvm_get_host_type_returns_host_type_cidr6_block);
370 add_test_with_context (suite, hosts,
371 gvm_get_host_type_returns_host_type_range_short);
372 add_test_with_context (suite, hosts,
373 gvm_get_host_type_returns_host_type_range6_short);
374 add_test_with_context (suite, hosts,
375 gvm_get_host_type_returns_host_type_range_long);
376 add_test_with_context (suite, hosts,
377 gvm_get_host_type_returns_host_type_range6_long);
378 add_test_with_context (suite, hosts, gvm_get_host_type_returns_error);
379
380 add_test_with_context (suite, hosts, gvm_hosts_new_with_max_returns_error);
381 add_test_with_context (suite, hosts, gvm_hosts_new_with_max_returns_success);
382
383 add_test_with_context (suite, hosts, gvm_hosts_move_host_to_end);
384 add_test_with_context (suite, hosts, gvm_hosts_allowed_only);
385
386 if (argc > 1)
387 ret = run_single_test (suite, argv[1], create_text_reporter ());
388 else
389 ret = run_test_suite (suite, create_text_reporter ());
390
391 destroy_test_suite (suite);
392
393 return ret;
394}

References gvm_hosts_allowed_only().

Here is the call graph for this function: