1 /* ``Licensed under the Apache License, Version 2.0 (the "License");
2  * you may not use this file except in compliance with the License.
3  * You may obtain a copy of the License at
4  *
5  *     http://www.apache.org/licenses/LICENSE-2.0
6  *
7  * Unless required by applicable law or agreed to in writing, software
8  * distributed under the License is distributed on an "AS IS" BASIS,
9  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10  * See the License for the specific language governing permissions and
11  * limitations under the License.
12  *
13  * The Initial Developer of the Original Code is Ericsson Utvecklings AB.
14  * Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
15  * AB. All Rights Reserved.''
16  *
17  *     $Id$
18  */
19 
20 #include "testcase_driver.h"
21 #include "allocator_test.h"
22 
23 char *
testcase_name(void)24 testcase_name(void)
25 {
26     return "basic";
27 }
28 
29 void
testcase_run(TestCaseState_t * tcs)30 testcase_run(TestCaseState_t *tcs)
31 {
32     Carrier_t *c;
33     Block_t *blk;
34     void *p;
35     Allctr_t *a = START_ALC("basic_", 0, NULL);
36     tcs->extra = (void *) a;
37 
38     ASSERT(tcs, a);
39 
40     p = ALLOC(a, 10);
41     ASSERT(tcs, p);
42     p = REALLOC(a, p, 15);
43     ASSERT(tcs, p);
44     FREE(a, p);
45 
46     c = FIRST_MBC(a);
47     ASSERT(tcs, !NEXT_C(c));
48     blk = MBC_TO_FIRST_BLK(a, c);
49     ASSERT(tcs, IS_LAST_BLK(blk));
50     ASSERT(tcs, IS_FREE_BLK(blk));
51 
52     STOP_ALC((Allctr_t *) a);
53     tcs->extra = NULL;
54 
55 }
56 
57 void
testcase_cleanup(TestCaseState_t * tcs)58 testcase_cleanup(TestCaseState_t *tcs)
59 {
60     if (tcs->extra)
61 	STOP_ALC((Allctr_t *) tcs->extra);
62 }
63 
64 ERL_NIF_INIT(basic, testcase_nif_funcs, testcase_nif_init,
65 	     NULL, NULL, NULL);
66