X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-renameat.c;h=f767d714e91ffd580907cac2352f0832e4cc258c;hb=b8c5e24996c9626f03890cd986fc1fb7b17fa610;hp=eba8e161faf7aa2ca52f2c7cea550b8d67318fc4;hpb=55b092cac1b884d967124f0235d3ba11941d5954;p=gnulib.git diff --git a/tests/test-renameat.c b/tests/test-renameat.c index eba8e161f..f767d714e 100644 --- a/tests/test-renameat.c +++ b/tests/test-renameat.c @@ -1,5 +1,5 @@ /* Tests of renameat. - Copyright (C) 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2009-2012 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 @@ -61,6 +61,30 @@ main (void) /* Clean up any trash from prior testsuite runs. */ ignore_value (system ("rm -rf " BASE "*")); + /* Test behaviour for invalid file descriptors. */ + { + errno = 0; + ASSERT (renameat (-1, "foo", AT_FDCWD, "bar") == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (renameat (99, "foo", AT_FDCWD, "bar") == -1); + ASSERT (errno == EBADF); + } + ASSERT (close (creat (BASE "oo", 0600)) == 0); + { + errno = 0; + ASSERT (renameat (AT_FDCWD, BASE "oo", -1, "bar") == -1); + ASSERT (errno == EBADF); + } + { + errno = 0; + ASSERT (renameat (AT_FDCWD, BASE "oo", 99, "bar") == -1); + ASSERT (errno == EBADF); + } + ASSERT (unlink (BASE "oo") == 0); + /* Test basic rename functionality, using current directory. */ result = test_rename (do_rename, false); dfd1 = open (".", O_RDONLY);