Branch Coverage

amqp_socket.c
Criterion Covered Total %
branch 167 328 50.9


line true false branch
123 0 533 assert(self);
124 0 533 assert(self->klass->send);
130 0 787 assert(self);
131 0 787 assert(self->klass->recv);
136 0 0 assert(self);
137 0 0 assert(self->klass->open);
143 0 38 assert(self);
144 0 38 assert(self->klass->open);
149 0 5 assert(self);
150 0 5 assert(self->klass->close);
155 38 36 if (self) {
156 0 38 assert(self->klass->delete);
162 0 780 assert(self);
163 0 780 assert(self->klass->get_sockfd);
174 43 395 assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT);
0 43 assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT);
188 0 438 if (-1 > timeout_ms) {
194 433 5 if (0 < res) {
199 5 0 } else if (0 == res) {
202 0 0 switch (amqp_os_socket_error()) {
268 3 6 if (-1 == fd) {
292 524 9 if (res > 0) {
295 519 5 if (0 == len_left) {
301 5 4 if (AMQP_STATUS_OK == res) {
304 0 4 if (AMQP_STATUS_TIMEOUT == res) {
318 0 37 if (AMQP_STATUS_OK != res) {
401 0 38 if (-1 == sockfd) {
407 38 0 if (flags == -1 || fcntl(sockfd, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) {
0 38 if (flags == -1 || fcntl(sockfd, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) {
414 38 0 if (flags == -1 || fcntl(sockfd, F_SETFL, (long)(flags | O_NONBLOCK)) == -1) {
0 38 if (flags == -1 || fcntl(sockfd, F_SETFL, (long)(flags | O_NONBLOCK)) == -1) {
428 0 38 if (0 != setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one))) {
434 0 38 if (0 != setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one))) {
439 0 38 if (0 == connect(sockfd, addr->ai_addr, addr->ai_addrlen)) {
443 0 38 if (EINPROGRESS != errno) {
449 1 37 if (AMQP_STATUS_OK != last_error) {
457 37 0 if (-1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) ||
0 37 if (-1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) ||
482 0 38 if (AMQP_STATUS_OK != last_error) {
494 0 38 if (0 != last_error) {
498 38 0 for (addr = address_list; addr; addr = addr->ai_next) {
501 37 1 if (sockfd >= 0) {
504 1 0 } else if (sockfd == AMQP_STATUS_TIMEOUT) {
511 37 1 if (last_error != AMQP_STATUS_OK || sockfd == -1) {
0 37 if (last_error != AMQP_STATUS_OK || sockfd == -1) {
529 37 0 if (sizeof(header) == res) {
558 37 37 if (l.len == r.len) {
559 37 0 if (l.bytes && r.bytes) {
37 0 if (l.bytes && r.bytes) {
560 37 0 if (0 == memcmp(l.bytes, r.bytes, l.len)) {
576 0 37 assert(NULL != mechanisms.bytes);
584 74 0 for (; current != end; start = current + 1) {
590 37 37 if (NULL == current) {
595 37 37 if (bytes_equal(mechanism, supported_mechanism)) {
609 0 37 char *username = va_arg(args, char *);
611 0 37 char *password = va_arg(args, char *);
617 0 37 if (response.bytes == NULL)
632 0 0 char *identity = va_arg(args, char *);
636 0 0 if (response.bytes == NULL) {
672 0 488 if (res < 0) {
690 393 394 if (res < 0) {
692 0 393 if (-1 == fd) {
705 389 4 if (AMQP_STATUS_OK == res) {
716 0 394 if (AMQP_STATUS_OK != res) {
725 20 2 while (amqp_data_in_buffer(state)) {
729 0 20 if (AMQP_STATUS_OK != res) {
733 20 0 if (frame.frame_type != 0) {
739 0 20 if (NULL == channel_pool) {
746 20 0 if (frame_copy == NULL || link == NULL) {
0 20 if (frame_copy == NULL || link == NULL) {
755 1 19 if (state->last_queued_frame == NULL) {
775 468 397 while (amqp_data_in_buffer(state)) {
778 0 468 if (AMQP_STATUS_OK != res) {
782 5 463 if (AMQP_FRAME_HEARTBEAT == decoded_frame->frame_type) {
787 455 8 if (decoded_frame->frame_type != 0) {
795 0 397 if (AMQP_STATUS_TIMER_FAILURE == res) {
797 2 395 } else if (AMQP_STATUS_TIMEOUT == res) {
803 1 1 if (AMQP_STATUS_OK != res) {
815 4 392 if (AMQP_STATUS_TIMEOUT == res) {
816 0 4 if (amqp_time_equal(deadline, state->next_recv_heartbeat)) {
819 4 0 } else if (amqp_time_equal(deadline, timeout_deadline)) {
821 0 0 } else if (amqp_time_equal(deadline, state->next_send_heartbeat)) {
827 0 392 } else if (AMQP_STATUS_OK != res) {
841 0 0 if (NULL == channel_pool) {
848 0 0 if (NULL == link || NULL == frame_copy) {
0 0 if (NULL == link || NULL == frame_copy) {
860 0 0 if (NULL == link) {
864 0 0 if (NULL == state->first_queued_frame) {
878 0 0 if (NULL == link) {
882 0 0 if (NULL == state->first_queued_frame) {
901 0 59 for (cur = state->first_queued_frame; NULL != cur; cur = cur->next) {
904 0 0 if (channel == frame_ptr->channel) {
906 0 0 if (NULL == state->first_queued_frame) {
919 0 59 if (AMQP_STATUS_OK != res) {
923 59 0 if (channel == decoded_frame->channel) {
927 0 0 if (res != AMQP_STATUS_OK) {
945 0 121 if (AMQP_STATUS_OK != res) {
949 20 101 if (state->first_queued_frame != NULL) {
952 1 19 if (state->first_queued_frame == NULL) {
972 0 74 if (res != AMQP_STATUS_OK) {
977 0 74 if (AMQP_STATUS_OK != res) {
981 74 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
74 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
982 0 74 expected_channel != frame.channel ||
1028 710 10 while (*list != 0) {
1029 664 46 if (*list == expected) {
1047 2 300 if (status < 0) {
1056 0 300 if (status < 0) {
1057 0 0 if (status == AMQP_STATUS_TIMEOUT) {
1071 300 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
300 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
1072 5 295 (((frame.channel == channel) &&
1074 0 5 expected_reply_ids) ||
1075 0 0 (frame.payload.method.id == AMQP_CHANNEL_CLOSE_METHOD))) ||
1076 0 0 ((frame.channel == 0) &&
1083 0 0 if (NULL == channel_pool) {
1090 0 0 if (frame_copy == NULL || link == NULL) {
0 0 if (frame_copy == NULL || link == NULL) {
1099 0 0 if (state->last_queued_frame == NULL) {
1109 295 5 result.reply_type =
1128 0 54 if (res != AMQP_STATUS_OK) {
1146 0 211 if (res != AMQP_STATUS_OK) {
1157 206 5 if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL) {
1179 0 37 assert(base != NULL);
1180 0 37 assert(result != NULL);
1181 0 37 assert(pool != NULL);
1183 0 37 if (NULL == add) {
1192 0 37 if (NULL == temp_result.entries) {
1196 222 37 for (i = 0; i < base->num_entries; ++i) {
1200 0 37 for (i = 0; i < add->num_entries; ++i) {
1203 0 0 if (NULL != e) {
1204 0 0 if (AMQP_FIELD_KIND_TABLE == add->entries[i].value.kind &&
0 0 if (AMQP_FIELD_KIND_TABLE == add->entries[i].value.kind &&
1212 0 0 if (AMQP_STATUS_OK != res) {
1250 37 0 if (channel_max < 0 || channel_max > UINT16_MAX) {
0 37 if (channel_max < 0 || channel_max > UINT16_MAX) {
1255 0 37 if (frame_max < 0) {
1260 37 0 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
0 37 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
1266 0 37 if (AMQP_STATUS_OK != res) {
1271 0 37 if (AMQP_STATUS_OK != res) {
1277 0 37 if (AMQP_STATUS_OK != res) {
1283 37 0 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
0 37 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
1292 0 37 if (AMQP_STATUS_OK != res) {
1299 0 37 if (!sasl_mechanism_in_list(s->mechanisms, sasl_method)) {
1315 0 37 if (NULL == channel_pool) {
1321 0 37 if (response_bytes.bytes == NULL) {
1354 0 37 if (AMQP_STATUS_OK != res) {
1365 0 37 if (res < 0) {
1377 0 37 if (AMQP_STATUS_OK != res) {
1382 0 37 if (AMQP_CONNECTION_CLOSE_METHOD == method.id) {
1396 37 0 if (server_channel_max != 0 &&
37 0 if (server_channel_max != 0 &&
1397 37 0 (server_channel_max < client_channel_max || client_channel_max == 0)) {
1399 0 0 } else if (server_channel_max == 0 && client_channel_max == 0) {
0 0 } else if (server_channel_max == 0 && client_channel_max == 0) {
1403 37 0 if (server_frame_max != 0 && server_frame_max < client_frame_max) {
37 0 if (server_frame_max != 0 && server_frame_max < client_frame_max) {
1407 37 0 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
0 37 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
1413 0 37 if (res < 0) {
1425 0 37 if (res < 0) {
1441 0 37 if (result.reply_type != AMQP_RESPONSE_NORMAL) {