refactor(ci): prevent memory leak message without memory leak

This commit is contained in:
Jakob Hasse 2023-11-17 12:15:46 +08:00
parent 82a110c7f3
commit 7781bfae79

View File

@ -32,11 +32,13 @@ void unity_utils_check_leak(unsigned int before_free,
unsigned int leaked = (size_t)(free_delta * -1); unsigned int leaked = (size_t)(free_delta * -1);
printf("MALLOC_CAP_%s %s leak: Before %u bytes free, After %u bytes free (delta %u)\n", if (leaked > 0) {
type, printf("MALLOC_CAP_%s %s leak: Before %u bytes free, After %u bytes free (delta %u)\n",
leaked <= threshold ? "potential" : "critical", type,
before_free, after_free, leaked); leaked <= threshold ? "potential" : "critical",
fflush(stdout); before_free, after_free, leaked);
fflush(stdout);
}
TEST_ASSERT_MESSAGE(leaked <= threshold, "The test leaked too much memory"); TEST_ASSERT_MESSAGE(leaked <= threshold, "The test leaked too much memory");
} }