'Test running user switch in its own namespace'

def testOwnNamespace(self):

    p = pexpect.spawn('mn    --innamespace    --switch    user')
    p.expect(self.prompt)
    interfaces = ['h1-eth0', 's1-eth1', '[^-]eth0', 'lo', self.prompt]
    p.sendline('s1    ifconfig    -a')
    ifcount = 0
    while True:
        index = p.expect(interfaces)
        if ((index == 1) or (index == 3)):
            ifcount += 1
        elif (index == 0):
            self.fail('h1    interface    displayed    in    "s1    ifconfig"')
        elif (index == 2):
            self.fail('eth0    displayed    in    "s1    ifconfig"')
        else:
            break
    self.assertEqual(ifcount, 2, 'Missing    interfaces    on    s1')
    p.sendline('pingall')
    p.expect('(\\d+)%    dropped')
    dropped = int(p.match.group(1))
    self.assertEqual(dropped, 0, 'pingall    failed')
    p.expect(self.prompt)
    p.sendline('exit')
    p.wait()
