예제 #1
0
void simple_test() {
  time_map_type * time_map = time_map_alloc( );
  test_work_area_type * work_area = test_work_area_alloc("enkf_time_map" , true);
  const char * mapfile = "map";
  
  test_assert_true( time_map_update( time_map , 0 , 100 )   );
  test_assert_true( time_map_update( time_map , 1 , 200 )   );
  test_assert_true( time_map_update( time_map , 1 , 200 )   );
  test_assert_false( time_map_update( time_map , 1 , 250 )  );

  test_assert_true( time_map_equal( time_map , time_map ) );
  time_map_fwrite( time_map , mapfile);
  {
    time_map_type * time_map2 = time_map_alloc( );

    test_assert_false( time_map_equal( time_map , time_map2 ) );
    time_map_fread( time_map2 , mapfile );
    test_assert_true( time_map_equal( time_map , time_map2 )  );
    time_map_free( time_map2 );
  }
  {
    time_t mtime1 = util_file_mtime( mapfile );
    sleep(2);
    time_map_fwrite( time_map , mapfile);
    
    test_assert_time_t_equal( mtime1 , util_file_mtime( mapfile ) );
    time_map_update( time_map , 2 , 300 );
    time_map_fwrite( time_map , mapfile);
    test_assert_time_t_not_equal( mtime1 , util_file_mtime( mapfile ) );
  }
  test_work_area_free( work_area );
}
예제 #2
0
파일: enkf_fs.c 프로젝트: shulNN/ert
static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point , bool read_only) {
  enkf_fs_type * fs          = util_malloc(sizeof * fs );
  UTIL_TYPE_ID_INIT( fs , ENKF_FS_TYPE_ID );
  fs->time_map               = time_map_alloc();
  fs->cases_config           = cases_config_alloc();
  fs->state_map              = state_map_alloc();
  fs->misfit_ensemble        = misfit_ensemble_alloc();
  fs->index                  = NULL;
  fs->eclipse_static         = NULL;
  fs->parameter              = NULL;
  fs->dynamic_forecast       = NULL;
  fs->dynamic_analyzed       = NULL;
  fs->read_only              = read_only;
  fs->mount_point            = util_alloc_string_copy( mount_point );
  fs->refcount               = 0;
  fs->lock_fd                = 0;
  
  if (mount_point == NULL)
    util_abort("%s: fatal internal error: mount_point == NULL \n",__func__);
  {
    char ** path_tmp;
    int     path_len;

    util_path_split( fs->mount_point , &path_len , &path_tmp);
    fs->case_name = util_alloc_string_copy( path_tmp[path_len - 1]);
    fs->root_path = util_alloc_joined_string( (const char **) path_tmp , path_len , UTIL_PATH_SEP_STRING);
    fs->lock_file = util_alloc_filename( fs->mount_point , fs->case_name , "lock");

    util_free_stringlist( path_tmp , path_len );
  }
  return fs;
}
예제 #3
0
void thread_test() {
  time_map_type * time_map = time_map_alloc( );
  
  {
    int pool_size = 1000;
    thread_pool_type * tp = thread_pool_alloc( pool_size/2 , true );
    
    thread_pool_add_job( tp , update_time_map , time_map );
  
    thread_pool_join(tp);
    thread_pool_free(tp);
  }
  {
    int i;
    for (i=0; i < MAP_SIZE; i++) 
      test_assert_true( time_map_iget( time_map , i ) == i );
  }
  time_map_free( time_map );
}
예제 #4
0
void ecl_test( const char * ecl_case ) {
  ecl_sum_type * ecl_sum  = ecl_sum_fread_alloc_case( ecl_case , ":");
  time_t start_time = ecl_sum_get_start_time( ecl_sum );
  time_t end_time   = ecl_sum_get_end_time( ecl_sum );
  time_map_type * ecl_map = time_map_alloc( );
  
  test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) );
  test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) );
  
  test_assert_time_t_equal( time_map_get_start_time( ecl_map ) , start_time );
  test_assert_time_t_equal( time_map_get_end_time( ecl_map ) , end_time );
  test_assert_double_equal( time_map_get_end_days( ecl_map ) , ecl_sum_get_sim_length( ecl_sum ));

  time_map_clear( ecl_map );
  time_map_update( ecl_map , 1 , 256 );
  test_assert_false( time_map_summary_update( ecl_map , ecl_sum ));
  
  time_map_free( ecl_map );
  ecl_sum_free( ecl_sum );
}