Begin test/example for popen().

This commit is contained in:
Bob Lantz
2012-04-13 15:50:45 -07:00
parent 5ca91f9ced
commit 237a3c54cf
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/python
"""
This example tests the Host.popen()/pexec() interface
"""
from mininet.net import Mininet
from mininet.node import CPULimitedHost
from mininet.topo import SingleSwitchTopo
from mininet.log import setLogLevel
# from mininet.cli import CLI
from mininet.util import custom
def testpopen(sched='cfs'):
"Test popen() interface"
host = custom( CPULimitedHost, cpu=.2, sched=sched )
net = Mininet( SingleSwitchTopo( 2 ), host=host )
net.start()
h1 = net.get( 'h1' )
# CLI(net)
out, err, code = h1.pexec( 'ifconfig' )
print 'stdout:', out.strip()
print 'stderr:', err.strip()
print 'exit code:', code
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
testpopen('rt')
testpopen('cfs')