void ert_workflow_list_free( ert_workflow_list_type * workflow_list ) { hash_free( workflow_list->workflows ); hash_free( workflow_list->alias_map ); stringlist_free( workflow_list->path_list ); workflow_joblist_free( workflow_list->joblist ); free( workflow_list ); }
void test_has_job(const char * job) { workflow_joblist_type * joblist = workflow_joblist_alloc(); test_assert_false( workflow_joblist_has_job( joblist , "NoNotThis")); workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , job); test_assert_true( workflow_joblist_has_job( joblist , "CREATE_FILE")); workflow_joblist_free( joblist ); }
int main( int argc , char ** argv) { const char * exjob_file = "job"; const char * bin_path = argv[1]; const char * internal_workflow = argv[2]; test_work_area_type * work_area = test_work_area_alloc( "job_workflow_test" ); signal(SIGSEGV , util_abort_signal); create_exjob( exjob_file , bin_path ); { int int_value = rand(); int read_value = 100; workflow_joblist_type * joblist = workflow_joblist_alloc(); if (!workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , exjob_file)) { remove( exjob_file ); { config_type * job_config = workflow_joblist_get_job_config( joblist ); config_fprintf_errors( job_config , true , stdout ); } test_error_exit("Loading job CREATE_FILE failed\n"); } else remove( exjob_file ); if (!workflow_joblist_add_job_from_file( joblist , "READ_FILE" , internal_workflow)) test_error_exit("Loading job READ_FILE failed\n"); { config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); if (config_get_schema_size( workflow_compiler ) != 2) test_error_exit("Config compiler - wrong size \n"); } { const char * workflow_file = "workflow"; const char * tmp_file = "fileX"; workflow_type * workflow; create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); { bool runOK; runOK = workflow_run( workflow , &read_value , false , NULL); if (runOK) { if (int_value != read_value) test_error_exit("Wrong numeric value read back \n"); test_assert_int_equal( workflow_get_stack_size( workflow ) , 2 ); test_assert_not_NULL( workflow_iget_stack_ptr( workflow , 0 ) ); test_assert_NULL( workflow_iget_stack_ptr( workflow , 1 ) ); { void * return_value = workflow_iget_stack_ptr( workflow , 0 ); int return_int = *((int *) return_value); if (int_value != return_int) test_error_exit("Wrong numeric value read back \n"); test_assert_not_NULL( workflow_pop_stack( workflow )); test_assert_NULL( workflow_pop_stack( workflow )); test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 ); free( return_value ); } } else { config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); config_fprintf_errors( workflow_compiler , true ,stdout); unlink( tmp_file ); test_error_exit("Workflow did not run\n"); } unlink( tmp_file ); } } workflow_joblist_free( joblist ); } { workflow_joblist_type * joblist = workflow_joblist_alloc(); const char * workflow_file = "workflow"; const char * tmp_file = "fileX"; int read_value; int int_value = 100; workflow_type * workflow; create_workflow( workflow_file , tmp_file , int_value ); workflow = workflow_alloc(workflow_file , joblist ); unlink( workflow_file ); test_assert_false( workflow_run( workflow , &read_value , false , NULL) ); test_assert_int_equal( workflow_get_stack_size( workflow ) , 0 ); } test_work_area_free( work_area ); exit(0); }