4f7817fd378fe31c681d2bd745c6559b1ef6a204
2 libmc - check mcconfig submodule. Get full paths to user's config files.
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/mcconfig"
30 #include "lib/global.h"
32 #include "lib/strutil.h"
33 #include "lib/strescape.h"
34 #include "lib/vfs/vfs.h"
35 #include "lib/fileloc.h"
37 #include "lib/mcconfig.h"
38 #include "src/vfs/local/local.c"
40 #define HOME_DIR "/home/testuser"
43 # define CONF_MAIN HOME_DIR PATH_SEP_STR ".config"
44 # define CONF_DATA HOME_DIR PATH_SEP_STR ".local" PATH_SEP_STR "share"
45 # define CONF_CACHE HOME_DIR PATH_SEP_STR ".cache"
47 # define CONF_MAIN HOME_DIR
48 # define CONF_DATA CONF_MAIN
49 # define CONF_CACHE CONF_MAIN
56 g_setenv ("HOME", HOME_DIR
, TRUE
);
58 g_setenv ("XDG_CONFIG_HOME", CONF_MAIN
, TRUE
);
59 g_setenv ("XDG_DATA_HOME", CONF_DATA
, TRUE
);
60 g_setenv ("XDG_CACHE_HOME", CONF_CACHE
, TRUE
);
62 str_init_strings("UTF-8");
74 #define path_fail_unless(conf_dir, conf_name) {\
75 result = mc_config_get_full_path (conf_name); \
76 fail_unless (strcmp( conf_dir PATH_SEP_STR MC_USERCONF_DIR PATH_SEP_STR conf_name, result) == 0); \
79 /* --------------------------------------------------------------------------------------------- */
80 START_TEST (user_configs_path_test
)
84 path_fail_unless (CONF_MAIN
, MC_CONFIG_FILE
);
86 path_fail_unless (CONF_MAIN
, MC_FHL_INI_FILE
);
87 path_fail_unless (CONF_MAIN
, MC_HOTLIST_FILE
);
88 path_fail_unless (CONF_MAIN
, GLOBAL_KEYMAP_FILE
);
89 path_fail_unless (CONF_MAIN
, MC_USERMENU_FILE
);
90 path_fail_unless (CONF_MAIN
, EDIT_SYNTAX_FILE
);
91 path_fail_unless (CONF_MAIN
, EDIT_HOME_MENU
);
92 path_fail_unless (CONF_MAIN
, EDIT_DIR PATH_SEP_STR
"edit.indent.rc");
93 path_fail_unless (CONF_MAIN
, EDIT_DIR PATH_SEP_STR
"edit.spell.rc");
94 path_fail_unless (CONF_MAIN
, MC_PANELS_FILE
);
95 path_fail_unless (CONF_MAIN
, MC_FILEBIND_FILE
);
97 path_fail_unless (CONF_DATA
, MC_SKINS_SUBDIR
);
98 path_fail_unless (CONF_DATA
, FISH_PREFIX
);
99 path_fail_unless (CONF_DATA
, "bashrc");
100 path_fail_unless (CONF_DATA
, "inputrc");
101 path_fail_unless (CONF_DATA
, MC_EXTFS_DIR
);
102 path_fail_unless (CONF_DATA
, MC_HISTORY_FILE
);
103 path_fail_unless (CONF_DATA
, MC_FILEPOS_FILE
);
104 path_fail_unless (CONF_DATA
, EDIT_CLIP_FILE
);
105 path_fail_unless (CONF_DATA
, MC_MACRO_FILE
);
107 path_fail_unless (CONF_CACHE
, "mc.log");
108 path_fail_unless (CONF_CACHE
, MC_TREESTORE_FILE
);
109 path_fail_unless (CONF_CACHE
, EDIT_TEMP_FILE
);
110 path_fail_unless (CONF_CACHE
, EDIT_BLOCK_FILE
);
115 /* --------------------------------------------------------------------------------------------- */
122 Suite
*s
= suite_create (TEST_SUITE_NAME
);
123 TCase
*tc_core
= tcase_create ("Core");
126 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
128 /* Add new tests here: *************** */
129 tcase_add_test (tc_core
, user_configs_path_test
);
130 /* *********************************** */
132 suite_add_tcase (s
, tc_core
);
133 sr
= srunner_create (s
);
134 srunner_set_log (sr
, "user_configs_path.log");
135 // srunner_set_fork_status (sr, CK_NOFORK);
136 srunner_run_all (sr
, CK_NORMAL
);
137 number_failed
= srunner_ntests_failed (sr
);
139 return (number_failed
== 0) ? 0 : 1;
142 /* --------------------------------------------------------------------------------------------- */