def test_console(dirname, model): # run rdo_console app on test model model_file = '' + dirname + model['name'] exit_code = int(model['exit_code']) command = (rdo_ex + ' -i ' + utils.wrap_the_string_in_quotes(model_file) + ' >' + os.devnull) if model['script'] and len(model['script']) > 0: command += ' -s ' + utils.wrap_the_string_in_quotes(dirname + model['script']) utils.enc_print('Run:', command, '\n') simulation_code = subprocess.call(command, shell=True) utils.enc_print ('SIMULATION EXIT CODE :', simulation_code) # check simulation exit code simulation_exit_code_string = 'ERROR' if simulation_code == exit_code: cycle_exit_code = APP_CODE_TERMINATION_NORMAL simulation_exit_code_string = 'OK' else: cycle_exit_code = APP_CODE_TERMINATION_ERROR utils.enc_print ('CHECK SIM EXIT CODE :', simulation_exit_code_string, '\n') # check etalons if simulation_code == exit_code and model['etalons'] and len(model['etalons']): try: # compare etalons cycle_exit_code = compare_etalons(model['etalons'], dirname) except: traceback.print_exc(file=sys.stdout) cycle_exit_code = APP_CODE_TERMINATION_ERROR # check error log elif simulation_code == exit_code and model['log_compilation']: try: simulation_log_file = dirname + RDO_CONSOLE_COMPILE_LOG_FILE_NAME simulation_log_file_etalon = dirname + model['log_compilation'] res = compare.full(simulation_log_file, simulation_log_file_etalon) check_message_cmp_string = 'ERROR' if res: cycle_exit_code = APP_CODE_TERMINATION_NORMAL check_message_cmp_string = 'OK' else: cycle_exit_code = APP_CODE_TERMINATION_ERROR utils.enc_print ('CHECK ERROR LIST :', check_message_cmp_string) except: traceback.print_exc(file=sys.stdout) cycle_exit_code = APP_CODE_TERMINATION_ERROR return cycle_exit_code
def test_convertor(dirname, model): text_uuid = str(uuid.uuid4()) temp_directory_name = dirname + text_uuid + DIR_LINE try: shutil.copytree(dirname, temp_directory_name, ignore=shutil.ignore_patterns(*IGNORE_PATTERNS)) model_file = '' + temp_directory_name + model['name'] exit_code = int(model['exit_code']) command = (rdo_ex + ' -i ' + utils.wrap_the_string_in_quotes(model_file) + ' >' + os.devnull + ' -c') utils.enc_print ('Run:', command, '\n') convertor_exit_code = subprocess.call(command, shell=True) utils.enc_print ('CONVERT EXIT CODE :', convertor_exit_code, '\n') if convertor_exit_code == exit_code: cycle_exit_code = compare_etalons(model['etalons'], temp_directory_name) if cycle_exit_code != APP_CODE_TERMINATION_NORMAL: arc_name = dirname + text_uuid + '.zip' utils.enc_print('Make zip archive: ' + arc_name) zipf = zipfile.ZipFile(arc_name, 'w') zipdir(temp_directory_name, zipf) zipf.close() except: traceback.print_exc(file=sys.stdout) cycle_exit_code = APP_CODE_TERMINATION_ERROR try: shutil.rmtree(temp_directory_name) except: traceback.print_exc(file=sys.stdout) cycle_exit_code = APP_CODE_TERMINATION_ERROR return cycle_exit_code
args = parser.parse_args() app_directory = '' + args.app_directory model_path = '' + args.model_path utils.enc_print("App directory:", os.path.abspath(app_directory)) utils.enc_print("Test project file path:", os.path.abspath(model_path)) rdo_ex = get_executables(app_directory) if rdo_ex is None: utils.enc_print ('Critical error! Build app not found.') sys.exit(APP_CODE_TERMINATION_ERROR) if not os.path.exists(model_path): utils.enc_print ('Critical error! Test nodel not found.') sys.exit(APP_CODE_TERMINATION_ERROR) utils.enc_print ('\nFind RDO executable:') utils.enc_print (rdo_ex) delete_model_data(model_path) plugin_arg = '1 0 2 4 5 3' command = (rdo_ex + ' -platform minimal --plugin0=' + utils.wrap_the_string_in_quotes(plugin_arg) + ' -i ' + model_path + ' >' + os.devnull) utils.enc_print('Run: ', command) simulation_code = subprocess.call(command, shell=True) utils.enc_print ('EXIT CODE: ', simulation_code) utils.enc_print ('PYTHON EXIT CODE :', simulation_code) sys.exit(simulation_code)
app_directory = '' + args.app_directory model_path = '' + args.model_path utils.enc_print("App directory:", os.path.abspath(app_directory)) utils.enc_print("Test project file path:", os.path.abspath(model_path)) rdo_ex = get_executables(app_directory) if rdo_ex is None: utils.enc_print('Critical error! Build app not found.') sys.exit(APP_CODE_TERMINATION_ERROR) if not os.path.exists(model_path): utils.enc_print('Critical error! Test nodel not found.') sys.exit(APP_CODE_TERMINATION_ERROR) utils.enc_print('\nFind RDO executable:') utils.enc_print(rdo_ex) delete_model_data(model_path) plugin_arg = '1 0 2 4 5 3' command = (rdo_ex + ' -platform minimal --plugin0=' + utils.wrap_the_string_in_quotes(plugin_arg) + ' -i ' + model_path + ' >' + os.devnull) utils.enc_print('Run: ', command) simulation_code = subprocess.call(command, shell=True) utils.enc_print('EXIT CODE: ', simulation_code) utils.enc_print('PYTHON EXIT CODE :', simulation_code) sys.exit(simulation_code)