test-mempool-alloconly.c revision c77400ca35fef6a4ddb760c02706143ceda45a49
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
{
unsigned int i;
for (i = 0; i < size; i++) {
if (bytes[i] != b)
return FALSE;
}
return TRUE;
}
void test_mempool_alloconly(void)
{
#define SENTRY_SIZE 32
#define SENTRY_CHAR 0xDE
#define PMALLOC_MAX_COUNT 128
unsigned int i, j, k;
char *sentry;
test_begin("mempool_alloconly");
for (i = 0; i < 64; i++) {
for (j = 1; j <= 128; j++) {
/* make sure p_malloc() doesn't overwrite unallocated
data in data stack. parts of the code relies on
this. */
for (k = 1; k <= PMALLOC_MAX_COUNT; k++) {
}
for (k = 1; k <= PMALLOC_MAX_COUNT; k++)
pool_unref(&pool);
}
}
test_end();
}
{
return FATAL_TEST_FAILURE;
switch(stage) {
case 0: /* forbidden size */
test_begin("fatal_mempool_alloconly");
return FATAL_TEST_FAILURE;
case 1: /* logically impossible size */
return FATAL_TEST_FAILURE;
case 2: /* physically impossible size */
return FATAL_TEST_FAILURE;
/* Continue with other tests as follows:
case 3:
something_fatal();
return FATAL_TEST_FAILURE;
*/
}
/* Either our tests have finished, or the test suite has got confused. */
pool_unref(&pool);
test_end();
return FATAL_TEST_FINISHED;
}