X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-symlink.h;h=0c92bd40b9905e2e26be17ce8315853052a0def5;hb=afc6cbe4fe4892c5ee4166cab87fede6f294a27d;hp=99072935c3838aeb10f09dbc60bcd306411ef641;hpb=48b0feac54dce2caf46cc53dd160e699737ff52a;p=gnulib.git diff --git a/tests/test-symlink.h b/tests/test-symlink.h index 99072935c..0c92bd40b 100644 --- a/tests/test-symlink.h +++ b/tests/test-symlink.h @@ -1,5 +1,5 @@ /* Tests of symlink. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2010 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 @@ -28,18 +28,25 @@ test_symlink (int (*func) (char const *, char const *), bool print) if (func ("nowhere", BASE "link1")) { if (print) - fputs ("skipping test: symlinks not supported on this filesystem\n", + fputs ("skipping test: symlinks not supported on this file system\n", stderr); return 77; } /* Some systems allow the creation of 0-length symlinks as a synonym for "."; but most reject it. */ - errno = 0; - if (func ("", BASE "link2") == -1) - ASSERT (errno == ENOENT || errno == EINVAL); - else - ASSERT (unlink (BASE "link2") == 0); + { + int status; + errno = 0; + status = func ("", BASE "link2"); + if (status == -1) + ASSERT (errno == ENOENT || errno == EINVAL); + else + { + ASSERT (status == 0); + ASSERT (unlink (BASE "link2") == 0); + } + } /* Sanity checks of failures. */ errno = 0; @@ -69,6 +76,17 @@ test_symlink (int (*func) (char const *, char const *), bool print) ASSERT (func ("nowhere", BASE "file/") == -1); ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + /* Trailing slash must always be rejected. */ + ASSERT (unlink (BASE "link1") == 0); + ASSERT (func (BASE "link2", BASE "link1") == 0); + errno = 0; + ASSERT (func (BASE "nowhere", BASE "link1/") == -1); + ASSERT (errno == EEXIST || errno == ENOTDIR || errno == ENOENT); + errno = 0; + ASSERT (unlink (BASE "link2") == -1); + ASSERT (errno == ENOENT); + + /* Cleanup. */ ASSERT (rmdir (BASE "dir") == 0); ASSERT (unlink (BASE "file") == 0); ASSERT (unlink (BASE "link1") == 0);