Major refactoring: testing

This commit is contained in:
Bill Zissimopoulos 2015-12-23 12:28:56 -08:00
parent 0191b9551b
commit 41269e9d21
6 changed files with 25 additions and 10 deletions

View File

@ -176,6 +176,8 @@
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TurnOffAllWarnings</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
</ClCompile>
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\ext\tlib\testsuite.h" />

View File

@ -13,6 +13,12 @@
<ClCompile Include="..\..\..\ext\tlib\testsuite.c">
<Filter>Source\tlib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\tst\winfsp-tests\winfsp-tests.c">
<Filter>Source</Filter>
</ClCompile>
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c">
<Filter>Source</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">

View File

@ -56,7 +56,8 @@ FSP_API NTSTATUS FspFsctlCreateVolume(PWSTR DevicePath,
if (INVALID_HANDLE_VALUE == VolumeHandle)
{
Result = FspNtStatusFromWin32(GetLastError());
if (STATUS_OBJECT_NAME_NOT_FOUND == Result)
if (STATUS_OBJECT_NAME_NOT_FOUND == Result ||
STATUS_OBJECT_PATH_NOT_FOUND == Result)
Result = STATUS_NO_SUCH_DEVICE;
goto exit;
}

View File

@ -77,6 +77,8 @@ NTSTATUS FspVolumeCreate(
}
/* check the VolumeParams */
if (0 == VolumeParams.SectorSize)
VolumeParams.SectorSize = 512;
if (FspFsctlTransactTimeoutMinimum > VolumeParams.TransactTimeout ||
VolumeParams.TransactTimeout > FspFsctlTransactTimeoutMaximum)
VolumeParams.TransactTimeout = FspFsctlTransactTimeoutDefault;

View File

@ -9,19 +9,20 @@ extern int WinFspNetTests;
void mount_invalid_test(void)
{
NTSTATUS Result;
FSP_FSCTL_VOLUME_PARAMS Params = { 0 };
WCHAR VolumePath[MAX_PATH];
FSP_FSCTL_VOLUME_PARAMS VolumeParams = { 0 };
WCHAR VolumePath[MAX_PATH] = L"foo";
HANDLE VolumeHandle;
Params.SectorSize = 16384;
Params.SerialNumber = 0x12345678;
Result = FspFsctlCreateVolume(L"WinFsp.DoesNotExist", &Params, 0, VolumePath, sizeof VolumePath);
ASSERT(STATUS_NO_SUCH_DEVICE == Result);
Result = FspFsctlOpenVolume(L"\\Device\\Volume{31EF947D-B0F3-4A19-A4E7-BE0C1BE94886}.DoesNotExist", &VolumeHandle);
VolumeParams.SectorSize = 16384;
VolumeParams.SerialNumber = 0x12345678;
Result = FspFsctlCreateVolume(L"WinFsp.DoesNotExist", &VolumeParams,
VolumePath, sizeof VolumePath, &VolumeHandle);
ASSERT(STATUS_NO_SUCH_DEVICE == Result);
ASSERT(L'\0' == VolumePath[0]);
ASSERT(INVALID_HANDLE_VALUE == VolumeHandle);
}
#if 0
void mount_create_delete_dotest(PWSTR DeviceName)
{
NTSTATUS Result;
@ -228,11 +229,14 @@ void mount_volume_transact_test(void)
if (WinFspNetTests)
mount_volume_transact_dotest(L"WinFsp.Net");
}
#endif
void mount_tests(void)
{
TEST(mount_invalid_test);
#if 0
TEST(mount_create_delete_test);
TEST(mount_volume_cancel_test);
TEST(mount_volume_transact_test);
#endif
}

View File

@ -6,7 +6,7 @@ int WinFspNetTests = 0;
int main(int argc, char *argv[])
{
TESTSUITE(mount_tests);
TESTSUITE(timeout_tests);
//TESTSUITE(timeout_tests);
tlib_run_tests(argc, argv);
return 0;