X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-canonicalize.c;h=6794cf510e07acf63358cc369a4e94209a8144de;hb=c50edd6462eaaae00f8549f9bad99d4e68b94376;hp=70b6341de9ad7a6ec0693245a393554b0cea3066;hpb=6948250861edce048d7bb3c6b47d13fa3649905e;p=gnulib.git diff --git a/tests/test-canonicalize.c b/tests/test-canonicalize.c index 70b6341de..6794cf510 100644 --- a/tests/test-canonicalize.c +++ b/tests/test-canonicalize.c @@ -1,5 +1,5 @@ /* Test of execution of file name canonicalization. - Copyright (C) 2007-2009 Free Software Foundation, Inc. + Copyright (C) 2007-2013 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,18 +29,8 @@ #include #include "same-inode.h" - -#define ASSERT(expr) \ - do \ - { \ - if (!(expr)) \ - { \ - fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ - fflush (stderr); \ - abort (); \ - } \ - } \ - while (0) +#include "ignore-value.h" +#include "macros.h" #define BASE "t-can.tmp" @@ -57,7 +47,7 @@ main (void) any leftovers from a previous partial run. */ { int fd; - ASSERT (system ("rm -rf " BASE " ise") == 0); + ignore_value (system ("rm -rf " BASE " ise")); ASSERT (mkdir (BASE, 0700) == 0); fd = creat (BASE "/tra", 0600); ASSERT (0 <= fd); @@ -92,6 +82,9 @@ main (void) result2 = canonicalize_filename_mode (NULL, CAN_EXISTING); ASSERT (result2 == NULL); ASSERT (errno == EINVAL); + result2 = canonicalize_filename_mode (".", CAN_MISSING | CAN_ALL_BUT_LAST); + ASSERT (result2 == NULL); + ASSERT (errno == EINVAL); } /* Check that a non-directory with trailing slash yields NULL. */ @@ -144,6 +137,15 @@ main (void) ASSERT (symlink ("../s/2", BASE "/d/1") == 0); ASSERT (symlink ("//.//../..", BASE "/droot") == 0); + /* Check that symbolic links are not resolved, with CAN_NOLINKS. */ + { + char *result1 = canonicalize_filename_mode (BASE "/huk", CAN_NOLINKS); + ASSERT (result1 != NULL); + ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/huk"), + "/" BASE "/huk") == 0); + free (result1); + } + /* Check that the symbolic link to a file can be resolved. */ { char *result1 = canonicalize_file_name (BASE "/huk");