1 /* lib/vfs - get vfs class from string
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"
28 #include "lib/global.h"
29 #include "lib/strutil.h"
30 #include "lib/vfs/xdirentry.h"
31 #include "lib/vfs/vfs.c" /* for testing static methods */
33 #include "src/vfs/local/local.c"
38 str_init_strings (NULL
);
42 vfs_setup_work_dir ();
51 /* --------------------------------------------------------------------------------------------- */
53 START_TEST (test_register_vfs_class
)
55 static struct vfs_s_subclass test_subclass
;
56 static struct vfs_class vfs_test_ops
;
58 test_subclass
.flags
= VFS_S_REMOTE
;
59 vfs_s_init_class (&vfs_test_ops
, &test_subclass
);
61 vfs_test_ops
.name
= "testfs";
62 vfs_test_ops
.flags
= VFSF_NOLINKS
;
63 vfs_test_ops
.prefix
= "test:";
64 vfs_register_class (&vfs_test_ops
);
66 fail_if (vfs_list
->len
!= 2, "Failed to register test VFS module");;
69 struct vfs_class
*result
;
70 result
= vfs_get_class("/#test://bla-bla/some/path");
71 fail_if(result
== NULL
, "VFS module not found!");
72 fail_unless(result
== &vfs_test_ops
, "Result(%p) don't match to vfs_test_ops(%p)!", result
, &vfs_test_ops
);
77 struct vfs_class
*result
;
78 result
= vfs_get_class("/#test://bla-bla/some/path/#test_not_exists://bla-bla/some/path");
79 fail_if(result
== NULL
, "VFS module not found!");
80 fail_unless(result
== &vfs_test_ops
, "Result(%p) don't match to vfs_test_ops(%p)!", result
, &vfs_test_ops
);
86 /* --------------------------------------------------------------------------------------------- */
93 Suite
*s
= suite_create (TEST_SUITE_NAME
);
94 TCase
*tc_core
= tcase_create ("Core");
97 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
99 /* Add new tests here: *************** */
100 tcase_add_test (tc_core
, test_register_vfs_class
);
101 /* *********************************** */
103 suite_add_tcase (s
, tc_core
);
104 sr
= srunner_create (s
);
105 srunner_set_log (sr
, "get_vfs_class.log");
106 srunner_run_all (sr
, CK_NORMAL
);
107 number_failed
= srunner_ntests_failed (sr
);
109 return (number_failed
== 0) ? 0 : 1;
112 /* --------------------------------------------------------------------------------------------- */