From 41d093afaf0519a15b69fe16a6045a213f5bf0de Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 31 Mar 2012 23:10:45 +0300 Subject: [PATCH] Ticket #2768 ('make check' failed) tests/.../do_panel_cd.c: fix test when 'HOME' contains trailing slashes. Steps to reproduce: $ HOME=${HOME}/ make check Running suite(s): /src/filemanager cwd=/subvolumes/var_tmp/paludis/app-misc-mc-9999/temp mc_config_get_home_dir ()=/subvolumes/var_tmp/paludis/app-misc-mc-9999/temp/ 0%: Checks: 1, Failures: 1, Errors: 0 do_panel_cd.c:86:F:Core:test_do_panel_cd_empty_mean_home:0: Assertion 'ret' failed The patch adds home dir path normalization. Signed-off-by: Sergei Trofimovich --- tests/src/filemanager/do_panel_cd.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/src/filemanager/do_panel_cd.c b/tests/src/filemanager/do_panel_cd.c index 043f7d0bb..30368be96 100644 --- a/tests/src/filemanager/do_panel_cd.c +++ b/tests/src/filemanager/do_panel_cd.c @@ -59,6 +59,7 @@ teardown (void) START_TEST (test_do_panel_cd_empty_mean_home) { char *cwd; + char *home_wd; struct WPanel *panel; gboolean ret; vfs_path_t *empty_path; @@ -71,21 +72,25 @@ START_TEST (test_do_panel_cd_empty_mean_home) panel->sort_info.sort_field = g_new0(panel_field_t,1); empty_path = vfs_path_from_str (mc_config_get_home_dir()); + + /* + * normalize path to handle HOME with trailing slashes: + * HOME=/home/slyfox///////// ./do_panel_cd + */ + home_wd = vfs_path_to_str (empty_path); ret = do_panel_cd (panel, empty_path, cd_parse_command); vfs_path_free (empty_path); fail_unless(ret); cwd = vfs_path_to_str (panel->cwd_vpath); - ret = strcmp(cwd, mc_config_get_home_dir ()) == 0; - if (!ret) - { - printf ("cwd=%s\n", cwd); - printf ("mc_config_get_home_dir ()=%s\n", mc_config_get_home_dir ()); - } - fail_unless(ret); - + printf ("mc_config_get_home_dir ()=%s\n", mc_config_get_home_dir ()); + printf ("cwd=%s\n", cwd); + printf ("home_wd=%s\n", home_wd); + fail_unless(strcmp(cwd, home_wd) == 0); + g_free (cwd); + g_free (home_wd); vfs_path_free (panel->cwd_vpath); vfs_path_free (panel->lwd_vpath); g_free ((gpointer) panel->sort_info.sort_field);