Author: pschweitzer
Date: Thu Mar 2 19:33:25 2017
New Revision: 74025
URL:
http://svn.reactos.org/svn/reactos?rev=74025&view=rev
Log:
[KERNEL32_APITEST]
Add tests for DeviceIoControl. These are mainly used to test our storage stack
CORE-12858
Added:
trunk/rostests/apitests/kernel32/DeviceIoControl.c (with props)
Modified:
trunk/rostests/apitests/kernel32/CMakeLists.txt
trunk/rostests/apitests/kernel32/testlist.c
Modified: trunk/rostests/apitests/kernel32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/CMakeLi…
==============================================================================
--- trunk/rostests/apitests/kernel32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/kernel32/CMakeLists.txt [iso-8859-1] Thu Mar 2 19:33:25 2017
@@ -3,6 +3,7 @@
list(APPEND SOURCE
DefaultActCtx.c
+ DeviceIoControl.c
dosdev.c
FindActCtxSectionStringW.c
FindFiles.c
Added: trunk/rostests/apitests/kernel32/DeviceIoControl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/DeviceI…
==============================================================================
--- trunk/rostests/apitests/kernel32/DeviceIoControl.c (added)
+++ trunk/rostests/apitests/kernel32/DeviceIoControl.c [iso-8859-1] Thu Mar 2 19:33:25
2017
@@ -0,0 +1,68 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for DeviceIoControl
+ * PROGRAMMER: Pierre Schweitzer <pierre(a)reactos.org>
+ */
+
+#include <apitest.h>
+#include <strsafe.h>
+#include <winioctl.h>
+
+START_TEST(DeviceIoControl)
+{
+ UINT Ret;
+ WCHAR Letter;
+ HANDLE Device;
+ DISK_GEOMETRY DG;
+ DWORD Size, Error;
+ WCHAR Path[MAX_PATH];
+ DISK_GEOMETRY_EX DGE;
+
+ Path[0] = 'C';
+ Path[1] = ':';
+ Path[2] = '\\';
+ Ret = GetSystemDirectoryW(Path, MAX_PATH);
+ ok(Ret > 0, "GetSystemDirectory failed\n");
+
+ Letter = Path[0];
+ ok(Path[1] == ':', "Not a drive letter: %c\n", Path[1]);
+ ok(Path[2] == '\\', "Not a drive letter: %c\n", Path[2]);
+
+ Ret = StringCchPrintfW(Path, MAX_PATH, L"%\\\\?\\c:", Letter);
+ ok(Ret == S_OK, "StringCchPrintfW failed: %d\n", Ret);
+
+ Device = CreateFileW(Path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ ok(Device != INVALID_HANDLE_VALUE, "CreateFileW for %S failed: %ld\n",
Path, GetLastError());
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &DG,
sizeof(DG) - 1, &Size, NULL);
+ ok(Ret == 0, "DeviceIoControl succeed\n");
+ Error = GetLastError();
+ ok(Error == ERROR_INSUFFICIENT_BUFFER, "Expecting ERROR_INSUFFICIENT_BUFFER, got
%ld\n", Error);
+ ok(Size == 0, "Invalid output size: %ld\n", Size);
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &DG,
sizeof(DG), &Size, NULL);
+ ok(Ret != 0, "DeviceIoControl failed: %ld\n", GetLastError());
+ ok(Size == sizeof(DG), "Invalid output size: %ld\n", Size);
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &DGE,
FIELD_OFFSET(DISK_GEOMETRY_EX, Data) - 1, &Size, NULL);
+ ok(Ret == 0, "DeviceIoControl succeed\n");
+ Error = GetLastError();
+ ok(Error == ERROR_INSUFFICIENT_BUFFER, "Expecting ERROR_INSUFFICIENT_BUFFER, got
%ld\n", Error);
+ ok(Size == 0, "Invalid output size: %ld\n", Size);
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &DGE,
FIELD_OFFSET(DISK_GEOMETRY_EX, Data), &Size, NULL);
+ ok(Ret != 0, "DeviceIoControl failed: %ld\n", GetLastError());
+ ok(Size == FIELD_OFFSET(DISK_GEOMETRY_EX, Data), "Invalid output size:
%ld\n", Size);
+
+ Size = 0;
+ Ret = DeviceIoControl(Device, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0, &DGE,
sizeof(DGE), &Size, NULL);
+ ok(Ret != 0, "DeviceIoControl failed: %ld\n", GetLastError());
+ ok(Size == sizeof(DGE), "Invalid output size: %ld\n", Size);
+
+ CloseHandle(Device);
+}
Propchange: trunk/rostests/apitests/kernel32/DeviceIoControl.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/kernel32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/testlis…
==============================================================================
--- trunk/rostests/apitests/kernel32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/kernel32/testlist.c [iso-8859-1] Thu Mar 2 19:33:25 2017
@@ -4,6 +4,7 @@
#include <apitest.h>
extern void func_DefaultActCtx(void);
+extern void func_DeviceIoControl(void);
extern void func_dosdev(void);
extern void func_FindActCtxSectionStringW(void);
extern void func_FindFiles(void);
@@ -27,6 +28,7 @@
const struct test winetest_testlist[] =
{
{ "DefaultActCtx", func_DefaultActCtx },
+ { "DeviceIoControl", func_DeviceIoControl },
{ "dosdev", func_dosdev },
{ "FindActCtxSectionStringW", func_FindActCtxSectionStringW },
{ "FindFiles", func_FindFiles },