mem: [test] fix memory leak

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
This commit is contained in:
Pablo de Lara 2023-12-15 09:16:56 +00:00 committed by Tomasz Kantecki
parent a3e260436a
commit c83771eeec

View File

@ -50,7 +50,7 @@ int main(int argc, char *argv[])
{
int i, j, sign;
long long r, l;
void *buf;
void *buf = NULL;
unsigned char *a;
int failures = 0, ret_neg = 1;
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
if (failures) {
printf("Fail large buf test\n");
return failures;
goto exit;
}
#ifdef TEST_VERBOSE
putchar('.');
@ -83,7 +83,7 @@ int main(int argc, char *argv[])
if (failures) {
printf("Fail alloc test\n");
free(newbuf);
return failures;
goto exit;
}
free(newbuf);
}
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
failures |= isal_zero_detect(buf, i);
if (failures) {
printf("Fail len=%d\n", i);
return failures;
goto exit;
}
}
#ifdef TEST_VERBOSE
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
if (failures) {
printf("Fail:\n");
return failures;
goto exit;
}
#ifdef TEST_VERBOSE
putchar('.');
@ -118,7 +118,8 @@ int main(int argc, char *argv[])
ret_neg = isal_zero_detect(a, TEST_MEM);
if (ret_neg == 0) {
printf("Fail on not detect\n");
return -1;
failures = -1;
goto exit;
}
a[TEST_MEM / 2] = 0;
#ifdef TEST_VERBOSE
@ -132,7 +133,8 @@ int main(int argc, char *argv[])
ret_neg = isal_zero_detect(a, TEST_MEM);
if (ret_neg == 0) {
printf("Fail on not detect offsets %d, %d\n", i, j);
return -1;
failures = -1;
goto exit;
}
a[i] = 0;
}
@ -153,7 +155,8 @@ int main(int argc, char *argv[])
ret_neg = isal_zero_detect(a, TEST_MEM);
if (ret_neg == 0) {
printf("Fail on not detect rand %d, e=%lld\n", i, r);
return -1;
failures = -1;
goto exit;
}
a[r] = 0;
}
@ -169,7 +172,8 @@ int main(int argc, char *argv[])
ret_neg = isal_zero_detect(a, TEST_MEM);
if (ret_neg == 0) {
printf("Fail on not detect rand offset=%d, idx=%d\n", i, j);
return -1;
failures = -1;
goto exit;
}
a[TEST_MEM - i] = 0;
}
@ -185,7 +189,7 @@ int main(int argc, char *argv[])
if (failures) {
printf("Fail on detect non-zero with l=%lld\n", l);
return -1;
goto exit;
}
a[i] = 1;
@ -193,11 +197,13 @@ int main(int argc, char *argv[])
if ((i < l) && (ret_neg == 0)) {
printf("Fail on non-zero buffer l=%lld err=%d\n", l, i);
return -1;
failures = -1;
goto exit;
}
if ((i >= l) && (ret_neg != 0)) {
printf("Fail on bad pass detect l=%lld err=%d\n", l, i);
return -1;
failures = -1;
goto exit;
}
a[i] = 0;
}
@ -215,7 +221,8 @@ int main(int argc, char *argv[])
ret_neg = isal_zero_detect(a, l);
if (ret_neg == 0) {
printf("Fail on not detect rand %d, l=%lld, e=%lld\n", i, l, r);
return -1;
failures = -1;
goto exit;
}
a[r] = 0;
}
@ -239,12 +246,14 @@ int main(int argc, char *argv[])
if ((r < l) && (ret_neg == 0)) {
printf("Fail on non-zero rand buffer %d, l=%lld, e=%lld\n", i, l, r);
return -1;
failures = -1;
goto exit;
}
if ((r >= l) && (ret_neg != 0)) {
printf("Fail on bad pass zero detect rand %d, l=%lld, e=%lld\n", i, l,
r);
return -1;
failures = -1;
goto exit;
}
a[r] = 0;
@ -254,6 +263,7 @@ int main(int argc, char *argv[])
#endif
fflush(0);
exit:
aligned_free(buf);
printf(failures == 0 ? " Pass\n" : " Fail\n");
return failures;