Author: tfaber
Date: Fri May 4 10:28:54 2012
New Revision: 56489
URL:
http://svn.reactos.org/svn/reactos?rev=56489&view=rev
Log:
[KERNEL32_APITEST]
- Add some tests for GetCurrentDirectory and SetCurrentDirectory
Added:
trunk/rostests/apitests/kernel32/GetCurrentDirectory.c (with props)
trunk/rostests/apitests/kernel32/SetCurrentDirectory.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] Fri May 4 10:28:54 2012
@@ -2,7 +2,9 @@
add_definitions(-D_DLL -D__USE_CRTIMP)
list(APPEND SOURCE
+ GetCurrentDirectory.c
GetDriveType.c
+ SetCurrentDirectory.c
testlist.c)
add_executable(kernel32_apitest ${SOURCE})
Added: trunk/rostests/apitests/kernel32/GetCurrentDirectory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/GetCurr…
==============================================================================
--- trunk/rostests/apitests/kernel32/GetCurrentDirectory.c (added)
+++ trunk/rostests/apitests/kernel32/GetCurrentDirectory.c [iso-8859-1] Fri May 4
10:28:54 2012
@@ -1,0 +1,218 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for GetCurrentDirectory
+ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
+ */
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <wine/test.h>
+#include <ndk/rtltypes.h>
+
+static
+BOOLEAN
+CheckBuffer(
+ const VOID *Buffer,
+ SIZE_T Size,
+ UCHAR Value)
+{
+ const UCHAR *Array = Buffer;
+ SIZE_T i;
+
+ for (i = 0; i < Size; i++)
+ if (Array[i] != Value)
+ {
+ trace("Expected %x, found %x at offset %lu\n", Value, Array[i],
(ULONG)i);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static
+BOOLEAN
+CheckStringBufferA(
+ const VOID *Buffer,
+ SIZE_T Size,
+ PCSTR Expected,
+ UCHAR Fill)
+{
+ const CHAR *Chars = Buffer;
+ const UCHAR *UChars = Buffer;
+ SIZE_T Length = strlen(Expected);
+ SIZE_T i;
+
+ if (Size < Length)
+ {
+ ok(0, "Size = %lu, Length = %lu\n", (ULONG)Size, (ULONG)Length);
+ return FALSE;
+ }
+
+ for (i = 0; i < Length; i++)
+ if (Chars[i] != Expected[i])
+ {
+ trace("Expected %x, found %x at offset %lu\n", Expected[i],
Chars[i], (ULONG)i);
+ return FALSE;
+ }
+
+ ok(Chars[i] == 0, "Expected null terminator, found %x at offset %lu\n",
Chars[i], (ULONG)i);
+ i++;
+
+ for (; i < Size; i++)
+ if (UChars[i] != Fill)
+ {
+ trace("Expected %x, found %x at offset %lu\n", Fill, UChars[i],
(ULONG)i);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static
+BOOLEAN
+CheckStringBufferW(
+ const VOID *Buffer,
+ SIZE_T Size,
+ PCWSTR Expected,
+ UCHAR Fill)
+{
+ const WCHAR *Chars = Buffer;
+ const UCHAR *UChars = Buffer;
+ SIZE_T Length = wcslen(Expected);
+ SIZE_T i;
+
+ if (Size < Length)
+ {
+ ok(0, "Size = %lu, Length = %lu\n", (ULONG)Size, (ULONG)Length);
+ return FALSE;
+ }
+
+ for (i = 0; i < Length; i++)
+ if (Chars[i] != Expected[i])
+ {
+ trace("Expected %x, found %x at offset %lu\n", Expected[i],
Chars[i], (ULONG)i);
+ return FALSE;
+ }
+
+ ok(Chars[i] == 0, "Expected null terminator, found %x at offset %lu\n",
Chars[i], (ULONG)i);
+ i++;
+
+ i *= sizeof(WCHAR);
+
+ for (; i < Size; i++)
+ if (UChars[i] != Fill)
+ {
+ trace("Expected %x, found %x at offset %lu\n", Fill, UChars[i],
(ULONG)i);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static
+VOID
+TestGetCurrentDirectoryA(VOID)
+{
+ CHAR Buffer[MAX_PATH];
+ DWORD Length;
+ BOOL Ret;
+ BOOLEAN Okay;
+
+ Ret = SetCurrentDirectoryA("C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectory failed with %lu\n", GetLastError());
+
+ Length = GetCurrentDirectoryA(0, NULL);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(sizeof(Buffer), Buffer);
+ ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
+ Okay = CheckStringBufferA(Buffer, sizeof(Buffer), "C:\\", 0x55);
+ ok(Okay, "CheckStringBufferA failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(0, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(1, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(2, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(3, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryA(4, Buffer);
+ ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
+ Okay = CheckStringBufferA(Buffer, sizeof(Buffer), "C:\\", 0x55);
+ ok(Okay, "CheckStringBufferA failed\n");
+}
+
+static
+VOID
+TestGetCurrentDirectoryW(VOID)
+{
+ WCHAR Buffer[MAX_PATH];
+ DWORD Length;
+ BOOL Ret;
+ BOOLEAN Okay;
+
+ Ret = SetCurrentDirectoryW(L"C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectory failed with %lu\n", GetLastError());
+
+ Length = GetCurrentDirectoryW(0, NULL);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
+ ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
+ Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
+ ok(Okay, "CheckStringBufferW failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(0, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(1, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(2, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(3, Buffer);
+ ok(Length == sizeof("C:\\"), "Length = %lu\n", Length);
+ Okay = CheckBuffer(Buffer, sizeof(Buffer), 0x55);
+ ok(Okay, "CheckBuffer failed\n");
+
+ RtlFillMemory(Buffer, sizeof(Buffer), 0x55);
+ Length = GetCurrentDirectoryW(4, Buffer);
+ ok(Length == sizeof("C:\\") - 1, "Length = %lu\n", Length);
+ Okay = CheckStringBufferW(Buffer, sizeof(Buffer), L"C:\\", 0x55);
+ ok(Okay, "CheckStringBufferW failed\n");
+}
+
+START_TEST(GetCurrentDirectory)
+{
+ TestGetCurrentDirectoryA();
+ TestGetCurrentDirectoryW();
+}
Propchange: trunk/rostests/apitests/kernel32/GetCurrentDirectory.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/kernel32/SetCurrentDirectory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/kernel32/SetCurr…
==============================================================================
--- trunk/rostests/apitests/kernel32/SetCurrentDirectory.c (added)
+++ trunk/rostests/apitests/kernel32/SetCurrentDirectory.c [iso-8859-1] Fri May 4
10:28:54 2012
@@ -1,0 +1,109 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for SetCurrentDirectory
+ * PROGRAMMER: Thomas Faber <thfabba(a)gmx.de>
+ */
+
+#define WIN32_NO_STATUS
+#include <stdio.h>
+#include <wine/test.h>
+#include <ndk/rtltypes.h>
+
+static
+VOID
+SetUnrelatedDirectory(VOID)
+{
+ WCHAR Buffer[MAX_PATH];
+ BOOL Ret;
+
+ GetWindowsDirectoryW(Buffer, sizeof(Buffer) / sizeof(WCHAR));
+ Ret = SetCurrentDirectoryW(Buffer);
+ ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
+}
+
+static
+VOID
+TestSetCurrentDirectoryA(VOID)
+{
+ BOOL Ret;
+ CHAR Buffer[MAX_PATH];
+ DWORD Length;
+
+ SetUnrelatedDirectory();
+
+ Ret = SetCurrentDirectoryA("C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
+ Length = GetCurrentDirectoryA(sizeof(Buffer), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n",
Buffer);
+
+ /* Same directory - succeeds */
+ Ret = SetCurrentDirectoryA("C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
+ Length = GetCurrentDirectoryA(sizeof(Buffer), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n",
Buffer);
+
+ /* Same directory, lowercase - succeeds and does not change case */
+ Ret = SetCurrentDirectoryA("c:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
+ Length = GetCurrentDirectoryA(sizeof(Buffer), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!strcmp(Buffer, "C:\\"), "Current directory is %s\n",
Buffer);
+
+ SetUnrelatedDirectory();
+
+ /* Now this one does change case */
+ Ret = SetCurrentDirectoryA("c:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryA failed\n");
+ Length = GetCurrentDirectoryA(sizeof(Buffer), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!strcmp(Buffer, "c:\\"), "Current directory is %s\n",
Buffer);
+}
+
+static
+VOID
+TestSetCurrentDirectoryW(VOID)
+{
+ BOOL Ret;
+ WCHAR Buffer[MAX_PATH];
+ DWORD Length;
+
+ SetUnrelatedDirectory();
+
+ Ret = SetCurrentDirectoryW(L"C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
+ Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n",
Buffer);
+
+ /* Same directory - succeeds */
+ Ret = SetCurrentDirectoryW(L"C:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
+ Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n",
Buffer);
+
+ /* Same directory, lowercase - succeeds and does not change case */
+ Ret = SetCurrentDirectoryW(L"c:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
+ Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!wcscmp(Buffer, L"C:\\"), "Current directory is %ls\n",
Buffer);
+
+ SetUnrelatedDirectory();
+
+ /* Now this one does change case */
+ Ret = SetCurrentDirectoryW(L"c:\\");
+ ok(Ret == TRUE, "SetCurrentDirectoryW failed\n");
+ Length = GetCurrentDirectoryW(sizeof(Buffer) / sizeof(WCHAR), Buffer);
+ ok(Length == 3, "Length = %lu\n", Length);
+ ok(!wcscmp(Buffer, L"c:\\"), "Current directory is %ls\n",
Buffer);
+}
+
+START_TEST(SetCurrentDirectory)
+{
+ TestSetCurrentDirectoryA();
+ TestSetCurrentDirectoryW();
+}
Propchange: trunk/rostests/apitests/kernel32/SetCurrentDirectory.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] Fri May 4 10:28:54 2012
@@ -5,11 +5,15 @@
#define STANDALONE
#include "wine/test.h"
+extern void func_GetCurrentDirectory(void);
extern void func_GetDriveType(void);
+extern void func_SetCurrentDirectory(void);
const struct test winetest_testlist[] =
{
- { "GetDriveType", func_GetDriveType },
+ { "GetCurrentDirectory", func_GetCurrentDirectory },
+ { "GetDriveType", func_GetDriveType },
+ { "SetCurrentDirectory", func_SetCurrentDirectory },
{ 0, 0 }
};