ntdll: Try2: Object manager's directory object tests

Vitaliy Margolen wine-patch at kievinfo.com
Mon Nov 14 23:22:38 CST 2005


Sorry use this one instead.
Had extra RtlFreeUnicodeString on not initialized yet unicode string.

They are all todo_wine as we don't have them implemented yet.
I need to be sure that these tests pass on all winNT systems.
So far I have tested them on NT4.0, 2k and XP sp1.

Vitaliy Margolen

changelog:
  ntdll
  - Object manager's directory object tests
-------------- next part --------------
Index: dlls/ntdll/tests/om.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/tests/om.c,v
retrieving revision 1.4
diff -u -p -r1.4 om.c
--- dlls/ntdll/tests/om.c	2 Nov 2005 14:15:10 -0000	1.4
+++ dlls/ntdll/tests/om.c	15 Nov 2005 05:20:16 -0000
@@ -25,6 +25,8 @@
 #include "winnt.h"
 #include "stdlib.h"
 
+static NTSTATUS (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING, LPCSTR);
+static VOID     (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
 static NTSTATUS (WINAPI *pNtCreateEvent) ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN, BOOLEAN);
 static NTSTATUS (WINAPI *pNtCreateMutant)( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES, BOOLEAN );
 static NTSTATUS (WINAPI *pNtOpenMutant)  ( PHANDLE, ACCESS_MASK, const POBJECT_ATTRIBUTES );
@@ -33,6 +35,8 @@ static NTSTATUS (WINAPI *pNtClose)      
 static VOID     (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR );
 static NTSTATUS (WINAPI *pNtCreateNamedPipeFile)( PHANDLE, ULONG, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK,
                                        ULONG, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG, ULONG, PLARGE_INTEGER );
+static NTSTATUS (WINAPI *pNtOpenDirectoryObject)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
+static NTSTATUS (WINAPI *pNtCreateDirectoryObject)(PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES);
 
 
 void test_case_sensitive (void)
@@ -139,11 +143,177 @@ void test_namespace_pipe(void)
     pNtClose(pipe);
 }
 
+#define DIRECTORY_QUERY (0x0001)
+
+void test_directory(void)
+{
+    UNICODE_STRING str;
+    OBJECT_ATTRIBUTES attr;
+    HANDLE dir, dir1, h;
+    NTSTATUS status;
+
+todo_wine{
+    /* No name and/or no attributes */
+    status = pNtCreateDirectoryObject(NULL, DIRECTORY_QUERY, NULL);
+    ok(status == STATUS_ACCESS_VIOLATION,
+        "NtCreateDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(NULL, DIRECTORY_QUERY, NULL);
+    ok(status == STATUS_ACCESS_VIOLATION,
+        "NtOpenDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08lx)\n", status);
+
+    status = pNtCreateDirectoryObject(&dir, DIRECTORY_QUERY, NULL);
+    ok(status == STATUS_SUCCESS, "Failed to create Directory without attributes(%08lx)\n", status);
+    pNtClose(dir);
+
+    InitializeObjectAttributes(&attr, NULL, 0, 0, NULL);
+    status = pNtCreateDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to create nameless Directory(%08lx)\n", status);
+
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, NULL);
+    ok(status == STATUS_INVALID_PARAMETER,
+        "NtOpenDirectoryObject should have failed with STATUS_INVALID_PARAMETER got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+
+    /* Bad name */
+    pRtlCreateUnicodeStringFromAsciiz(&str, "");
+    InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to create Directory(%08lx)\n", status);
+    pNtClose(h);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+    pNtClose(dir);
+
+    InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_COLLISION,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "BaseNamedObjects");
+    InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\\\BaseNamedObjects");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects");
+    status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to open Directory(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\\\om.c-test");
+    InitializeObjectAttributes(&attr, &str, 0, 0, NULL);
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\om.c-test");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to create Directory(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+    pNtClose(h);
+
+    /* Use of root directory */
+    InitializeObjectAttributes(&attr, NULL, 0, dir, NULL);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_NAME_INVALID,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_NAME_INVALID got(%08lx)\n", status);
+
+    InitializeObjectAttributes(&attr, &str, 0, dir, NULL);
+    pRtlCreateUnicodeStringFromAsciiz(&str, "");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to create Directory(%08lx)\n", status);
+    pNtClose(h);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to open Directory(%08lx)\n", status);
+    pNtClose(h);
+    pRtlFreeUnicodeString(&str);
+
+    InitializeObjectAttributes(&attr, &str, 0, dir, NULL);
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-test");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-test\\");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test\\");
+    status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
+        "NtCreateDirectoryObject should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_OBJECT_PATH_NOT_FOUND,
+        "NtOpenDirectoryObject should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test");
+    status = pNtCreateDirectoryObject(&dir1, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to create Directory(%08lx)\n", status);
+    status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, &attr);
+    ok(status == STATUS_SUCCESS, "Failed to open Directory(%08lx)\n", status);
+    pRtlFreeUnicodeString(&str);
+
+    pNtClose(h);
+    pNtClose(dir1);
+    pNtClose(dir);
+}
+}
+
 START_TEST(om)
 {
     HMODULE hntdll = GetModuleHandleA("ntdll.dll");
     if (hntdll)
     {
+        pRtlCreateUnicodeStringFromAsciiz = (void *)GetProcAddress(hntdll, "RtlCreateUnicodeStringFromAsciiz");
+        pRtlFreeUnicodeString   = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
         pNtCreateEvent          = (void *)GetProcAddress(hntdll, "NtCreateEvent");
         pNtCreateMutant         = (void *)GetProcAddress(hntdll, "NtCreateMutant");
         pNtOpenMutant           = (void *)GetProcAddress(hntdll, "NtOpenMutant");
@@ -151,8 +321,11 @@ START_TEST(om)
         pNtClose                = (void *)GetProcAddress(hntdll, "NtClose");
         pRtlInitUnicodeString   = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
         pNtCreateNamedPipeFile  = (void *)GetProcAddress(hntdll, "NtCreateNamedPipeFile");
+        pNtOpenDirectoryObject  = (void *)GetProcAddress(hntdll, "NtOpenDirectoryObject");
+        pNtCreateDirectoryObject= (void *)GetProcAddress(hntdll, "NtCreateDirectoryObject");
 
         test_case_sensitive();
         test_namespace_pipe();
+        test_directory();
     }
 }


More information about the wine-patches mailing list