1 /* Test for realpath/canonicalize function.
2 Copyright (C) 1998 Free Software Foundation, Inc.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
24 /* Prototype for our test function. */
25 extern void do_prepare (int argc
, char *argv
[]);
26 extern int do_test (int argc
, char *argv
[]);
28 /* We have a preparation function. */
29 #define PREPARE do_prepare
31 #include <test-skeleton.c>
33 /* Name of the temporary files we create. */
39 do_prepare (int argc
, char *argv
[])
43 test_dir_len
= strlen (test_dir
);
45 /* Generate the circular symlinks. */
46 name1
= malloc (test_dir_len
+ sizeof ("/canonXXXXXX"));
47 mempcpy (mempcpy (name1
, test_dir
, test_dir_len
),
48 "/canonXXXXXX", sizeof ("/canonXXXXXX"));
49 name2
= strdup (name1
);
51 add_temp_file (mktemp (name1
));
52 add_temp_file (mktemp (name2
));
58 do_test (int argc
, char *argv
[])
62 printf ("create symlinks from %s to %s and vice versa\n", name1
, name2
);
63 if (symlink (name1
, name2
) == -1
64 || symlink (name2
, name1
) == -1)
65 /* We cannot test this. */
68 /* Call the function. This is equivalent the using `realpath' but the
69 function allocates the room for the result. */
71 canon
= canonicalize_file_name (name1
);
73 return canon
!= NULL
|| errno
!= ELOOP
;