Mercurial > hg > octave-jordi > gnulib-hg
annotate tests/test-canonicalize-lgpl.c @ 8534:342c23c60847
Tests for module 'tsearch'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 25 Mar 2007 02:48:08 +0000 |
parents | 87ba7f58a9a1 |
children | 1f57552cdb11 |
rev | line source |
---|---|
8415
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of execution of program termination handlers. |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
2 Copyright (C) 2007 Free Software Foundation, Inc. |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software; you can redistribute it and/or modify |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 2, or (at your option) |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 any later version. |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 along with this program; if not, write to the Free Software Foundation, |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 #ifdef HAVE_CONFIG_H |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 # include <config.h> |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 #endif |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
23 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
24 #include "canonicalize.h" |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include <stdlib.h> |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 #include <string.h> |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 #define ASSERT(expr) if (!(expr)) abort (); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 int |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 main () |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 { |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 /* Check that the symbolic link to a file can be resolved. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 { |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 char *result1 = canonicalize_file_name ("t-can-lgpl.tmp/huk"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 char *result2 = canonicalize_file_name ("t-can-lgpl.tmp/tra"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 ASSERT (result1 != NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 ASSERT (result2 != NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 ASSERT (strcmp (result1, result2) == 0); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 ASSERT (strcmp (result1 + strlen (result1) - 19, "/t-can-lgpl.tmp/tra") == 0); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 free (result1); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 free (result2); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 } |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 /* Check that the symbolic link to a directory can be resolved. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 { |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
48 char *result1 = canonicalize_file_name ("t-can-lgpl.tmp/plo"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
49 char *result2 = canonicalize_file_name ("t-can-lgpl.tmp/bef"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
50 char *result3 = canonicalize_file_name ("t-can-lgpl.tmp/lum"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
51 ASSERT (result1 != NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
52 ASSERT (result2 != NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
53 ASSERT (result3 != NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
54 ASSERT (strcmp (result1, result2) == 0); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
55 ASSERT (strcmp (result2, result3) == 0); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
56 ASSERT (strcmp (result1 + strlen (result1) - 19, "/t-can-lgpl.tmp/lum") == 0); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
57 free (result1); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
58 free (result2); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
59 free (result3); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
60 } |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
61 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
62 /* Check that a symbolic link to a nonexistent file yields NULL. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
63 { |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
64 char *result = canonicalize_file_name ("t-can-lgpl.tmp/ouk"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
65 ASSERT (result == NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
66 } |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
67 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
68 /* Check that a loop of symbolic links is detected. */ |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
69 { |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
70 char *result = canonicalize_file_name ("ise"); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
71 ASSERT (result == NULL); |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
72 } |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
73 |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
74 return 0; |
87ba7f58a9a1
Tests for module 'canonicalize-lgpl'.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
75 } |