Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/vmalloc/tresize.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1999-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "vmtest.h"
21
22
/* This tests the sequential placement of blocks by Vmbest
23
** and its effect on vmresize(). This test should be looked
24
** at every time the allocation algorithm in Vmbest changes.
25
*/
26
27
tmain()
28
{
29
Vmalloc_t *vm;
30
Void_t *dt[10];
31
int i;
32
33
if(!(vm = vmopen(Vmdcsbrk, Vmbest, 0)) )
34
terror("Couldn't open region");
35
36
if(!(dt[0] = vmalloc(vm, 32)) )
37
terror("vmalloc failed1");
38
if(!(dt[1] = vmalloc(vm, 32)) )
39
terror("vmalloc failed2");
40
if(!(dt[2] = vmalloc(vm, 32)) )
41
terror("vmalloc failed3");
42
vmfree(vm,dt[1]);
43
vmfree(vm,dt[2]);
44
if(vmresize(vm, dt[0], 60, 1) != dt[0])
45
terror("bestresize did not extend correctly");
46
if(vmresize(vm, dt[0], 32, 1) != dt[0])
47
terror("bestresize did not reduce correctly2");
48
49
if(!(dt[1] = vmalloc(vm, 16)) )
50
terror("vmalloc failed4");
51
if(!(dt[2] = vmalloc(vm, 16)) )
52
terror("vmalloc failed5");
53
if(!(dt[3] = vmalloc(vm, 24)) )
54
terror("vmalloc failed6");
55
if(!(dt[4] = vmalloc(vm, 32)) )
56
terror("vmalloc failed7");
57
if(!(dt[5] = vmalloc(vm, 40)) )
58
terror("vmalloc failed8");
59
vmfree(vm,dt[2]);
60
vmfree(vm,dt[3]);
61
vmfree(vm,dt[4]);
62
vmfree(vm,dt[5]);
63
if(vmresize(vm,dt[1],80,0) != dt[1])
64
terror("vmresize failed");
65
vmfree(vm,dt[1]);
66
67
if(vmresize(vm, dt[0], 120, 1) != dt[0])
68
terror("vmresize did not extend correctly3");
69
70
texit(0);
71
}
72
73