MemoryErrorTestMacros

Wrap memory manager macros into error generating macros which use test_errortimer_t to return an error at a certain time step.  Every macro expects an test_errortimer_t as first parameter.

In case KONFIG_UNITTEST is not defined, every TEST macro calls the corresponding ALLOC_MM, RESIZE_MM, or FREE_MM macro.

Summary
MemoryErrorTestMacrosWrap memory manager macros into error generating macros which use test_errortimer_t to return an error at a certain time step.
CopyrightThis program is free software.
Files
C-kern/api/test/mm/err_macros.hHeader file MemoryErrorTestMacros.
C-kern/test/mm/err_macros.cImplementation file MemoryErrorTestMacros impl.
Functions
allocate-test
ALLOC_ERR_MMAllocates a new memory block with error.
RESIZE_ERR_MMResizes memory block with error.
FREE_ERR_MMFrees memory block with error.
test
unittest_test_mm_mm_testTest <test_t> functionality.

Copyright

This program is free software.  You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

Author

© 2013 Jörg Seebohn

Files

C-kern/api/test/mm/err_macros.h

C-kern/test/mm/err_macros.c

Implementation file MemoryErrorTestMacros impl.

Functions

Summary
allocate-test
ALLOC_ERR_MMAllocates a new memory block with error.
RESIZE_ERR_MMResizes memory block with error.
FREE_ERR_MMFrees memory block with error.
test
unittest_test_mm_mm_testTest <test_t> functionality.

allocate-test

ALLOC_ERR_MM

#define ALLOC_ERR_MM(
   errtimer,
   size,
   mblock
) ( __extension__ ({ err = process_testerrortimer(errtimer); if (! err) err = ALLOC_MM(size, mblock); err ; }))

Allocates a new memory block with error.  See also <malloc_mmimpl>. errtimer is of type test_errortimer_t.

RESIZE_ERR_MM

#define RESIZE_ERR_MM(
   errtimer,
   newsize,
   mblock
) ( __extension__ ({ err = process_testerrortimer(errtimer); if (! err) err = RESIZE_MM(newsize, mblock); err ; }))

Resizes memory block with error.  See also <mresize_mmimpl>. errtimer is of type test_errortimer_t.

FREE_ERR_MM

#define FREE_ERR_MM(
   errtimer,
   mblock
) ( __extension__ ({ err = FREE_MM(mblock) ; if (! err) err = process_testerrortimer(errtimer) ; err ; }))

Frees memory block with error.  See also <mfree_mmimpl>. errtimer is of type test_errortimer_t.

test

unittest_test_mm_mm_test

int unittest_test_mm_mm_test(void)

Test <test_t> functionality.

struct test_errortimer_t
Holds a timer value and an error code.
Wrap memory manager macros into error generating macros which use test_errortimer_t to return an error at a certain time step.
Implements MemoryErrorTestMacros.
#define ALLOC_ERR_MM(
   errtimer,
   size,
   mblock
) ( __extension__ ({ err = process_testerrortimer(errtimer); if (! err) err = ALLOC_MM(size, mblock); err ; }))
Allocates a new memory block with error.
#define RESIZE_ERR_MM(
   errtimer,
   newsize,
   mblock
) ( __extension__ ({ err = process_testerrortimer(errtimer); if (! err) err = RESIZE_MM(newsize, mblock); err ; }))
Resizes memory block with error.
#define FREE_ERR_MM(
   errtimer,
   mblock
) ( __extension__ ({ err = FREE_MM(mblock) ; if (! err) err = process_testerrortimer(errtimer) ; err ; }))
Frees memory block with error.
int unittest_test_mm_mm_test(void)
Test test_t functionality.
#define KONFIG_UNITTEST
Define this in your Makefile to include additional code for testing single components.
#define ALLOC_MM(size,
mblock) malloc_mm(mm_maincontext(), size, mblock)
Allocates a new memory block.
#define RESIZE_MM(newsize,
mblock) mresize_mm(mm_maincontext(), newsize, mblock)
Resizes memory block.
#define FREE_MM(mblock) mfree_mm(mm_maincontext(), mblock)
Frees memory block.
Close