예제 #1
0
workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflow_list , const char * workflow_file , const char * workflow_name) {
  if (util_file_exists( workflow_file )) {
    workflow_type * workflow = workflow_alloc( workflow_file , workflow_list->joblist );
    char * name;

    if (workflow_name == NULL)
      util_alloc_file_components( workflow_file , NULL , &name , NULL );
    else
      name = (char *) workflow_name;


    hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__);
    if (hash_has_key( workflow_list->alias_map , name))
      hash_del( workflow_list->alias_map , name);

    if (workflow_name == NULL)
      free( name );

    return workflow;
  } else
    return NULL;
}
예제 #2
0
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);
}