diff options
author | Eric Blake <ebb9@byu.net> | 2009-09-26 17:22:15 -0600 |
---|---|---|
committer | Eric Blake <ebb9@byu.net> | 2009-10-02 05:56:29 -0600 |
commit | 028ee2f5c765e41b188465f9ad2617c3ba6d9a1e (patch) | |
tree | 1e23d29e93d281a7f001cbcbdde93deaf1d592f5 /tests/test-rename.c | |
parent | a3785708b2c43617769e56342c86bbbc8b93fdbc (diff) | |
download | gnulib-028ee2f5c765e41b188465f9ad2617c3ba6d9a1e.tar.gz |
rename-tests: new test, exposes several platform bugs
This test passes on GNU/Linux, OpenBSD, and Cygwin 1.7.
Elsewhere, this test fails because of at least these bugs:
Solaris 10, cygwin 1.5.x, and mingw all mistakenly succeed on
rename("file","other/"). Solaris 9 and the gnulib replacement
for SunOS 4.1 mistakenly succeed on rename("file/","other").
Cygwin 1.5.x and mingw mistakenly succeed on rename("dir","d/.").
Cygwin 1.5.x and NetBSD 1.6 (even with the gnulib replacement)
mistakenly reduce the link count on rename("hard1","hard2").
* modules/rename-tests: New file.
* tests/test-rename.h: Likewise.
* tests/test-rename.c: Likewise.
* doc/posix-functions/rename.texi (rename): Improve documentation,
including bugs that will eventually be fixed in gnulib.
Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests/test-rename.c')
-rw-r--r-- | tests/test-rename.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test-rename.c b/tests/test-rename.c new file mode 100644 index 0000000000..7bfdd848a7 --- /dev/null +++ b/tests/test-rename.c @@ -0,0 +1,53 @@ +/* Test of rename() function. + Copyright (C) 2009 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <config.h> + +#include <unistd.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <unistd.h> + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + fflush (stderr); \ + abort (); \ + } \ + } \ + while (0) + +#define BASE "test-rename.t" + +#include "test-rename.h" + +int +main (int argc, char **argv) +{ + /* Remove any garbage left from previous partial runs. */ + ASSERT (system ("rm -rf " BASE "*") == 0); + + return test_rename (rename, true); +} |