Folks,
I have attached a patch that provides additional INFO when the test
fails in the calloc portion of the test. The second part of the patch
fixes a cut and paste error(I think). It is suppose to be testing malloc
at this point but it still called calloc. So I replaced it with the
malloc call.
I do have a fundamental question about this test. The way that this
test verifies the free(pm1)
As you can see in the patch I added a TINFO to get the values of pm1
pm2.
<snip>
> /* check out calloc/free */
> if((pm2=pm1=(char *)calloc(MEMSIZE,1)) == NULL) {
>
> tst_resm(TFAIL, "calloc - alloc of %dMB failed",
> MEMSIZE/1024/1024);
> tst_exit();
> }
>
> for(i=0; i<MEMSIZE; i++)
> if(*pm2++ != 0) {
> tst_resm(TFAIL, "calloc returned non zero memory");
> tst_exit();
> }
>
> pm2=pm1;
> for(i=0; i<MEMSIZE; i++)
> *pm2++ = 'X';
> pm2=pm1;
> for(i=0; i<MEMSIZE; i++)
> if(*pm2++ != 'X') {
> tst_resm(TFAIL, "could not write/verify memory ");
> tst_exit();
> }
>
> pm2=pm1;
> free(pm1);
>
> if((pm1=(char *)calloc(MEMSIZE,1)) == NULL) {
> tst_resm(TFAIL, "calloc did not alloc memory ");
> tst_exit();
> }
>
> if(pm1 != pm2) { <---*** This is not a
> guaranty ***
> tst_resm(TINFO, "pm1=%p pm2=%p ", pm1,pm2);
> tst_resm(TFAIL, "free did not dealloc memory ");
> tst_exit();
> }
> free(pm1);
>
> tst_resm(TPASS,"calloc - calloc of %uMB of memory succeeded",
> MEMSIZE/1024/1024);
</snip>
The issue I have is that after the free(pm1), when it does the calloc
the second time there is no guaranty that pm1 will equal pm2. It does
99% of the time. But I have seen this fail on ppc64 intermittently.
Thanks,
Jeff
--- ./ltp-full-20070731/testcases/kernel/mem/mem/mem02.c.orig
+++ ./ltp-full-20070731/testcases/kernel/mem/mem/mem02.c
@@ -105,6 +105,7 @@ int main() /***** BEGINNING OF MAIN.
}
if(pm1 != pm2) {
+ tst_resm(TINFO, "pm1=%p pm2=%p ", pm1,pm2);
tst_resm(TFAIL, "free did not dealloc memory ");
tst_exit();
}
@@ -133,7 +134,7 @@ int main() /***** BEGINNING OF MAIN.
pm2=pm1;
free(pm1);
- if((pm1=(char *)calloc(MEMSIZE,1)) == NULL) {
+ if((pm1=(char *)malloc(MEMSIZE)) == NULL) {
tst_resm(TFAIL, "malloc did not alloc memory ");
tst_exit();
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list