def test_unpack(self): """Test if unpack fails""" controller = Controller(address='unix:abstract=abcde') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(True) with pytest.raises(ConnectionReturnError): controller.switch(1, 2)
def test_unpack(self): """Test if unpack fails""" controller = Controller(address='unix:abstract=abcde') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(True) with pytest.raises(ConnectionReturnError): controller.switch(1, 2)
def do_switch(self, line): try: val = self.SWITCH_MAPPING[line.lower()] except KeyError: print "Invalid" return c = Controller() c.establish_connection() print c.switch(self.SWITCH_MAPPING[line.split()[0]], int(line.split()[1]))
def do_switch(self, line): try: val = self.SWITCH_MAPPING[line.lower()] except KeyError: print "Invalid" return c = Controller() c.establish_connection() print c.switch(self.SWITCH_MAPPING[line.split()[0]], int(line.split()[1]))
def switch(self, channel, port, index): """Create Controller object and call switch method""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() sources = TestSources(3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) preview = PreviewSinks(3001) preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(PATH, 3001, out_file) time.sleep(3) controller = Controller() res = controller.switch(channel, port) print res time.sleep(3) video_sink.terminate() sources.terminate_video() preview.terminate() serv.terminate(1) finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def switch(self, channel, port, index): """Create Controller object and call switch method""" for _ in range(self.NUM): serv = Server(path=PATH, video_format="debug") try: serv.run() sources = TestSources(3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) preview = PreviewSinks(3001) preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(3001, out_file) time.sleep(3) controller = Controller() res = controller.switch(channel, port) print(res) time.sleep(3) video_sink.terminate() sources.terminate_video() preview.terminate() serv.terminate(1) finally: serv.terminate_and_output_status(cov=True)
def switch(self, channel, port, index): """Create Controller object and call switch method""" for _ in range(self.NUM): serv = Server(path=PATH) try: serv.run() sources = TestSources(3000) sources.new_test_video(pattern=4) sources.new_test_video(pattern=5) preview = PreviewSinks(3001) preview.run() out_file = "output-{0}.data".format(index) video_sink = VideoFileSink(3001, out_file) time.sleep(3) controller = Controller() res = controller.switch(channel, port) print res time.sleep(3) video_sink.terminate() sources.terminate_video() preview.terminate() serv.terminate(1) finally: if serv.proc: poll = serv.proc.poll() print self.__class__ if poll == -11: print "SEGMENTATION FAULT OCCURRED" print "ERROR CODE - {0}".format(poll) serv.terminate(1) log = open('server.log') print log.read()
def test_action_fails(self): """Test what happens if the requested action fails""" controller = Controller(address='unix:abstract=abcde') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(return_variant=True, should_fail=True) assert controller.switch(Controller.VIDEO_CHANNEL_A, 2) is False
def test_action_fails(self): """Test what happens if the requested action fails""" controller = Controller(address='unix:abstract=abcde') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection( return_variant=True, should_fail=True) assert controller.switch(Controller.VIDEO_CHANNEL_A, 2) is False
def test_normal_unpack(self): """Test if valid""" controller = Controller(address='unix:abstract=abcdef') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(False) assert controller.switch(1, 2) is True
def test_normal_unpack(self): """Test if valid""" controller = Controller(address='unix:abstract=abcdef') controller.establish_connection = Mock(return_value=None) controller.connection = MockConnection(False) assert controller.switch(1, 2) is True
cmd.split(), stdout=tempf, stderr=tempf, bufsize=-1, shell=False) params = [(65,3004), (65, 3003)] i = 0 p = psutil.Process(s.pid) cpu_usage_file = open("cpu.log", "w") while 1: # print(i) cpu = p.get_cpu_percent(interval=INTERVAL) mem = p.get_memory_percent() print(cpu) print(mem) cpu_usage_file.write(str(cpu) + '\n' + str(mem) + '\n') controller.switch(params[i][0], params[i][1]) # time.sleep(1) i+=1 i%=2 #end all sources.terminate_audio() vid1.terminate() vid2.terminate() s.terminate() finally: if s.proc: s.kill()
stdout=tempf, stderr=tempf, bufsize=-1, shell=False) params = [(65,3004), (65, 3003)] i = 0 p = psutil.Process(s.pid) cpu_usage_file = open("cpu.log", "w") while 1: # print i cpu = p.get_cpu_percent(interval=INTERVAL) mem = p.get_memory_percent() print cpu print mem cpu_usage_file.write(str(cpu) + '\n' + str(mem) + '\n') controller.switch(params[i][0], params[i][1]) # time.sleep(1) i+=1 i%=2 #end all sources.terminate_audio() vid1.terminate() vid2.terminate() s.terminate() finally: if s.proc: s.kill()