Permalink
Browse files

Implement test cases in CommonTest.java

  • Loading branch information...
haosdent committed Jan 25, 2014
1 parent f0fd388 commit c0572e62aec48486708f18901fac5bce5b9ce49e
Showing with 71 additions and 7 deletions.
  1. +71 −7 src/test/java/me/haosdent/cgroup/subsystem/CommonTest.java
@@ -1,26 +1,90 @@
package me.haosdent.cgroup.subsystem;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import me.haosdent.cgroup.manage.Admin;
import me.haosdent.cgroup.manage.Group;
import me.haosdent.cgroup.util.Constants;
import me.haosdent.cgroup.util.Threads;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import static org.junit.Assert.*;
public class CommonTest {
private static final Logger LOG = LoggerFactory.getLogger(CommonTest.class);
private static Admin admin;
private static Group root;
private static Group one;
private static Group two;
@BeforeClass
public static void setUpClass() {
try {
admin = new Admin(Constants.SUBSYS_CPU);
root = admin.getRootGroup();
one = admin.createGroup("one", Constants.SUBSYS_CPU);
two = admin.createGroup("two", Constants.SUBSYS_CPU);
} catch (IOException e) {
LOG.error("Create cgroup Failed.", e);
assertTrue(false);
}
}
@AfterClass
public static void tearDownClass() {
try {
admin.umount();
} catch (IOException e) {
LOG.error("Umount cgroup failed.", e);
}
}
@Before
public void setUp() {}
@After
public void tearDown() {}
@Test
public void testAddTask() {}
public void testAddTask() {
try {
int tid = Threads.getThreadId();
one.getCpu().addTask(tid);
} catch (IOException e) {
LOG.error("Add task failed.", e);
assertTrue(false);
}
}
@Test
public void testSetEventControl() {}
public void testSetEventControl() {
//TODO
}
@Test
public void testSetNotifyOnRelease() {}
public void testSetNotifyOnRelease() {
try {
one.getCpu().setNotifyOnRelease(true);
assertTrue(one.getCpu().isNotifyOnRelease());
} catch (IOException e) {
LOG.error("Set notify_on_release failed.", e);
assertTrue(false);
}
}
@Test
public void testSetReleaseAgent() {}
public void testSetReleaseAgent() {
try {
String excepted = "echo 0";
one.getCpu().setReleaseAgent(excepted);
String actual = one.getCpu().getReleaseAgent();
assertEquals(actual, excepted);
} catch (IOException e) {
LOG.error("Set release_agent failed.", e);
assertTrue(false);
}
}
}

0 comments on commit c0572e6

Please sign in to comment.