void test_install_job( const char * config_file, const char * job_file_OK , const char * job_file_ERROR) { ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL ); test_assert_false( ert_test_context_install_workflow_job( test_context , "JOB" , "File/does/not/exist")); test_assert_false( ert_test_context_install_workflow_job( test_context , "ERROR" , job_file_ERROR)); test_assert_true( ert_test_context_install_workflow_job( test_context , "OK" , job_file_OK)); ert_test_context_free( test_context ); }
void test_run_workflow(const char * config_file , const char * job_file) { ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL ); test_assert_false( ert_test_context_run_worklow( test_context , "No-does.not.exist")); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); { FILE * stream1 = util_fopen( "WFLOW1", "w"); FILE * stream2 = util_fopen( "WFLOW2", "w"); stringlist_type * args = stringlist_alloc_new( ); ert_test_context_fwrite_workflow_job( stream1 , "JOB" , args); stringlist_append_ref( args , "NewCase"); ert_test_context_fwrite_workflow_job( stream2 , "JOB" , args); stringlist_free( args ); fclose( stream1 ); fclose( stream2 ); } test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW1" , "WFLOW1")); test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW2" , "WFLOW2")); test_assert_true( ert_test_context_run_worklow( test_context , "WFLOW2")); test_assert_false( ert_test_context_run_worklow( test_context , "WFLOW1")); ert_test_context_free( test_context ); }
void test_load_results_job(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); stringlist_append_copy( args , "0"); stringlist_append_copy( args , ","); stringlist_append_copy( args , "1"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_free( args ); }
void test_update_default(const char * config_file , const char * job_file) { ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob0" , config_file); stringlist_type * args = stringlist_alloc_new(); test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file )); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); stringlist_free( args ); ert_test_context_free( test_context ); }
void test_update_new_case(const char * config_file , const char * job_file) { ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob1" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "NewCase" ); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); stringlist_free( args ); ert_test_context_free( test_context ); }
void test_create_case_job(ert_test_context_type * test_context, const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "newly_created_case"); test_assert_true( ert_test_context_install_workflow_job( test_context , job_name , job_file )); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); char * new_case = util_alloc_filename( "storage" , "newly_created_case" , NULL); test_assert_true(util_is_directory(new_case)); free(new_case); stringlist_free( args ); }
void test_init_case_job(ert_test_context_type * test_context, const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); test_assert_true( ert_test_context_install_workflow_job( test_context , "JOB" , job_file ) ); //Test init current case from existing { enkf_fs_type * cur_fs = enkf_main_mount_alt_fs( enkf_main , "new_current_case" , true ); enkf_main_select_fs(enkf_main, "new_current_case"); test_assert_ptr_not_equal(cur_fs , enkf_main_get_fs( enkf_main )); stringlist_append_copy( args, "default"); //case to init from test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); enkf_fs_decref(cur_fs); } { const char * current_case = enkf_main_get_current_fs( enkf_main ); test_assert_string_equal(current_case, "new_current_case"); test_assert_true(enkf_fs_has_node(enkf_main_get_fs(enkf_main), "PERMZ", PARAMETER, 0, 0, ANALYZED)); enkf_fs_type * default_fs = enkf_main_mount_alt_fs( enkf_main , "default" , true ); state_map_type * default_state_map = enkf_fs_get_state_map(default_fs); state_map_type * current_state_map = enkf_fs_get_state_map(enkf_main_get_fs(enkf_main)); test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(current_state_map)); enkf_fs_decref(default_fs); } //Test init case from existing case: stringlist_clear(args); stringlist_append_copy(args, "default"); //case to init from stringlist_append_copy(args, "new_not_current_case"); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); { enkf_fs_type * fs = enkf_main_mount_alt_fs(enkf_main, "new_not_current_case", true); test_assert_not_NULL( fs ); test_assert_true( enkf_fs_has_node(fs, "PERMZ", PARAMETER, 0, 0, ANALYZED )); enkf_fs_type * default_fs = enkf_main_mount_alt_fs( enkf_main , "default" , true ); state_map_type * default_state_map = enkf_fs_get_state_map(default_fs); state_map_type * new_state_map = enkf_fs_get_state_map(fs); test_assert_int_equal(state_map_get_size(default_state_map), state_map_get_size(new_state_map)); enkf_fs_decref(fs); } stringlist_free( args ); }
void test_update_selected_step(const char * config_file , const char * job_file) { ert_test_context_type * test_context = ert_test_context_alloc("AnalysisJob2" , config_file); stringlist_type * args = stringlist_alloc_new(); stringlist_append_copy( args , "50" ); stringlist_append_copy( args , "10" ); stringlist_append_copy( args , ",20" ); stringlist_append_copy( args , ",30-50" ); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args) ); stringlist_free( args ); ert_test_context_free( test_context ); }
void test_init_misfit_table(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); enkf_main_type * enkf_main = ert_test_context_get_main(test_context); enkf_fs_type * fs = enkf_main_get_fs(enkf_main); misfit_ensemble_type * misfit_ensemble = enkf_fs_get_misfit_ensemble( fs ); test_assert_false(misfit_ensemble_initialized(misfit_ensemble)); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); test_assert_true(misfit_ensemble_initialized(misfit_ensemble)); stringlist_free( args ); }
void test_install_workflow( const char * config_file , const char * job_file ) { ert_test_context_type * test_context = ert_test_context_alloc("INSTALL_WORKFLOW" , config_file , NULL ); const char * wf_file = "WFLOW"; ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); { FILE * stream = util_fopen( wf_file , "w"); stringlist_type * args = stringlist_alloc_new( ); stringlist_append_ref( args , "NewCase"); ert_test_context_fwrite_workflow_job( stream , "JOB" , args); stringlist_free( args ); fclose( stream ); } test_assert_true( ert_test_context_install_workflow( test_context , "WFLOW" , wf_file )); ert_test_context_free( test_context ); }
void test_run_workflow_job( const char * config_file , const char * job_file ) { ert_test_context_type * test_context = ert_test_context_alloc("CREATE_CONTEXT_JOB" , config_file , NULL ); stringlist_type * args0 = stringlist_alloc_new( ); stringlist_type * args1 = stringlist_alloc_new( ); stringlist_append_ref( args1 , "NewCase"); test_assert_false( ert_test_context_run_worklow_job( test_context , "NO-this-does-not-exist" , args1)); ert_test_context_install_workflow_job( test_context , "JOB" , job_file ); test_assert_false( ert_test_context_run_worklow_job( test_context , "JOB" , args0)); test_assert_true( ert_test_context_run_worklow_job( test_context , "JOB" , args1)); stringlist_free( args0 ); stringlist_free( args1 ); ert_test_context_free( test_context ); }
void test_rank_realizations_on_data_job(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); stringlist_append_copy( args , "NameOfDataRanking"); stringlist_append_copy( args , "PORO:1,2,3"); stringlist_append_copy( args , "false"); stringlist_append_copy( args , "0"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfDataRanking2"); stringlist_append_copy( args , "PORO:1,2,3"); stringlist_append_copy( args , "false"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_free( args ); }
void test_rank_realizations_on_observations_job(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); stringlist_append_copy( args , "NameOfObsRanking1"); stringlist_append_copy( args , "|"); stringlist_append_copy( args , "WOPR:*"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking2"); stringlist_append_copy( args, "1-5"); stringlist_append_copy( args, "55"); stringlist_append_copy( args , "|"); stringlist_append_copy( args , "WWCT:*"); stringlist_append_copy( args , "WOPR:*"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking3"); stringlist_append_copy( args, "5"); stringlist_append_copy( args, "55"); stringlist_append_copy( args, "|"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking4"); stringlist_append_copy( args, "1,3,5-10"); stringlist_append_copy( args, "55"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking5"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking6"); stringlist_append_copy( args, "|"); stringlist_append_copy( args , "UnrecognizableObservation"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_free( args ); }
void test_export_ranking(ert_test_context_type * test_context , const char * job_name , const char * job_file) { stringlist_type * args = stringlist_alloc_new(); ert_test_context_install_workflow_job( test_context , job_name , job_file ); stringlist_append_copy( args , "NameOfDataRanking"); stringlist_append_copy( args , "/tmp/fileToSaveDataRankingIn.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking1"); stringlist_append_copy( args , "/tmp/fileToSaveObservationRankingIn1.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_clear(args); stringlist_append_copy( args , "NameOfObsRanking6"); stringlist_append_copy( args , "/tmp/fileToSaveObservationRankingIn6.txt"); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); stringlist_free( args ); }
static void test_export_runpath_file(ert_test_context_type * test_context, const char * job_name, const char * job_file, stringlist_type * args, int_vector_type * iens_values, int_vector_type * iter_values) { ert_test_context_install_workflow_job( test_context , job_name , job_file ); test_assert_true( ert_test_context_run_worklow_job( test_context , job_name , args) ); { const enkf_main_type * enkf_main = ert_test_context_get_main(test_context); qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main ); const char * runpath_file_name = qc_module_get_runpath_list_file(qc_module); ecl_config_type * ecl_config = enkf_main_get_ecl_config(enkf_main); const model_config_type * model_config = enkf_main_get_model_config(enkf_main); const char * base_fmt = ecl_config_get_eclbase(ecl_config); const char * runpath_fmt = model_config_get_runpath_as_char(model_config); test_assert_true(util_file_exists(runpath_file_name)); FILE * file = util_fopen(runpath_file_name, "r"); int file_iens = 0; char file_path[256]; char file_base[256]; int file_iter = 0; char * cwd = util_alloc_cwd(); int counter = 0; int iens_index = 0; int iter_index = 0; while (4 == fscanf( file , "%d %s %s %d" , &file_iens , file_path , file_base, &file_iter)) { ++ counter; test_assert_true(int_vector_size(iens_values) >= iens_index+1); test_assert_true(int_vector_size(iter_values) >= iter_index+1); int iens = int_vector_iget(iens_values, iens_index); int iter = int_vector_iget(iter_values, iter_index); test_assert_int_equal(file_iens, iens); test_assert_int_equal(file_iter, iter); char * base = util_alloc_sprintf("--%d", iens); if (base_fmt && (util_int_format_count(base_fmt) == 1)) base = util_alloc_sprintf(base_fmt, iens); test_assert_string_equal(base, file_base); char * runpath = ""; if (util_int_format_count(runpath_fmt) == 1) runpath = util_alloc_sprintf(runpath_fmt, iens); else if (util_int_format_count(runpath_fmt) == 2) runpath = util_alloc_sprintf(runpath_fmt, iens,iter); test_assert_string_equal(runpath, file_path); if (iens_index+1 < int_vector_size(iens_values)) ++iens_index; else if ((iens_index+1 == int_vector_size(iens_values))) { ++iter_index; iens_index = 0; } free(base); free(runpath); } int linecount = int_vector_size(iens_values) * int_vector_size(iter_values); test_assert_int_equal(linecount, counter); free(cwd); fclose(file); } }