From c4bb23c6a63b0d43251fa0aa88f178e2725dd6f6 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Fri, 6 Dec 2013 10:51:58 -0200 Subject: [PATCH] More complete Container#ip_addresses test --- test/tc_lxc_running.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/test/tc_lxc_running.rb b/test/tc_lxc_running.rb index 4761052..f66ccdb 100644 --- a/test/tc_lxc_running.rb +++ b/test/tc_lxc_running.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'tempfile' require './lxc' LXC_TEMPLATE = 'ubuntu' @@ -39,9 +40,22 @@ class TestLXCRunning < Test::Unit::TestCase sleep 1 end assert(ips.length > 0) - @container.attach(:wait => true, - :namespaces => LXC::CLONE_NEWNET | LXC::CLONE_NEWUTS) do - LXC.run_command(['ifconfig', 'eth0']) + path = "/tmp/tc_lxc_running_ifconfig_eth0.#{Process.pid}" + file = File.open(path, 'w+') + 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