def wrap(): # start and assert started [start_managed_process(p) for p in processes] assert all(get_running()[name].exitcode is None for name in processes) # call the function try: func() # assert processes are still started assert all(get_running()[name].exitcode is None for name in processes) finally: # kill and assert all stopped [kill_managed_process(p) for p in processes] assert len(get_running()) == 0
def wrap(): if not DID_INIT: test_manager_prepare() # start and assert started [start_managed_process(p) for p in processes] assert all(get_running()[name].exitcode is None for name in processes) # call the function func() # assert processes are still started assert all(get_running()[name].exitcode is None for name in processes) # kill and assert all stopped [kill_managed_process(p) for p in processes] assert len(get_running()) == 0
def wrap(*args, **kwargs): # start and assert started for n, p in enumerate(processes): start_managed_process(p) if n < len(processes)-1: time.sleep(init_time) assert all(get_running()[name].exitcode is None for name in processes) # call the function try: func(*args, **kwargs) # assert processes are still started assert all(get_running()[name].exitcode is None for name in processes) finally: # kill and assert all stopped for p in processes: kill_managed_process(p) assert len(get_running()) == 0
def test_thread(): global return_code proc_sock = messaging.sub_sock('procLog', conflate=True) # wait until everything's started and get first sample time.sleep(30) first_proc = messaging.recv_sock(proc_sock, wait=True) # run for a minute and get last sample time.sleep(60) last_proc = messaging.recv_sock(proc_sock, wait=True) running = manager.get_running() all_running = all(p in running and running[p].is_alive() for p in manager.car_started_processes) return_code = print_cpu_usage(first_proc, last_proc) if not all_running: return_code = 1 _thread.interrupt_main()
print "Check sockets" controls_state_result = wait_for_socket('controlsState', timeout=30) radarstate_result = wait_for_socket('radarState', timeout=30) plan_result = wait_for_socket('plan', timeout=30) if route not in passive_routes: # TODO The passive routes have very flaky models path_plan_result = wait_for_socket('pathPlan', timeout=30) else: path_plan_result = True carstate_result = wait_for_socket('carState', timeout=30) print "Check if everything is running" running = manager.get_running() controlsd_running = running['controlsd'].is_alive() radard_running = running['radard'].is_alive() plannerd_running = running['plannerd'].is_alive() manager.kill_managed_process("controlsd") manager.kill_managed_process("radard") manager.kill_managed_process("plannerd") os.killpg(os.getpgid(unlogger.pid), signal.SIGTERM) sockets_ok = all([ controls_state_result, radarstate_result, plan_result, path_plan_result, carstate_result, controlsd_running, radard_running, plannerd_running ]) params_ok = True
def all_running(): running = manager.get_running() return all(p in running and running[p].is_alive() for p in manager.car_started_processes)