diff options
author | Takuto Ikuta <tikuta@chromium.org> | 2017-08-30 02:05:13 (GMT) |
---|---|---|
committer | Takuto Ikuta <tikuta@chromium.org> | 2017-08-30 04:03:06 (GMT) |
commit | 86f606fe3b22f9d794713b843e9c29eb303a9663 (patch) | |
tree | 864f7e592d4511db6a867f333e95bfe76e06018c /src/util_test.cc | |
parent | 7bbc708ff08f5660f4cff4b3e8c675bec428a1f2 (diff) | |
download | Ninja-86f606fe3b22f9d794713b843e9c29eb303a9663.zip Ninja-86f606fe3b22f9d794713b843e9c29eb303a9663.tar.gz Ninja-86f606fe3b22f9d794713b843e9c29eb303a9663.tar.bz2 |
Remove path component limit from input of CanonicalizePath in windows
Diffstat (limited to 'src/util_test.cc')
-rw-r--r-- | src/util_test.cc | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/util_test.cc b/src/util_test.cc index 45d0727..b4b7516 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -292,12 +292,12 @@ TEST(CanonicalizePath, TooManyComponents) { EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err)); EXPECT_EQ(slash_bits, 0xffffffff); - // 65 is not. + // 65 is OK if #component is less than 60 after path canonicalization. err = ""; path = "a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./" "a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./a/./x/y.h"; - EXPECT_FALSE(CanonicalizePath(&path, &slash_bits, &err)); - EXPECT_EQ(err, "too many path components"); + EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err)); + EXPECT_EQ(slash_bits, 0x0); // Backslashes version. err = ""; @@ -306,8 +306,28 @@ TEST(CanonicalizePath, TooManyComponents) { "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\" "a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\a\\.\\x\\y.h"; - EXPECT_FALSE(CanonicalizePath(&path, &slash_bits, &err)); - EXPECT_EQ(err, "too many path components"); + EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err)); + EXPECT_EQ(slash_bits, 0x1ffffffff); + + + // 59 after canonicalization is OK. + err = ""; + path = "a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/" + "a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/x/y.h"; + EXPECT_EQ(58, std::count(path.begin(), path.end(), '/')); + EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err)); + EXPECT_EQ(slash_bits, 0x0); + + // Backslashes version. + err = ""; + path = + "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" + "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" + "a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\a\\" + "a\\a\\a\\a\\a\\a\\a\\a\\a\\x\\y.h"; + EXPECT_EQ(58, std::count(path.begin(), path.end(), '\\')); + EXPECT_TRUE(CanonicalizePath(&path, &slash_bits, &err)); + EXPECT_EQ(slash_bits, 0x3ffffffffffffff); } #endif |