def build_for_target(test_node, target, g_option, f_option, clear, sections): #f_option is set if -f is used # Create the temperory build folders if f_option == 0: if os.path.exists(FOLDER.caliper_log_file): os.remove(FOLDER.caliper_log_file) if os.path.exists(FOLDER.summary_file): os.remove(FOLDER.summary_file) if not os.path.exists(FOLDER.build_dir): create_folder(FOLDER.build_dir) if not os.path.exists(FOLDER.exec_dir): create_folder(FOLDER.exec_dir) if not os.path.exists(FOLDER.results_dir): create_folder(FOLDER.results_dir) if not os.path.exists(FOLDER.yaml_dir): create_folder(FOLDER.yaml_dir) # This call assign target_arch with target architecture. Call # "get_host_arch" looks to be confusing :( target_arch = server_utils.get_host_arch(target) try: host_arch = server_utils.get_local_machine_arch() except Exception, e: logging.debug(" Error in get_local_machine_arch()") raise e
def run_client_command(tag, tmp_logfile, bench_name, classify, target, command): fp = open(tmp_logfile, "a+") start_log = "%%%%%% %s test start %%%%%% \n" % tag fp.write(start_log) fp.write("<<<BEGIN TEST>>>\n") tags = "[test: " + tag + "]\n" fp.write(tags) logs = "log: " + command + "\n" fp.write(logs) start = time.time() flag = 0 #command = caliper_dir + "/" + command logging.info("the client running command is %s" % command) # get the execution location in the remote host host_current_pwd = target.run("pwd").stdout.split("\n")[0] arch = server_utils.get_host_arch(target) host_exec_dir = os.path.join(host_current_pwd, 'caliper', "gen", arch) try: logging.info( "begining to execute the command of %s on the remote host" % command) [out, returncode] = run_remote_commands(host_exec_dir, classify, bench_name, command, target, fp, fp) except error.ServRunError, e: fp.write("[status]: FAIL\n") #sys.stdout.write(out) sys.stdout.write(e) flag = -1
def build_for_target(target): if server_utils.get_target_ip(target) == server_utils.get_local_ip(): return target_arch = server_utils.get_host_arch(target) try: build_caliper(target_arch) except Exception, e: raise
def run_client_command(cmd_sec_name, tmp_logfile, kind_bench, target, command): fp = open(tmp_logfile, "a+") start_log = "%%%%%% %s test start %%%%%% \n" % cmd_sec_name fp.write(start_log) fp.write("<<<BEGIN TEST>>>\n") tags = "[test: " + cmd_sec_name + "]\n" fp.write(tags) logs = "log: " + get_actual_commands(command, target) + "\n" fp.write(logs) start = time.time() flag = 0 logging.debug("the client running command is %s" % command) # get the execution location in the remote host is_localhost = 0 if server_utils.get_target_ip(target) in server_utils.get_local_ip(): is_localhost = 1 if (is_localhost == 1): arch = server_utils.get_local_machine_arch() host_exec_dir = os.path.join(caliper_path.GEN_DIR, arch) else: host_current_pwd = target.run("pwd").stdout.split("\n")[0] arch = server_utils.get_host_arch(target) host_exec_dir = os.path.join(host_current_pwd, 'caliper', "binary", arch) try: logging.debug("begining to execute the command of %s on remote host" % command) if (is_localhost == 1): logging.debug("client command in localhost is: %s" % command) [out, returncode] = run_commands(host_exec_dir, kind_bench, command, fp, fp) else: logging.debug("client command in localhost is: %s" % command) [out, returncode] = run_remote_commands(host_exec_dir, kind_bench, command, target, fp, fp) except error.ServRunError, e: fp.write("[status]: FAIL\n") sys.stdout.write(e) flag = -1
create_folder(FOLDER.exec_dir) create_folder(FOLDER.results_dir) create_folder(FOLDER.yaml_dir) create_folder(FOLDER.html_dir) if server_utils.get_target_ip(target) in server_utils.get_local_ip(): return build_for_local() try: host_arch = server_utils.get_local_machine_arch() except Exception, e: logging.debug(" Error in get_local_machine_arch()") raise e # This call assign target_arch with target architecture. Call # "get_host_arch" looks to be confusing :( target_arch = server_utils.get_host_arch(target) target_arch_dir = os.path.join(GEN_DIR, target_arch) create_folder(target_arch_dir, 0755) # Why should we check and remove local architecture folder??? host_arch_dir = os.path.join(GEN_DIR, host_arch) if os.path.exists(host_arch_dir): shutil.rmtree(host_arch_dir) logging.info(" ") logging.info(" Local Host Arch : %s" % host_arch) logging.info(" Target Arch : %s" % target_arch) logging.info(" Caliper reports and logs are stored : %s" % FOLDER.name) logging.info(" Caliper build directory : %s" % TMP_DIR) logging.info(" ")
if not os.path.exists(caliper_path.HTML_DATA_DIR_INPUT): os.makedirs(caliper_path.HTML_DATA_DIR_INPUT) if not os.path.exists(caliper_path.HTML_DATA_DIR_OUTPUT): os.makedirs(caliper_path.HTML_DATA_DIR_OUTPUT) if server_utils.get_target_ip(target) in server_utils.get_local_ip(): return build_for_local() try: host_arch = server_utils.get_local_machine_arch() except Exception, e: logging.debug(" Error in get_local_machine_arch()") raise e # This call assign target_arch with target architecture. Call # "get_host_arch" looks to be confusing :( target_arch = server_utils.get_host_arch(target) target_arch_dir = os.path.join(GEN_DIR, target_arch) if not os.path.exists(target_arch_dir): create_folder(target_arch_dir, 0755) WS_target_arch_dir = os.path.join(WS_GEN_DIR, target_arch) create_folder(WS_target_arch_dir, 0755) # Why should we check and remove local architecture folder??? #host_arch_dir = os.path.join(GEN_DIR, host_arch) #if os.path.exists(host_arch_dir): # shutil.rmtree(host_arch_dir) logging.info(" ") logging.info(" Local Host Arch : %s" % host_arch) logging.info(" Target Arch : %s" % target_arch) logging.info(" Caliper reports and logs are stored : %s" % FOLDER.workspace)
def caliper_run(target_exec_dir, target): # get the test cases defined files config_files = server_utils.get_cases_def_files(target_exec_dir) logging.debug("the selected configuration are %s" % config_files) for i in range(0, len(config_files)): # run benchmarks selected in each configuration file # config_file = os.path.join(caliper_path.CALIPER_PRE, config_files[i]) config_file = os.path.join(config_files[i]) config, sections = server_utils.read_config_file(config_file) logging.debug(sections) # get if it is the 'common' or 'arm' or 'android' classify = config_files[i].split("/")[-1].strip().split("_")[0] logging.debug(classify) for i in range(0, len(sections)): # run for each benchmark target_arch = server_utils.get_host_arch(target) build_name = sections[i] + '_' + target_arch + '.suc' build_suc = os.path.join(Folder.build_dir, build_name) if not os.path.exists(build_suc): continue build_host_name = sections[i] + '_' + \ server_utils.get_local_machine_arch() + '.fail' if os.path.exists(build_host_name): continue # try to resolve the configuration of the configuration file try: run_file = config.get(sections[i], 'run') parser = config.get(sections[i], 'parser') except Exception: raise AttributeError("The is no option value of parser") print_format() logging.info("Running %s" % sections[i]) bench = os.path.join(classify, sections[i]) try: result = run_all_cases(target_exec_dir, target, bench, sections[i], run_file) except Exception: logging.info("Running %s Exception" % sections[i]) crash_handle.main() print_format() if sections[i] == "ltp": try: unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/; fi" ) except Exception: unmount = target.run( "if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs ;fi" ) unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) run_flag = server_utils.get_fault_tolerance_config( 'fault_tolerance', 'run_error_continue') if run_flag == 1: continue else: return result else: logging.info("Running %s Finished" % sections[i]) if sections[i] == "ltp": try: unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) except Exception: unmount = target.run( "if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs/ ;fi" ) unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) print_format() return 0
def caliper_run(target_exec_dir, server, target): # get the test cases defined files config_files = server_utils.get_cases_def_files(target_exec_dir) logging.debug("the selected configuration are %s" % config_files) for i in range(0, len(config_files)): # run benchmarks selected in each configuration file # config_file = os.path.join(caliper_path.CALIPER_PRE, config_files[i]) config_file = os.path.join(config_files[i]) config, sections = server_utils.read_config_file(config_file) logging.debug(sections) # get if it is the 'common' or 'arm' or 'android' classify = config_files[i].split("/")[-1].strip().split("_")[0] logging.debug(classify) if classify == "server" and server: try: server_ip = settings.get_value("SERVER", "ip", type=str) server_port = settings.get_value("SERVER", "port", type=int) server_user = settings.get_value("SERVER", "user", type=str) logging.info( "Please wait while caliper triggers the server.py script in the server" ) server_pwd = server.run("pwd").stdout server_pwd = server_pwd.split("\n")[0] server_caliper_dir = os.path.join(server_pwd, "caliper_server") server_caliper_dir = os.path.join(server_caliper_dir, "server.py") server_user = server_user + '@' + server_ip script = server_caliper_dir + ' ' + str(server_port) subprocess.Popen( ['ssh', '%s' % server_user, 'python %s' % script]) except Exception as e: logging.info(e) raise AttributeError( "Error in establising connection with server") for i in range(0, len(sections)): # run for each benchmark target_arch = server_utils.get_host_arch(target) build_name = sections[i] + '_' + target_arch + '.suc' build_suc = os.path.join(Folder.build_dir, build_name) if not os.path.exists(build_suc): continue build_host_name = sections[i] + '_' + \ server_utils.get_local_machine_arch() + '.fail' if os.path.exists(build_host_name): continue # try to resolve the configuration of the configuration file try: run_file = config.get(sections[i], 'run') parser = config.get(sections[i], 'parser') except Exception: raise AttributeError("The is no option value of parser") print_format() logging.info("Running %s" % sections[i]) bench = os.path.join(classify, sections[i]) try: system_initialise(target) if classify == "server": logging.info("Waiting for server to grant access") sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((server_ip, server_port)) logging.info("%s" % str(sock.recv(1024))) result = run_all_cases(target_exec_dir, target, bench, sections[i], run_file) if classify == "server": sock.send("1") sock.close() except Exception: logging.info("Running %s Exception" % sections[i]) crash_handle.main() print_format() if sections[i] == "ltp": try: unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/; fi" ) except Exception: unmount = target.run( "if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs ;fi" ) unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) run_flag = server_utils.get_fault_tolerance_config( 'fault_tolerance', 'run_error_continue') if run_flag == 1: continue else: return result else: logging.info("Running %s Finished" % sections[i]) if sections[i] == "ltp": try: unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) except Exception: unmount = target.run( "if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs/ ;fi" ) unmount = target.run( "if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi" ) print_format() return 0
def caliper_run(target_exec_dir, target): # get the test cases defined files config_files = server_utils.get_cases_def_files(target_exec_dir) logging.debug("the selected configuration are %s" % config_files) for i in range(0, len(config_files)): # run benchmarks selected in each configuration file # config_file = os.path.join(caliper_path.CALIPER_PRE, config_files[i]) config_file = os.path.join(config_files[i]) config, sections = server_utils.read_config_file(config_file) logging.debug(sections) # get if it is the 'common' or 'arm' or 'android' classify = config_files[i].split("/")[-1].strip().split("_")[0] logging.debug(classify) for i in range(0, len(sections)): # run for each benchmark target_arch = server_utils.get_host_arch(target) build_name = sections[i]+'_'+target_arch+'.suc' build_suc = os.path.join(Folder.build_dir, build_name) if not os.path.exists(build_suc): continue build_host_name = sections[i] + '_' + \ server_utils.get_local_machine_arch() + '.fail' if os.path.exists(build_host_name): continue # try to resolve the configuration of the configuration file try: run_file = config.get(sections[i], 'run') parser = config.get(sections[i], 'parser') except Exception: raise AttributeError("The is no option value of parser") print_format() logging.info("Running %s" % sections[i]) bench = os.path.join(classify, sections[i]) try: system_initialise(target) result = run_all_cases(target_exec_dir, target, bench, sections[i], run_file) except Exception: logging.info("Running %s Exception" % sections[i]) crash_handle.main() print_format() if sections[i]== "ltp": try: unmount = target.run("if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/; fi") except Exception: unmount = target.run("if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs ;fi") unmount = target.run("if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi") run_flag = server_utils.get_fault_tolerance_config( 'fault_tolerance', 'run_error_continue') if run_flag == 1: continue else: return result else: logging.info("Running %s Finished" % sections[i]) if sections[i] == "ltp": try: unmount = target.run("if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi") except Exception: unmount = target.run("if df -h |grep caliper_nfs ; then fuser -km /mnt/caliper_nfs/ ;fi") unmount = target.run("if df -h |grep caliper_nfs ; then umount /mnt/caliper_nfs/ ;fi") print_format() return 0