Skip to content

Commit

Permalink
Remove useless test in config/parse unit test.
Browse files Browse the repository at this point in the history
Since the packSize field is 7 bits, it could never fail the check for > 127.

The compiler will catch any packs that are larger than 7 bits and then the pack size will need to be adjusted. For now just adjust the comment to reflect what the test does and give a clearer indication of what to do when a pack grows too large.
  • Loading branch information
dwsteele committed May 6, 2022
1 parent 77311a9 commit 53bfdbc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions test/src/module/config/parseTest.c
Expand Up @@ -51,21 +51,19 @@ testRun(void)
TEST_RESULT_UINT(sizeof(ParseRuleOption), TEST_64BIT() ? 40 : 28, "ParseRuleOption size");
TEST_RESULT_UINT(sizeof(ParseRuleOptionDeprecate), TEST_64BIT() ? 16 : 12, "ParseRuleOptionDeprecate size");

// Each pack must be <= 127 bytes because only one byte is used for the size. If this check fails then the size of
// PARSE_RULE_PACK_SIZE must be increased. There would be little cost of increasing this as a preventative measure but a
// check would still be required, so may as well be as efficient as possible.
// Each pack must be <= 127 bytes because only one varint byte is used for the size. The compiler will catch packs larger
// than 127 bytes and in that case PARSE_RULE_PACK_SIZE must be increased. There would be little cost to increasing this as
// a preventative measure but a check would still be required, so may as well be as efficient as possible.
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("check that no packs are > 127 bytes");
TEST_TITLE("gather pack size statistics");

unsigned int packOver127 = 0;
unsigned int packTotal = 0;
size_t packMaxSize = 0;
const char *packMaxName = NULL;
size_t packTotalSize = 0;

for (unsigned int optIdx = 0; optIdx < CFG_OPTION_TOTAL; optIdx++)
{
packOver127 += parseRuleOption[optIdx].packSize > 127;
packTotal += parseRuleOption[optIdx].pack != NULL;
packTotalSize += parseRuleOption[optIdx].packSize;

Expand All @@ -76,7 +74,6 @@ testRun(void)
}
}

TEST_RESULT_UINT(packOver127, 0, "no packs over 127 bytes");
TEST_LOG_FMT("total size of option packs is %zu bytes", packTotalSize);
TEST_LOG_FMT("avg option pack size is %0.2f bytes", (float)packTotalSize / (float)packTotal);
TEST_LOG_FMT("max option pack size is '%s' at %zu bytes", packMaxName, packMaxSize);
Expand Down

0 comments on commit 53bfdbc

Please sign in to comment.