Branch Coverage

amqp_socket.c
Criterion Covered Total %
branch 165 330 50.0


line true false branch
123 0 535 assert(self);
124 0 535 assert(self->klass->send);
130 0 783 assert(self);
131 0 783 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 37 36 if (self) {
156 0 37 assert(self->klass->delete);
162 0 780 assert(self);
163 0 780 assert(self->klass->get_sockfd);
174 44 394 assert(event == AMQP_SF_POLLIN || event == AMQP_SF_POLLOUT);
0 44 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 7 if (-1 == fd) {
292 525 10 if (res > 0) {
295 519 6 if (0 == len_left) {
301 6 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 0 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 37 0 for (; current != end; start = current + 1) {
590 0 37 if (NULL == current) {
595 37 0 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 485 if (res < 0) {
690 392 391 if (res < 0) {
692 0 392 if (-1 == fd) {
705 388 4 if (AMQP_STATUS_OK == res) {
716 0 391 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) {
764 0 2 if (AMQP_STATUS_OK != res) {
778 465 394 while (amqp_data_in_buffer(state)) {
781 0 465 if (AMQP_STATUS_OK != res) {
785 5 460 if (AMQP_FRAME_HEARTBEAT == decoded_frame->frame_type) {
790 455 5 if (decoded_frame->frame_type != 0) {
798 0 394 if (AMQP_STATUS_TIMER_FAILURE == res) {
800 2 392 } else if (AMQP_STATUS_TIMEOUT == res) {
806 1 1 if (AMQP_STATUS_OK != res) {
818 4 389 if (AMQP_STATUS_TIMEOUT == res) {
819 0 4 if (amqp_time_equal(deadline, state->next_recv_heartbeat)) {
822 4 0 } else if (amqp_time_equal(deadline, timeout_deadline)) {
824 0 0 } else if (amqp_time_equal(deadline, state->next_send_heartbeat)) {
830 0 389 } 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 59 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 59 if (AMQP_STATUS_OK != res) {
926 59 0 if (channel == decoded_frame->channel) {
930 0 0 if (res != AMQP_STATUS_OK) {
948 0 121 if (AMQP_STATUS_OK != res) {
952 20 101 if (state->first_queued_frame != NULL) {
955 1 19 if (state->first_queued_frame == NULL) {
975 0 74 if (res != AMQP_STATUS_OK) {
980 0 74 if (AMQP_STATUS_OK != res) {
984 74 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
74 0 if (AMQP_FRAME_METHOD != frame.frame_type ||
985 0 74 expected_channel != frame.channel ||
1031 710 10 while (*list != 0) {
1032 664 46 if (*list == expected) {
1050 2 300 if (status < 0) {
1059 0 300 if (status < 0) {
1060 0 0 if (status == AMQP_STATUS_TIMEOUT) {
1074 300 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
300 0 if (!((frame.frame_type == AMQP_FRAME_METHOD) &&
1075 5 295 (((frame.channel == channel) &&
1077 0 5 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 295 5 result.reply_type =
1131 0 54 if (res != AMQP_STATUS_OK) {
1149 0 211 if (res != AMQP_STATUS_OK) {
1160 206 5 if (state->most_recent_api_result.reply_type == AMQP_RESPONSE_NORMAL) {
1182 0 37 assert(base != NULL);
1183 0 37 assert(result != NULL);
1184 0 37 assert(pool != NULL);
1186 0 37 if (NULL == add) {
1195 0 37 if (NULL == temp_result.entries) {
1199 222 37 for (i = 0; i < base->num_entries; ++i) {
1203 0 37 for (i = 0; i < add->num_entries; ++i) {
1206 0 0 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 37 0 if (channel_max < 0 || channel_max > UINT16_MAX) {
0 37 if (channel_max < 0 || channel_max > UINT16_MAX) {
1258 0 37 if (frame_max < 0) {
1263 37 0 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
0 37 if (heartbeat < 0 || heartbeat > UINT16_MAX) {
1269 0 37 if (AMQP_STATUS_OK != res) {
1274 0 37 if (AMQP_STATUS_OK != res) {
1280 0 37 if (AMQP_STATUS_OK != res) {
1286 37 0 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
0 37 if ((s->version_major != AMQP_PROTOCOL_VERSION_MAJOR) ||
1295 0 37 if (AMQP_STATUS_OK != res) {
1302 0 37 if (!sasl_mechanism_in_list(s->mechanisms, sasl_method)) {
1318 0 37 if (NULL == channel_pool) {
1324 0 37 if (response_bytes.bytes == NULL) {
1357 0 37 if (AMQP_STATUS_OK != res) {
1368 0 37 if (res < 0) {
1380 0 37 if (AMQP_STATUS_OK != res) {
1385 0 37 if (AMQP_CONNECTION_CLOSE_METHOD == method.id) {
1399 37 0 if (server_channel_max != 0 &&
37 0 if (server_channel_max != 0 &&
1400 37 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 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) {
1410 37 0 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
0 37 if (server_heartbeat != 0 && server_heartbeat < client_heartbeat) {
1416 0 37 if (res < 0) {
1428 0 37 if (res < 0) {
1444 0 37 if (result.reply_type != AMQP_RESPONSE_NORMAL) {