Skip to content

Commit

Permalink
Complete CpuTest#testGetStat case.
Browse files Browse the repository at this point in the history
  • Loading branch information
haosdent committed Jan 9, 2014
1 parent d0540d5 commit 70a472f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/java/me/haosdent/cgroup/subsystem/Cpu.java
Expand Up @@ -34,6 +34,18 @@ public Stat(String statStr) {
this.nrThrottled = Integer.parseInt(splits[1].split(" ")[1]);
this.throttledTime = Integer.parseInt(splits[2].split(" ")[1]);
}

@Override
public boolean equals(Object obj) {
Stat excepted = (Stat) obj;
boolean result = false;
if (this.nrPeriods == excepted.nrPeriods
&& this.nrThrottled == excepted.nrThrottled
&& this.throttledTime == excepted.throttledTime) {
result = true;
}
return result;
}
}

public void setShares(int shares) throws IOException {
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/me/haosdent/cgroup/subsystem/CpuTest.java
Expand Up @@ -51,5 +51,17 @@ public void testSetRtPeriodTime() {}
public void testSetRtRuntimeTime() {}

@Test
public void testGetStat() {}
public void testGetStat() {
try {
Admin admin = new Admin(Constants.SUBSYS_CPU);
Group one = admin.createGroup("one", Constants.SUBSYS_CPU);
Cpu.Stat actual = one.getCpu().getStat();
Cpu.Stat expected = new Cpu.Stat("nr_periods 0\nnr_throttled 0\nthrottled_time 0");
assertEquals(actual, expected);
admin.umount();
} catch (IOException e) {
LOG.error("Create Admin Failed.", e);
assertTrue(false);
}
}
}

0 comments on commit 70a472f

Please sign in to comment.