ntdll/tests: Add a FILE_APPEND_DATA test.

Matteo Bruni matteo.mystral at gmail.com
Wed Jan 12 10:26:14 CST 2011


-------------- next part --------------
From c68d5c55addb38c7dd0cea54af86cc60e3497ed0 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Wed, 12 Jan 2011 01:09:32 +0100
Subject: ntdll/tests: Add a FILE_APPEND_DATA test.

---
 dlls/ntdll/tests/file.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 5afb025..e8f23e0 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -816,6 +816,46 @@ static void read_file_test(void)
     CloseHandle( event );
 }
 
+static void append_file_test(void)
+{
+    const char text[] = "foobar";
+    HANDLE handle;
+    NTSTATUS status;
+    IO_STATUS_BLOCK iosb;
+    DWORD written;
+    char buffer[128];
+
+    GetTempFileNameA( ".", "foo", 0, buffer );
+    /* It is possible to open a file with only FILE_APPEND_DATA access flags.
+       It matches the O_WRONLY|O_APPEND open() posix behavior */
+    handle = CreateFileA(buffer, FILE_APPEND_DATA, 0, NULL, CREATE_ALWAYS,
+                         FILE_FLAG_DELETE_ON_CLOSE, 0);
+    ok( handle != INVALID_HANDLE_VALUE, "Failed to create a temp file in FILE_APPEND_DATA mode.\n" );
+    if(handle == INVALID_HANDLE_VALUE)
+    {
+        skip("Couldn't create a temporary file, skipping FILE_APPEND_DATA test\n");
+        return;
+    }
+
+    iosb.Status = STATUS_PENDING;
+    iosb.Information = 0;
+
+    status = NtWriteFile(handle, NULL, NULL, NULL, &iosb,
+                         text, sizeof(text), NULL, NULL);
+
+    if (status == STATUS_PENDING)
+    {
+        WaitForSingleObject( handle, INFINITE );
+        status = iosb.Status;
+    }
+    written = iosb.Information;
+
+    todo_wine
+    ok(status == STATUS_SUCCESS && written == sizeof(text), "FILE_APPEND_DATA NtWriteFile failed\n");
+
+    CloseHandle(handle);
+}
+
 static void nt_mailslot_test(void)
 {
     HANDLE hslot;
@@ -1555,6 +1595,7 @@ START_TEST(file)
     open_file_test();
     delete_file_test();
     read_file_test();
+    append_file_test();
     nt_mailslot_test();
     test_iocompletion();
     test_file_basic_information();
-- 
1.7.3.4


More information about the wine-patches mailing list