9#include <cgreen/cgreen.h>
10#include <cgreen/mocks.h>
22Ensure (hosts, gvm_hosts_new_never_returns_null)
29Ensure (hosts, gvm_get_host_type_returns_host_type_ipv4)
39Ensure (hosts, gvm_get_host_type_returns_host_type_ipv6)
46#define TEN "0123456789"
47#define SIXTY TEN TEN TEN TEN TEN TEN
48#define HUNDRED TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
50Ensure (hosts, gvm_get_host_type_returns_host_type_hostname)
70Ensure (hosts, gvm_get_host_type_returns_host_type_cidr_block)
84Ensure (hosts, gvm_get_host_type_returns_host_type_cidr6_block)
94Ensure (hosts, gvm_get_host_type_returns_host_type_range_short)
116Ensure (hosts, gvm_get_host_type_returns_host_type_range6_short)
124Ensure (hosts, gvm_get_host_type_returns_host_type_range_long)
146Ensure (hosts, gvm_get_host_type_returns_host_type_range6_long)
155Ensure (hosts, gvm_get_host_type_returns_error)
184Ensure (hosts, gvm_hosts_new_with_max_returns_success)
192Ensure (hosts, gvm_hosts_new_with_max_returns_error)
205Ensure (hosts, gvm_hosts_move_host_to_end)
218 assert_that (totalhosts, is_equal_to (14));
229 assert_that (hosts->
current, is_equal_to (current - 1));
246 GSList *removed = NULL;
248 hosts =
gvm_hosts_new (
"192.168.0.1,192.168.0.2,192.168.0.3");
252 assert_that (totalhosts, is_equal_to (3));
256 assert_that (totalhosts, is_equal_to (2));
257 assert_that (g_slist_length (removed), is_equal_to (1));
258 g_slist_free_full (removed, g_free);
262 assert_that (totalhosts, is_equal_to (1));
263 assert_that (g_slist_length (removed), is_equal_to (1));
264 g_slist_free_full (removed, g_free);
280 suite = create_test_suite ();
282 add_test_with_context (suite, hosts, gvm_hosts_new_never_returns_null);
283 add_test_with_context (suite, hosts,
284 gvm_get_host_type_returns_host_type_ipv4);
285 add_test_with_context (suite, hosts,
286 gvm_get_host_type_returns_host_type_ipv6);
287 add_test_with_context (suite, hosts,
288 gvm_get_host_type_returns_host_type_hostname);
289 add_test_with_context (suite, hosts,
290 gvm_get_host_type_returns_host_type_cidr_block);
291 add_test_with_context (suite, hosts,
292 gvm_get_host_type_returns_host_type_cidr6_block);
293 add_test_with_context (suite, hosts,
294 gvm_get_host_type_returns_host_type_range_short);
295 add_test_with_context (suite, hosts,
296 gvm_get_host_type_returns_host_type_range6_short);
297 add_test_with_context (suite, hosts,
298 gvm_get_host_type_returns_host_type_range_long);
299 add_test_with_context (suite, hosts,
300 gvm_get_host_type_returns_host_type_range6_long);
301 add_test_with_context (suite, hosts, gvm_get_host_type_returns_error);
303 add_test_with_context (suite, hosts, gvm_hosts_new_with_max_returns_error);
304 add_test_with_context (suite, hosts, gvm_hosts_new_with_max_returns_success);
306 add_test_with_context (suite, hosts, gvm_hosts_move_host_to_end);
310 return run_single_test (suite, argv[1], create_text_reporter ());
312 return run_test_suite (suite, create_text_reporter ());
Implementation of an API to handle Hosts objects.
gchar * gvm_host_value_str(const gvm_host_t *host)
Gets a host's value in printable format.
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.
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...
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.
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.
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.
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
unsigned int gvm_hosts_count(const gvm_hosts_t *hosts)
Gets the count of single hosts objects in a hosts collection.
void gvm_hosts_free(gvm_hosts_t *hosts)
Frees memory occupied by an gvm_hosts_t structure.
Ensure(hosts, gvm_hosts_new_never_returns_null)
int main(int argc, char **argv)
GVM Networking related API.
The structure for a single host object.
The structure for Hosts collection.