From dcccba655fe848564e961b3f285ce3a82d3ac73a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 7 Mar 2020 14:07:28 +0300 Subject: Add more support for symlinks on Windows See mksymlink() for details of the symlinks support on Windows. --- tests/fdstream/driver.cxx | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'tests/fdstream/driver.cxx') diff --git a/tests/fdstream/driver.cxx b/tests/fdstream/driver.cxx index 097383c..3215e02 100644 --- a/tests/fdstream/driver.cxx +++ b/tests/fdstream/driver.cxx @@ -419,26 +419,40 @@ main (int argc, const char* argv[]) ofs.clear (ofdstream::failbit); } -#ifndef _WIN32 - - // Fail for an existing symlink to unexistent file. + // Note that on Windows regular file symlinks may not be supported (see + // mksymlink() for details), so the following tests are allowed to fail + // with ENOSYS on Windows. // - path link (td / path ("link")); - mksymlink (td / path ("unexistent"), link); - try { - fdopen (link, (fdopen_mode::out | - fdopen_mode::create | - fdopen_mode::exclusive)); + // Fail for an existing symlink to unexistent file. + // + path link (td / path ("link")); + mksymlink (td / path ("unexistent"), link); - assert (false); + try + { + fdopen (link, (fdopen_mode::out | + fdopen_mode::create | + fdopen_mode::exclusive)); + + assert (false); + } + catch (const ios::failure&) + { + } } - catch (const ios::failure&) + catch (const system_error& e) { +#ifndef _WIN32 + assert (false); +#else + assert (e.code ().category () == generic_category () && + e.code ().value () == ENOSYS); +#endif } -#else +#ifdef _WIN32 // Check translation modes. // -- cgit v1.1