More complete Container#ip_addresses test

This commit is contained in:
Andre Nathan 2013-12-06 10:51:58 -02:00
parent 057f8b3390
commit c4bb23c6a6

View file

@ -1,4 +1,5 @@
require 'test/unit' require 'test/unit'
require 'tempfile'
require './lxc' require './lxc'
LXC_TEMPLATE = 'ubuntu' LXC_TEMPLATE = 'ubuntu'
@ -39,9 +40,22 @@ class TestLXCRunning < Test::Unit::TestCase
sleep 1 sleep 1
end end
assert(ips.length > 0) assert(ips.length > 0)
@container.attach(:wait => true, path = "/tmp/tc_lxc_running_ifconfig_eth0.#{Process.pid}"
:namespaces => LXC::CLONE_NEWNET | LXC::CLONE_NEWUTS) do file = File.open(path, 'w+')
LXC.run_command(['ifconfig', 'eth0']) begin
opts = {
:wait => true,
:stdout => file,
:namespaces => LXC::CLONE_NEWNET | LXC::CLONE_NEWUTS,
}
@container.attach(opts) do
LXC.run_command('ifconfig eth0')
end
file.rewind
assert_match(/^eth0\s+Link\sencap:Ethernet\s+HWaddr\s/, file.readline)
ensure
file.close
File.unlink(path)
end end
end end
end end