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); }
void config_content_free( config_content_type * content ) { vector_free( content->nodes ); vector_free( content->path_elm_stack ); vector_free( content->path_elm_storage ); hash_free( content->items ); config_error_free( content->parse_errors ); subst_list_free( content->define_list ); util_safe_free( content->config_file ); util_safe_free( content->abs_path ); set_free( content->parsed_files ); if (content->invoke_path != NULL) config_root_path_free( content->invoke_path ); free( content ); }
int main(int argc , char ** argv) { #ifdef ERT_LINUX const char * rel_path = "rel/path"; const char * rel_true = "rel/path/XXX"; const char * path_true1 = "rel/path/XXX"; #endif test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" ); const char * root = test_work_area_get_cwd( work_area ); char * abs_path = util_alloc_filename( root , "rel/path" , NULL); char * abs_true = util_alloc_filename( root , "rel/path/XXX" , NULL); char * path_true2 = util_alloc_filename( root , "rel/path/XXX" , NULL); util_chdir( test_work_area_get_original_cwd( work_area )); config_root_path_type * root_path = config_root_path_alloc( root ); { config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path ); test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 ); config_path_elm_free( path_elm ); } { config_path_elm_type * path_elm = config_path_elm_alloc( root_path , abs_path ); test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 ); config_path_elm_free( path_elm ); } config_root_path_free( root_path ); util_chdir( root ); root_path = config_root_path_alloc( NULL ); { config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path ); test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true1 ); config_path_elm_free( path_elm ); } exit(0); }
void config_content_set_invoke_path( config_content_type * content) { if (content->invoke_path != NULL) config_root_path_free( content->invoke_path ); content->invoke_path = config_root_path_alloc( NULL ); }