Mercurial > gnulib
annotate tests/test-copy-file.c @ 40186:8964917f9574
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Mon, 18 Feb 2019 08:02:49 -0800 |
parents | b06060465f09 |
children |
rev | line source |
---|---|
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* Test of copying of files. |
40057
b06060465f09
maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents:
19484
diff
changeset
|
2 Copyright (C) 2008-2019 Free Software Foundation, Inc. |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 This program is free software: you can redistribute it and/or modify |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 it under the terms of the GNU General Public License as published by |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 the Free Software Foundation; either version 3 of the License, or |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 (at your option) any later version. |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 GNU General Public License for more details. |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 You should have received a copy of the GNU General Public License |
19190 | 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 /* Written by Bruno Haible <bruno@clisp.org>, 2008. */ |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 #include <config.h> |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
20 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 #include "copy-file.h" |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
22 |
16273
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
23 #include <stdlib.h> |
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
24 |
12496
a48d3d749ca5
Refactor common macros used in tests.
Bruno Haible <bruno@clisp.org>
parents:
12421
diff
changeset
|
25 #include "macros.h" |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 int |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 main (int argc, char *argv[]) |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 { |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 const char *file1; |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 const char *file2; |
16273
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
32 int null_stderr; |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 ASSERT (argc == 3); |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 file1 = argv[1]; |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 file2 = argv[2]; |
16273
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
38 null_stderr = (getenv ("NO_STDERR_OUTPUT") != NULL); |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 |
16273
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
40 if (null_stderr) |
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
41 ASSERT (qcopy_file_preserving (file1, file2) == 0); |
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
42 else |
d50152d6b5d2
copy-file: add error-code-returning variant.
Reuben Thomas <rrt@sc3d.org>
parents:
16201
diff
changeset
|
43 copy_file_preserving (file1, file2); |
10107
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 return 0; |
0f973047765d
Tests for the 'copy-file' module.
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 } |