From 53b44dcb5c492aa6e7fb8c0cd64107436dd33705 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Wed, 28 Sep 2022 18:46:17 +0100 Subject: [PATCH] tst: winfsp-tests: silo testing --- tools/deploy.bat | 2 +- tst/winfsp-tests/posix-test.c | 5 ++++- tst/winfsp-tests/volpath-test.c | 14 ++++++++++++-- tst/winfsp-tests/winfsp-tests.c | 12 ++++++++++++ tst/winfsp-tests/winfsp-tests.h | 1 + 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/tools/deploy.bat b/tools/deploy.bat index fe3a1344..5777d22d 100755 --- a/tools/deploy.bat +++ b/tools/deploy.bat @@ -17,7 +17,7 @@ if not X%2==X set Chkpnt=%2 ) > %~dp0..\build\VStudio\build\%Config%\deploy-setup.bat ( - echo docker run -it --rm --isolation=process -v%Deploy%:%Deploy%:RO %CImage% cmd.exe + echo docker run -it --rm --isolation=process -v%Deploy%:%Deploy%:RW %CImage% cmd.exe /k cd %Deploy% ) > %~dp0..\build\VStudio\build\%Config%\docker-run.bat set Files= diff --git a/tst/winfsp-tests/posix-test.c b/tst/winfsp-tests/posix-test.c index d051bfd9..ee671284 100644 --- a/tst/winfsp-tests/posix-test.c +++ b/tst/winfsp-tests/posix-test.c @@ -158,7 +158,10 @@ static void posix_map_sid_test(void) CloseHandle(Token); - for (size_t i = 0; sizeof map / sizeof map[0] > i; i++) + size_t n = sizeof map / sizeof map[0]; + if (RunningInContainer) + n -= 2; /* container: disable tests for "user manager\containeradministrator" */ + for (size_t i = 0; n > i; i++) { Success = ConvertStringSidToSidW(map[i].SidStr, &Sid0); ASSERT(Success); diff --git a/tst/winfsp-tests/volpath-test.c b/tst/winfsp-tests/volpath-test.c index d6035a59..dd556db8 100644 --- a/tst/winfsp-tests/volpath-test.c +++ b/tst/winfsp-tests/volpath-test.c @@ -254,8 +254,13 @@ static void volpath_mount_test(void) /* * This test does FspFileSystemSetMountPoint and therefore * cannot be used with --external or --mountpoint. + * + * Also the MountMgr appears to be buggy and fail with spurious + * STATUS_NOT_SUPPORTED and STATUS_INVALID_PARAMETER error codes + * under Windows Containers (at least with ServerCore 1909). So + * disable if RunningInContainer. */ - if (NtfsTests || OptMountPoint) + if (NtfsTests || OptMountPoint || RunningInContainer) return; if (WinFspDiskTests) @@ -322,7 +327,12 @@ void volpath_tests(void) /* * This test does FspFileSystemSetMountPoint and therefore * cannot be used with --external or --mountpoint. + * + * Also the MountMgr appears to be buggy and fail with spurious + * STATUS_NOT_SUPPORTED and STATUS_INVALID_PARAMETER error codes + * under Windows Containers (at least with ServerCore 1909). So + * disable if RunningInContainer. */ - if (!NtfsTests && !OptMountPoint) + if (!NtfsTests && !OptMountPoint && !RunningInContainer) TEST(volpath_mount_test); } diff --git a/tst/winfsp-tests/winfsp-tests.c b/tst/winfsp-tests/winfsp-tests.c index 9dd97134..fe9aaad1 100644 --- a/tst/winfsp-tests/winfsp-tests.c +++ b/tst/winfsp-tests/winfsp-tests.c @@ -32,6 +32,7 @@ int NtfsTests = 0; int WinFspDiskTests = 1; int WinFspNetTests = 1; +int RunningInContainer = 0; BOOLEAN OptExternal = FALSE; BOOLEAN OptFuseExternal = FALSE; @@ -258,6 +259,12 @@ int main(int argc, char *argv[]) if (0 == getenv("WINFSP_TESTS_EXCEPTION_FILTER_DISABLE")) SetUnhandledExceptionFilter(UnhandledExceptionHandler); + RunningInContainer = ERROR_SUCCESS == RegGetValueW( + HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control", + L"ContainerType", + RRF_RT_REG_DWORD, 0, + 0, 0); + for (int argi = 1; argc > argi; argi++) { const char *a = argv[argi]; @@ -266,6 +273,7 @@ int main(int argc, char *argv[]) if (0 == strcmp("--ntfs", a) || 0 == strcmp("--external", a)) { OptExternal = TRUE; + OptFuseExternal = FALSE; NtfsTests = 1; WinFspDiskTests = 0; WinFspNetTests = 0; @@ -404,6 +412,10 @@ int main(int argc, char *argv[]) if (!NtfsTests && OptShareName) ABORT("option --share requires --ntfs/--external"); + if (RunningInContainer) + /* container: disable network file system tests */ + WinFspNetTests = 0; + DisableBackupRestorePrivileges(); AddNetShareIfNeeded(); diff --git a/tst/winfsp-tests/winfsp-tests.h b/tst/winfsp-tests/winfsp-tests.h index c44c00cd..69eef988 100644 --- a/tst/winfsp-tests/winfsp-tests.h +++ b/tst/winfsp-tests/winfsp-tests.h @@ -213,6 +213,7 @@ VOID GetTestDirectoryEx(PWSTR DirBuf, ULONG DirBufSize, PWSTR DriveBuf); extern int NtfsTests; extern int WinFspDiskTests; extern int WinFspNetTests; +extern int RunningInContainer; extern BOOLEAN OptExternal; extern BOOLEAN OptFuseExternal;