mirror of
https://github.com/intel/isa-l.git
synced 2024-12-13 09:52:56 +01:00
raid: [test] fix memory leak
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
This commit is contained in:
parent
c183961175
commit
54d1153a61
@ -73,9 +73,9 @@ void rand_buffer(unsigned char *buf, long buffer_size)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, k, ret, fail = 0;
|
||||
void *buffs[TEST_SOURCES + 2];
|
||||
void *buffs[TEST_SOURCES + 2] = { NULL };
|
||||
char c;
|
||||
char *tmp_buf[TEST_SOURCES + 2];
|
||||
char *tmp_buf[TEST_SOURCES + 2] = { NULL };
|
||||
int serr, lerr;
|
||||
|
||||
printf("Test pq_check_test %d sources X %d bytes\n", TEST_SOURCES, TEST_LEN);
|
||||
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||
if (ret == 0) {
|
||||
fail++;
|
||||
printf("\nfail corrupt zero buffer test j=%d, i=%d\n", j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[j])[i] = 0; // un-corrupt buffer
|
||||
}
|
||||
@ -158,7 +158,7 @@ int main(int argc, char *argv[])
|
||||
printf
|
||||
("\nFail rand test with un-corrupted buffer j=%d, i=%d\n",
|
||||
j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
c = ((char *)buffs[j])[i];
|
||||
((char *)buffs[j])[i] = c ^ 1; // corrupt buffer
|
||||
@ -166,7 +166,7 @@ int main(int argc, char *argv[])
|
||||
if (ret == 0) { // Check it now fails
|
||||
fail++;
|
||||
printf("\nfail corrupt buffer test j=%d, i=%d\n", j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[j])[i] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
||||
if (ret != 0) { // Should pass
|
||||
printf("\nfail rand fixed len test %d sources\n", j);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
c = ((char *)buffs[i])[k];
|
||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
("\nfail rand fixed len test corrupted buffer %d sources\n",
|
||||
j);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[i])[k] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -237,7 +237,7 @@ int main(int argc, char *argv[])
|
||||
("\nfail rand var src, len test %d sources, len=%d\n",
|
||||
j, k);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
tmp = (char *)buffs[serr];
|
||||
@ -251,7 +251,7 @@ int main(int argc, char *argv[])
|
||||
"%d sources, len=%d, ret=%d\n", j, k,
|
||||
ret);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[serr])[lerr] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -293,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
"offset: %d, len: %d, ret: %d\n", i,
|
||||
TEST_LEN - i, ret);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
tmp_buf[serr][lerr] = c;
|
||||
@ -309,6 +309,9 @@ int main(int argc, char *argv[])
|
||||
if (fail == 0)
|
||||
printf("Pass\n");
|
||||
|
||||
exit:
|
||||
for (i = 0; i < TEST_SOURCES + 2; i++)
|
||||
aligned_free(buffs[i]);
|
||||
return fail;
|
||||
|
||||
}
|
||||
|
@ -65,9 +65,9 @@ int dump(unsigned char *buf, int len)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, k, ret, fail = 0;
|
||||
void *buffs[TEST_SOURCES + 2]; // Pointers to src and dest
|
||||
char *tmp_buf[TEST_SOURCES + 2];
|
||||
int i, j, k, ret = 0, fail = 0;
|
||||
void *buffs[TEST_SOURCES + 2] = { NULL }; // Pointers to src and dest
|
||||
char *tmp_buf[TEST_SOURCES + 2] = { NULL };
|
||||
|
||||
printf("Test pq_gen_test ");
|
||||
|
||||
@ -79,7 +79,8 @@ int main(int argc, char *argv[])
|
||||
ret = posix_memalign(&buf, 32, TEST_LEN);
|
||||
if (ret) {
|
||||
printf("alloc error: Fail");
|
||||
return 1;
|
||||
fail = 1;
|
||||
goto exit;
|
||||
}
|
||||
buffs[i] = buf;
|
||||
}
|
||||
@ -102,7 +103,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail zero test %d\n", fail);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -126,7 +127,7 @@ int main(int argc, char *argv[])
|
||||
for (t = TEST_SOURCES; t < TEST_SOURCES + 2; t++)
|
||||
dump(buffs[t], 15);
|
||||
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -142,7 +143,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail rand test %d sources\n", j);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -164,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
if (fail > 0) {
|
||||
printf("fail rand test %d sources, len=%d, fail="
|
||||
"%d, ret=%d\n", j, k, fail, ret);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
@ -187,7 +188,7 @@ int main(int argc, char *argv[])
|
||||
if (fail > 0) {
|
||||
printf("fail end test - offset: %d, len: %d, fail: %d, "
|
||||
"ret: %d\n", k, TEST_LEN - k, fail, ret);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -199,5 +200,8 @@ int main(int argc, char *argv[])
|
||||
if (!fail)
|
||||
printf(" done: Pass\n");
|
||||
|
||||
exit:
|
||||
for (i = 0; i < TEST_SOURCES + 2; i++)
|
||||
aligned_free(buffs[i]);
|
||||
return fail;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ void rand_buffer(unsigned char *buf, long buffer_size)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, k, ret, fail = 0;
|
||||
void *buffs[TEST_SOURCES + 1];
|
||||
void *buffs[TEST_SOURCES + 1] = { NULL };
|
||||
char c;
|
||||
int serr, lerr;
|
||||
char *tmp_buf[TEST_SOURCES + 1];
|
||||
@ -67,7 +67,8 @@ int main(int argc, char *argv[])
|
||||
void *buf;
|
||||
if (posix_memalign(&buf, 16, TEST_LEN)) {
|
||||
printf("alloc error: Fail");
|
||||
return 1;
|
||||
fail = 1;
|
||||
goto exit;
|
||||
}
|
||||
buffs[i] = buf;
|
||||
}
|
||||
@ -99,7 +100,7 @@ int main(int argc, char *argv[])
|
||||
if (ret == 0) {
|
||||
fail++;
|
||||
printf("\nfail corrupt buffer test j=%d, i=%d\n", j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[j])[i] = 0; // un-corrupt buffer
|
||||
}
|
||||
@ -138,7 +139,7 @@ int main(int argc, char *argv[])
|
||||
printf
|
||||
("\nFail rand test with un-corrupted buffer j=%d, i=%d\n",
|
||||
j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
c = ((char *)buffs[j])[i];
|
||||
((char *)buffs[j])[i] = c ^ 1; // corrupt buffer
|
||||
@ -146,7 +147,7 @@ int main(int argc, char *argv[])
|
||||
if (ret == 0) { // Check it now fails
|
||||
fail++;
|
||||
printf("\nfail corrupt buffer test j=%d, i=%d\n", j, i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[j])[i] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -172,7 +173,7 @@ int main(int argc, char *argv[])
|
||||
if (ret != 0) { // Should pass
|
||||
printf("\nfail rand test %d sources\n", j);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
c = ((char *)buffs[i])[k];
|
||||
@ -184,7 +185,7 @@ int main(int argc, char *argv[])
|
||||
("\nfail rand test corrupted buffer %d sources\n",
|
||||
j);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[i])[k] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -215,7 +216,7 @@ int main(int argc, char *argv[])
|
||||
if (ret != 0) { // Should pass
|
||||
printf("\nfail rand test %d sources\n", j);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
c = ((char *)buffs[serr])[lerr];
|
||||
@ -227,7 +228,7 @@ int main(int argc, char *argv[])
|
||||
"%d sources, len=%d, ret=%d\n", j, k,
|
||||
ret);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
((char *)buffs[serr])[lerr] = c; // un-corrupt buffer
|
||||
}
|
||||
@ -254,7 +255,7 @@ int main(int argc, char *argv[])
|
||||
if (ret != 0) {
|
||||
printf("fail end test - offset: %d, len: %d\n", i, TEST_LEN - i);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
// Test bad data
|
||||
for (serr = 0; serr < TEST_SOURCES + 1; serr++) {
|
||||
@ -269,7 +270,7 @@ int main(int argc, char *argv[])
|
||||
"offset: %d, len: %d, ret: %d\n", i,
|
||||
TEST_LEN - i, ret);
|
||||
fail++;
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
tmp_buf[serr][lerr] = c;
|
||||
@ -285,6 +286,10 @@ int main(int argc, char *argv[])
|
||||
if (fail == 0)
|
||||
printf("Pass\n");
|
||||
|
||||
exit:
|
||||
for (i = 0; i < TEST_SOURCES + 1; i++)
|
||||
aligned_free(buffs[i]);
|
||||
|
||||
return fail;
|
||||
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ void rand_buffer(unsigned char *buf, long buffer_size)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, j, k, ret, fail = 0;
|
||||
void *buffs[TEST_SOURCES + 1];
|
||||
char *tmp_buf[TEST_SOURCES + 1];
|
||||
void *buffs[TEST_SOURCES + 1] = { NULL };
|
||||
char *tmp_buf[TEST_SOURCES + 1] = { NULL };
|
||||
|
||||
printf("Test xor_gen_test ");
|
||||
|
||||
@ -66,7 +66,8 @@ int main(int argc, char *argv[])
|
||||
ret = posix_memalign(&buf, 32, TEST_LEN);
|
||||
if (ret) {
|
||||
printf("alloc error: Fail");
|
||||
return 1;
|
||||
fail = 1;
|
||||
goto exit;
|
||||
}
|
||||
buffs[i] = buf;
|
||||
}
|
||||
@ -84,7 +85,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail zero test");
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -100,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail rand test %d\n", fail);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -116,7 +117,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail rand test %d sources\n", j);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -138,7 +139,7 @@ int main(int argc, char *argv[])
|
||||
if (fail > 0) {
|
||||
printf("fail rand test %d sources, len=%d, ret=%d\n", j, k,
|
||||
fail);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
@ -159,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (fail > 0) {
|
||||
printf("fail end test - offset: %d, len: %d\n", i, TEST_LEN - i);
|
||||
return 1;
|
||||
goto exit;
|
||||
}
|
||||
#ifdef TEST_VERBOSE
|
||||
putchar('.');
|
||||
@ -170,5 +171,9 @@ int main(int argc, char *argv[])
|
||||
if (!fail)
|
||||
printf(" done: Pass\n");
|
||||
|
||||
exit:
|
||||
for (i = 0; i < TEST_SOURCES + 1; i++)
|
||||
aligned_free(buffs[i]);
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user