'Test ifconfig and ps on h1 and s1'

def testHostCommands(self):

    p = pexpect.spawn('mn')
    p.expect(self.prompt)
    interfaces = ['h1-eth0', 's1-eth1', '[^-](eth|en)\\w*\\d', 'lo', self.prompt]
    p.sendline('h1    ifconfig    -a')
    ifcount = 0
    while True:
        index = p.expect(interfaces)
        if ((index == 0) or (index == 3)):
            ifcount += 1
        elif (index == 1):
            self.fail('s1    interface    displayed    in    "h1    ifconfig"')
        elif (index == 2):
            self.fail('eth0    displayed    in    "h1    ifconfig"')
        else:
            break
    self.assertEqual(ifcount, 2, 'Missing    interfaces    on    h1')
    p.sendline('s1    ifconfig    -a')
    ifcount = 0
    while True:
        index = p.expect(interfaces)
        if (index == 0):
            self.fail('h1    interface    displayed    in    "s1    ifconfig"')
        elif ((index == 1) or (index == 2) or (index == 3)):
            ifcount += 1
        else:
            break
    self.assertTrue((ifcount >= 3), 'Missing    interfaces    on    s1')
    p.sendline("h1    ps    -a    |    egrep    -v    'ps|grep'")
    p.expect(self.prompt)
    h1Output = p.before
    p.sendline("s1    ps    -a    |    egrep    -v    'ps|grep'")
    p.expect(self.prompt)
    s1Output = p.before
    h1Output = h1Output.split('\n')[1:]
    s1Output = s1Output.split('\n')[1:]
    diffs = set(h1Output).difference(set(s1Output))
    self.assertTrue((len(diffs) <= 2), ('h1    and    s1    "ps"    output    differ    too    much:    %s' % diffs))
    p.sendline('exit')
    p.wait()
