beef++
This commit is contained in:
parent
ef15aa3434
commit
2a460dbff6
|
@ -10,6 +10,22 @@ public class TestProcState extends SigarTestCase {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void traceState(Sigar sigar, long pid) {
|
||||||
|
try {
|
||||||
|
ProcState procState =
|
||||||
|
sigar.getProcState(pid);
|
||||||
|
char state = procState.getState();
|
||||||
|
traceln("[" + procState.getName() + "] " +
|
||||||
|
"pid=" + pid +
|
||||||
|
",state=" + state +
|
||||||
|
",threads=" + procState.getThreads() +
|
||||||
|
",processor=" + procState.getProcessor() +
|
||||||
|
",priority=" + procState.getPriority());
|
||||||
|
} catch (SigarException e) {
|
||||||
|
traceln("pid " + pid + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
Sigar sigar = getSigar();
|
Sigar sigar = getSigar();
|
||||||
|
|
||||||
|
@ -19,14 +35,15 @@ public class TestProcState extends SigarTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcState procState = sigar.getProcState(sigar.getPid());
|
ProcState procState = sigar.getProcState(sigar.getPid());
|
||||||
|
traceState(sigar, sigar.getPid());
|
||||||
|
|
||||||
char state = procState.getState();
|
char state = procState.getState();
|
||||||
traceln(procState.getName() + "=" + state);
|
|
||||||
traceln("threads=" + procState.getThreads());
|
|
||||||
traceln("processor=" + procState.getProcessor());
|
|
||||||
traceln("priority=" + procState.getPriority());
|
|
||||||
|
|
||||||
assertTrue((state == 'R') || (state == 'S'));
|
assertTrue((state == 'R') || (state == 'S'));
|
||||||
|
|
||||||
assertTrue(procState.getName().indexOf("java") != -1);
|
assertTrue(procState.getName().indexOf("java") != -1);
|
||||||
|
|
||||||
|
long[] pids = sigar.getProcList();
|
||||||
|
for (int i=0; i<pids.length; i++) {
|
||||||
|
traceState(sigar, pids[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue