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

[7.2] tests: fix endian bug in test_typelist #5562

Merged
merged 1 commit into from
Dec 19, 2019
Merged
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
tests: fix endian bug in test_typelist
[7.2 version] Fix a byte-swapping bug that appeared on
big-endian arch but wasn't visible on little-endian.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
  • Loading branch information
Mark Stapp committed Dec 18, 2019
commit 703f865749fda58ce6e88bd9239506df59e8c4e2
9 changes: 5 additions & 4 deletions tests/lib/test_typelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,13 @@ static void ts_hash(const char *text, const char *expect)
unsigned i = 0;
uint8_t hash[32];
char hashtext[65];
uint32_t count;
uint32_t swap_count, count;

count = htonl(list_count(&head));
count = list_count(&head);
swap_count = htonl(count);

SHA256_Init(&ctx);
SHA256_Update(&ctx, &count, sizeof(count));
SHA256_Update(&ctx, &swap_count, sizeof(swap_count));

frr_each (list, &head, item) {
struct {
Expand All @@ -115,7 +116,7 @@ static void ts_hash(const char *text, const char *expect)
};
SHA256_Update(&ctx, &hashitem, sizeof(hashitem));
i++;
assert(i < count);
assert(i <= count);
}
SHA256_Final(hash, &ctx);

Expand Down