annotate tests/test-fchmod.c @ 17960:1c04e5182252

git-version-gen: revert "detect untagged revisions" Revert commit bedd7833 as it breaks `make dist` in Inetutils at least, due to the interdependencies with top/GNUMakefile, which depend on the tag prefixes. This results in `make dist` inducing a new call to autoconf where a simple tar-ball build would be expected.
author Mats Erik Andersson <mats.andersson@gisladisker.se>
date Tue, 14 Apr 2015 21:25:59 +0100
parents ab58d4870664
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15686
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test changing the protections of a file.
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
2 Copyright (C) 2011-2015 Free Software Foundation, Inc.
15686
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <sys/stat.h>
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "signature.h"
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 SIGNATURE_CHECK (fchmod, int, (int, mode_t));
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <errno.h>
17296
87f819736ab1 Fix typo in previous change, by including <unistd.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents: 17295
diff changeset
25 #include <unistd.h>
15686
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 #include "macros.h"
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 int
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 main (void)
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 {
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 /* Test behaviour for invalid file descriptors. */
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 {
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 errno = 0;
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 ASSERT (fchmod (-1, 0600) == -1);
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 ASSERT (errno == EBADF);
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 }
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 {
17295
3a09cc104f4c tests: don't assume fd 99 is closed
Paul Eggert <eggert@cs.ucla.edu>
parents: 17249
diff changeset
39 close (99);
15686
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 errno = 0;
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (fchmod (99, 0600) == -1);
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 ASSERT (errno == EBADF);
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 }
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 return 0;
1a791c8d9039 Tests for module 'fchmod'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 }