tst: passthrough-dotnet: include in test suite

This commit is contained in:
Bill Zissimopoulos 2017-04-11 18:23:56 -07:00
parent 739eb80cfb
commit a29390412b
3 changed files with 45 additions and 40 deletions

View File

@ -12,20 +12,26 @@ if X!ProjDir!==X (echo usage: build-sample Config Arch Sample ProjDir >&2 & goto
call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64 call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
set RegKey="HKLM\SOFTWARE\WinFsp" if X!FSP_SAMPLE_DIR!==X (
set RegVal="InstallDir" set RegKey="HKLM\SOFTWARE\WinFsp"
reg query !RegKey! /v !RegVal! /reg:32 >nul 2>&1 set RegVal="InstallDir"
if !ERRORLEVEL! equ 0 ( reg query !RegKey! /v !RegVal! /reg:32 >nul 2>&1
for /f "tokens=2,*" %%i in ('reg query !RegKey! /v !RegVal! /reg:32 ^| findstr !RegVal!') do ( if !ERRORLEVEL! equ 0 (
set InstallDir=%%j for /f "tokens=2,*" %%i in ('reg query !RegKey! /v !RegVal! /reg:32 ^| findstr !RegVal!') do (
) set InstallDir=%%j
)
)
if not exist "!InstallDir!" (echo cannot find WinFsp installation >&2 & goto fail)
if not exist "!InstallDir!samples\!Sample!" (echo cannot find WinFsp sample !Sample! >&2 & goto fail)
set SampleDir=!InstallDir!samples
) else (
set SampleDir=!FSP_SAMPLE_DIR!
) )
if not exist "!InstallDir!" (echo cannot find WinFsp installation >&2 & goto fail)
if not exist "!InstallDir!samples\!Sample!" (echo cannot find WinFsp sample !Sample! >&2 & goto fail)
if exist "!ProjDir!" rmdir /s/q "!ProjDir!" if exist "!ProjDir!" rmdir /s/q "!ProjDir!"
mkdir "!ProjDir!" mkdir "!ProjDir!"
xcopy /s/e/q/y "!InstallDir!samples\!Sample!" "!ProjDir!" xcopy /s/e/q/y "!SampleDir!\!Sample!" "!ProjDir!"
devenv "!ProjDir!\!Sample!.sln" /build "!Config!|!Arch!" devenv "!ProjDir!\!Sample!.sln" /build "!Config!|!Arch!"
if !ERRORLEVEL! neq 0 goto :fail if !ERRORLEVEL! neq 0 goto :fail

View File

@ -364,20 +364,20 @@ exit /b 0
:__ifstest-memfs :__ifstest-memfs
%1 %1
set IfsTestDirectories=^ set IfsTestDirectories=^
securit^ securit^
opcreatg^ opcreatg^
opcreatp^ opcreatp^
closedel^ closedel^
volinfo^ volinfo^
fileinfo^ fileinfo^
dirinfo^ dirinfo^
filelock^ filelock^
oplocks^ oplocks^
chgnotif^ chgnotif^
readwr^ readwr^
seccache^ seccache^
reparspt^ reparspt^
estream estream
set IfsTestMemfsExit=0 set IfsTestMemfsExit=0
call :__ifstest %1 /g Security call :__ifstest %1 /g Security
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
@ -421,7 +421,7 @@ rem StreamEnhancements.StreamNotifyNameTest: WinFsp does not notify when streams
call :__ifstest %1 /g StreamEnhancements -t StreamRenameTest -t StreamNotifyNameTest call :__ifstest %1 /g StreamEnhancements -t StreamRenameTest -t StreamNotifyNameTest
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
for %%d in (!IfsTestDirectories!) do ( for %%d in (!IfsTestDirectories!) do (
if exist %%d (echo :ifstest directory %%d still exists & set IfsTestMemfsExit=1) if exist %%d (echo :ifstest directory %%d still exists & set IfsTestMemfsExit=1)
) )
exit /b !IfsTestMemfsExit! exit /b !IfsTestMemfsExit!
@ -505,7 +505,8 @@ if !ERRORLEVEL! neq 0 goto fail
exit /b 0 exit /b 0
:sample-passthrough-dotnet :sample-passthrough-dotnet
call :__run_sample_test passthrough-dotnet anycpu passthrough-dotnet winfsp-tests-x64 call :__run_sample_test passthrough-dotnet anycpu passthrough-dotnet winfsp-tests-x64 ^
"-create_backup_test -create_restore_test -create_namelen_test -delete_access_test"
if !ERRORLEVEL! neq 0 goto fail if !ERRORLEVEL! neq 0 goto fail
exit /b 0 exit /b 0
@ -536,7 +537,7 @@ L:
"%ProjRoot%\build\VStudio\build\%Configuration%\%4.exe" ^ "%ProjRoot%\build\VStudio\build\%Configuration%\%4.exe" ^
--external --resilient --case-insensitive-cmp --share-prefix="\%1\%TMP::=$%\%1\test" ^ --external --resilient --case-insensitive-cmp --share-prefix="\%1\%TMP::=$%\%1\test" ^
-create_allocation_test -getfileinfo_name_test -rename_flipflop_test -rename_mmap_test -exec_rename_dir_test ^ -create_allocation_test -getfileinfo_name_test -rename_flipflop_test -rename_mmap_test -exec_rename_dir_test ^
-reparse* -stream* -reparse* -stream* %~5
if !ERRORLEVEL! neq 0 set RunSampleTestExit=1 if !ERRORLEVEL! neq 0 set RunSampleTestExit=1
popd popd
echo net use L: /delete echo net use L: /delete

View File

@ -197,6 +197,11 @@ namespace passthrough
ThrowIoExceptionWithHResult(ex.HResult); ThrowIoExceptionWithHResult(ex.HResult);
} }
} }
public static void Rename(String FileName, String NewFileName, Boolean ReplaceIfExists)
{
if (!MoveFileExW(FileName, NewFileName, ReplaceIfExists ? 1U/*MOVEFILE_REPLACE_EXISTING*/ : 0))
ThrowIoExceptionWithWin32(Marshal.GetLastWin32Error());
}
/* interop */ /* interop */
[StructLayout(LayoutKind.Sequential, Pack = 4)] [StructLayout(LayoutKind.Sequential, Pack = 4)]
@ -243,6 +248,11 @@ namespace passthrough
Int32 FileInformationClass, Int32 FileInformationClass,
ref FILE_DISPOSITION_INFO lpFileInformation, ref FILE_DISPOSITION_INFO lpFileInformation,
UInt32 dwBufferSize); UInt32 dwBufferSize);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern Boolean MoveFileExW(
[MarshalAs(UnmanagedType.LPWStr)] String lpExistingFileName,
[MarshalAs(UnmanagedType.LPWStr)] String lpNewFileName,
UInt32 dwFlags);
[DllImport("advapi32.dll", SetLastError = true)] [DllImport("advapi32.dll", SetLastError = true)]
private static extern Boolean SetFileSecurityW( private static extern Boolean SetFileSecurityW(
[MarshalAs(UnmanagedType.LPWStr)] String FileName, [MarshalAs(UnmanagedType.LPWStr)] String FileName,
@ -590,21 +600,9 @@ namespace passthrough
String NewFileName, String NewFileName,
Boolean ReplaceIfExists) Boolean ReplaceIfExists)
{ {
FileDesc FileDesc = (FileDesc)FileDesc0;
FileName = ConcatPath(FileName); FileName = ConcatPath(FileName);
NewFileName = ConcatPath(NewFileName); NewFileName = ConcatPath(NewFileName);
if (null != FileDesc.Stream) FileDesc.Rename(FileName, NewFileName, ReplaceIfExists);
{
if (ReplaceIfExists)
File.Delete(NewFileName);
File.Move(FileName, NewFileName);
}
else
{
if (ReplaceIfExists)
throw new UnauthorizedAccessException();
Directory.Move(FileName, NewFileName);
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
protected override Int32 GetSecurity( protected override Int32 GetSecurity(