Fixed TestProcDiskIO
Added bytesTotal and some more verification.
This commit is contained in:
parent
0d91f7d6a4
commit
f15aa84dfe
|
@ -18,21 +18,35 @@ public class TestProcDiskIO extends SigarTestCase {
|
||||||
procDiskIO = sigar.getProcDiskIO(pid);
|
procDiskIO = sigar.getProcDiskIO(pid);
|
||||||
} catch (SigarException e) {
|
} catch (SigarException e) {
|
||||||
traceln("pid " + pid + ": " + e.getMessage());
|
traceln("pid " + pid + ": " + e.getMessage());
|
||||||
|
// throw e;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long bytesRead = procDiskIO.getBytesRead();
|
||||||
|
long bytesWritten = procDiskIO.getBytesWritten();
|
||||||
|
long bytesTotal = procDiskIO.getBytesTotal();
|
||||||
|
|
||||||
traceln("Pid=" + pid);
|
traceln("Pid=" + pid);
|
||||||
traceln("Bytes Read=" + Sigar.formatSize(procDiskIO.getBytesRead()));
|
traceln("Bytes Read=" + Sigar.formatSize(bytesRead));
|
||||||
traceln("Bytes Written=" + Sigar.formatSize(procDiskIO.getBytesWritten()));
|
traceln("Bytes Written=" + Sigar.formatSize(bytesWritten));
|
||||||
|
traceln("Bytes Total=" + Sigar.formatSize(bytesTotal));
|
||||||
|
|
||||||
|
if (bytesRead != -1 && bytesWritten != -1 && bytesTotal != -1) {
|
||||||
|
assertTrue("Bytes total should equal bytesRead + bytesWritten",
|
||||||
|
(bytesTotal == bytesRead + bytesWritten));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
Sigar sigar = getSigar();
|
Sigar sigar = getSigar();
|
||||||
|
|
||||||
|
boolean caughtException = false;
|
||||||
try {
|
try {
|
||||||
sigar.getProcDiskIO(getInvalidPid());
|
sigar.getProcDiskIO(getInvalidPid());
|
||||||
} catch (SigarException e) {
|
} catch (SigarException e) {
|
||||||
|
caughtException = true;
|
||||||
}
|
}
|
||||||
|
assertTrue("Test on invalid PID should have thrown an exception.", caughtException);
|
||||||
|
|
||||||
long[] pids = sigar.getProcList();
|
long[] pids = sigar.getProcList();
|
||||||
for (int i=0; i<pids.length; i++) {
|
for (int i=0; i<pids.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue