コード例 #1
0
ファイル: test_functions.c プロジェクト: j000/libcgroup
/**
 * Tests the cgroup_add_controller() and cgroup_free_controller() wrapper
 * apis under different scenarios
 * @param the test number
 */
void test_cgroup_add_free_controller(int i)
{
	struct cgroup *cgroup1 = NULL, *cgroup2 = NULL;
	struct cgroup_controller *cgctl1, *cgctl2;

	/* Test with a Null cgroup */
	cgctl1 = cgroup_add_controller(cgroup1, "cpu");
	if (!cgctl1)
		message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
	else
		message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);

	cgroup1 = cgroup_new_cgroup("testgroup");
	cgctl1 = cgroup_add_controller(cgroup1, "cpuset");
	if (cgctl1)
		message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
	else
		message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);

	cgctl2 = cgroup_add_controller(cgroup1, "cpu");
	if (cgctl2)
		message(i++, PASS, "add_controller()", 0, info[NOMESSAGE]);
	else
		message(i++, FAIL, "add_controller()", -1, info[NOMESSAGE]);

	cgroup_free(&cgroup1);
	cgroup_free_controllers(cgroup2);
}
コード例 #2
0
ファイル: lua_cgroup.c プロジェクト: iavael/ulatencyd
/*
static int l_cgroup_get_controller (lua_State *L)
{
  struct cgroup_controller *cc, *cc2 = NULL;
  struct cgroup *cg = check_cgroup(L, 1);
  const char *name = luaL_checkstring(L, 2);

  if (cg) {
    cc = cgroup_get_controller (cg, name);
    if(cc) {
      cc2 = push_cgroup_controller(L);
      cc2 = cc;
    }
    return 1;
  }

  lua_pushstring(L, "Not a valid cgroup");
  lua_error (L);
  return 0;
}
*/
static int l_cgroup_free_controllers (lua_State *L)
{
  struct u_cgroup *cg = check_cgroup(L, 1);
  if (cg) {
    cgroup_free_controllers (cg->group);
    lua_pushboolean(L, 1);
    return 1;
  }
  lua_pushstring(L, "Not a valid cgroup");
  lua_error (L);
  return 0;
}