ntdll/tests: Extend the FILE_APPEND_DATA test.
This commit is contained in:
parent
2c9774f002
commit
ab8d704e24
|
@ -851,43 +851,85 @@ todo_wine
|
||||||
|
|
||||||
static void append_file_test(void)
|
static void append_file_test(void)
|
||||||
{
|
{
|
||||||
const char text[] = "foobar";
|
static const char text[6] = "foobar";
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
IO_STATUS_BLOCK iosb;
|
IO_STATUS_BLOCK iosb;
|
||||||
DWORD written;
|
LARGE_INTEGER offset;
|
||||||
char path[MAX_PATH], buffer[MAX_PATH];
|
char path[MAX_PATH], buffer[MAX_PATH], buf[16];
|
||||||
|
|
||||||
GetTempPathA( MAX_PATH, path );
|
GetTempPathA( MAX_PATH, path );
|
||||||
GetTempFileNameA( path, "foo", 0, buffer );
|
GetTempFileNameA( path, "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;
|
|
||||||
}
|
|
||||||
|
|
||||||
U(iosb).Status = STATUS_PENDING;
|
handle = CreateFile(buffer, FILE_WRITE_DATA, 0, NULL, CREATE_ALWAYS, 0, 0);
|
||||||
iosb.Information = 0;
|
ok(handle != INVALID_HANDLE_VALUE, "CreateFile error %d\n", GetLastError());
|
||||||
|
|
||||||
status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb,
|
U(iosb).Status = -1;
|
||||||
text, sizeof(text), NULL, NULL);
|
iosb.Information = -1;
|
||||||
|
status = pNtWriteFile(handle, NULL, NULL, NULL, &iosb, text, 3, NULL, NULL);
|
||||||
if (status == STATUS_PENDING)
|
ok(status == STATUS_SUCCESS, "NtWriteFile error %#x\n", status);
|
||||||
{
|
ok(iosb.Status == STATUS_SUCCESS, "expected STATUS_SUCCESS, got %#x\n", iosb.Status);
|
||||||
WaitForSingleObject( handle, 1000 );
|
ok(iosb.Information == 3, "expected 3, got %lu\n", iosb.Information);
|
||||||
status = U(iosb).Status;
|
|
||||||
}
|
|
||||||
written = iosb.Information;
|
|
||||||
|
|
||||||
todo_wine
|
|
||||||
ok(status == STATUS_SUCCESS && written == sizeof(text), "FILE_APPEND_DATA NtWriteFile failed\n");
|
|
||||||
|
|
||||||
CloseHandle(handle);
|
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 = 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);
|
||||||
|
|
||||||
|
CloseHandle(handle);
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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)
|
static void nt_mailslot_test(void)
|
||||||
|
|
Loading…
Reference in New Issue