Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/tests/vmalloc/tstat.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
tmain()
23
{
24
Vmalloc_t* vm;
25
Void_t* addr;
26
Vmstat_t st;
27
28
if(!(vm = vmopen(Vmdcheap,Vmbest,0)) )
29
terror("Can't open Vmbest region");
30
if(!(addr = vmalloc(vm,123)) )
31
terror("vmalloc failed1");
32
if(vmstat(vm,&st) < 0 )
33
terror("vmstat failed11");
34
if(st.n_busy != 1 || st.s_busy < 123 || st.s_busy > (123+32))
35
terror("Wrong statistics1");
36
if(vmfree(vm,addr) < 0)
37
terror("vmfree failed1");
38
if(vmstat(vm,&st) < 0 )
39
terror("vmstat failed12");
40
if(st.n_busy != 0 || st.s_busy > 0 )
41
terror("Wrong statistics12");
42
vmclose(vm);
43
44
if(!(vm = vmopen(Vmdcheap,Vmpool,0)) )
45
terror("Can't open Vmpool region");
46
if(!(addr = vmalloc(vm,13)) )
47
terror("vmalloc failed2");
48
if(vmstat(vm,&st) < 0 )
49
terror("vmstat failed21");
50
if(st.n_busy != 1 || st.s_busy != 13 )
51
terror("Wrong statistics2");
52
if(vmfree(vm,addr) < 0)
53
terror("vmfree failed2");
54
if(vmstat(vm,&st) < 0 )
55
terror("vmstat failed22");
56
if(st.n_busy != 0 || st.s_busy > 0 )
57
terror("Wrong statistics22");
58
vmclose(vm);
59
60
if(!(vm = vmopen(Vmdcheap,Vmlast,0)) )
61
terror("Can't open Vmlast region");
62
if(!(addr = vmalloc(vm,123)) )
63
terror("vmalloc failed3");
64
if(vmstat(vm,&st) < 0 )
65
terror("vmstat failed31");
66
if(st.n_busy != 1 || st.s_busy < 123 )
67
terror("Wrong statistics3");
68
if(vmfree(vm,addr) < 0)
69
terror("vmfree failed3");
70
if(vmstat(vm,&st) < 0 )
71
terror("vmstat failed32");
72
if(st.n_busy != 0 || st.s_busy > 0 )
73
terror("Wrong statistics32");
74
vmclose(vm);
75
76
if(!(vm = vmopen(Vmdcheap,Vmdebug,0)) )
77
terror("Can't open Vmdebug region");
78
if(!(addr = vmalloc(vm,123)) )
79
terror("vmalloc failed4");
80
if(vmstat(vm,&st) < 0 )
81
terror("vmstat failed41");
82
if(st.n_busy != 1 || st.s_busy != 123 )
83
terror("Wrong statistics4");
84
if(vmfree(vm,addr) < 0)
85
terror("vmfree failed4");
86
if(vmstat(vm,&st) < 0 )
87
terror("vmstat failed42");
88
if(st.n_busy != 0 || st.s_busy > 0 )
89
terror("Wrong statistics42");
90
vmclose(vm);
91
92
texit(0);
93
}
94
95