2 lib/vfs - manipulate with current directory
5 The Free Software Foundation, Inc.
8 Slava Zanko <slavazanko@gmail.com>, 2011
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "/lib/vfs"
32 #include "lib/global.h"
33 #include "lib/strutil.h"
34 #include "lib/vfs/xdirentry.h"
36 #include "src/vfs/local/local.c"
41 str_init_strings (NULL
);
45 vfs_setup_work_dir ();
52 str_uninit_strings ();
56 test_chdir (const vfs_path_t
* vpath
)
59 char *path
= vfs_path_to_str (vpath
);
60 printf ("test_chdir: %s\n", path
);
68 /* --------------------------------------------------------------------------------------------- */
70 #define cd_and_check( cd_dir, etalon ) \
71 vpath = vfs_path_from_str (cd_dir); \
73 vfs_path_free (vpath); \
74 buffer = _vfs_get_cwd (); \
76 strcmp(etalon, buffer) == 0, \
77 "\n expected(%s) doesn't equal \nto actual(%s)", etalon, buffer); \
80 START_TEST (set_up_current_dir_url
)
83 static struct vfs_s_subclass test_subclass
;
84 static struct vfs_class vfs_test_ops
;
87 vfs_s_init_class (&vfs_test_ops
, &test_subclass
);
89 vfs_test_ops
.name
= "testfs";
90 vfs_test_ops
.flags
= VFSF_NOLINKS
;
91 vfs_test_ops
.prefix
= "test";
92 vfs_test_ops
.chdir
= test_chdir
;
94 vfs_register_class (&vfs_test_ops
);
96 cd_and_check ("/dev/some.file/test://", "/dev/some.file/test://");
98 cd_and_check ("/dev/some.file/test://bla-bla", "/dev/some.file/test://bla-bla");
100 cd_and_check ("..", "/dev/some.file/test://");
102 cd_and_check ("..", "/dev");
104 cd_and_check ("..", "/");
106 cd_and_check ("..", "/");
108 test_subclass
.flags
= VFS_S_REMOTE
;
110 cd_and_check ("/test://user:pass@host.net/path", "/test://user:pass@host.net/path");
111 cd_and_check ("..", "/test://user:pass@host.net");
113 cd_and_check ("..", "/");
119 /* --------------------------------------------------------------------------------------------- */
126 Suite
*s
= suite_create (TEST_SUITE_NAME
);
127 TCase
*tc_core
= tcase_create ("Core");
130 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
132 /* Add new tests here: *************** */
133 tcase_add_test (tc_core
, set_up_current_dir_url
);
134 /* *********************************** */
136 suite_add_tcase (s
, tc_core
);
137 sr
= srunner_create (s
);
138 srunner_set_log (sr
, "current_dir.log");
139 srunner_run_all (sr
, CK_NORMAL
);
140 number_failed
= srunner_ntests_failed (sr
);
142 return (number_failed
== 0) ? 0 : 1;
145 /* --------------------------------------------------------------------------------------------- */