<s> from __future__ import print_function <EOL> import unittest <EOL> from nose . tools import ok_ , eq_ , timed , nottest <EOL> from subprocess import Popen , PIPE , STDOUT <EOL> import time <EOL> from mininet . net import Mininet <EOL> from mininet . node import RemoteController , OVSKernelSwitch <EOL> TIMEOUT = <NUM_LIT> <EOL> RYU_HOST = '<STR_LIT:127.0.0.1>' <EOL> RYU_PORT = <NUM_LIT> <EOL> PYTHON_BIN = '<STR_LIT>' <EOL> RYU_MGR = '<STR_LIT>' <EOL> class OVS12KernelSwitch ( OVSKernelSwitch ) : <EOL> """<STR_LIT>""" <EOL> def start ( self , controllers ) : <EOL> super ( OVS12KernelSwitch , self ) . start ( controllers ) <EOL> self . cmd ( '<STR_LIT>' , self , <EOL> "<STR_LIT>" ) <EOL> class TestWithOVS12 ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . mn = Mininet ( ) <EOL> c = cls . mn . addController ( controller = RemoteController , <EOL> ip = RYU_HOST , port = RYU_PORT ) <EOL> c . start ( ) <EOL> s1 = cls . mn . addSwitch ( '<STR_LIT>' , cls = OVS12KernelSwitch ) <EOL> s1 . start ( cls . mn . controllers ) <EOL> h1 = cls . mn . addHost ( '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> link = cls . mn . addLink ( h1 , s1 ) <EOL> s1 . attach ( link . intf2 ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> cls . mn . stop ( ) <EOL> @ timed ( TIMEOUT ) <EOL> def test_add_flow_v10 ( self ) : <EOL> app = '<STR_LIT>' <EOL> self . _run_ryu_manager_and_check_output ( app ) <EOL> @ timed ( TIMEOUT ) <EOL> def test_request_reply_v12 ( self ) : <EOL> app = '<STR_LIT>' <EOL> self . _run_ryu_manager_and_check_output ( app ) <EOL> @ timed ( TIMEOUT ) <EOL> def test_add_flow_v12_actions ( self ) : <EOL> app = '<STR_LIT>' <EOL> self . _run_ryu_manager_and_check_output ( app ) <EOL> @ timed ( TIMEOUT ) <EOL> def test_add_flow_v12_matches ( self ) : <EOL> app = '<STR_LIT>' <EOL> self . _run_ryu_manager_and_check_output ( app ) <EOL> @ nottest <EOL> def test_of_config ( self ) : <EOL> pass <EOL> def _run_ryu_manager_and_check_output ( self , app ) : <EOL> cmd = [ PYTHON_BIN , RYU_MGR , app ] <EOL> p = Popen ( cmd , stdout = PIPE , stderr = STDOUT ) <EOL> while True : <EOL> if p . poll ( ) is not None : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> line = p . stdout . readline ( ) . strip ( ) <EOL> if line == '<STR_LIT>' : <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> continue <EOL> print ( "<STR_LIT>" % line ) <EOL> if line . find ( '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> ok_ ( line . find ( '<STR_LIT>' ) != - <NUM_LIT:1> ) <EOL> p . terminate ( ) <EOL> p . communicate ( ) <EOL> break <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
