| 2447 | // platform_specific_tests ---------------------------------------------------------// |
| 2448 | |
| 2449 | void platform_specific_tests() |
| 2450 | { |
| 2451 | #if defined(BOOST_FILESYSTEM_POSIX_API) |
| 2452 | |
| 2453 | cout << "POSIX specific tests..." << endl; |
| 2454 | BOOST_TEST(fs::system_complete("").empty()); |
| 2455 | BOOST_TEST_EQ(fs::initial_path().root_path().string(), std::string("/")); |
| 2456 | BOOST_TEST_EQ(fs::system_complete("/").string(), std::string("/")); |
| 2457 | BOOST_TEST_EQ(fs::system_complete("foo").string(), fs::initial_path().string() + "/foo"); |
| 2458 | BOOST_TEST_EQ(fs::system_complete("/foo").string(), fs::initial_path().root_path().string() + "foo"); |
| 2459 | |
| 2460 | #else // defined(BOOST_FILESYSTEM_POSIX_API) |
| 2461 | |
| 2462 | cout << "Windows specific tests..." << endl; |
| 2463 | if (!skip_long_windows_tests) |
| 2464 | { |
| 2465 | cout << " (may take several seconds)" << endl; |
| 2466 | |
| 2467 | // Tests involving accessing Samba shares, including non-existant ones, sometimes spuriously fail with ERROR_NETNAME_DELETED. |
| 2468 | // This error code doesn't necessarily mean that the share doesn't exist, just that the network connection was closed. |
| 2469 | // Retry those tests a few times until we get a definitive result. |
| 2470 | #define TEST_RETRY_ON_NET_ERROR(x) \ |
| 2471 | for (unsigned int i = 0; i < retry_count; ++i) try \ |
| 2472 | { \ |
| 2473 | BOOST_TEST(x); \ |
| 2474 | break; \ |
| 2475 | } \ |
| 2476 | catch (boost::filesystem::filesystem_error& e) \ |
| 2477 | { \ |
| 2478 | boost::system::error_code ec = e.code(); \ |
| 2479 | if (ec != boost::system::error_code(ERROR_NETNAME_DELETED, boost::system::system_category())) \ |
| 2480 | throw; \ |
| 2481 | std::cout << BOOST_STRINGIZE(x) " (attempt " << i << ") failed with error " << ec << ", " << ec.message() << std::endl; \ |
| 2482 | if ((i + 1) < retry_count) \ |
| 2483 | { \ |
| 2484 | Sleep(1000); \ |
| 2485 | continue; \ |
| 2486 | } \ |
| 2487 | BOOST_ERROR(BOOST_STRINGIZE(x) " failed (retry count exceeded)"); \ |
| 2488 | } |
| 2489 | |
| 2490 | const unsigned int retry_count = 10; |
| 2491 | TEST_RETRY_ON_NET_ERROR(!fs::exists(fs::path("//share-not"))); |
| 2492 | TEST_RETRY_ON_NET_ERROR(!fs::exists(fs::path("//share-not/"))); |
| 2493 | TEST_RETRY_ON_NET_ERROR(!fs::exists(fs::path("//share-not/foo"))); |
| 2494 | |
| 2495 | #undef TEST_RETRY_ON_NET_ERROR |
| 2496 | } |
| 2497 | cout << endl; |
| 2498 | |
| 2499 | BOOST_TEST(!fs::exists("tools/jam/src/:sys:stat.h")); // !exists() if ERROR_INVALID_NAME |
| 2500 | BOOST_TEST(!fs::exists(":sys:stat.h")); // !exists() if ERROR_INVALID_PARAMETER |
| 2501 | BOOST_TEST(dir.string().size() > 1 && dir.string()[1] == ':'); // verify path includes drive |
| 2502 | |
| 2503 | BOOST_TEST(fs::system_complete("").empty()); |
| 2504 | BOOST_TEST(fs::system_complete("/") == fs::initial_path().root_path()); |
| 2505 | BOOST_TEST(fs::system_complete("foo") == fs::initial_path() / "foo"); |
| 2506 |
no test coverage detected