https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eb05356a2615e0f079438…
commit eb05356a2615e0f0794389358f52676e8aaa3aae
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Oct 15 10:44:50 2017 +0200
[KERNEL32_APITEST] Add a few tests for GetVolumeInformation that were used to fix
previous issues
---
modules/rostests/apitests/kernel32/CMakeLists.txt | 1 +
.../apitests/kernel32/GetVolumeInformation.c | 127 +++++++++++++++++++++
modules/rostests/apitests/kernel32/testlist.c | 2 +
3 files changed, 130 insertions(+)
diff --git a/modules/rostests/apitests/kernel32/CMakeLists.txt
b/modules/rostests/apitests/kernel32/CMakeLists.txt
index 32debf9476..86107d733d 100644
--- a/modules/rostests/apitests/kernel32/CMakeLists.txt
+++ b/modules/rostests/apitests/kernel32/CMakeLists.txt
@@ -13,6 +13,7 @@ list(APPEND SOURCE
GetCurrentDirectory.c
GetDriveType.c
GetModuleFileName.c
+ GetVolumeInformation.c
interlck.c
IsDBCSLeadByteEx.c
LoadLibraryExW.c
diff --git a/modules/rostests/apitests/kernel32/GetVolumeInformation.c
b/modules/rostests/apitests/kernel32/GetVolumeInformation.c
new file mode 100644
index 0000000000..7d2cf8bf3f
--- /dev/null
+++ b/modules/rostests/apitests/kernel32/GetVolumeInformation.c
@@ -0,0 +1,127 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Tests for GetVolumeInformation
+ * PROGRAMMER: Pierre Schweitzer <pierre(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+
+static VOID
+TestGetVolumeInformationA(VOID)
+{
+ BOOL Ret;
+ CHAR Outbuf[MAX_PATH];
+ DWORD i, MCL, Flags, Len;
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, MAX_PATH);
+ ok(Ret != FALSE, "GetVolumeInformationA failed: %ld\n", GetLastError());
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not null terminated!\n");
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Len = i;
+ Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, Len + 1);
+ ok(Ret != FALSE, "GetVolumeInformationA failed: %ld\n", GetLastError());
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not null terminated!\n");
+ ok(i == Len, "String was truncated\n");
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Len = i;
+ SetLastError(0xdeadbeef);
+ Ret = GetVolumeInformationA("C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, Len);
+ ok(Ret != TRUE, "GetVolumeInformationA succeed\n");
+ ok(GetLastError() == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH error, got
%ld\n", GetLastError());
+ ok(Outbuf[0] != 0xAA, "Output buffer was not written to\n");
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i == MAX_PATH, "String was null terminated!\n");
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] != 0xAA)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not written to!\n");
+ ok(i < Len, "Buffer has been overruned\n");
+}
+
+static VOID
+TestGetVolumeInformationW(VOID)
+{
+ BOOL Ret;
+ WCHAR Outbuf[MAX_PATH];
+ DWORD i, MCL, Flags, Len;
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, MAX_PATH);
+ ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not null terminated!\n");
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Len = i;
+ Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, Len + 1);
+ ok(Ret != FALSE, "GetVolumeInformationW failed: %ld\n", GetLastError());
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not null terminated!\n");
+ ok(i == Len, "String was truncated\n");
+
+ memset(Outbuf, 0xAA, MAX_PATH);
+ Len = i;
+ SetLastError(0xdeadbeef);
+ Ret = GetVolumeInformationW(L"C:\\", NULL, 0, NULL, &MCL, &Flags,
Outbuf, Len);
+ ok(Ret != TRUE, "GetVolumeInformationW succeed\n");
+ ok(GetLastError() == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH error, got
%ld\n", GetLastError());
+ ok(Outbuf[0] != 0xAA, "Output buffer was not written to\n");
+ for (i = 0; i < MAX_PATH; ++i)
+ {
+ if (Outbuf[i] == 0)
+ {
+ break;
+ }
+ }
+ ok(i != MAX_PATH, "String was not null terminated!\n");
+ ok(i >= Len, "Buffer has not been overruned\n");
+}
+
+START_TEST(GetVolumeInformation)
+{
+ TestGetVolumeInformationW();
+ TestGetVolumeInformationA();
+}
diff --git a/modules/rostests/apitests/kernel32/testlist.c
b/modules/rostests/apitests/kernel32/testlist.c
index 72e3ef973a..f00b9e99a6 100644
--- a/modules/rostests/apitests/kernel32/testlist.c
+++ b/modules/rostests/apitests/kernel32/testlist.c
@@ -14,6 +14,7 @@ extern void func_GetComputerNameEx(void);
extern void func_GetCurrentDirectory(void);
extern void func_GetDriveType(void);
extern void func_GetModuleFileName(void);
+extern void func_GetVolumeInformation(void);
extern void func_interlck(void);
extern void func_IsDBCSLeadByteEx(void);
extern void func_LoadLibraryExW(void);
@@ -42,6 +43,7 @@ const struct test winetest_testlist[] =
{ "GetCurrentDirectory", func_GetCurrentDirectory },
{ "GetDriveType", func_GetDriveType },
{ "GetModuleFileName", func_GetModuleFileName },
+ { "GetVolumeInformation", func_GetVolumeInformation },
{ "interlck", func_interlck },
{ "IsDBCSLeadByteEx", func_IsDBCSLeadByteEx },
{ "LoadLibraryExW", func_LoadLibraryExW },