Malloc tests
Gedare Bloom
gedare at rtems.org
Thu Jan 6 20:54:46 UTC 2022
On Tue, Jan 4, 2022 at 6:10 PM zack leung <zakthertemsdev at gmail.com> wrote:
>
> Helllo ,
> I'm working on a patch for malloc_get_usable size right now so far i have
> this test case for malloc, I just make sure that the value is null and i
> just malloc an int and then i make a call to the function malloc_usable
> size and then i compare it like this.
>
> static void test_malloc_usablesize( void ){
> int * a = malloc(sizeof(int));
> rtems_test_assert((int) malloc_usable_size(a) == 12);
> free (a);
>
> int * b = NULL;
> rtems_test_assert( 0 == malloc_usable_size(b));
> free(b);
>
>
> }
> Is there a good amount of storage to allocate? Also I heard someone made a
I think that this test case is quite brittle. The "usable size" will
depend on the implementation details of malloc, and the conditions of
the heap when the allocation request gets made. I don't have better
ideas however for how to test the correctness of the usable_size
function. Maybe there are certain sequences of malloc/free calls that
can be relied upon to give you deterministic sizes of allocations?
> formatter for rtems source files. Can someone tell me how to use it and if
> it is on the main branch?
This was part of a gsoc project last year. We haven't quite made the
switch over to it and the associated coding style I think, but you can
find the code via
https://devel.rtems.org/wiki/GSoC/2021#StudentsSummerofCodeTrackingTable
the student was Meh Mbeh Ida Delphine
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list