Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>2017-08-26 03:08:27 +0300
committerDan Moseley <danmose@microsoft.com>2017-08-26 03:08:27 +0300
commit424823b9123729ec990b31666177b6b17905eb1c (patch)
tree0cbf224bab1a422c3ebba72106e0106ed689ffe0 /src/System.IO.FileSystem
parent98caf2d33eea9c6b6a973874968cd40d9ba396d4 (diff)
Add tests to validate we don't fall over enumerating files that just … (#23528)
* Add tests to validate we don't fall over enumerating files that just cross the legacy MAX_PATH barrier. As we do special logic on Windows to support long paths this is an important boundary to test. While these path lengths don't have special meaning outside of Windows, we'll always run them they should still pass . * Conditionalize tests for long path support NetFX needs to have the long path functionality enabled to run these tests.
Diffstat (limited to 'src/System.IO.FileSystem')
-rw-r--r--src/System.IO.FileSystem/tests/Directory/GetFiles.cs40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/System.IO.FileSystem/tests/Directory/GetFiles.cs b/src/System.IO.FileSystem/tests/Directory/GetFiles.cs
index 3c4724334f..79c22762df 100644
--- a/src/System.IO.FileSystem/tests/Directory/GetFiles.cs
+++ b/src/System.IO.FileSystem/tests/Directory/GetFiles.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Linq;
-using System.Runtime.InteropServices;
using Xunit;
namespace System.IO.Tests
@@ -42,6 +41,45 @@ namespace System.IO.Tests
File.Delete(linkPath);
Assert.Equal(0, GetEntries(containingFolder.FullName).Count());
}
+
+ [ConditionalFact(nameof(AreAllLongPathsAvailable))]
+ public void EnumerateFilesOverLegacyMaxPath()
+ {
+ // We want to test that directories under the legacy MAX_PATH (260 characters, including the null) can iterate files
+ // even if the full path is over 260.
+
+ string directory = IOServices.GetPath(GetTestFilePath(), 250);
+ Assert.Equal(250, directory.Length);
+ Assert.True(Directory.CreateDirectory(directory).Exists);
+
+ for (int i = 0; i < 6; i++)
+ {
+ string testFile = Path.Combine(directory, new string((char)('0' + i), i + 7));
+ File.Create(testFile).Dispose();
+ }
+
+ string[] files = GetEntries(directory);
+ Assert.Equal(6, files.Length);
+ }
+
+ [ConditionalFact(nameof(AreAllLongPathsAvailable))]
+ public void EnumerateFilesDirectoryOverLegacyMaxPath()
+ {
+ // Check enumerating when the entire path is over MAX_PATH
+
+ string directory = IOServices.GetPath(GetTestFilePath(), 270);
+ Assert.Equal(270, directory.Length);
+ Assert.True(Directory.CreateDirectory(directory).Exists);
+
+ for (int i = 0; i < 6; i++)
+ {
+ string testFile = Path.Combine(directory, new string((char)('0' + i), i + 7));
+ File.Create(testFile).Dispose();
+ }
+
+ string[] files = GetEntries(directory);
+ Assert.Equal(6, files.Length);
+ }
}
public class Directory_GetFiles_str_str : Directory_GetFileSystemEntries_str_str