Exemplo n.º 1
0
void test_assert_mem_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line) {
  if (memcmp(p1 ,p2 , byte_size) != 0) {
    const char * char_ptr1 = (const char *) p1;
    const char * char_ptr2 = (const char *) p2;
    size_t offset = 0;

    while( char_ptr1[offset] == char_ptr2[offset])
      offset++;
    
    test_error_exit( "%s:%d => Memory regions have different content. First difference at offset:%ld\n" , file , line , offset);
  }
}
Exemplo n.º 2
0
int main( int argc , char ** argv) {
  const char * rft_file = argv[1];
  const char * mode_string = argv[2];


  if (strcmp( mode_string , "RFT") == 0)
    test_rft( rft_file );
  else if (strcmp( mode_string , "RFT_RW") == 0)
      test_rft_read_write(rft_file);
  else if (strcmp( mode_string , "PLT") == 0)
    test_plt( rft_file );
  else if (strcmp( mode_string , "MSW-PLT") == 0)
    test_plt_msw( rft_file );
  else
    test_error_exit("Second argument:%s not recognized. Valid values are: RFT and PLT" , mode_string);
  
  exit(0);
}
Exemplo n.º 3
0
int main(int argc , char ** argv) {
  char * cwd = util_alloc_cwd();

  {
    config_root_path_type * root_path = config_root_path_alloc( NULL );
    
    if (!test_check_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
      test_error_exit("abs:path:%s   expeceted:%s \n",config_root_path_get_abs_path( root_path ) , cwd );

    if (!test_check_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
      test_error_exit("input:path:%s   expeceted:%s \n",config_root_path_get_input_path( root_path ) , NULL );
    
    if (!test_check_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
      test_error_exit("rel:path:%s   expeceted:%s \n",config_root_path_get_rel_path( root_path ) , NULL );

    
    config_root_path_free( root_path );
  }


  {
    config_root_path_type * root_path = config_root_path_alloc( "/does/not/exist" );
    if (root_path != NULL)
      test_error_exit("Created root_path instance for not-existing input \n");
  }
  

  
  {
    const char * input_path = argv[1];
    char * cwd      = util_alloc_cwd();
    char * rel_path = util_alloc_rel_path( cwd , input_path );

    config_root_path_type * root_path1 = config_root_path_alloc( input_path );
    config_root_path_type * root_path2 = config_root_path_alloc( rel_path );

    if (!test_check_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
      test_error_exit("Rel: %s != %s \n",config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2));
    
    if (!test_check_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
      test_error_exit("Abs: %s != %s \n",config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 ));
    
    config_root_path_free( root_path1 );
    config_root_path_free( root_path2 );
  }


  exit(0);
}
Exemplo n.º 4
0
void test_assert_mem_not_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line) {
  if (memcmp(p1 ,p2 , byte_size) == 0)
    test_error_exit( "%s:%d => Memory regions have the same content \n" , file , line);
}
Exemplo n.º 5
0
void test_assert_not_NULL__( const void * p , const char * file , int line) {
  if (p == NULL) 
    test_error_exit( "%s:%d => Pointer is NULL \n" , file , line , p);
}
Exemplo n.º 6
0
void test_assert_ptr_not_equal__( const void * p1 , const void * p2 , const char * file , int line) {
  bool equal = (p1 == p2);
  if (equal) 
    test_error_exit( "%s:%d => Pointers are equal p1:[%p]  p2:[%p]\n" , file , line , p1 , p2 );
}
Exemplo n.º 7
0
void test_assert_false__( bool value, const char * file , int line) {
  if (value) 
    test_error_exit("%s:%d => assert( false ) failed" , file , line);
}
Exemplo n.º 8
0
void test_assert_true__( bool value, const char * file , int line) {
  if (!value) 
    test_error_exit("%s:%d => assert( true ) failed\n" , file , line);
}
Exemplo n.º 9
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);
}
Exemplo n.º 10
0
void test_assert_string_not_equal__( const char * s1 , const char * s2 , const char * file, int line) {
  bool equal = test_check_string_equal( s1 , s2 );
  if (equal) 
    test_error_exit( "%s:%d => String are equal s1:[%s]  s2:[%s]\n" , file , line , s1 , s2 );
}
Exemplo n.º 11
0
void test_assert_uint_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line) {
  if (i1 != i2) 
    test_error_exit( "%s:%d => Integers are different i1:[%d]  i2:[%d]\n" , file , line , i1 , i2 );
}
Exemplo n.º 12
0
void test_assert_long_not_equal__( long i1 , long i2 , const char * file , long line) {
  if (i1 == i2)
    test_error_exit( "%s:%d => Long values are equal i1:[%d]  i2:[%d]\n" , file , line , i1 , i2 );
}
Exemplo n.º 13
0
void test_assert_float_not_equal__( float d1 , float d2, const char * file , int line) {
  if (test_check_float_equal(d1 , d2))
    test_error_exit( "%s:%d => float values:%15.12g %15.12g are equal.\n" , file , line , d1 , d2);
}
Exemplo n.º 14
0
void test_assert_float_equal__( float d1 , float d2, const char * file , int line) {
  if (!test_check_float_equal(d1 , d2))
    test_error_exit( "%s:%d => float values:%g %g are not sufficiently similar\n" , file , line , d1 , d2);
}
Exemplo n.º 15
0
void test_assert_size_t_not_equal__( size_t s1 , size_t s2 , const char * file , int line) {
  if (s1 == s2)
    test_error_exit("%s:%d => size_t values are different s1:%d  s2:[%d]\n" , file , line , s1 , s2);
}
Exemplo n.º 16
0
void test_assert_double_equal__( double d1 , double d2, const char * file , int line) {
  if (!test_check_double_equal(d1 , d2))
    test_error_exit( "%s:%d => double values:%g %g are not sufficiently similar\n" , file , line , d1 , d2);
}
Exemplo n.º 17
0
void test_assert_double_not_equal__( double d1 , double d2, const char * file , int line) {
  if (test_check_double_equal(d1 , d2))
    test_error_exit( "%s:%d => double values:%15.12g %15.12g are equal.\n" , file , line , d1 , d2);
}
Exemplo n.º 18
0
void test_assert_bool_not_equal__( bool b1 , bool b2 , const char * file , int line) {
  if (b1 == b2) 
    test_error_exit( "%s:%d => Booleans are equal b1:[%d]  b2:[%d]\n" , file , line , b1 , b2 );
}
Exemplo n.º 19
0
void test_assert_int_not_equal__( int i1 , int i2 , const char * file , int line) {
  if (i1 == i2) 
    test_error_exit( "%s:%d => Integers are equal i1:[%d]  i2:[%d]\n" , file , line , i1 , i2 );
}
Exemplo n.º 20
0
void test_assert_time_t_not_equal__( time_t t1 , time_t t2 , const char * file , int line) {
  if (t1 == t2) 
    test_error_exit("%s:%d => time_t values are different t1:%d  t2:[%d]\n" , file , line , t1 , t2);
}