package net.hyperic.sigar.test;

import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarException;
import net.hyperic.sigar.ProcMem;

public class TestProcMem extends SigarTestCase {

    public TestProcMem(String name) {
        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();

        try {
            sigar.getProcMem(getInvalidPid());
        } catch (SigarException e) {
        }

        ProcMem procMem = sigar.getProcMem(sigar.getPid());

        traceln("Size=" + Sigar.formatSize(procMem.getSize()));
        traceln("Vsize=" + Sigar.formatSize(procMem.getVsize()));
        traceln("Resident=" + Sigar.formatSize(procMem.getResident()));
        traceln("Share=" + Sigar.formatSize(procMem.getShare()));
        traceln("Rss=" + Sigar.formatSize(procMem.getRss()));
        assertTrue(procMem.getSize() > 0);
        // XXX vsize, resident, share, rss
    }
}

@@ -259,30 +259,50 @@
    p
-ublic
+rivate
  void t
-estCreate(
+raceMem(Sigar sigar, long pid
 ) th
@@ -330,32 +330,23 @@
     
-Sigar sigar = getSigar()
+ProcMem procMem
 ;%0A%0A 
@@ -369,16 +369,26 @@
         
+ procMem =
  sigar.g
@@ -401,23 +401,11 @@
 Mem(
-getInvalidPid()
+pid
 );%0A 
@@ -452,72 +452,121 @@
     
-%7D%0A%0A
     
-    ProcMem procMem = sigar.getProcMem(sigar.getPid()
+traceln(%22pid %22 + pid + %22: %22 + e.getMessage());%0A            return;%0A        %7D%0A%0A        traceln(%22Pid=%22 + pid
 );%0A
-%0A
     
@@ -899,16 +899,18 @@
         
+//
 assertTr
@@ -984,11 +984,345 @@
 ss%0A    %7D
+%0A%0A    public void testCreate() throws Exception %7B%0A        Sigar sigar = getSigar();%0A%0A        try %7B%0A            sigar.getProcMem(getInvalidPid());%0A        %7D catch (SigarException e) %7B%0A        %7D%0A%0A        long%5B%5D pids = sigar.getProcList();%0A        for (int i=0; i%3Cpids.length; i++) %7B%0A            traceMem(sigar, pids%5Bi%5D);%0A        %7D%0A    %7D
 %0A%7D%0A

test all pids