This commit is contained in:
Doug MacEachern 2005-11-23 03:09:23 +00:00
parent ef15aa3434
commit 2a460dbff6
1 changed files with 23 additions and 6 deletions

View File

@ -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]);
}
} }
} }