Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[browser][file system] Tests System.IO.FileSystem #39768

Merged
merged 50 commits into from
Aug 10, 2020
Merged

[browser][file system] Tests System.IO.FileSystem #39768

merged 50 commits into from
Aug 10, 2020

Conversation

kjpou1
Copy link
Contributor

@kjpou1 kjpou1 commented Jul 22, 2020

Added 45 [PlatformSpecific(~TestPlatforms.Browser)] checks to tests.

 info: test[0]
        Tests run: 3804, Errors: 0, Failures: 0, Skipped: 100. Time: 37.597637s

// IO.Pipes not supported
public void FlushCanBeUsedOnPipes_Success(bool? flushToDisk)
public void CanSeekReturnsFalseForPipe()
public async Task AnonymousPipeReadViaFileStream(bool asyncReads)
public async Task AnonymousPipeWriteViaFileStream(bool asyncWrites)
public async Task AnonymousPipeViaFileStream_AllDataCopied(int writeSize, int numWrites)

// System.PlatformNotSupportedException : Cannot wait on monitors on this runtime.
public void EmptyFile_Read_Succeeds()
public void NonEmptyFile_Read_GetsExpectedData()
public void NonEmptyWrite_WritesExpectedData()
public Task ManyConcurrentWriteAsyncs()

  • Directory.CreateDirectory.cs

    • Browser platform volume does not limit each component of the path to a total of 255 characters.
    • Remove the test DirectoryWithComponentLongerThanMaxComponentAsPath_ThrowsException for Browser platform.
    • Add new test DirectoryWithComponentLongerThanMaxComponentAsPath_BrowserDoesNotThrowsException for Browser platform in case this check is added in the future.

Error number: #39955 - Resolved

File locking not supported: #40065

System.IO.FileSystem/tests/File/ReadWriteAllBytes.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()

System.IO.FileSystem/tests/File/ReadWriteAllBytesAsync.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()

System.IO.FileSystem/tests/File/ReadWriteAllLines.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()

        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()

System.IO.FileSystem/tests/File/ReadWriteAllLinesAsync.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()

System.IO.FileSystem/tests/File/ReadWriteAllText.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void OpenFile_ThrowsIOException()

System.IO.FileSystem/tests/File/ReadWriteAllTextAsync.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public async Task OpenFile_ThrowsIOExceptionAsync()

System.IO.FileSystem/tests/File/Create.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void FileInUse()

System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void NoTruncateOnFileShareViolation(FileMode fileMode)

System.IO.FileSystem/tests/FileStream/ctor_str_fm_fa_fs.write.cs
        [ActiveIssue("https://github.com/dotnet/runtime/issues/40065", TestPlatforms.Browser)]
         public void FileShareWithoutWriteThrows()

A FIFO special file is similar to a pipe, except that it is created in a different way. Instead of being an anonymous communications channel, a FIFO special file is entered into the file system by calling mkfifo(). Pipes are not supported on WebAssembly. Platform specific skip for browser in the following tests.

System.IO.FileSystem/tests/DirectoryInfo/Exists.cs
        public void FalseForNonRegularFile()

System.IO.FileSystem/tests/Directory/Exists.cs
        public void FalseForNonRegularFile()

System.IO.FileSystem/tests/FileInfo/Exists.cs
        public void TrueForNonRegularFile()

System.IO.FileSystem/tests/File/Exists.cs
        public void FalseForNonRegularFile()

File rename issue reporting wrong error: #40305
PR #40310 works around the issue for now while waiting for fix emscripten-core/emscripten#11804 / emscripten-core/emscripten#11812

Depends on PR: #39763 - merged

{
protected static int geteuid()
{
throw new PlatformNotSupportedException();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about returning 0 here and eliminating the platform checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By doing that and modifying the places that use geteuid the tests fail with:

[FAIL] System.IO.Tests.File_AppendAllLinesAsync.WriteToReadOnlyFile
        
  �[40m�[37mdbug�[39m�[22m�[49m: test[0]
        System.UnauthorizedAccessException : Access to the path '/tmp/File_AppendAllLinesAsync_mqajhnoo.uqp/WriteToReadOnlyFile_105_93d848c1' is denied.
        
  �[40m�[37mdbug�[39m�[22m�[49m: test[0]
        ---- System.IO.IOException : Permission denied

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pal uses sendFile and emscripten's implementation doesn't seem too friendly w/ read only files. The error message refers to not being able to write to the destination file.

If you skip this block

#if HAVE_SENDFILE_4
// On 32-bit, if you use 64-bit offsets, the last argument of `sendfile' will be a
// `size_t' a 32-bit integer while the `st_size' field of the stat structure will be off64_t.
// So `size' will have to be `uint64_t'. In all other cases, it will be `size_t'.
uint64_t size = (uint64_t)sourceStat.st_size;
// Note that per man page for large files, you have to iterate until the
// whole file is copied (Linux has a limit of 0x7ffff000 bytes copied).
while (size > 0)
{
ssize_t sent = sendfile(outFd, inFd, NULL, (size >= SSIZE_MAX ? SSIZE_MAX : (size_t)size));
if (sent < 0)
{
if (errno != EINVAL && errno != ENOSYS)
{
tmpErrno = errno;
close(outFd);
errno = tmpErrno;
return -1;
}
else
{
break;
}
}
else
{
assert((size_t)sent <= size);
size -= (size_t)sent;
}
}
if (size == 0)
{
copied = true;
}
// sendfile couldn't be used; fall back to a manual copy below. This could happen
// if we're on an old kernel, for example, where sendfile could only be used
// with sockets and not regular files.
#endif // HAVE_SENDFILE_4
, I think copying will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have gone through the build and it looks like this code block is already being skipped in the native pal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I was looking at the wrong place thinking it was included.

We should trace to see what call is bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@MaximLipnin
Copy link
Contributor

You also need to remove the test suite from src/libraries/tests.proj:
https://github.com/dotnet/runtime/blob/master/src/libraries/tests.proj#L32

@@ -24,6 +24,7 @@ protected virtual void Move(DirectoryInfo sourceDir, string destDir)
#region UniversalTests

[Fact]
[PlatformSpecific(~TestPlatforms.Browser)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here

@kjpou1
Copy link
Contributor Author

kjpou1 commented Jul 22, 2020

You also need to remove the test suite from src/libraries/tests.proj:
https://github.com/dotnet/runtime/blob/master/src/libraries/tests.proj#L32

Thanks Maxim was just waiting for PR #39763 because it would have failed anyway

@mdh1418
Copy link
Member

mdh1418 commented Aug 3, 2020

There were a few places in System.IO.MemoryMappedFiles that also had (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser), since we are changing IsSuperUser to return false rather than throwing here, should those two instances in MemoryMappedFiles.CreateFromFile.Tests.cs L700 and L706 be changed in this PR as well? If we don't want to mix suites, I can just put up another PR after this gets merged.

@kjpou1
Copy link
Contributor Author

kjpou1 commented Aug 3, 2020

@mdh1418

There were a few places in System.IO.MemoryMappedFiles that also had (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && PlatformDetection.IsSuperUser), since we are changing IsSuperUser to return false rather than throwing here, should those two instances in MemoryMappedFiles.CreateFromFile.Tests.cs L700 and L706 be changed in this PR as well? If we don't want to mix suites, I can just put up another PR after this gets merged.

Could you check the files that are in the PR. I thought I got all of them.

@mdh1418
Copy link
Member

mdh1418 commented Aug 7, 2020

Currently the results are: Tests run: 3903, Errors: 0, Failures: 0, Skipped: 117. Time: 10.340306s

@mdh1418 mdh1418 marked this pull request as ready for review August 7, 2020 17:40
Copy link
Contributor

@MaximLipnin MaximLipnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a couple of minor comments

@mdh1418 mdh1418 merged commit 4dbe414 into dotnet:master Aug 10, 2020
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@kjpou1 kjpou1 deleted the wasm-filesystem-tests branch August 19, 2020 07:37
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-System.IO
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error being overridden incorrectly on FS.Rename
7 participants