def handle(self, test_spec, target_name, toolchain_name): """ Function determines MUT's mbed disk/port and copies binary to target. Test is being invoked afterwards. """ data = json.loads(test_spec) # Get test information, image and test timeout test_id = data['test_id'] test = TEST_MAP[test_id] test_description = TEST_MAP[test_id].get_description() image = data["image"] duration = data.get("duration", 10) # Find a suitable MUT: mut = None for id, m in MUTs.iteritems(): if m['mcu'] == data['mcu']: mut = m break if mut is None: print "Error: No mbed available: mut[%s]" % data['mcu'] return disk = mut['disk'] port = mut['port'] target_by_mcu = TARGET_MAP[mut['mcu']] # Program # When the build and test system were separate, this was relative to a # base network folder base path: join(NETWORK_BASE_PATH, ) image_path = image if not exists(image_path): print "Error: Image file does not exist: %s" % image_path elapsed_time = 0 test_result = "{error}" return (test_result, target_name, toolchain_name, test_id, test_description, round(elapsed_time, 2), duration) if not target_by_mcu.is_disk_virtual: delete_dir_files(disk) # Program MUT with proper image file copy(image_path, disk) # Copy Extra Files if not target_by_mcu.is_disk_virtual and test.extra_files: for f in test.extra_files: copy(f, disk) sleep(target_by_mcu.program_cycle_s()) # Host test execution start_host_exec_time = time() test_result = self.run_host_test(target_name, port, duration) elapsed_time = time() - start_host_exec_time print print_test_result(test_result, target_name, toolchain_name, test_id, test_description, elapsed_time, duration) return (test_result, target_name, toolchain_name, test_id, test_description, round(elapsed_time, 2), duration)
def handle(self): print "\nRequest", test_spec = self.request.recv(1024) print test_spec, data = json.loads(test_spec) # The MUTs list can be different from server to server, so we have to # provide a way for the client to query the capabilities of this server if 'info' in data: if data['info'] == 'muts': muts_info = json.dumps(MUTs) print muts_info self.request.send(muts_info) return test_id = data['test_id'] test = TEST_MAP[test_id] image = data["image"] duration = data.get("duration", 10) # Find a suitable MUT: mut = None for id, m in MUTs.iteritems(): if m['mcu'] == data['mcu']: mut = m break if mut is None: print "No mbed available: %s" % data['mcu'] self.send_result("{error}") return disk = mut['disk'] port = mut['port'] # Program # When the build and test system were separate, this was relative to a # base network folder base path: join(NETWORK_BASE_PATH, ) image_path = image if not exists(image_path): print "Image file does not exist: %s" % image_path self.send_result("{error}") return delete_dir_files(disk) copy(image_path, disk) # Copy Extra Files if test.extra_files: for f in test.extra_files: copy(f, disk) sleep(1) # Host test self.request.setblocking(0) result = run_host_test(self.request, test.host_test, disk, port, duration) self.send_result(result)
def handle(self, test_spec, target_name, toolchain_name): """ Function determines MUT's mbed disk/port and copies binary to target. Test is being invoked afterwards. """ data = json.loads(test_spec) # Get test information, image and test timeout test_id = data['test_id'] test = TEST_MAP[test_id] test_description = TEST_MAP[test_id].get_description() image = data["image"] duration = data.get("duration", 10) # Find a suitable MUT: mut = None for id, m in MUTs.iteritems(): if m['mcu'] == data['mcu']: mut = m break if mut is None: print "Error: No mbed available: mut[%s]" % data['mcu'] return disk = mut['disk'] port = mut['port'] target_by_mcu = TARGET_MAP[mut['mcu']] # Program # When the build and test system were separate, this was relative to a # base network folder base path: join(NETWORK_BASE_PATH, ) image_path = image if not exists(image_path): print "Error: Image file does not exist: %s" % image_path elapsed_time = 0 test_result = "{error}" return (test_result, target_name, toolchain_name, test_id, test_description, round(elapsed_time, 2), duration) if not target_by_mcu.is_disk_virtual: delete_dir_files(disk) # Program MUT with proper image file copy(image_path, disk) # Copy Extra Files if not target_by_mcu.is_disk_virtual and test.extra_files: for f in test.extra_files: copy(f, disk) sleep(target_by_mcu.program_cycle_s()) # Host test execution start_host_exec_time = time() #test_result = self.run_simple_test(target_name, port, duration, verbose=opts.verbose) test_result = self.run_host_test(test.host_test, disk, port, duration, opts.verbose) elapsed_time = time() - start_host_exec_time print print_test_result(test_result, target_name, toolchain_name, test_id, test_description, elapsed_time, duration) return (test_result, target_name, toolchain_name, test_id, test_description, round(elapsed_time, 2), duration)