package net.hyperic.sigar.test;

import net.hyperic.sigar.Sigar;
import net.hyperic.sigar.SigarNotImplementedException;
import net.hyperic.sigar.SigarProxy;
import net.hyperic.sigar.Cpu;

public class TestCpu extends SigarTestCase {

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

    private void checkCpu(Cpu cpu) {
        traceln("User=" + cpu.getUser());
        assertTrue(cpu.getUser() >= 0);

        traceln("Sys=" + cpu.getSys());
        assertTrue(cpu.getSys() >= 0);

        traceln("Idle=" + cpu.getIdle());
        assertTrue(cpu.getIdle() >= 0);

        traceln("Wait=" + cpu.getWait());
        assertTrue(cpu.getWait() >= 0);

        traceln("Total=" + cpu.getTotal());
        assertTrue(cpu.getTotal() >= 0);
    }

    public void testCreate() throws Exception {
        SigarProxy sigar = Sigar.getInstance(); //test reuse

        Cpu cpu = sigar.getCpu();

        traceln("getCpu:");
        checkCpu(cpu);

        try {
            Cpu[] cpuList = sigar.getCpuList();

            for (int i=0; i<cpuList.length; i++) {
                traceln("Cpu " + i + ":");
                checkCpu(cpuList[i]);
            }
        } catch (SigarNotImplementedException e) {
            //ok
        }
    }
}

@@ -347,17 +347,19 @@
 ln(%22User
-=
+...
 %22 + cpu.
@@ -431,17 +431,20 @@
 eln(%22Sys
-=
+....
 %22 + cpu.
@@ -515,17 +515,19 @@
 ln(%22Idle
-=
+...
 %22 + cpu.
@@ -600,17 +600,19 @@
 ln(%22Wait
-=
+...
 %22 + cpu.
@@ -686,17 +686,18 @@
 n(%22Total
-=
+..
 %22 + cpu.
@@ -740,25 +740,24 @@
 getTotal() %3E
-=
  0);%0A    %7D%0A%0A

format output, check total > 0