Mercurial > hg > octave-lojdl > gnulib-hg
annotate tests/test-canonicalize.c @ 17460:d11431703671
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Fri, 09 Aug 2013 08:03:30 -0700 |
parents | e542fd46ad6f |
children |
rev | line source |
---|---|
9050 | 1 /* Test of execution of file name canonicalization. |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
2 Copyright (C) 2007-2013 Free Software Foundation, Inc. |
9050 | 3 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9227
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
9050 | 5 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9227
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9227
diff
changeset
|
7 (at your option) any later version. |
9050 | 8 |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9227
diff
changeset
|
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
9050 | 16 |
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ | |
18 | |
19 #include <config.h> | |
20 | |
21 #include "canonicalize.h" | |
22 | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
23 #include <errno.h> |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
24 #include <fcntl.h> |
9050 | 25 #include <stdio.h> |
26 #include <stdlib.h> | |
27 #include <string.h> | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
28 #include <sys/stat.h> |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
29 #include <unistd.h> |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
30 |
12019
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
31 #include "same-inode.h" |
12842
b2bf8684a2db
tests: silence warning about system return
Eric Blake <ebb9@byu.net>
parents:
12559
diff
changeset
|
32 #include "ignore-value.h" |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12422
diff
changeset
|
33 #include "macros.h" |
9050 | 34 |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
35 #define BASE "t-can.tmp" |
9050 | 36 |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
37 static void * |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
38 null_ptr (void) |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
39 { |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
40 return NULL; |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
41 } |
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
42 |
9050 | 43 int |
12197
e45d9bb2233e
tests: avoid several compiler warnings
Eric Blake <ebb9@byu.net>
parents:
12146
diff
changeset
|
44 main (void) |
9050 | 45 { |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
46 /* Setup some hierarchy to be used by this test. Start by removing |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
47 any leftovers from a previous partial run. */ |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
48 { |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
49 int fd; |
12842
b2bf8684a2db
tests: silence warning about system return
Eric Blake <ebb9@byu.net>
parents:
12559
diff
changeset
|
50 ignore_value (system ("rm -rf " BASE " ise")); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
51 ASSERT (mkdir (BASE, 0700) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
52 fd = creat (BASE "/tra", 0600); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
53 ASSERT (0 <= fd); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
54 ASSERT (close (fd) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
55 } |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
56 |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
57 /* Check for ., .., intermediate // handling, and for error cases. */ |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
58 { |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
59 char *result1 = canonicalize_file_name (BASE "//./..//" BASE "/tra"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
60 char *result2 = canonicalize_filename_mode (BASE "//./..//" BASE "/tra", |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
61 CAN_EXISTING); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
62 ASSERT (result1 != NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
63 ASSERT (result2 != NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
64 ASSERT (strcmp (result1, result2) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
65 ASSERT (strstr (result1, "/" BASE "/tra") |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12197
diff
changeset
|
66 == result1 + strlen (result1) - strlen ("/" BASE "/tra")); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
67 free (result1); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
68 free (result2); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
69 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
70 result1 = canonicalize_file_name (""); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
71 ASSERT (result1 == NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
72 ASSERT (errno == ENOENT); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
73 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
74 result2 = canonicalize_filename_mode ("", CAN_EXISTING); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
75 ASSERT (result2 == NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
76 ASSERT (errno == ENOENT); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
77 errno = 0; |
12422
f7842310a565
New module 'arg-nonnull'. Declare which arguments expect non-NULL values.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
78 result1 = canonicalize_file_name (null_ptr ()); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
79 ASSERT (result1 == NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
80 ASSERT (errno == EINVAL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
81 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
82 result2 = canonicalize_filename_mode (NULL, CAN_EXISTING); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
83 ASSERT (result2 == NULL); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
84 ASSERT (errno == EINVAL); |
16193
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
85 result2 = canonicalize_filename_mode (".", CAN_MISSING | CAN_ALL_BUT_LAST); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
86 ASSERT (result2 == NULL); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
87 ASSERT (errno == EINVAL); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
88 } |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
89 |
12017
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
90 /* Check that a non-directory with trailing slash yields NULL. */ |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
91 { |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
92 char *result1; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
93 char *result2; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
94 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
95 result1 = canonicalize_file_name (BASE "/tra/"); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
96 ASSERT (result1 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
97 ASSERT (errno == ENOTDIR); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
98 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
99 result2 = canonicalize_filename_mode (BASE "/tra/", CAN_EXISTING); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
100 ASSERT (result2 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
101 ASSERT (errno == ENOTDIR); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
102 } |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
103 |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
104 /* Check that a missing directory yields NULL. */ |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
105 { |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
106 char *result1; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
107 char *result2; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
108 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
109 result1 = canonicalize_file_name (BASE "/zzz/.."); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
110 ASSERT (result1 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
111 ASSERT (errno == ENOENT); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
112 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
113 result2 = canonicalize_filename_mode (BASE "/zzz/..", CAN_EXISTING); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
114 ASSERT (result2 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
115 ASSERT (errno == ENOENT); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
116 } |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
117 |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
118 /* From here on out, tests involve symlinks. */ |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
119 if (symlink (BASE "/ket", "ise") != 0) |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
120 { |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
121 ASSERT (remove (BASE "/tra") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
122 ASSERT (rmdir (BASE) == 0); |
12146
e076a06bae48
maint: prefer 'file system' over 'filesystem'
Eric Blake <ebb9@byu.net>
parents:
12057
diff
changeset
|
123 fputs ("skipping test: symlinks not supported on this file system\n", |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
12197
diff
changeset
|
124 stderr); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
125 return 77; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
126 } |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
127 ASSERT (symlink ("bef", BASE "/plo") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
128 ASSERT (symlink ("tra", BASE "/huk") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
129 ASSERT (symlink ("lum", BASE "/bef") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
130 ASSERT (symlink ("wum", BASE "/ouk") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
131 ASSERT (symlink ("../ise", BASE "/ket") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
132 ASSERT (mkdir (BASE "/lum", 0700) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
133 ASSERT (symlink ("s", BASE "/p") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
134 ASSERT (symlink ("d", BASE "/s") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
135 ASSERT (mkdir (BASE "/d", 0700) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
136 ASSERT (close (creat (BASE "/d/2", 0600)) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
137 ASSERT (symlink ("../s/2", BASE "/d/1") == 0); |
12019
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
138 ASSERT (symlink ("//.//../..", BASE "/droot") == 0); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
139 |
16193
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
140 /* Check that symbolic links are not resolved, with CAN_NOLINKS. */ |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
141 { |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
142 char *result1 = canonicalize_filename_mode (BASE "/huk", CAN_NOLINKS); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
143 ASSERT (result1 != NULL); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
144 ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/huk"), |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
145 "/" BASE "/huk") == 0); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
146 free (result1); |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
147 } |
0b2b4b60945f
canonicalize: add support for not resolving symlinks
Pádraig Brady <P@draigBrady.com>
parents:
14079
diff
changeset
|
148 |
9050 | 149 /* Check that the symbolic link to a file can be resolved. */ |
150 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
151 char *result1 = canonicalize_file_name (BASE "/huk"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
152 char *result2 = canonicalize_file_name (BASE "/tra"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
153 char *result3 = canonicalize_filename_mode (BASE "/huk", CAN_EXISTING); |
9050 | 154 ASSERT (result1 != NULL); |
155 ASSERT (result2 != NULL); | |
156 ASSERT (result3 != NULL); | |
157 ASSERT (strcmp (result1, result2) == 0); | |
158 ASSERT (strcmp (result2, result3) == 0); | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
159 ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/tra"), |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
160 "/" BASE "/tra") == 0); |
9050 | 161 free (result1); |
162 free (result2); | |
163 free (result3); | |
164 } | |
165 | |
166 /* Check that the symbolic link to a directory can be resolved. */ | |
167 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
168 char *result1 = canonicalize_file_name (BASE "/plo"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
169 char *result2 = canonicalize_file_name (BASE "/bef"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
170 char *result3 = canonicalize_file_name (BASE "/lum"); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
171 char *result4 = canonicalize_filename_mode (BASE "/plo", CAN_EXISTING); |
9050 | 172 ASSERT (result1 != NULL); |
173 ASSERT (result2 != NULL); | |
174 ASSERT (result3 != NULL); | |
175 ASSERT (result4 != NULL); | |
176 ASSERT (strcmp (result1, result2) == 0); | |
177 ASSERT (strcmp (result2, result3) == 0); | |
178 ASSERT (strcmp (result3, result4) == 0); | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
179 ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/lum"), |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
180 "/" BASE "/lum") == 0); |
9050 | 181 free (result1); |
182 free (result2); | |
183 free (result3); | |
184 free (result4); | |
185 } | |
186 | |
187 /* Check that a symbolic link to a nonexistent file yields NULL. */ | |
188 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
189 char *result1; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
190 char *result2; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
191 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
192 result1 = canonicalize_file_name (BASE "/ouk"); |
9050 | 193 ASSERT (result1 == NULL); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
194 ASSERT (errno == ENOENT); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
195 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
196 result2 = canonicalize_filename_mode (BASE "/ouk", CAN_EXISTING); |
9050 | 197 ASSERT (result2 == NULL); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
198 ASSERT (errno == ENOENT); |
9050 | 199 } |
200 | |
12017
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
201 /* Check that a non-directory symlink with trailing slash yields NULL. */ |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
202 { |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
203 char *result1; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
204 char *result2; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
205 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
206 result1 = canonicalize_file_name (BASE "/huk/"); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
207 ASSERT (result1 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
208 ASSERT (errno == ENOTDIR); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
209 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
210 result2 = canonicalize_filename_mode (BASE "/huk/", CAN_EXISTING); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
211 ASSERT (result2 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
212 ASSERT (errno == ENOTDIR); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
213 } |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
214 |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
215 /* Check that a missing directory via symlink yields NULL. */ |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
216 { |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
217 char *result1; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
218 char *result2; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
219 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
220 result1 = canonicalize_file_name (BASE "/ouk/.."); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
221 ASSERT (result1 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
222 ASSERT (errno == ENOENT); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
223 errno = 0; |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
224 result2 = canonicalize_filename_mode (BASE "/ouk/..", CAN_EXISTING); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
225 ASSERT (result2 == NULL); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
226 ASSERT (errno == ENOENT); |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
227 } |
acc38673eec3
canonicalize-lgpl: reject non-directory with trailing slash
Eric Blake <ebb9@byu.net>
parents:
12014
diff
changeset
|
228 |
9050 | 229 /* Check that a loop of symbolic links is detected. */ |
230 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
231 char *result1; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
232 char *result2; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
233 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
234 result1 = canonicalize_file_name ("ise"); |
9050 | 235 ASSERT (result1 == NULL); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
236 ASSERT (errno == ELOOP); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
237 errno = 0; |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
238 result2 = canonicalize_filename_mode ("ise", CAN_EXISTING); |
9050 | 239 ASSERT (result2 == NULL); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
240 ASSERT (errno == ELOOP); |
9050 | 241 } |
242 | |
243 /* Check that alternate modes can resolve missing basenames. */ | |
244 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
245 char *result1 = canonicalize_filename_mode (BASE "/zzz", CAN_ALL_BUT_LAST); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
246 char *result2 = canonicalize_filename_mode (BASE "/zzz", CAN_MISSING); |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
247 char *result3 = canonicalize_filename_mode (BASE "/zzz/", CAN_ALL_BUT_LAST); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
248 char *result4 = canonicalize_filename_mode (BASE "/zzz/", CAN_MISSING); |
9050 | 249 ASSERT (result1 != NULL); |
250 ASSERT (result2 != NULL); | |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
251 ASSERT (result3 != NULL); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
252 ASSERT (result4 != NULL); |
9050 | 253 ASSERT (strcmp (result1, result2) == 0); |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
254 ASSERT (strcmp (result2, result3) == 0); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
255 ASSERT (strcmp (result3, result4) == 0); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
256 ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/zzz"), |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
257 "/" BASE "/zzz") == 0); |
9050 | 258 free (result1); |
259 free (result2); | |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
260 free (result3); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
261 free (result4); |
9050 | 262 } |
263 | |
264 /* Check that alternate modes can resolve broken symlink basenames. */ | |
265 { | |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
266 char *result1 = canonicalize_filename_mode (BASE "/ouk", CAN_ALL_BUT_LAST); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
267 char *result2 = canonicalize_filename_mode (BASE "/ouk", CAN_MISSING); |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
268 char *result3 = canonicalize_filename_mode (BASE "/ouk/", CAN_ALL_BUT_LAST); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
269 char *result4 = canonicalize_filename_mode (BASE "/ouk/", CAN_MISSING); |
9050 | 270 ASSERT (result1 != NULL); |
271 ASSERT (result2 != NULL); | |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
272 ASSERT (result3 != NULL); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
273 ASSERT (result4 != NULL); |
9050 | 274 ASSERT (strcmp (result1, result2) == 0); |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
275 ASSERT (strcmp (result2, result3) == 0); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
276 ASSERT (strcmp (result3, result4) == 0); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
277 ASSERT (strcmp (result1 + strlen (result1) - strlen ("/" BASE "/wum"), |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
278 "/" BASE "/wum") == 0); |
9050 | 279 free (result1); |
280 free (result2); | |
12020
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
281 free (result3); |
29f9f80b67c1
canonicalize: in CAN_ALL_BUT_LAST, allow trailing slash
Eric Blake <ebb9@byu.net>
parents:
12019
diff
changeset
|
282 free (result4); |
9050 | 283 } |
284 | |
285 /* Check that alternate modes can handle missing dirnames. */ | |
286 { | |
287 char *result1 = canonicalize_filename_mode ("t-can.zzz/zzz", CAN_ALL_BUT_LAST); | |
288 char *result2 = canonicalize_filename_mode ("t-can.zzz/zzz", CAN_MISSING); | |
289 ASSERT (result1 == NULL); | |
290 ASSERT (result2 != NULL); | |
291 ASSERT (strcmp (result2 + strlen (result2) - 14, "/t-can.zzz/zzz") == 0); | |
292 free (result2); | |
293 } | |
294 | |
9227
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
295 /* Ensure that the following is resolved properly. |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
296 Before 2007-09-27, it would mistakenly report a loop. */ |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
297 { |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
298 char *result1 = canonicalize_filename_mode (BASE, CAN_EXISTING); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
299 char *result2 = canonicalize_filename_mode (BASE "/p/1", CAN_EXISTING); |
9227
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
300 ASSERT (result1 != NULL); |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
301 ASSERT (result2 != NULL); |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
302 ASSERT (strcmp (result2 + strlen (result1), "/d/2") == 0); |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
303 free (result1); |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
304 free (result2); |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
305 } |
484ada1ccebf
canonicalize: Avoid a false-positive cycle failure.
Jim Meyering <jim@meyering.net>
parents:
9050
diff
changeset
|
306 |
12019
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
307 /* Check that leading // is honored correctly. */ |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
308 { |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
309 struct stat st1; |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
310 struct stat st2; |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
311 char *result1 = canonicalize_file_name ("//."); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
312 char *result2 = canonicalize_filename_mode ("//.", CAN_EXISTING); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
313 char *result3 = canonicalize_file_name (BASE "/droot"); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
314 char *result4 = canonicalize_filename_mode (BASE "/droot", CAN_EXISTING); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
315 ASSERT (result1); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
316 ASSERT (result2); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
317 ASSERT (result3); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
318 ASSERT (result4); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
319 ASSERT (stat ("/", &st1) == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
320 ASSERT (stat ("//", &st2) == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
321 if (SAME_INODE (st1, st2)) |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
322 { |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
323 ASSERT (strcmp (result1, "/") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
324 ASSERT (strcmp (result2, "/") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
325 ASSERT (strcmp (result3, "/") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
326 ASSERT (strcmp (result4, "/") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
327 } |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
328 else |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
329 { |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
330 ASSERT (strcmp (result1, "//") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
331 ASSERT (strcmp (result2, "//") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
332 ASSERT (strcmp (result3, "//") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
333 ASSERT (strcmp (result4, "//") == 0); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
334 } |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
335 free (result1); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
336 free (result2); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
337 free (result3); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
338 free (result4); |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
339 } |
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
340 |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
341 /* Cleanup. */ |
12019
4e6951cd4f33
canonicalize, canonicalize-lgpl: honor // if distinct from /
Eric Blake <ebb9@byu.net>
parents:
12017
diff
changeset
|
342 ASSERT (remove (BASE "/droot") == 0); |
12014
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
343 ASSERT (remove (BASE "/d/1") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
344 ASSERT (remove (BASE "/d/2") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
345 ASSERT (remove (BASE "/d") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
346 ASSERT (remove (BASE "/s") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
347 ASSERT (remove (BASE "/p") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
348 ASSERT (remove (BASE "/plo") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
349 ASSERT (remove (BASE "/huk") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
350 ASSERT (remove (BASE "/bef") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
351 ASSERT (remove (BASE "/ouk") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
352 ASSERT (remove (BASE "/ket") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
353 ASSERT (remove (BASE "/lum") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
354 ASSERT (remove (BASE "/tra") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
355 ASSERT (remove (BASE) == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
356 ASSERT (remove ("ise") == 0); |
63cfe4168142
test-canonicalize: consolidate into single C program
Eric Blake <ebb9@byu.net>
parents:
9889
diff
changeset
|
357 |
9050 | 358 return 0; |
359 } |