job_type * alloc_job( rng_type * rng , const char * cmd) { const int second = 1000000; const int submit_min = 0; const int submit_max = 10 * second; const int callback_min = 0.5 * second; const int callback_max = 2 * second; const int run_min = 2 * second; const int run_max = 10 * second; job_type * job = util_malloc( sizeof * job ); UTIL_TYPE_ID_INIT( job , JOB_TYPE_ID ) job->callback_run = false; job->queue_index = -1; job->submit_usleep = submit_min + rng_get_int( rng , (submit_max - submit_min )); job->callback_usleep = callback_min + rng_get_int( rng , (callback_max - callback_min )); job->run_usleep = run_min + rng_get_int( rng , (run_max - run_min )); job->run_path = util_alloc_sprintf("%08d", rng_get_int(rng , 100000000)); job->cmd = cmd; job->argc = 4; job->argv = util_malloc( 4 * sizeof * job->argv ); job->argv[0] = job->run_path; job->argv[1] = "RUNNING"; job->argv[2] = "OK"; job->argv[3] = util_alloc_sprintf("%d", job->run_usleep); util_make_path( job->run_path ); return job; }
int main(int argc , char ** argv) { rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); { int val1 = rng_get_int( rng , MAX_INT); int val2 = rng_get_int( rng , MAX_INT); test_assert_int_not_equal( val1 , val2 ); rng_init( rng , INIT_DEFAULT ); val2 = rng_get_int( rng , MAX_INT ); test_assert_int_equal( val1 , val2 ); } { int val2 , val1; int state_size = rng_state_size( rng ); char * buffer1 = util_calloc( state_size , sizeof * buffer1 ); char * buffer2 = util_calloc( state_size , sizeof * buffer2 ); test_assert_int_not_equal( state_size , 0 ); test_assert_int_equal( state_size , MZRAN_STATE_SIZE ); rng_init( rng , INIT_DEFAULT ); rng_get_state( rng , buffer1 ); val1 = rng_get_int( rng , MAX_INT); val2 = rng_get_int( rng , MAX_INT); test_assert_int_not_equal( val1 , val2 ); rng_set_state( rng , buffer1 ); val2 = rng_get_int( rng , MAX_INT); test_assert_int_equal( val1 , val2 ); rng_init( rng , INIT_DEFAULT ); rng_get_state( rng , buffer2 ); test_assert_mem_equal( buffer1 , buffer2 , state_size ); val2 = rng_get_int( rng , MAX_INT); rng_get_state( rng , buffer2 ); test_assert_mem_not_equal( buffer1 , buffer2 , state_size ); free( buffer1 ); free( buffer2 ); } rng_free( rng ); exit(0); }
bool ert_test_context_run_worklow_job( ert_test_context_type * test_context , const char * job_name, const stringlist_type * args) { enkf_main_type * enkf_main = ert_test_context_get_main( test_context ); ert_workflow_list_type * workflow_list = enkf_main_get_workflow_list( enkf_main ); if (ert_workflow_list_has_job( workflow_list , job_name )) { bool status; { char * workflow = util_alloc_sprintf("WORKFLOW-%06d" , rng_get_int( test_context->rng , 1000000)); { FILE * stream = util_fopen( workflow , "w"); ert_test_context_fwrite_workflow_job( stream , job_name , args ); fclose(stream); } ert_test_context_install_workflow( test_context , workflow , workflow); status = ert_test_context_run_worklow( test_context , workflow ); free(workflow); } return status; } else return false; }
int main( int argc , char ** argv) { int num_kw = 1000; // Total file size should roughly exceed 2GB int kw_size = 600000; ecl_kw_type * kw = ecl_kw_alloc("KW" , kw_size , ECL_INT_TYPE ); rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); int i; offset_type file_size; for (i=0; i < kw_size; i++) ecl_kw_iset_int( kw , i , rng_get_int( rng , 912732 )); { fortio_type * fortio = fortio_open_writer( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); for (i = 0; i < num_kw; i++) { printf("Writing keyword %d/%d to file:LARGE_FILE.UNRST \n",i+1 , num_kw ); ecl_kw_fwrite( kw , fortio ); } fortio_fclose( fortio ); } /*{ fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); for (i = 0; i < num_kw - 1; i++) { printf("SKipping keyword %d/%d from file:LARGE_FILE.UNRST \n",i+1 , num_kw ); ecl_kw_fskip( fortio ); } { ecl_kw_type * file_kw = ecl_kw_fread_alloc( fortio ); if (ecl_kw_equal( kw , file_kw )) printf("Keyword read back from file correctly :-) \n"); else printf("Fatal error - keyword different on return ...\n"); ecl_kw_free( file_kw ); } fortio_fclose( fortio ); } */ file_size = util_file_size( "LARGE_FILE.UNRST" ); printf("File size: %lld \n",file_size); { fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); printf("Seeking to file end: "); fortio_fseek( fortio , file_size , SEEK_SET); fortio_fclose( fortio ); printf("Seek OK \n"); } printf("Doing ecl_file_open(..)\n"); { ecl_file_type * file = ecl_file_open( "LARGE_FILE.UNRST" , 0); ecl_kw_type * file_kw = ecl_file_iget_named_kw( file , "KW" , num_kw - 1); if (ecl_kw_equal( kw , file_kw )) printf("Keyword read back from file correctly :-) \n"); else printf("Fatal error - keyword different on return ...\n"); ecl_file_close( file ); } remove( "LARGE_FILE.UNRST" ); exit(0); }