Mercurial > hg > octave-lojdl > gnulib-hg
diff tests/test-canonicalize.c @ 12020:29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Coreutils' `readlink -f foo/' should not fail if lstat("foo")
gives ENOENT.
* lib/canonicalize.c (canonicalize_filename_mode): Skip trailing
slashes when checking if last component is missing.
* tests/test-canonicalize.c (main): Test this.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Sat, 12 Sep 2009 06:04:46 -0600 (2009-09-12) |
parents | 4e6951cd4f33 |
children | aee865e7b49f |
line wrap: on
line diff
--- a/tests/test-canonicalize.c +++ b/tests/test-canonicalize.c @@ -240,26 +240,42 @@ { char *result1 = canonicalize_filename_mode (BASE "/zzz", CAN_ALL_BUT_LAST); char *result2 = canonicalize_filename_mode (BASE "/zzz", CAN_MISSING); + char *result3 = canonicalize_filename_mode (BASE "/zzz/", CAN_ALL_BUT_LAST); + char *result4 = canonicalize_filename_mode (BASE "/zzz/", CAN_MISSING); ASSERT (result1 != NULL); ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (result4 != NULL); ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result3, result4) == 0); ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/zzz"), "/" BASE "/zzz") == 0); free (result1); free (result2); + free (result3); + free (result4); } /* Check that alternate modes can resolve broken symlink basenames. */ { char *result1 = canonicalize_filename_mode (BASE "/ouk", CAN_ALL_BUT_LAST); char *result2 = canonicalize_filename_mode (BASE "/ouk", CAN_MISSING); + char *result3 = canonicalize_filename_mode (BASE "/ouk/", CAN_ALL_BUT_LAST); + char *result4 = canonicalize_filename_mode (BASE "/ouk/", CAN_MISSING); ASSERT (result1 != NULL); ASSERT (result2 != NULL); + ASSERT (result3 != NULL); + ASSERT (result4 != NULL); ASSERT (strcmp (result1, result2) == 0); + ASSERT (strcmp (result2, result3) == 0); + ASSERT (strcmp (result3, result4) == 0); ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/wum"), "/" BASE "/wum") == 0); free (result1); free (result2); + free (result3); + free (result4); } /* Check that alternate modes can handle missing dirnames. */