1 /* lib/vfs - manipulate with current directory
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"
29 #include "lib/global.h"
30 #include "lib/strutil.h"
31 #include "lib/vfs/xdirentry.h"
33 #include "src/vfs/local/local.c"
38 str_init_strings (NULL
);
42 vfs_setup_work_dir ();
49 str_uninit_strings ();
53 test_chdir(const vfs_path_t
* vpath
)
56 char *path
= vfs_path_to_str(vpath
);
57 printf("test_chdir: %s\n", path
);
65 /* --------------------------------------------------------------------------------------------- */
67 #define cd_and_check( cd_dir, etalon ) \
70 strcmp(etalon, mc_get_current_wd(buffer,MC_MAXPATHLEN)) == 0, \
71 "\n expected(%s) doesn't equal \nto actual(%s)", etalon, buffer);
73 START_TEST (set_up_current_dir_url
)
75 static struct vfs_s_subclass test_subclass
;
76 static struct vfs_class vfs_test_ops
;
77 char buffer
[MC_MAXPATHLEN
];
79 vfs_s_init_class (&vfs_test_ops
, &test_subclass
);
81 vfs_test_ops
.name
= "testfs";
82 vfs_test_ops
.flags
= VFSF_NOLINKS
;
83 vfs_test_ops
.prefix
= "test";
84 vfs_test_ops
.chdir
= test_chdir
;
86 vfs_register_class (&vfs_test_ops
);
88 cd_and_check ("/dev/some.file/test://", "/dev/some.file/test://");
90 cd_and_check ("/dev/some.file/test://bla-bla", "/dev/some.file/test://bla-bla");
92 cd_and_check ("..", "/dev/some.file/test://");
94 cd_and_check ("..", "/dev");
96 cd_and_check ("..", "/");
98 cd_and_check ("..", "/");
100 test_subclass
.flags
= VFS_S_REMOTE
;
102 cd_and_check ("/test://user:pass@host.net/path", "/test://user:pass@host.net/path");
103 cd_and_check ("..", "/test://user:pass@host.net");
105 cd_and_check ("..", "/");
110 /* --------------------------------------------------------------------------------------------- */
117 Suite
*s
= suite_create (TEST_SUITE_NAME
);
118 TCase
*tc_core
= tcase_create ("Core");
121 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
123 /* Add new tests here: *************** */
124 tcase_add_test (tc_core
, set_up_current_dir_url
);
125 /* *********************************** */
127 suite_add_tcase (s
, tc_core
);
128 sr
= srunner_create (s
);
129 srunner_set_log (sr
, "current_dir.log");
130 srunner_run_all (sr
, CK_NORMAL
);
131 number_failed
= srunner_ntests_failed (sr
);
133 return (number_failed
== 0) ? 0 : 1;
136 /* --------------------------------------------------------------------------------------------- */