summaryrefslogtreecommitdiff
path: root/src/tests/ecore_con
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:27:34 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-12-19 15:30:56 -0200
commitdd5cdda64b5fd3966718af62d417117942e2f323 (patch)
tree28e5ff6f8b5f4fc76fcefce709790b4a91def65b /src/tests/ecore_con
parent25a9e1d886054d3907fb43e3682525b1a3901209 (diff)
more eo simplified to use Eina_Slice instead of pointer to.
Working directly with Eina_Slice is easier than a pointer to it, requires no validation of the pointers and is cheap since it's just putting together size_t + void*. However we can't hint the user of 'const(Eina.Slice)' properties as Eolian is incorrectly generating getters as: const Eina_Slice class_property_get(...) which is makes compilers complain about ignored qualifiers: ../src/lib/ecore/efl_io_copier.eo.h:329:7: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers] Leave some TODO so @q66 can fix those.
Diffstat (limited to 'src/tests/ecore_con')
-rw-r--r--src/tests/ecore_con/ecore_con_test_efl_net_ip_address.c56
1 files changed, 25 insertions, 31 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 cd2999c..9eda9dd 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
@@ -268,7 +268,7 @@ static void
268_ipv4_check(Eo *o, const struct sockaddr_in *addr) 268_ipv4_check(Eo *o, const struct sockaddr_in *addr)
269{ 269{
270 Eina_Slice slice = { .mem = &addr->sin_addr, .len = sizeof(addr->sin_addr) }; 270 Eina_Slice slice = { .mem = &addr->sin_addr, .len = sizeof(addr->sin_addr) };
271 const Eina_Slice *rs; 271 Eina_Slice rs;
272 char buf[INET_ADDRSTRLEN + sizeof(":65536")] = ""; 272 char buf[INET_ADDRSTRLEN + sizeof(":65536")] = "";
273 273
274 ck_assert_ptr_ne(o, NULL); 274 ck_assert_ptr_ne(o, NULL);
@@ -277,8 +277,7 @@ _ipv4_check(Eo *o, const struct sockaddr_in *addr)
277 ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin_port)); 277 ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin_port));
278 278
279 rs = efl_net_ip_address_get(o); 279 rs = efl_net_ip_address_get(o);
280 ck_assert_ptr_ne(rs, NULL); 280 ck_assert_int_eq(eina_slice_compare(rs, slice), 0);
281 ck_assert_int_eq(eina_slice_compare(*rs, slice), 0);
282 281
283 inet_ntop(AF_INET, slice.mem, buf, INET_ADDRSTRLEN); 282 inet_ntop(AF_INET, slice.mem, buf, INET_ADDRSTRLEN);
284 283
@@ -306,7 +305,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok)
306 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 305 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
307 efl_net_ip_address_family_set(efl_added, AF_INET), 306 efl_net_ip_address_family_set(efl_added, AF_INET),
308 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), 307 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
309 efl_net_ip_address_set(efl_added, &slice)); 308 efl_net_ip_address_set(efl_added, slice));
310 _ipv4_check(o, &addr); 309 _ipv4_check(o, &addr);
311 efl_del(o); 310 efl_del(o);
312 311
@@ -315,7 +314,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok)
315 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 314 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
316 efl_net_ip_address_family_set(efl_added, AF_INET), 315 efl_net_ip_address_family_set(efl_added, AF_INET),
317 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), 316 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
318 efl_net_ip_address_set(efl_added, &slice)); 317 efl_net_ip_address_set(efl_added, slice));
319 _ipv4_check(o, &addr); 318 _ipv4_check(o, &addr);
320 efl_del(o); 319 efl_del(o);
321 320
@@ -323,7 +322,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_ok)
323 addr.sin_addr.s_addr = htonl(0x12345678); 322 addr.sin_addr.s_addr = htonl(0x12345678);
324 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 323 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
325 efl_net_ip_address_family_set(efl_added, AF_INET), 324 efl_net_ip_address_family_set(efl_added, AF_INET),
326 efl_net_ip_address_set(efl_added, &slice)); 325 efl_net_ip_address_set(efl_added, slice));
327 _ipv4_check(o, &addr); 326 _ipv4_check(o, &addr);
328 efl_del(o); 327 efl_del(o);
329 328
@@ -356,7 +355,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail)
356 355
357 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true"); 356 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true");
358 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 357 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
359 efl_net_ip_address_set(efl_added, &wrong_slice)); 358 efl_net_ip_address_set(efl_added, wrong_slice));
360 ck_assert_ptr_eq(o, NULL); 359 ck_assert_ptr_eq(o, NULL);
361 TRAP_ERRORS_FINISH(2); 360 TRAP_ERRORS_FINISH(2);
362 361
@@ -369,14 +368,14 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail)
369 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true"); 368 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: pd->addr.sa_family == 0 is true");
370 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 369 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
371 efl_net_ip_address_port_set(efl_added, 1234), 370 efl_net_ip_address_port_set(efl_added, 1234),
372 efl_net_ip_address_set(efl_added, &wrong_slice)); 371 efl_net_ip_address_set(efl_added, wrong_slice));
373 ck_assert_ptr_eq(o, NULL); 372 ck_assert_ptr_eq(o, NULL);
374 TRAP_ERRORS_FINISH(3); 373 TRAP_ERRORS_FINISH(3);
375 374
376 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); 375 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
377 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 376 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
378 efl_net_ip_address_family_set(efl_added, AF_INET), 377 efl_net_ip_address_family_set(efl_added, AF_INET),
379 efl_net_ip_address_set(efl_added, &wrong_slice)); 378 efl_net_ip_address_set(efl_added, wrong_slice));
380 _ipv4_check(o, &addr); 379 _ipv4_check(o, &addr);
381 efl_del(o); 380 efl_del(o);
382 TRAP_ERRORS_FINISH(1); 381 TRAP_ERRORS_FINISH(1);
@@ -386,7 +385,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail)
386 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 385 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
387 efl_net_ip_address_family_set(efl_added, AF_INET), 386 efl_net_ip_address_family_set(efl_added, AF_INET),
388 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)), 387 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin_port)),
389 efl_net_ip_address_set(efl_added, &slice)); 388 efl_net_ip_address_set(efl_added, slice));
390 _ipv4_check(o, &addr); 389 _ipv4_check(o, &addr);
391 390
392 TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu"); 391 TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu");
@@ -397,24 +396,20 @@ START_TEST(ecore_test_efl_net_ip_address_ipv4_manual_fail)
397 efl_net_ip_address_port_set(o, 999); 396 efl_net_ip_address_port_set(o, 999);
398 TRAP_ERRORS_FINISH(1); 397 TRAP_ERRORS_FINISH(1);
399 398
400 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: address == NULL"); 399 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
401 efl_net_ip_address_set(o, NULL);
402 TRAP_ERRORS_FINISH(1);
403
404 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true");
405 slice.len = 1; 400 slice.len = 1;
406 efl_net_ip_address_set(o, &slice); 401 efl_net_ip_address_set(o, slice);
407 TRAP_ERRORS_FINISH(1); 402 TRAP_ERRORS_FINISH(1);
408 403
409 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); 404 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
410 slice.len = sizeof(addr.sin_addr.s_addr); 405 slice.len = sizeof(addr.sin_addr.s_addr);
411 efl_net_ip_address_set(o, &slice); 406 efl_net_ip_address_set(o, slice);
412 TRAP_ERRORS_FINISH(0); 407 TRAP_ERRORS_FINISH(0);
413 408
414 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); 409 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
415 addr.sin_addr.s_addr = htonl(0x12345678); 410 addr.sin_addr.s_addr = htonl(0x12345678);
416 slice.len = sizeof(addr.sin_addr.s_addr); 411 slice.len = sizeof(addr.sin_addr.s_addr);
417 efl_net_ip_address_set(o, &slice); 412 efl_net_ip_address_set(o, slice);
418 TRAP_ERRORS_FINISH(1); 413 TRAP_ERRORS_FINISH(1);
419 414
420 efl_del(o); 415 efl_del(o);
@@ -729,7 +724,7 @@ static void
729_ipv6_check(Eo *o, const struct sockaddr_in6 *addr) 724_ipv6_check(Eo *o, const struct sockaddr_in6 *addr)
730{ 725{
731 Eina_Slice slice = { .mem = &addr->sin6_addr, .len = sizeof(addr->sin6_addr) }; 726 Eina_Slice slice = { .mem = &addr->sin6_addr, .len = sizeof(addr->sin6_addr) };
732 const Eina_Slice *rs; 727 Eina_Slice rs;
733 char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = ""; 728 char buf[INET6_ADDRSTRLEN + sizeof("[]:65536")] = "";
734 729
735 ck_assert_ptr_ne(o, NULL); 730 ck_assert_ptr_ne(o, NULL);
@@ -738,8 +733,7 @@ _ipv6_check(Eo *o, const struct sockaddr_in6 *addr)
738 ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin6_port)); 733 ck_assert_int_eq(efl_net_ip_address_port_get(o), ntohs(addr->sin6_port));
739 734
740 rs = efl_net_ip_address_get(o); 735 rs = efl_net_ip_address_get(o);
741 ck_assert_ptr_ne(rs, NULL); 736 ck_assert_int_eq(eina_slice_compare(rs, slice), 0);
742 ck_assert_int_eq(eina_slice_compare(*rs, slice), 0);
743 737
744 buf[0] = '['; 738 buf[0] = '[';
745 inet_ntop(AF_INET6, slice.mem, buf + 1, INET6_ADDRSTRLEN); 739 inet_ntop(AF_INET6, slice.mem, buf + 1, INET6_ADDRSTRLEN);
@@ -777,7 +771,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_ok)
777 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 771 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
778 efl_net_ip_address_family_set(efl_added, AF_INET6), 772 efl_net_ip_address_family_set(efl_added, AF_INET6),
779 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), 773 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
780 efl_net_ip_address_set(efl_added, &slice)); 774 efl_net_ip_address_set(efl_added, slice));
781 _ipv6_check(o, &addr); 775 _ipv6_check(o, &addr);
782 efl_del(o); 776 efl_del(o);
783 777
@@ -786,7 +780,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_ok)
786 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 780 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
787 efl_net_ip_address_family_set(efl_added, AF_INET6), 781 efl_net_ip_address_family_set(efl_added, AF_INET6),
788 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), 782 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
789 efl_net_ip_address_set(efl_added, &slice)); 783 efl_net_ip_address_set(efl_added, slice));
790 _ipv6_check(o, &addr); 784 _ipv6_check(o, &addr);
791 efl_del(o); 785 efl_del(o);
792 786
@@ -808,10 +802,10 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail)
808 802
809 /* generic errors checked at ecore_test_efl_net_ip_address_ipv4_manual_fail */ 803 /* generic errors checked at ecore_test_efl_net_ip_address_ipv4_manual_fail */
810 804
811 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); 805 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
812 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 806 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
813 efl_net_ip_address_family_set(efl_added, AF_INET6), 807 efl_net_ip_address_family_set(efl_added, AF_INET6),
814 efl_net_ip_address_set(efl_added, &wrong_slice)); 808 efl_net_ip_address_set(efl_added, wrong_slice));
815 _ipv6_check(o, &addr); 809 _ipv6_check(o, &addr);
816 efl_del(o); 810 efl_del(o);
817 TRAP_ERRORS_FINISH(1); 811 TRAP_ERRORS_FINISH(1);
@@ -821,7 +815,7 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail)
821 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL, 815 o = efl_add(EFL_NET_IP_ADDRESS_CLASS, NULL,
822 efl_net_ip_address_family_set(efl_added, AF_INET6), 816 efl_net_ip_address_family_set(efl_added, AF_INET6),
823 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)), 817 efl_net_ip_address_port_set(efl_added, ntohs(addr.sin6_port)),
824 efl_net_ip_address_set(efl_added, &slice)); 818 efl_net_ip_address_set(efl_added, slice));
825 _ipv6_check(o, &addr); 819 _ipv6_check(o, &addr);
826 820
827 TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu"); 821 TRAP_ERRORS_BEGIN(ecore_con, ERR, "port already set to %hu, new %hu");
@@ -832,20 +826,20 @@ START_TEST(ecore_test_efl_net_ip_address_ipv6_manual_fail)
832 efl_net_ip_address_port_set(o, 999); 826 efl_net_ip_address_port_set(o, 999);
833 TRAP_ERRORS_FINISH(1); 827 TRAP_ERRORS_FINISH(1);
834 828
835 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address->len is true"); 829 TRAP_ERRORS_BEGIN(eina_safety, ERR, "safety check failed: rw_slice.len != address.len is true");
836 slice.len = 1; 830 slice.len = 1;
837 efl_net_ip_address_set(o, &slice); 831 efl_net_ip_address_set(o, slice);
838 TRAP_ERRORS_FINISH(1); 832 TRAP_ERRORS_FINISH(1);
839 833
840 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); 834 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
841 slice.len = sizeof(addr.sin6_addr); 835 slice.len = sizeof(addr.sin6_addr);
842 efl_net_ip_address_set(o, &slice); 836 efl_net_ip_address_set(o, slice);
843 TRAP_ERRORS_FINISH(0); 837 TRAP_ERRORS_FINISH(0);
844 838
845 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s"); 839 TRAP_ERRORS_BEGIN(ecore_con, ERR, "address already set to %s, new %s");
846 _ipv6_set(&addr, 1, 2, 3, 4, 5, 6, 7, 8); 840 _ipv6_set(&addr, 1, 2, 3, 4, 5, 6, 7, 8);
847 slice.len = sizeof(addr.sin6_addr); 841 slice.len = sizeof(addr.sin6_addr);
848 efl_net_ip_address_set(o, &slice); 842 efl_net_ip_address_set(o, slice);
849 TRAP_ERRORS_FINISH(1); 843 TRAP_ERRORS_FINISH(1);
850 844
851 efl_del(o); 845 efl_del(o);