diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index f359e6a..2d51776 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -993,7 +993,7 @@ container_cgroup_item(VALUE self, VALUE rb_key) static VALUE container_config_item(VALUE self, VALUE rb_key) { - int len1, len2; + int len1, len2, mlines; char *key, *value; struct container_data *data; struct lxc_container *container; @@ -1017,10 +1017,11 @@ container_config_item(VALUE self, VALUE rb_key) rb_raise(Error, "unable to read configuration file"); } rb_config = rb_str_new2(value); + mlines = value[len2-1] == '\n'; free(value); /* Return a list in case of multiple lines */ - return value[len2-1] == '\n' ? rb_str_split(rb_config, "\n") : rb_config; + return mlines ? rb_str_split(rb_config, "\n") : rb_config; } /* diff --git a/test/test_lxc_created.rb b/test/test_lxc_created.rb index 904fe55..e48beb8 100644 --- a/test/test_lxc_created.rb +++ b/test/test_lxc_created.rb @@ -36,6 +36,10 @@ class TestLXCCreated < Test::Unit::TestCase assert_match(/^00:16:3e:/, @container.config_item('lxc.network.0.hwaddr')) end + def test_container_mount_points + assert_instance_of(Array, @container.config_item('lxc.mount.entry')) + end + def test_container_rename new_name = "renamed_#{@name}" renamed = @container.rename(new_name)