ntdll/tests: Extend the FILE_APPEND_DATA test.
Dmitry Timoshkov
dmitry at baikal.ru
Fri Sep 20 02:00:37 CDT 2013
---
dlls/ntdll/tests/file.c | 88 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 65 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 120fdac..09de25d 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -851,43 +851,85 @@ todo_wine
static void append_file_test(void)
{
- const char text[] = "foobar";
+ static const char text[6] = "foobar";
HANDLE handle;
NTSTATUS status;
IO_STATUS_BLOCK iosb;
- DWORD written;
- char path[MAX_PATH], buffer[MAX_PATH];
+ LARGE_INTEGER offset;
+ char path[MAX_PATH], buffer[MAX_PATH], buf[16];
GetTempPathA( MAX_PATH, path );
GetTempFileNameA( path, "foo", 0, buffer );
+
+ handle = CreateFile(buffer, FILE_WRITE_DATA, 0, NULL, CREATE_ALWAYS, 0, 0);
+ ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ U(iosb).Status = -1;
+ iosb.Information = -1;
+ status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text, 3, NULL, NULL);
+ ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
+ ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
+ ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
+
+ CloseHandle(handle);
+
/* 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;
- }
+ handle = CreateFile(buffer, FILE_APPEND_DATA, 0, NULL, OPEN_EXISTING, 0, 0);
+ ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
+
+ U(iosb).Status = -1;
+ iosb.Information = -1;
+ offset.QuadPart = 0;
+ status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 3, 3, &offset, NULL);
+todo_wine
+ ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
+todo_wine
+ ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
+todo_wine
+ ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
- U(iosb).Status = STATUS_PENDING;
- iosb.Information = 0;
+ CloseHandle(handle);
- status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb,
- text, sizeof(text), NULL, NULL);
+ handle = CreateFile(buffer, FILE_READ_DATA | FILE_WRITE_DATA | FILE_APPEND_DATA, 0, NULL, OPEN_EXISTING, 0, 0);
+ ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
- if (status == STATUS_PENDING)
- {
- WaitForSingleObject( handle, 1000 );
- status = U(iosb).Status;
- }
- written = iosb.Information;
+ memset(buf, 0, sizeof(buf));
+ U(iosb).Status = -1;
+ iosb.Information = -1;
+ offset.QuadPart = 0;
+ status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
+ ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
+ ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
+todo_wine
+ ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
+ buf[6] = 0;
+todo_wine
+ ok(memcmp(buf, text, 6) == 0, "wrong file contents: %s\n", buf);
- todo_wine
- ok(status == STATUS_SUCCESS && written == sizeof(text), "FILE_APPEND_DATA NtWriteFile failed\n");
+ U(iosb).Status = -1;
+ iosb.Information = -1;
+ offset.QuadPart = 0;
+ status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text + 3, 3, &offset, NULL);
+ ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
+ ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
+ ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
+
+ memset(buf, 0, sizeof(buf));
+ U(iosb).Status = -1;
+ iosb.Information = -1;
+ offset.QuadPart = 0;
+ status = pNtReadFile(handle, 0, NULL, NULL, &iosb, buf, sizeof(buf), &offset, NULL);
+ ok(status == STATUS_SUCCESS, "NtReadFile error %#x\n", status);
+ ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
+todo_wine
+ ok(iosb.Information == 6, "expected 6, got %lu\n", iosb.Information);
+ buf[6] = 0;
+todo_wine
+ ok(memcmp(buf, "barbar", 6) == 0, "wrong file contents: %s\n", buf);
CloseHandle(handle);
+ DeleteFile(buffer);
}
static void nt_mailslot_test(void)
--
1.8.3.4
More information about the wine-patches
mailing list