1 /* lib/vfs - test vfs_path_t manipulation functions
3 Copyright (C) 2011 Free Software Foundation, Inc.
6 Slava Zanko <slavazanko@gmail.com>, 2011
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public License
10 as published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #define TEST_SUITE_NAME "/lib/vfs"
27 #include "lib/global.c"
30 #define HAVE_CHARSET 1
33 #include "lib/charsets.h"
35 #include "lib/strutil.h"
36 #include "lib/vfs/xdirentry.h"
37 #include "lib/vfs/path.h"
39 #include "src/vfs/local/local.c"
42 struct vfs_s_subclass test_subclass1
;
43 struct vfs_class vfs_test_ops1
;
45 static int test_chdir (const vfs_path_t
* vpath
);
52 str_init_strings (NULL
);
56 vfs_setup_work_dir ();
58 test_subclass1
.flags
= VFS_S_REMOTE
;
59 vfs_s_init_class (&vfs_test_ops1
, &test_subclass1
);
61 vfs_test_ops1
.name
= "testfs1";
62 vfs_test_ops1
.flags
= VFSF_NOLINKS
;
63 vfs_test_ops1
.prefix
= "test1";
64 vfs_test_ops1
.chdir
= test_chdir
;
65 vfs_register_class (&vfs_test_ops1
);
67 mc_global
.sysconfig_dir
= (char *) TEST_SHARE_DIR
;
68 load_codepages_list ();
74 free_codepages_list ();
77 str_uninit_strings ();
80 /* --------------------------------------------------------------------------------------------- */
83 test_chdir (const vfs_path_t
* vpath
)
85 char *path
= vfs_path_to_str (vpath
);
86 printf ("test_chdir: %s\n", path
);
91 /* --------------------------------------------------------------------------------------------- */
93 START_TEST (relative_cd
)
97 vpath
= vfs_path_from_str ("/test1://user:pass@some.host:12345/path/to/dir");
98 fail_if (mc_chdir(vpath
) == -1);
99 vfs_path_free (vpath
);
101 vpath
= vfs_path_from_str_flags ("some-non-exists-dir", VPF_NO_CANON
);
102 fail_if (mc_chdir(vpath
) == -1);
103 vfs_path_free (vpath
);
106 /* --------------------------------------------------------------------------------------------- */
115 Suite
*s
= suite_create (TEST_SUITE_NAME
);
116 TCase
*tc_core
= tcase_create ("Core");
119 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
121 /* Add new tests here: *************** */
122 tcase_add_test (tc_core
, relative_cd
);
123 /* *********************************** */
125 suite_add_tcase (s
, tc_core
);
126 sr
= srunner_create (s
);
127 srunner_set_log (sr
, "relative_cd.log");
128 srunner_run_all (sr
, CK_NORMAL
);
129 number_failed
= srunner_ntests_failed (sr
);
131 return (number_failed
== 0) ? 0 : 1;
134 /* --------------------------------------------------------------------------------------------- */