From 3401932ba5f70ad620ca52b53424982482c0a965 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sun, 1 Aug 2004 03:00:54 +0000 Subject: [PATCH] call ProcArgs and ProcExe for every pid --- .../net/hyperic/sigar/test/TestProcArgs.java | 13 ++++++ .../net/hyperic/sigar/test/TestProcExe.java | 44 +++++++++++++++---- .../hyperic/sigar/test/TestProcModules.java | 10 ++--- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java b/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java index cee57fd8..ee774d3f 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcArgs.java @@ -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" + args[j] + "<=="); + } + } catch (SigarException e) { + } + } } } diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java b/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java index 65e7ef85..5749249e 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcExe.java @@ -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