Changeset 729:5d8ac5da7092 in freeDiameter
- Timestamp:
- Feb 24, 2011, 5:19:14 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/testcnx.c
r688 r729 466 466 "-----END RSA PRIVATE KEY-----\n"; 467 467 468 469 struct fd_list eps = FD_LIST_INITIALIZER(eps); 470 468 /* Diffie-Hellman parameters, generated with GNUTLS certtool: 469 certtool --generate-dh-params 470 Generator: 06 471 472 Prime: ea:c3:75:0b:32:cf:d9:17:98:5c:da:d1 473 e0:1d:b9:7c:be:29:60:b0:6f:68:a9:f6 474 8d:75:05:59:69:04:ae:39:7c:2b:74:04 475 3c:e2:da:28:8a:9b:93:aa:67:05:a7:3e 476 06:3e:0d:31:63:88:55:ad:5a:bd:41:22 477 b7:58:a7:45:b3:d5:03:ad:de:3c:8d:69 478 42:bf:84:3d:c1:90:e7:39:6a:4b:87:01 479 19:e5:f3:a4:e5:8e:e2:45:d5:0c:6b:17 480 22:2b:2e:50:83:91:0c:5b:82:fc:72:27 481 49:3b:9f:29:11:53:c7:90:b8:8d:87:73 482 1a:7b:05:ab:cb:30:59:16:71:30:60:1b 483 4c:80:15:3a:a2:d3:47:b7:4a:61:de:64 484 7e:79:de:88:53:b7:7a:c6:a2:9a:bb:55 485 40:2d:7a:71:c7:41:b5:29:df:d7:5c:fb 486 42:e4:d8:5e:0b:99:d3:3c:93:0f:33:51 487 8b:f4:60:e4:c5:b5:58:21:c0:51:c4:43 488 25:7c:37:fe:5c:d3:62:6c:2a:af:a7:2a 489 82:d5:d3:e2:bb:5d:ad:84:15:f6:78:d9 490 d5:a8:f7:f0:48:5c:8d:e0:3d:04:ac:cf 491 aa:34:3f:5d:f2:0d:3d:ee:ec:b8:d8:e8 492 ad:dc:d3:40:59:a0:fd:45:62:47:63:c0 493 bd:f5:df:8b 494 */ 495 static char dh_params_data[] = "-----BEGIN DH PARAMETERS-----\n" 496 "MIIBCAKCAQEA6sN1CzLP2ReYXNrR4B25fL4pYLBvaKn2jXUFWWkErjl8K3QEPOLa\n" 497 "KIqbk6pnBac+Bj4NMWOIVa1avUEit1inRbPVA63ePI1pQr+EPcGQ5zlqS4cBGeXz\n" 498 "pOWO4kXVDGsXIisuUIORDFuC/HInSTufKRFTx5C4jYdzGnsFq8swWRZxMGAbTIAV\n" 499 "OqLTR7dKYd5kfnneiFO3esaimrtVQC16ccdBtSnf11z7QuTYXguZ0zyTDzNRi/Rg\n" 500 "5MW1WCHAUcRDJXw3/lzTYmwqr6cqgtXT4rtdrYQV9njZ1aj38EhcjeA9BKzPqjQ/\n" 501 "XfINPe7suNjordzTQFmg/UViR2PAvfXfiwIBBg==\n" 502 "-----END DH PARAMETERS-----\n"; 503 504 505 /* List server endpoints */ 506 static struct fd_list eps = FD_LIST_INITIALIZER(eps); 507 508 /* Pass parameters to the connect thread */ 471 509 struct connect_flags { 472 510 int proto; … … 474 512 }; 475 513 476 void * connect_thr(void * arg) 514 /* Client's side of the connection established from a separate thread */ 515 static void * connect_thr(void * arg) 477 516 { 478 517 struct connect_flags * cf = arg; … … 506 545 } 507 546 547 /* Parameters to the handshake thread */ 508 548 struct handshake_flags { 509 549 struct cnxctx * cnx; … … 512 552 }; 513 553 514 void * handshake_thr(void * arg) 554 /* Handshake the client's side */ 555 static void * handshake_thr(void * arg) 515 556 { 516 557 struct handshake_flags * hf = arg; … … 519 560 return NULL; 520 561 } 521 522 void * destroy_thr(void * arg) 562 563 /* Terminate the client's connection side */ 564 static void * destroy_thr(void * arg) 523 565 { 524 566 struct cnxctx * cnx = arg; … … 541 583 gnutls_datum_t notrust_cert = { (uint8_t *)notrust_cert_data, sizeof(notrust_cert_data) }; 542 584 gnutls_datum_t notrust_priv = { (uint8_t *)notrust_priv_data, sizeof(notrust_priv_data) }; 543 585 gnutls_datum_t dh_params = { (uint8_t *)dh_params_data, sizeof(dh_params_data) }; 586 587 /* Listening socket, server side */ 544 588 struct cnxctx * listener; 545 589 #ifndef DISABLE_SCTP 546 590 struct cnxctx * listener_sctp; 547 591 #endif /* DISABLE_SCTP */ 592 593 /* Server & client connected sockets */ 548 594 struct cnxctx * server_side; 549 595 struct cnxctx * client_side; 596 550 597 pthread_t thr; 551 598 int ret, i; … … 579 626 580 627 /* Set default DH params */ 581 CHECK_GNUTLS_DO( ret = gnutls_dh_params_ generate2( fd_g_config->cnf_sec_data.dh_cache, GNUTLS_DEFAULT_DHBITS), );628 CHECK_GNUTLS_DO( ret = gnutls_dh_params_import_pkcs3( fd_g_config->cnf_sec_data.dh_cache, &dh_params, GNUTLS_X509_FMT_PEM), ); 582 629 CHECK( GNUTLS_E_SUCCESS, ret ); 583 630 584 /* Initialize the server addresses */ 631 632 /* Initialize the server address (this should give a safe loopback address + port, even on non-standard configs) */ 585 633 { 586 634 struct addrinfo hints, *ai, *aip; … … 595 643 }; 596 644 freeaddrinfo(ai); 645 646 CHECK( 0, FD_IS_LIST_EMPTY(&eps) ? 1 : 0 ); 597 647 } 598 648 … … 647 697 fd_msg_dump_walk(0, cer); 648 698 #endif 649 699 650 700 CHECK( 0, fd_msg_bufferize( cer, &cer_buf, &cer_sz ) ); 651 701 CHECK( 0, fd_msg_free(cer) ); … … 660 710 661 711 /* Start the client thread */ 662 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );712 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 663 713 664 714 /* Accept the connection of the client */ … … 686 736 free(rcv_buf); 687 737 688 /* Now close the connection */738 /* Now close the connections */ 689 739 fd_cnx_destroy(client_side); 690 740 fd_cnx_destroy(server_side); … … 700 750 701 751 /* Start the client thread */ 702 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );752 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 703 753 704 754 /* Accept the connection of the client */ … … 762 812 763 813 /* Start the client thread */ 764 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );814 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 765 815 766 816 /* Accept the connection of the client */ … … 793 843 794 844 /* At this point in legacy Diameter we start the handshake */ 795 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );845 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 796 846 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 797 847 CHECK( 0, pthread_join(thr, NULL) ); … … 815 865 816 866 /* Now close the connection */ 817 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );867 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 818 868 fd_cnx_destroy(server_side); 819 869 CHECK( 0, pthread_join(thr, NULL) ); … … 847 897 848 898 /* Start the client thread */ 849 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );899 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 850 900 851 901 /* Accept the connection of the client */ … … 878 928 879 929 /* At this point in legacy Diameter we start the handshake */ 880 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );930 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 881 931 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 882 932 CHECK( 0, pthread_join(thr, NULL) ); … … 900 950 901 951 /* Now close the connection */ 902 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );952 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 903 953 fd_cnx_destroy(server_side); 904 954 CHECK( 0, pthread_join(thr, NULL) ); … … 932 982 933 983 /* Start the client thread */ 934 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );984 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 935 985 936 986 /* Accept the connection of the client */ … … 944 994 945 995 /* Start the handshake directly */ 946 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );996 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 947 997 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 948 998 CHECK( 0, pthread_join(thr, NULL) ); … … 965 1015 966 1016 /* Now close the connection */ 967 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1017 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 968 1018 fd_cnx_destroy(server_side); 969 1019 CHECK( 0, pthread_join(thr, NULL) ); … … 997 1047 998 1048 /* Start the client thread */ 999 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1049 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1000 1050 1001 1051 /* Accept the connection of the client */ … … 1009 1059 1010 1060 /* Start the handshake directly */ 1011 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) ); 1061 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1062 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1063 CHECK( 0, pthread_join(thr, NULL) ); 1064 CHECK( 0, hf.ret ); 1065 1066 /* Send a few TLS protected messages, and replies */ 1067 for (i = 0; i < 2 * NB_STREAMS; i++) { 1068 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0)); 1069 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz)); 1070 CHECK( cer_sz, rcv_sz ); 1071 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1072 free(rcv_buf); 1073 1074 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0)); 1075 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz)); 1076 CHECK( cer_sz, rcv_sz ); 1077 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1078 free(rcv_buf); 1079 } 1080 1081 1082 /* Now close the connection */ 1083 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1084 fd_cnx_destroy(server_side); 1085 CHECK( 0, pthread_join(thr, NULL) ); 1086 1087 /* Free the credentials */ 1088 gnutls_certificate_free_keys(hf.creds); 1089 gnutls_certificate_free_cas(hf.creds); 1090 gnutls_certificate_free_credentials(hf.creds); 1091 } 1092 #endif /* DISABLE_SCTP */ 1093 1094 /* Test with different number of streams between server and client */ 1095 #ifndef DISABLE_SCTP 1096 { 1097 struct connect_flags cf; 1098 struct handshake_flags hf; 1099 1100 memset(&cf, 0, sizeof(cf)); 1101 cf.proto = IPPROTO_SCTP; 1102 1103 memset(&hf, 0, sizeof(hf)); 1104 1105 /* Initialize remote certificate */ 1106 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), ); 1107 CHECK( GNUTLS_E_SUCCESS, ret ); 1108 /* Set the CA */ 1109 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), ); 1110 CHECK( 1, ret ); 1111 /* Set the key */ 1112 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), ); 1113 CHECK( GNUTLS_E_SUCCESS, ret ); 1114 1115 /* Start the client thread with more streams than the server */ 1116 fd_g_config->cnf_sctp_str = 2 * NB_STREAMS; 1117 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1118 1119 /* Accept the connection of the client */ 1120 server_side = fd_cnx_serv_accept(listener_sctp); 1121 CHECK( 1, server_side ? 1 : 0 ); 1122 1123 /* Retrieve the client connection object */ 1124 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1125 CHECK( 1, client_side ? 1 : 0 ); 1126 hf.cnx = client_side; 1127 1128 /* Start the handshake directly */ 1129 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1130 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1131 CHECK( 0, pthread_join(thr, NULL) ); 1132 CHECK( 0, hf.ret ); 1133 1134 /* Send a few TLS protected message, and replies */ 1135 for (i = 0; i < 4 * NB_STREAMS; i++) { 1136 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0)); 1137 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz)); 1138 CHECK( cer_sz, rcv_sz ); 1139 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1140 free(rcv_buf); 1141 1142 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0)); 1143 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz)); 1144 CHECK( cer_sz, rcv_sz ); 1145 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1146 free(rcv_buf); 1147 } 1148 1149 /* Now close the connection */ 1150 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1151 fd_cnx_destroy(server_side); 1152 CHECK( 0, pthread_join(thr, NULL) ); 1153 1154 /* Do the same test but with more streams on the server this time */ 1155 fd_g_config->cnf_sctp_str = NB_STREAMS / 2; 1156 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1157 1158 /* Accept the connection of the client */ 1159 server_side = fd_cnx_serv_accept(listener_sctp); 1160 CHECK( 1, server_side ? 1 : 0 ); 1161 1162 /* Retrieve the client connection object */ 1163 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1164 CHECK( 1, client_side ? 1 : 0 ); 1165 hf.cnx = client_side; 1166 1167 /* Start the handshake directly */ 1168 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1012 1169 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1013 1170 CHECK( 0, pthread_join(thr, NULL) ); … … 1029 1186 } 1030 1187 1031 1032 1188 /* Now close the connection */ 1033 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) ); 1034 fd_cnx_destroy(server_side); 1035 CHECK( 0, pthread_join(thr, NULL) ); 1036 1037 /* Free the credentials */ 1038 gnutls_certificate_free_keys(hf.creds); 1039 gnutls_certificate_free_cas(hf.creds); 1040 gnutls_certificate_free_credentials(hf.creds); 1041 } 1042 #endif /* DISABLE_SCTP */ 1043 1044 /* Test with different number of streams between server and client */ 1045 #ifndef DISABLE_SCTP 1046 { 1047 struct connect_flags cf; 1048 struct handshake_flags hf; 1049 1050 memset(&cf, 0, sizeof(cf)); 1051 cf.proto = IPPROTO_SCTP; 1052 1053 memset(&hf, 0, sizeof(hf)); 1054 1055 /* Initialize remote certificate */ 1056 CHECK_GNUTLS_DO( ret = gnutls_certificate_allocate_credentials (&hf.creds), ); 1057 CHECK( GNUTLS_E_SUCCESS, ret ); 1058 /* Set the CA */ 1059 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_trust_mem( hf.creds, &ca, GNUTLS_X509_FMT_PEM), ); 1060 CHECK( 1, ret ); 1061 /* Set the key */ 1062 CHECK_GNUTLS_DO( ret = gnutls_certificate_set_x509_key_mem( hf.creds, &client_cert, &client_priv, GNUTLS_X509_FMT_PEM), ); 1063 CHECK( GNUTLS_E_SUCCESS, ret ); 1064 1065 /* Start the client thread with more streams than the server */ 1066 fd_g_config->cnf_sctp_str = 2 * NB_STREAMS; 1067 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) ); 1068 1069 /* Accept the connection of the client */ 1070 server_side = fd_cnx_serv_accept(listener_sctp); 1071 CHECK( 1, server_side ? 1 : 0 ); 1072 1073 /* Retrieve the client connection object */ 1074 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1075 CHECK( 1, client_side ? 1 : 0 ); 1076 hf.cnx = client_side; 1077 1078 /* Start the handshake directly */ 1079 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) ); 1080 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1081 CHECK( 0, pthread_join(thr, NULL) ); 1082 CHECK( 0, hf.ret ); 1083 1084 /* Send a few TLS protected message, and replies */ 1085 for (i = 0; i < 4 * NB_STREAMS; i++) { 1086 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0)); 1087 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz)); 1088 CHECK( cer_sz, rcv_sz ); 1089 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1090 free(rcv_buf); 1091 1092 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0)); 1093 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz)); 1094 CHECK( cer_sz, rcv_sz ); 1095 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1096 free(rcv_buf); 1097 } 1098 1099 /* Now close the connection */ 1100 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) ); 1101 fd_cnx_destroy(server_side); 1102 CHECK( 0, pthread_join(thr, NULL) ); 1103 1104 /* Do the same test but with more streams on the server this time */ 1105 fd_g_config->cnf_sctp_str = NB_STREAMS / 2; 1106 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) ); 1107 1108 /* Accept the connection of the client */ 1109 server_side = fd_cnx_serv_accept(listener_sctp); 1110 CHECK( 1, server_side ? 1 : 0 ); 1111 1112 /* Retrieve the client connection object */ 1113 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1114 CHECK( 1, client_side ? 1 : 0 ); 1115 hf.cnx = client_side; 1116 1117 /* Start the handshake directly */ 1118 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) ); 1119 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1120 CHECK( 0, pthread_join(thr, NULL) ); 1121 CHECK( 0, hf.ret ); 1122 1123 /* Send a few TLS protected message, and replies */ 1124 for (i = 0; i < 2 * NB_STREAMS; i++) { 1125 CHECK( 0, fd_cnx_send(server_side, cer_buf, cer_sz, 0)); 1126 CHECK( 0, fd_cnx_receive(client_side, NULL, &rcv_buf, &rcv_sz)); 1127 CHECK( cer_sz, rcv_sz ); 1128 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1129 free(rcv_buf); 1130 1131 CHECK( 0, fd_cnx_send(client_side, cer_buf, cer_sz, 0)); 1132 CHECK( 0, fd_cnx_receive(server_side, NULL, &rcv_buf, &rcv_sz)); 1133 CHECK( cer_sz, rcv_sz ); 1134 CHECK( 0, memcmp( rcv_buf, cer_buf, cer_sz ) ); 1135 free(rcv_buf); 1136 } 1137 1138 /* Now close the connection */ 1139 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) ); 1189 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1140 1190 fd_cnx_destroy(server_side); 1141 1191 CHECK( 0, pthread_join(thr, NULL) ); … … 1174 1224 1175 1225 /* Start the client thread */ 1176 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1226 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1177 1227 1178 1228 /* Accept the connection of the client */ … … 1186 1236 1187 1237 /* Start the handshake directly */ 1188 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1238 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1189 1239 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1190 1240 CHECK( 0, pthread_join(thr, NULL) ); 1191 1241 1192 1242 /* Now close the connection */ 1193 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1243 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1194 1244 fd_cnx_destroy(server_side); 1195 1245 CHECK( 0, pthread_join(thr, NULL) ); … … 1224 1274 1225 1275 /* Start the client thread */ 1226 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1276 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1227 1277 1228 1278 /* Accept the connection of the client */ … … 1236 1286 1237 1287 /* Start the handshake directly */ 1238 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1288 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1239 1289 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1240 1290 CHECK( 0, pthread_join(thr, NULL) ); 1241 1291 1242 1292 /* Now close the connection */ 1243 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1293 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1244 1294 fd_cnx_destroy(server_side); 1245 1295 CHECK( 0, pthread_join(thr, NULL) ); … … 1273 1323 1274 1324 /* Start the client thread */ 1275 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1325 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1276 1326 1277 1327 /* Accept the connection of the client */ … … 1285 1335 1286 1336 /* Start the handshake directly */ 1287 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1337 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1288 1338 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1289 1339 CHECK( 0, pthread_join(thr, NULL) ); 1290 1340 1291 1341 /* Now close the connection */ 1292 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1342 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1293 1343 fd_cnx_destroy(server_side); 1294 1344 CHECK( 0, pthread_join(thr, NULL) ); … … 1322 1372 1323 1373 /* Start the client thread */ 1324 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1374 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1325 1375 1326 1376 /* Accept the connection of the client */ … … 1337 1387 1338 1388 /* Start the handshake, check it is successful */ 1339 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1389 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1340 1390 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1341 1391 CHECK( 0, pthread_join(thr, NULL) ); … … 1343 1393 1344 1394 /* Now close the connection */ 1345 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1395 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1346 1396 fd_cnx_destroy(server_side); 1347 1397 CHECK( 0, pthread_join(thr, NULL) ); 1348 1398 1349 1399 /* Do it again with an invalid hostname */ 1350 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1400 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1351 1401 1352 1402 /* Accept the connection of the client */ … … 1363 1413 1364 1414 /* Start the handshake, check it is successful */ 1365 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1415 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1366 1416 CHECK( EINVAL, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1367 1417 CHECK( 0, pthread_join(thr, NULL) ); 1368 1418 1369 1419 /* Now close the connection */ 1370 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1420 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1371 1421 fd_cnx_destroy(server_side); 1372 1422 CHECK( 0, pthread_join(thr, NULL) ); … … 1405 1455 1406 1456 /* Start the client thread */ 1407 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1457 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1408 1458 1409 1459 /* Accept the connection of the client */ … … 1417 1467 1418 1468 /* Start the handshake */ 1419 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1469 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1420 1470 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1421 1471 CHECK( 0, pthread_join(thr, NULL) ); … … 1459 1509 1460 1510 /* Now close the connection */ 1461 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1511 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1462 1512 fd_cnx_destroy(server_side); 1463 1513 CHECK( 0, pthread_join(thr, NULL) ); … … 1497 1547 1498 1548 /* Start the client thread */ 1499 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1549 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1500 1550 1501 1551 /* Accept the connection of the client */ … … 1509 1559 1510 1560 /* Start the handshake */ 1511 CHECK( 0, pthread_create(&thr, 0, handshake_thr, &hf) );1561 CHECK( 0, pthread_create(&thr, NULL, handshake_thr, &hf) ); 1512 1562 CHECK( 0, fd_cnx_handshake(server_side, GNUTLS_SERVER, NULL, NULL) ); 1513 1563 CHECK( 0, pthread_join(thr, NULL) ); … … 1550 1600 1551 1601 /* Now close the connection */ 1552 CHECK( 0, pthread_create(&thr, 0, destroy_thr, client_side) );1602 CHECK( 0, pthread_create(&thr, NULL, destroy_thr, client_side) ); 1553 1603 fd_cnx_destroy(server_side); 1554 1604 CHECK( 0, pthread_join(thr, NULL) ); … … 1581 1631 1582 1632 /* Start the client thread, that should fail */ 1583 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1633 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1584 1634 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1585 1635 CHECK( 0, client_side ? 1 : 0 ); … … 1595 1645 1596 1646 /* Start the client thread, that should fail */ 1597 CHECK( 0, pthread_create(&thr, 0, connect_thr, &cf) );1647 CHECK( 0, pthread_create(&thr, NULL, connect_thr, &cf) ); 1598 1648 CHECK( 0, pthread_join( thr, (void *)&client_side ) ); 1599 1649 CHECK( 0, client_side ? 1 : 0 ); -
tests/tests.h
r695 r729 77 77 (void)fd_core_shutdown(); \ 78 78 (void)fd_core_wait_shutdown_complete(); \ 79 (void)fd_thr_term(& timeout_thr);\79 (void)fd_thr_term(&signal_thr); \ 80 80 exit(PASS); \ 81 81 } … … 105 105 } 106 106 107 static pthread_t timeout_thr;108 static void * timeout_catch(void * arg)107 static pthread_t signal_thr; 108 static void * signal_catch(void * arg) 109 109 { 110 110 int sig; 111 111 sigset_t ss; 112 fd_log_threadname ( " Test alarmcatcher" );112 fd_log_threadname ( "Signal catcher" ); 113 113 114 114 sigemptyset(&ss); 115 116 /* We use SIGALRM */ 115 117 sigaddset(&ss, SIGALRM); 116 118 119 /* Unblock any other signal for this thread, so that default handler is enabled */ 120 CHECK_SYS_DO( pthread_sigmask( SIG_SETMASK, &ss, NULL ), ); 121 122 /* Now wait for sigwait or cancelation */ 117 123 CHECK_POSIX_DO( sigwait(&ss, &sig), ); 118 119 124 FAILTEST("The timeout (" _stringize(TEST_TIMEOUT) " sec) was reached. Use -n or change TEST_TIMEOUT if the test needs more time to execute."); 120 125 … … 165 170 if (!no_timeout) { 166 171 alarm(TEST_TIMEOUT); 167 CHECK( 0, pthread_create(&timeout_thr, NULL, timeout_catch, NULL) );168 172 } 173 CHECK( 0, pthread_create(&signal_thr, NULL, signal_catch, NULL) ); 169 174 } 170 175 171 176 static inline void test_init(int argc, char * argv[], char *fname) 172 177 { 178 sigset_t sig_all; 179 sigfillset(&sig_all); 180 181 CHECK( 0, pthread_sigmask(SIG_BLOCK, &sig_all, NULL)); 182 173 183 memset(fd_g_config, 0, sizeof(struct fd_config)); 174 184 … … 176 186 177 187 fd_log_threadname(basename(fname)); 188 189 /* Parse the command line */ 190 parse_cmdline(argc, argv); 178 191 179 192 /* Initialize gcrypt and gnutls */ … … 194 207 CHECK( 0, fd_sess_start() ); 195 208 196 /* Parse the command line */197 parse_cmdline(argc, argv);198 199 209 return; 200 210 } -
tests/testsctp.c
r706 r729 78 78 }; 79 79 freeaddrinfo(ai); 80 81 CHECK( 0, FD_IS_LIST_EMPTY(&eps) ? 1 : 0 ); 80 82 } 81 83
Note: See TracChangeset
for help on using the changeset viewer.