dokan-dev / dokany

User mode file system library for windows with FUSE Wrapper
http://dokan-dev.github.io
5.31k stars 669 forks source link

Add winfstest as a test suite for Dokany #98

Closed billziss-gh closed 8 years ago

billziss-gh commented 9 years ago

Consider adding the winfstest test suite to Dokany. The testsuite can be found in the repo https://bitbucket.org/billziss/secfs.test under the winfstest directory.

This testsuite is inspired by the FreeBSD's fstest test suite. It is written from scratch to run on Windows. It requires Python 2.7 and will run under Windows or Cygwin Python.

The testsuite is currently small, but exercises a fair amount of the Dokany API.

Liryna commented 9 years ago

Hi @billziss-gh ,

I have try to build winfstest but I have the error:

>nmake Nmakefile

Microsoft (R) Program Maintenance Utility Version 14.00.23026.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl /MT /W2 winfstest.c /link /subsystem:console
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23026 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

winfstest.c
winfstest.c(34): fatal error C1083: Cannot open include file: 'windows.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.EXE"' : return code '0x2'
Stop.

Is there any documentation how to build/run the test ?

billziss-gh commented 9 years ago

Yes. One of those interesting Windows tools bugs. More information here:

https://connect.microsoft.com/VisualStudio/feedback/details/1610302/universalcrt-detection-breaks-when-windows-driver-kit-is-installed http://stackoverflow.com/questions/32885229/unable-to-compile-and-link-simple-c-program-with-visual-studio-2015-command-li

What I have done in my installation is went into the C:\Program Files (x86)\Windows Kits\10\Include directory and renamed the "wdf" directory to "00.remove00-to-enable.wdf". A more elaborate solution is described in the stackoverflow article.

Assuming you fix this issue and start a command prompt with the proper vcvars environment nmake /f Nmakefile should work.

Liryna commented 9 years ago

Thanks @billziss-gh, I have faced the same issue with another project so I made the changes in my environement. I will try to see how to add it in appveyor.

dimov-cz commented 8 years ago

It works, greate test suite!

dimov-cz commented 8 years ago

I have created new repo with this code for testing and sharing purposes https://github.com/dimov-cz/winfstest/tree/master I think this or something like this shoud be part of dokan project because this kind of testing can improve quality of all Dokan related projects. btw. mirror.exe is not passing all the tests ;)

js69 commented 8 years ago

I'm not sure how the batch file is supposed to handle the paths. I had to copy winfstest.exe and winfstest.py to to t\base and then ran as command:

python.exe .\simpletap.py .\t %1 %2

Is it normal that the current mirror.exe gets this result? total ................................. ok 167/171 - not ok 4/171

Liryna commented 8 years ago

167/171 success is not bad :smiley: ! Do we know what is the 4/171 failing ?

js69 commented 8 years ago
x:\winfstest\TestSuite>run-winfstest b:\tmp
x:\winfstest\TestSuite\t\base\00.t  ok
x:\winfstest\TestSuite\t\base\01.t  ok
x:\winfstest\TestSuite\t\base\02.t
not ok 3 - expect "RemoveDirectory b:\tmp\97f2c53e" ERROR_DIRECTORY - got ERROR_ACCESS_DENIED
not ok 8 - expect "DeleteFile b:\tmp\97f2c53e" ERROR_ACCESS_DENIED - got 0
not ok 2/10
x:\winfstest\TestSuite\t\base\03.t
not ok 4 - expect "RemoveDirectory b:\tmp\adce052f\foo" ERROR_DIRECTORY - got ERROR_ACCESS_DENIED
not ok 1/18
x:\winfstest\TestSuite\t\base\04.t  ok
x:\winfstest\TestSuite\t\base\05.t  ok
x:\winfstest\TestSuite\t\base\06.t  ok
x:\winfstest\TestSuite\t\base\07.t  ok
x:\winfstest\TestSuite\t\base\08.t  ok
x:\winfstest\TestSuite\t\base\09.t
not ok 17 - expect "CreateFile b:\tmp\fce5cd08 GENERIC_READ 0 0 OPEN_EXISTING FILE_FLAG_BACKUP_SEMANTICS 0" ERROR_SHARING_VIOLATION - got 0
not ok 1/19

total ................................. ok 167/171 - not ok 4/171
Liryna commented 8 years ago

Ok that's not big deal.

It is simply that DeleteFile and RemoveDirectory does not answer the correct error in the mirror.

For CreateFile, dokan does not handle SharedAccess https://github.com/dokan-dev/dokany/issues/152

It would be interesting to add it to appveyor if someone is interested to do it.

Liryna commented 8 years ago

Done with: https://github.com/dokan-dev/dokany/commit/c462b105a3e2768ee8dd64992bed066a03a97983

@js69 @dimov-cz I have correct some error There is only one test that fail now:

not ok 17 - expect "CreateFile b:\tmp\fce5cd08 GENERIC_READ 0 0 OPEN_EXISTING FILE_FLAG_BACKUP_SEMANTICS 0" ERROR_SHARING_VIOLATION - got 0

From: https://github.com/Liryna/winfstest/blob/master/TestSuite/t/base/09.t#L29-L30

I don't really understand why it should return ERROR_SHARING_VIOLATION since both open with GENERIC_READ. Do you have an idea ?

Liryna commented 8 years ago

It is right that NTFS return ERROR_SHARING_VIOLATION in such case.

    HANDLE tmp1 = CreateFile(L"M:\\test", GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
    std::cout << GetLastError() << std::endl;
    HANDLE tmp2 = CreateFile(L"M:\\test", GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
    std::cout << GetLastError() << std::endl;
    CloseHandle(tmp1);
    CloseHandle(tmp2);
...
0
0 //it should be 32 - ERROR_SHARING_VIOLATION

Mirror logs when it happen:

###Create 0000
CreateFile : C:\Users\Liryna\test\test
  AccountName: liryna, DomainName: DESKTOP-RBPTIQA
        ShareMode = 0x0
        AccessMode = 0x120089
        FILE_READ_DATA
        FILE_READ_ATTRIBUTES
        FILE_READ_EA
        READ_CONTROL
        SYNCHRONIZE
        STANDARD_RIGHTS_READ
        STANDARD_RIGHTS_WRITE
        STANDARD_RIGHTS_EXECUTE
        FlagsAndAttributes = 0x2000000
        FILE_FLAG_BACKUP_SEMANTICS
        OPEN_EXISTING

CreateFile status = 0 - lastError = 0
###QueryVolumeInfo -001
###GetFileInfo 0000
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
  unknown type:54
        DispatchQueryInformation result =  3221225485
###GetFileInfo 0000
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0000
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0000
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###Create 0001
CreateFile : C:\Users\Liryna\test\test
  AccountName: liryna, DomainName: DESKTOP-RBPTIQA
        ShareMode = 0x0
        AccessMode = 0x120089
        FILE_READ_DATA
        FILE_READ_ATTRIBUTES
        FILE_READ_EA
        READ_CONTROL
        SYNCHRONIZE
        STANDARD_RIGHTS_READ
        STANDARD_RIGHTS_WRITE
        STANDARD_RIGHTS_EXECUTE
        FlagsAndAttributes = 0x2000000
        FILE_FLAG_BACKUP_SEMANTICS
        OPEN_EXISTING

CreateFile status = 0 - lastError = 0
###GetFileInfo 0001
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
        FileBasicInformation
        DispatchQueryInformation result =  0
###GetFileInfo 0001
GetFileInfo : C:\Users\Liryna\test\test
        GetFileInformationByHandle success, file size = 0

        result =  0
        FileStandardInformation
        DispatchQueryInformation result =  0
###Cleanup 0000
Cleanup: C:\Users\Liryna\test\test

###Close 0000
Close: C:\Users\Liryna\test\test

###Cleanup 0001
Cleanup: C:\Users\Liryna\test\test

###Close 0001
Close: C:\Users\Liryna\test\test
dimov-cz commented 8 years ago

I think that this can be related to sharemode==0 - second attemp to open same resource shoud fail. In the test above, are tmp1 and tmp2 different and usable for operations? @Liryna

Liryna commented 8 years ago

I just found that parameters was not used during directory open :smile: (old code) Fixed with: https://github.com/dokan-dev/dokany/commit/7f73c616ae2f510381dda4e565d25e1f95516525

All 471 tests are passing now :sunglasses:

Thank you @billziss-gh and @dimov-cz for your work on winfstest

@billziss-gh I hope you will find the time to continue your great project :cry: