summaryrefslogtreecommitdiff
path: root/src/tests/ecore_con
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:49:16 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:49:16 -0200
commite2c0b7741b7545408f4f10dcfebc36aab65f4276 (patch)
treef2c54ff8f6616840d5a89f5a96aa783e50b6b676 /src/tests/ecore_con
parentdd5cdda64b5fd3966718af62d417117942e2f323 (diff)
tests/ecore_con: skip ipv6 tests if that's disabled on the running system.
Diffstat (limited to 'src/tests/ecore_con')
-rw-r--r--src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c b/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c
index 9eda9dd..7f15c1f 100644
--- a/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c
+++ b/src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c
@@ -30,6 +30,7 @@
30#include <ctype.h> 30#include <ctype.h>
31 31
32#include "ecore_con_suite.h" 32#include "ecore_con_suite.h"
33#include "ecore_con_private.h"
33 34
34struct log_ctx { 35struct log_ctx {
35 const char *dom; 36 const char *dom;
@@ -720,6 +721,34 @@ END_TEST
720 721
721/* IPv6 *****************************************************************/ 722/* IPv6 *****************************************************************/
722 723
724static Eina_Bool
725_ipv6_enabled(void)
726{
727 SOCKET fd;
728 struct sockaddr_in6 addr = {
729 .sin6_family = AF_INET6,
730 };
731 int r;
732
733 fd = socket(AF_INET6, SOCK_STREAM, 0);
734 if (fd == INVALID_SOCKET)
735 {
736 Eina_Error err = efl_net_socket_error_get();
737 fprintf(stderr, "WARNING: failed socket(AF_INET6, SOCK_STREAM, 0): %s\n", eina_error_msg_get(err));
738 return EINA_FALSE;
739 }
740
741 r = bind(fd, &addr, sizeof(addr));
742 if (r != 0)
743 {
744 Eina_Error err = efl_net_socket_error_get();
745 fprintf(stderr, "WARNING: failed bind(" SOCKET_FMT ", {.sin6_family=AF_INET6, .sin6_addr={0}, .sin6_port=0}, sizeof(struct sockaddr_in6)): %s\n", fd, eina_error_msg_get(err));
746 }
747
748 closesocket(fd);
749 return r == 0;
750}
751
723static void 752static void
724_ipv6_check(Eo *o, const struct sockaddr_in6 *addr) 753_ipv6_check(Eo *o, const struct sockaddr_in6 *addr)
725{ 754{
@@ -1268,6 +1297,13 @@ void ecore_con_test_efl_net_ip_address(TCase *tc)
1268 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_resolve_ok); 1297 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_resolve_ok);
1269 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_resolve_fail); 1298 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_resolve_fail);
1270 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_checks); 1299 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv4_checks);
1300
1301 if (!_ipv6_enabled())
1302 {
1303 fputs("\nWARNING: your system has IPv6 disabled. Skipping IPv6 tests!\n\n", stderr);
1304 return;
1305 }
1306
1271 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_manual_ok); 1307 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_manual_ok);
1272 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_manual_fail); 1308 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_manual_fail);
1273 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_create_ok); 1309 tcase_add_test(tc, ecore_test_efl_net_ip_address_ipv6_create_ok);