Branch Coverage

amqp_socket.c
Criterion Covered Total %
branch 172 330 52.1


line true false branch
123 0 523 assert(self);
124 0 523 assert(self->klass->send);
130 0 793 assert(self);
131 0 793 assert(self->klass->recv);
136 0 0 assert(self);
137 0 0 assert(self->klass->open);
143 0 39 assert(self);
144 0 39 assert(self->klass->open);
149 0 6 assert(self);
150 0 6 assert(self->klass->close);
155 38 37 if (self) {
156 0 38 assert(self->klass->delete);
162 0 782 assert(self);
163 0 782 assert(self->klass->get_sockfd);
174 40 399 assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT);
0 40 assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT);
188 0 439 if (-1 > timeout_ms) {
194 433 6 if (0 < res) {
199 6 0 } else if (0 == res) {
202 0 0 switch (amqp_os_socket_error()) {
268 3 2 if (-1 == fd) {
292 518 5 if (res > 0) {
295 517 1 if (0 == len_left) {
301 1 4 if (AMQP_STATUS_OK == res) {
304 0 4 if (AMQP_STATUS_TIMEOUT == res) {
318 0 38 if (AMQP_STATUS_OK != res) {
401 0 39 if (-1 == sockfd) {
407 39 0 if (flags == -1 || fcntl(sockfd, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) {
0 39 if (flags == -1 || fcntl(sockfd, F_SETFD, (long)(flags | FD_CLOEXEC)) == -1) {
414 39 0 if (flags == -1 || fcntl(sockfd, F_SETFL, (long)(flags | O_NONBLOCK)) == -1) {
0 39 if (flags == -1 || fcntl(sockfd, F_SETFL, (long)(flags | O_NONBLOCK)) == -1) {
428 0 39 if (0 != setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one))) {
434 0 39 if (0 != setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one))) {
439 0 39 if (0 == connect(sockfd, addr->ai_addr, addr->ai_addrlen)) {
443 0 39 if (EINPROGRESS != errno) {
449 1 38 if (AMQP_STATUS_OK != last_error) {
457 38 0 if (-1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) ||
0 38 if (-1 == getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &result, &result_len) ||
482 0 39 if (AMQP_STATUS_OK != last_error) {
494 0 39 if (0 != last_error) {
498 39 0 for (addr = address_list; addr; addr = addr->ai_next) {
501 38 1 if (sockfd >= 0) {
504 1 0 } else if (sockfd == AMQP_STATUS_TIMEOUT) {
511 38 1 if (last_error != AMQP_STATUS_OK || sockfd == -1) {
0 38 if (last_error != AMQP_STATUS_OK || sockfd == -1) {
529 38 0 if (sizeof(header) == res) {
558 38 38 if (l.len == r.len) {
559 38 0 if (l.bytes && r.bytes) {
38 0 if (l.bytes && r.bytes) {
560 38 0 if (0 == memcmp(l.bytes, r.bytes, l.len)) {
576 0 38 assert(NULL != mechanisms.bytes);
584 76 0 for (; current != end; start = current + 1) {
590 38 38 if (NULL == current) {
595 38 38 if (bytes_equal(mechanism, supported_mechanism)) {
609 0 38 char *username = va_arg(args, char *);
611 0 38 char *password = va_arg(args, char *);
617 0 38 if (response.bytes == NULL)
632 0 0 char *identity = va_arg(args, char *);
636 0 0 if (response.bytes == NULL) {
672 0 480 if (res < 0) {
690 397 396 if (res < 0) {
692 0 397 if (-1 == fd) {
705 392 5 if (AMQP_STATUS_OK == res) {
716 0 396 if (AMQP_STATUS_OK != res) {
725 18 2 while (amqp_data_in_buffer(state)) {
729 0 18 if (AMQP_STATUS_OK != res) {
733 18 0 if (frame.frame_type != 0) {
739 0 18 if (NULL == channel_pool) {
746 18 0 if (frame_copy == NULL || link == NULL) {
0 18 if (frame_copy == NULL || link == NULL) {
755 1 17 if (state->last_queued_frame == NULL) {
764 0 2 if (AMQP_STATUS_OK != res) {
778 462 400 while (amqp_data_in_buffer(state)) {
781 0 462 if (AMQP_STATUS_OK != res) {
785 6 456 if (AMQP_FRAME_HEARTBEAT == decoded_frame->frame_type) {
790 451 5 if (decoded_frame->frame_type != 0) {
798 0 400 if (AMQP_STATUS_TIMER_FAILURE == res) {
800 2 398 } else if (AMQP_STATUS_TIMEOUT == res) {
806 1 1 if (AMQP_STATUS_OK != res) {
818 5 394 if (AMQP_STATUS_TIMEOUT == res) {
819 0 5 if (amqp_time_equal(deadline, state->next_recv_heartbeat)) {
822 5 0 } else if (amqp_time_equal(deadline, timeout_deadline)) {
824 0 0 } else if (amqp_time_equal(deadline, state->next_send_heartbeat)) {
830 0 394 } else if (AMQP_STATUS_OK != res) {
844 0 0 if (NULL == channel_pool) {
851 0 0 if (NULL == link || NULL == frame_copy) {
0 0 if (NULL == link || NULL == frame_copy) {
863 0 0 if (NULL == link) {
867 0 0 if (NULL == state->first_queued_frame) {
881 0 0 if (NULL == link) {
885 0 0 if (NULL == state->first_queued_frame) {
904 0 51 for (cur = state->first_queued_frame; NULL != cur; cur = cur->next) {
907 0 0 if (channel == frame_ptr->channel) {
909 0 0 if (NULL == state->first_queued_frame) {
922 0 51 if (AMQP_STATUS_OK != res) {
926 51 0 if (channel == decoded_frame->channel) {
930 0 0 if (res != AMQP_STATUS_OK) {
948 0 121 if (AMQP_STATUS_OK != res) {
952 18 103 if (state->first_queued_frame != NULL) {
955 1 17 if (state->first_queued_frame == NULL) {
975 0 76 if (res != AMQP_STATUS_OK) {
980 0 76 if (AMQP_STATUS_OK != res) {
984 76 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
76 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
985 0 76 expected_channel != frame.channel ||
1031 716 8 while (*list != 0) {
1032 672 44 if (*list == expected) {
1050 2 303 if (status < 0) {
1059 1 302 if (status < 0) {
1060 1 0 if (status == AMQP_STATUS_TIMEOUT) {
1074 302 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
302 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
1075 4 298 (((frame.channel == channel) &&
1077 0 4 expected_reply_ids) ||
1078 0 0 (frame.payload.method.id == AMQP_CHANNEL_CLOSE_METHOD))) ||
1079 0 0 ((frame.channel == 0) &&
1086 0 0 if (NULL == channel_pool) {
1093 0 0 if (frame_copy == NULL || link == NULL) {
0 0 if (frame_copy == NULL || link == NULL) {
1102 0 0 if (state->last_queued_frame == NULL) {
1112 298 4 result.reply_type =
1131 0 56 if (res != AMQP_STATUS_OK) {
1149 0 211 if (res != AMQP_STATUS_OK) {
1160 207 4 if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL) {
1182 0 38 assert(base != NULL);
1183 0 38 assert(result != NULL);
1184 0 38 assert(pool != NULL);
1186 0 38 if (NULL == add) {
1195 0 38 if (NULL == temp_result.entries) {
1199 228 38 for (i = 0; i < base->num_entries; ++i) {
1203 1 38 for (i = 0; i < add->num_entries; ++i) {
1206 0 1 if (NULL != e) {
1207 0 0 if (AMQP_FIELD_KIND_TABLE == add->entries[i].value.kind &&
0 0 if (AMQP_FIELD_KIND_TABLE == add->entries[i].value.kind &&
1215 0 0 if (AMQP_STATUS_OK != res) {
1253 38 0 if (channel_max < 0 || channel_max > UINT16_MAX) {
0 38 if (channel_max < 0 || channel_max > UINT16_MAX) {
1258 0 38 if (frame_max < 0) {
1263 38 0 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
0 38 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
1269 0 38 if (AMQP_STATUS_OK != res) {
1274 0 38 if (AMQP_STATUS_OK != res) {
1280 0 38 if (AMQP_STATUS_OK != res) {
1286 38 0 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
0 38 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
1295 0 38 if (AMQP_STATUS_OK != res) {
1302 0 38 if (!sasl_mechanism_in_list(s->mechanisms, sasl_method)) {
1318 0 38 if (NULL == channel_pool) {
1324 0 38 if (response_bytes.bytes == NULL) {
1357 0 38 if (AMQP_STATUS_OK != res) {
1368 0 38 if (res < 0) {
1380 0 38 if (AMQP_STATUS_OK != res) {
1385 0 38 if (AMQP_CONNECTION_CLOSE_METHOD == method.id) {
1399 38 0 if (server_channel_max != 0 &&
38 0 if (server_channel_max != 0 &&
1400 38 0 (server_channel_max < client_channel_max || client_channel_max == 0)) {
1402 0 0 } else if (server_channel_max == 0 && client_channel_max == 0) {
0 0 } else if (server_channel_max == 0 && client_channel_max == 0) {
1406 38 0 if (server_frame_max != 0 && server_frame_max < client_frame_max) {
0 38 if (server_frame_max != 0 && server_frame_max < client_frame_max) {
1410 38 0 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
0 38 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
1416 0 38 if (res < 0) {
1428 0 38 if (res < 0) {
1444 0 38 if (result.reply_type != AMQP_RESPONSE_NORMAL) {