/* 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
#include <unistd.h>
#include "same-inode.h"
+#include "ignore-value.h"
#include "macros.h"
#define BASE "t-can.tmp"
any leftovers from a previous partial run. */
{
int fd;
- system ("rm -rf " BASE " ise");
+ ignore_value (system ("rm -rf " BASE " ise"));
ASSERT (mkdir (BASE, 0700) == 0);
fd = creat (BASE "/tra", 0600);
ASSERT (0 <= fd);
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. */
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");