def test_kill(self, monkeypatch): """Test kill ServerProcessError""" serv = Server(path='abc') serv.proc = Mock() monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError)) with pytest.raises(ServerProcessError): serv.kill()
def test_kill_fail(self): """Test when kill fails""" serv = Server(path=PATH) serv.proc = 1 serv.pid = -300 with pytest.raises(ServerProcessError): serv.kill()
def test_kill(self, monkeypatch): """Test kill ServerProcessError""" serv = Server(path='abc') serv.proc = Mock() monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError)) with pytest.raises(ServerProcessError): serv.kill()
def test_kill_fail(self): """Test when kill fails""" serv = Server(path=PATH) serv.proc = 1 serv.pid = -300 with pytest.raises(ServerProcessError): serv.kill()
def main(args): print("running server") serv = Server(path=args.path) serv.run() wait(5) print("running source pattern=1") sources = TestSources(video_port=3000, audio_port=4000) sources.new_test_video(pattern=1) wait(5) print("running gst-switch-ui") # the & will run this in the background so control returns # and we can bring up the 2nd source # Replaced call with subprocess.Popen. SwitchUi = subprocess.Popen("gst-switch-ui &",shell=True) wait(5) print("running source pattern=18") sources.new_test_video(pattern=18) raw_input("hit enter:") # Replaced pkill call with Popen.kill subprocess.Popen.kill(SwitchUi) serv.kill()
def test_kill_cov(self, monkeypatch): """Test kill and gcov_flush ServerProcessError""" serv = Server(path='abc') serv.proc = MockProcess(False) serv.gcov_flush = Mock() serv.make_coverage = Mock() monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError)) with pytest.raises(ServerProcessError): serv.kill(True)
def test_kill_cov(self, monkeypatch): """Test kill and gcov_flush ServerProcessError""" serv = Server(path='abc') serv.proc = MockProcess(False) serv.gcov_flush = Mock() serv.make_coverage = Mock() monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError)) with pytest.raises(ServerProcessError): serv.kill(True)
def test_video_sources(self): """Test video sources""" video_port = 3000 serv = Server(PATH, video_port=video_port) try: serv.run() preview = PreviewSinks() preview.run() for i in range(self.NUM): self.add_video_sources(i * 10 + 1, video_port) preview.terminate() serv.terminate() finally: if serv.proc: serv.kill()
def test_video_sources(self): """Test video sources""" video_port = 3000 serv = Server(PATH, video_port=video_port) try: serv.run() preview = PreviewSinks() preview.run() for i in range(self.NUM): self.add_video_sources(i * 10 + 1, video_port) preview.terminate() serv.terminate() finally: if serv.proc: serv.kill()
def test_audio_sources(self): """Test audio sources""" audio_port = 4000 serv = Server(PATH, audio_port=audio_port) try: serv.run() preview = PreviewSinks() preview.run() for i in range(self.NUM): self.add_audio_sources(i * 10 + 1, audio_port) preview.terminate() serv.terminate() finally: if serv.proc: serv.kill()
def test_audio_sources(self): """Test audio sources""" audio_port = 4000 serv = Server(PATH, audio_port=audio_port) try: serv.run() preview = PreviewSinks() preview.run() for i in range(self.NUM): self.add_audio_sources(i * 10 + 1, audio_port) preview.terminate() serv.terminate() finally: if serv.proc: serv.kill()
def test_normal_kill(self, monkeypatch): """Test kill when normally called""" serv = Server(path='abc') serv.proc = Mock() monkeypatch.setattr(os, 'kill', Mock()) res = serv.kill() assert res is True assert serv.proc is None
def test_normal_kill(self, monkeypatch): """Test kill when normally called""" serv = Server(path='abc') serv.proc = Mock() monkeypatch.setattr(os, 'kill', Mock()) res = serv.kill() assert res is True assert serv.proc is None
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()
def test_no_process_kill(self): """Test when no process exists and kill is called""" serv = Server(path=PATH) with pytest.raises(ServerProcessError): serv.kill()
def test_no_process_kill(self): """Test when no process exists and kill is called""" serv = Server(path=PATH) with pytest.raises(ServerProcessError): serv.kill()
sources.new_test_video(timeoverlay=True) controller = Controller() controller.establish_connection() res = [] tests_get = [controller.get_compose_port, controller.get_encode_port, controller.get_audio_port, controller.get_preview_ports, ] test_set_composite_mode = controller.set_composite_mode # testing random 10 modes for x in tests_get: print x.__name__, x() time.sleep(1) modes = [0, 3, 2, 1, 0, 1, 2, 3, 0] for mode in modes: print 'composite mode=', mode test_set_composite_mode(mode) time.sleep(0.6) output.terminate() sources.terminate_video() sources.terminate_audio() s.terminate() finally: if s.proc: s.kill()