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

Stéphane Graber stgraber at ubuntu.com
Mon Nov 17 19:46:05 UTC 2014


On Mon, Nov 17, 2014 at 12:33:38PM -0500, Dwight Engen wrote:
> 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>

Acked-by: Stéphane Graber <stgraber at ubuntu.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
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20141117/a76fede2/attachment.sig>


More information about the lxc-devel mailing list