call ProcArgs and ProcExe for every pid

This commit is contained in:
Doug MacEachern 2004-08-01 03:00:54 +00:00
parent 1fbabe5767
commit 3401932ba5
3 changed files with 54 additions and 13 deletions

View File

@ -51,5 +51,18 @@ public class TestProcArgs extends SigarTestCase {
} catch (SigarNotImplementedException e) {
//ok; might not happen on win32
}
long[] pids = sigar.getProcList();
for (int i=0; i<pids.length; i++) {
try {
String[] args = sigar.getProcArgs(pids[i]);
traceln("pid=" + pids[i]);
for (int j=0; j<args.length; j++) {
traceln(" " + j + "=>" + args[j] + "<==");
}
} catch (SigarException e) {
}
}
}
}

View File

@ -13,6 +13,26 @@ public class TestProcExe extends SigarTestCase {
super(name);
}
private void printExe(Sigar sigar, long pid) throws SigarException {
traceln("\npid=" + pid);
try {
ProcExe exe = sigar.getProcExe(pid);
String cwd = exe.getCwd();
traceln("cwd='" + cwd + "'");
//assertTrue(new File(cwd).isDirectory());
File exeFile = new File(exe.getName());
traceln("exe='" + exe.getName() + "'");
//assertTrue(exeFile.exists());
} catch (SigarNotImplementedException e) {
//ok
}
}
public void testCreate() throws Exception {
Sigar sigar = getSigar();
@ -25,22 +45,30 @@ public class TestProcExe extends SigarTestCase {
ProcExe exe = sigar.getProcExe(sigar.getPid());
File exeFile = new File(exe.getName());
String cwd = exe.getCwd();
traceln("cwd='" + cwd + "'");
assertTrue(new File(cwd).isDirectory());
traceln("exe='" + exe.getName() + "'");
assertTrue(exeFile.exists());
//win32 has .exe
assertTrue(exeFile.getName().startsWith("java"));
String cwd = exe.getCwd();
traceln("cwd='" + cwd + "'");
//XXX win32 as exe but not cwd
if (cwd.length() != 0) {
assertTrue(new File(cwd).isDirectory());
}
} catch (SigarNotImplementedException e) {
//ok
}
long[] pids = sigar.getProcList();
//go through all just to make sure no crashes
for (int i=0; i<pids.length; i++) {
try {
printExe(sigar, pids[i]);
} catch (SigarException e) {
} catch (junit.framework.AssertionFailedError e) {
}
}
}
}

View File

@ -44,11 +44,11 @@ public class TestProcModules extends SigarTestCase {
long[] pids = sigar.getProcList();
for (int i=0; i<pids.length; i++) {
try {
printModules(sigar, pids[i]);
} catch (SigarException e) {
traceln(pids[i] + ": " + e.getMessage());
}
try {
printModules(sigar, pids[i]);
} catch (SigarException e) {
traceln(pids[i] + ": " + e.getMessage());
}
}
}
}