static void run_all (gboolean run) { if (run) { test_strip_string (); test_is_static (); test_has_ip6_address (); test_has_default_route (); test_getdata (); test_read_hostname (); test_write_hostname (); test_is_ip4_address (); test_is_ip6_address (); test_convert_ipv4_config_block (); test_convert_ipv4_routes_block (); test_is_unmanaged (); test_wpa_parser (); test_convert_ipv4_routes_block (); test_new_connection (); test_update_connection (); test_add_connection (); test_delete_connection (); test_missing_config (); } }
static void do_poll_test(void) { struct pollfd* fds; int fds_cnt; // prepare fds fds_cnt = 1 + test_client_count(); fds = (struct pollfd*)malloc(sizeof(struct pollfd) * fds_cnt); memset(fds, 0, sizeof(struct pollfd) * fds_cnt); // add listener fds[0].fd = _sock_server; fds[0].events = POLLIN; // add others test_client_fillfds(&fds[1]); // call poll if (tuvp_net_poll(fds, fds_cnt) > 0) { if (fds[0].revents & POLLIN) { // server has new connection test_new_connection(_sock_server); } else { int i; for (i=1; i<fds_cnt; i++) { if (fds[i].revents & POLLHUP) { // client hang-up tuvp_close(fds[i].fd); test_client_sub(fds[i].fd); } else if (fds[i].revents & POLLIN) { // client has sent something test_handle_read(fds[i].fd); } } } } free(fds); }