Skip to content

Commit

Permalink
lua: fix return value of attach() method
Browse files Browse the repository at this point in the history
Add simple test case for attach() method. Add assert for return value
from create() method which also returns a boolean.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
  • Loading branch information
Dwight Engen authored and stgraber committed Nov 24, 2014
1 parent 0dcbd62 commit 4086cea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lua-lxc/core.c
Expand Up @@ -397,7 +397,7 @@ static int container_attach(lua_State *L)
return 1;
}

lua_pushboolean(L, !!(c->attach_run_wait(c, NULL, argv[0], (const char**)argv)));
lua_pushboolean(L, !(c->attach_run_wait(c, NULL, argv[0], (const char**)argv)));
return 1;
}

Expand Down
9 changes: 8 additions & 1 deletion src/lua-lxc/test/apitest.lua
Expand Up @@ -119,7 +119,7 @@ function test_container_create()
end
end
log(0, "%-20s %s", "Creating rootfs using:", optarg["t"])
container:create(optarg["t"])
assert(container:create(optarg["t"]) == true)
assert(container:defined() == true)
assert(container:name() == optarg["n"])
end
Expand Down Expand Up @@ -206,6 +206,12 @@ function test_container_in_cfglist(should_find)
end
end

function test_container_attach()
log(0, "Test attach...")
assert(container:running() == true)
assert(container:attach("/bin/ps") == true)
end

function test_container_cgroup()
log(0, "Test get/set cgroup items...")

Expand Down Expand Up @@ -330,6 +336,7 @@ test_config_network(0)
test_container_start()
test_container_started()

test_container_attach()
test_container_cgroup()
test_container_cmd()

Expand Down

0 comments on commit 4086cea

Please sign in to comment.