Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: fix peer test #57

Open
wants to merge 2 commits into
base: open-source
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions src/test/config_parser_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ init_test1_config(struct lf_config *config)
};

struct lf_config_peer *peer2;
peer1 = malloc(sizeof *peer2);
peer2 = malloc(sizeof *peer2);
lf_parse_isd_as("0-1", &ia);
*peer1 = (struct lf_config_peer){
*peer2 = (struct lf_config_peer){
.isd_as = rte_cpu_to_be_64(ia),
.drkey_protocol = rte_cpu_to_be_16(0),
.ratelimit_option = false,
Expand All @@ -145,7 +145,8 @@ init_test1_config(struct lf_config *config)
config->nb_peers = 3;
config->peers = peer0;
peer0->next = peer1;
peer1->next = NULL;
peer1->next = peer2;
peer2->next = NULL;

return 0;
}
Expand Down Expand Up @@ -439,29 +440,30 @@ check_config(struct lf_config *config, struct lf_config *config_exp)
printf("Error: nb_peers = %ld, expected %ld\n", config->nb_peers,
config_exp->nb_peers);
} else {

peer = config->peers;
peer_exp = config_exp->peers;
for (peer_counter = 0; peer_counter <= config->nb_peers;
++peer_counter) {
if (peer == NULL) {
printf("Error: Found %d peers but nb_peers is %ld",
peer_counter, config->nb_peers);
error_count++;
break;
}
peer_counter = 0;
while (peer != NULL) {
peer_counter++;
if (peer_exp == NULL) {
printf("Fatal: Expected structure is faulty: Found %d peers "
"but nb_peers is %ld",
peer_counter, config->nb_peers);
error_count++;
printf("Error: Found more peers than expected peers");
break;
}
res = check_peer(peer, peer_exp);
if (res != 0) {
error_count += res;
printf("Error: Peer number %d\n", peer_counter);
}
peer = peer->next;
peer_exp = peer_exp->next;
}
if (peer_exp != NULL) {
printf("Error: Found less peers than expected");
}
if (peer_counter != config->nb_peers) {
printf("Error: nb_peers = %ld, list length = %d", config->nb_peers,
peer_counter);
}
}

Expand Down