[lxc-devel] [PATCH] lua: fix return value of attach() method

Dwight Engen dwight.engen at oracle.com
Mon Nov 17 17:33:38 UTC 2014


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 at oracle.com>
---
 src/lua-lxc/core.c           |    2 +-
 src/lua-lxc/test/apitest.lua |    9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/lua-lxc/core.c b/src/lua-lxc/core.c
index 8734128..2e073d8 100644
--- a/src/lua-lxc/core.c
+++ b/src/lua-lxc/core.c
@@ -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;
 }
 
diff --git a/src/lua-lxc/test/apitest.lua b/src/lua-lxc/test/apitest.lua
index f299b6a..8da4336 100755
--- a/src/lua-lxc/test/apitest.lua
+++ b/src/lua-lxc/test/apitest.lua
@@ -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
@@ -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...")
 
@@ -330,6 +336,7 @@ test_config_network(0)
 test_container_start()
 test_container_started()
 
+test_container_attach()
 test_container_cgroup()
 test_container_cmd()
 
-- 
1.7.1



More information about the lxc-devel mailing list