1
/* ``The contents of this file are subject to the Erlang Public License,
2
* Version 1.1, (the "License"); you may not use this file except in
3
* compliance with the License. You should have received a copy of the
4
* Erlang Public License along with this software. If not, it can be
5
* retrieved via the world wide web at http://www.erlang.org/.
7
* Software distributed under the License is distributed on an "AS IS"
8
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
* the License for the specific language governing rights and limitations
12
* The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
* Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
* AB. All Rights Reserved.''
19
#include "testcase_driver.h"
20
#include "allocator_test.h"
32
return "mseg_clear_cache";
36
testcase_run(TestCaseState_t *tcs)
43
testcase_skipped(tcs, "No mseg_alloc; nothing to test");
45
seg = (seg_t *) testcase_alloc(sizeof(seg_t)*(MAX_SEGS+1));
49
for (i = 0; i <= MAX_SEGS; i++)
54
for (i = 0; i < MAX_SEGS; i++) {
56
seg[i].ptr = MSEG_ALLOC(&seg[i].size);
57
ASSERT(tcs, seg[i].ptr);
58
ASSERT(tcs, seg[i].size >= 1000);
62
testcase_printf(tcs, "MSEG_NO() = %lu\n", n);
64
ASSERT(tcs, n >= MAX_SEGS);
66
testcase_printf(tcs, "Deallocating half of the segments\n");
67
for (i = MAX_SEGS-1; i >= MAX_SEGS/2; i--) {
68
MSEG_DEALLOC(seg[i].ptr, seg[i].size);
73
testcase_printf(tcs, "MSEG_NO() = %lu\n", n);
75
ASSERT(tcs, n >= MAX_SEGS/2);
77
n = MSEG_CACHE_SIZE();
78
testcase_printf(tcs, "MSEG_CACHE_SIZE() = %lu\n", n);
81
testcase_printf(tcs, "MSEG_CLEAR_CACHE()\n");
84
n = MSEG_CACHE_SIZE();
85
testcase_printf(tcs, "MSEG_CACHE_SIZE() = %lu\n", n);
92
testcase_cleanup(TestCaseState_t *tcs)
95
seg_t *seg = (seg_t *) tcs->extra;
97
for (i = 0; seg[i].ptr; i++)
98
MSEG_DEALLOC(seg[i].ptr, seg[i].size);
99
testcase_free((void *) seg);