1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
//
// Test QmcContext class
//
#include <QTextStream>
#include <qmc_context.h>
QTextStream cerr(stderr);
QTextStream cout(stdout);
int
main(int argc, char* argv[])
{
int fail = 0, sts = 0;
int c;
char buf[MAXHOSTNAMELEN];
QString source;
pmProgname = basename(argv[0]);
while ((c = getopt(argc, argv, "D:?")) != EOF) {
switch (c) {
case 'D':
sts = __pmParseDebug(optarg);
if (sts < 0) {
pmprintf("%s: unrecognized debug flag specification (%s)\n",
pmProgname, optarg);
fail = 1;
}
else {
pmDebug |= sts;
}
break;
case '?':
default:
sts = 1;
break;
}
}
if (fail) {
pmprintf("Usage: %s\n", pmProgname);
pmflush();
exit(1);
}
(void)gethostname(buf, MAXHOSTNAMELEN);
buf[MAXHOSTNAMELEN-1] = '\0';
fprintf(stderr, "*** Simple connection ***\n");
source = QString("oview-short");
QmcSource *src1 = QmcSource::getSource(PM_CONTEXT_ARCHIVE, source, false);
if (src1->status() < 0) {
pmprintf("%s: Error: Unable to create context to \"%s\": %s\n",
pmProgname, (const char *)source.toAscii(),
pmErrStr(src1->status()));
pmflush();
fail = 1;
}
QmcContext context1(src1);
if (context1.handle() < 0) {
pmflush();
fail = 1;
}
context1.dump(cout);
pmID pmid;
uint_t indomIndex;
fprintf(stderr, "\n*** Cacheing of descriptors and indoms ***\n");
QmcDesc *desc;
QmcIndom *indom = NULL;
sts = context1.lookupInDom("hinv.ncpu", indomIndex);
if (sts < 0) {
pmprintf("%s: Error: hinv.ncpu: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
else {
sts = context1.lookupPMID("hinv.ncpu", pmid);
if (sts < 0) {
pmprintf("%s: Error: hinv.ncpu PMID: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
desc = &context1.desc(pmid);
if (desc->status() < 0) {
pmprintf("%s: Error: hinv.ncpu descriptor: %s\n",
pmProgname, pmErrStr(desc->status()));
pmflush();
fail = 1;
}
else if (indomIndex < UINT_MAX) {
pmprintf("%s: Error: hinv.ncpu indom is not NULL\n",
pmProgname);
pmflush();
fail = 1;
}
}
sts = context1.lookupInDom("hinv.cputype", indomIndex);
if (sts < 0) {
pmprintf("%s: Error: hinv.cputype: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
else {
sts = context1.lookupPMID("hinv.cputype", pmid);
if (sts < 0) {
pmprintf("%s: Error: hinv.cputype PMID: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
desc = &context1.desc(pmid);
indom = &context1.indom(indomIndex);
if (desc->status() < 0) {
pmprintf("%s: Error: hinv.cputype descriptor: %s\n",
pmProgname, pmErrStr(desc->status()));
pmflush();
fail = 1;
}
else if (indom->status() < 0) {
pmprintf("%s: Error: hinv.cputype indom: %s\n",
pmProgname, pmErrStr(indom->status()));
pmflush();
fail = 1;
}
}
QmcIndom *indom2;
sts = context1.lookupInDom("hinv.map.cpu", indomIndex);
if (sts < 0) {
pmprintf("%s: Error: hinv.map.cpu: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
else {
sts = context1.lookupPMID("hinv.map.cpu", pmid);
if (sts < 0) {
pmprintf("%s: Error: hinv.map.cpu PMID: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
desc = &context1.desc(pmid);
indom2 = &context1.indom(indomIndex);
if (desc->status() < 0) {
pmprintf("%s: Error: hinv.map.cpu descriptor: %s\n",
pmProgname, pmErrStr(desc->status()));
pmflush();
fail = 1;
}
else if (indom2->status() < 0) {
pmprintf("%s: Error: hinv.map.cpu indom: %s\n",
pmProgname, pmErrStr(indom2->status()));
pmflush();
fail = 1;
}
else if (indom != indom2) {
pmprintf("%s: Error: hinv.cputype and hinv.map.cpu indoms are not the same\n",
pmProgname);
pmflush();
fail = 1;
}
}
sts = context1.lookupInDom("hinv.ncpu", indomIndex);
if (sts < 0) {
pmprintf("%s: Error: hinv.ncpu: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
else {
sts = context1.lookupPMID("hinv.ncpu", pmid);
if (sts < 0) {
pmprintf("%s: Error: hinv.ncpu PMID: %s\n",
pmProgname, pmErrStr(sts));
pmflush();
fail = 1;
}
desc = &context1.desc(pmid);
if (desc->status() < 0) {
pmprintf("%s: Error: hinv.ncpu descriptor: %s\n",
pmProgname, pmErrStr(desc->status()));
pmflush();
fail = 1;
}
else if (indomIndex < UINT_MAX) {
pmprintf("%s: Error: hinv.ncpu indom is not NULL\n",
pmProgname);
pmflush();
fail = 1;
}
}
context1.dump(cout);
fprintf(stderr, "\n*** Bad Context ***\n");
source = QString("no-such-host");
QmcSource *src2 = QmcSource::getSource(PM_CONTEXT_HOST, source);
if (src2->status() >= 0) {
pmprintf("%s: Error: Able to create context to \"%s\": %s\n",
pmProgname, (const char *)source.toAscii(),
pmErrStr(src1->status()));
pmflush();
fail = 1;
}
QmcContext context2(src2);
if (context2.handle() >= 0) {
pmprintf("%s: Error: Created a valid context to an invalid host\n",
pmProgname);
fail = 1;
}
pmflush();
context2.dump(cout);
fprintf(stderr, "\n*** Exiting ***\n");
pmflush();
return fail;
}
|