ntoskrnl/tests: Open the test output file using a hardcoded path.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-04-04 22:36:47 -05:00 committed by Alexandre Julliard
parent fa928d16c3
commit cf1f8c6718
4 changed files with 16 additions and 23 deletions

View File

@ -2126,13 +2126,14 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
RtlInitUnicodeString(&pathU, test_input->path); RtlInitUnicodeString(&pathU, L"\\??\\C:\\windows\\winetest_ntoskrnl_okfile");
running_under_wine = test_input->running_under_wine; running_under_wine = test_input->running_under_wine;
winetest_debug = test_input->winetest_debug; winetest_debug = test_input->winetest_debug;
winetest_report_success = test_input->winetest_report_success; winetest_report_success = test_input->winetest_report_success;
attr.ObjectName = &pathU; attr.ObjectName = &pathU;
attr.Attributes = OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */ attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, 0, FILE_SYNCHRONOUS_IO_NONALERT); ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT);
pExEventObjectType = get_proc_address("ExEventObjectType"); pExEventObjectType = get_proc_address("ExEventObjectType");
ok(!!pExEventObjectType, "ExEventObjectType not found\n"); ok(!!pExEventObjectType, "ExEventObjectType not found\n");

View File

@ -46,7 +46,6 @@ struct test_input
DWORD process_id; DWORD process_id;
SIZE_T teststr_offset; SIZE_T teststr_offset;
ULONG64 *modified_value; ULONG64 *modified_value;
WCHAR path[1];
}; };
static inline char *drv_strrchr( const char *str, char ch ) static inline char *drv_strrchr( const char *str, char ch )

View File

@ -487,13 +487,14 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
RtlInitUnicodeString(&pathU, test_input->path); RtlInitUnicodeString(&pathU, L"\\??\\C:\\winetest_ntoskrnl_okfile");
running_under_wine = test_input->running_under_wine; running_under_wine = test_input->running_under_wine;
winetest_debug = test_input->winetest_debug; winetest_debug = test_input->winetest_debug;
winetest_report_success = test_input->winetest_report_success; winetest_report_success = test_input->winetest_report_success;
attr.ObjectName = &pathU; attr.ObjectName = &pathU;
attr.Attributes = OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */ attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */
ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, 0, FILE_SYNCHRONOUS_IO_NONALERT); ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT);
netio_init(); netio_init();
test_wsk_get_address_info(); test_wsk_get_address_info();

View File

@ -367,22 +367,20 @@ static ULONG64 modified_value;
static void main_test(void) static void main_test(void)
{ {
WCHAR temppathW[MAX_PATH], pathW[MAX_PATH];
struct test_input *test_input; struct test_input *test_input;
DWORD len, written, read; DWORD written, read;
UNICODE_STRING pathU;
LONG new_failures; LONG new_failures;
char buffer[512]; char buffer[512];
HANDLE okfile; HANDLE okfile;
BOOL res; BOOL res;
/* Create a temporary file that the driver will write ok/trace output to. */ /* Create a temporary file that the driver will write ok/trace output to. */
GetTempPathW(MAX_PATH, temppathW);
GetTempFileNameW(temppathW, L"dok", 0, pathW);
pRtlDosPathNameToNtPathName_U( pathW, &pathU, NULL, NULL );
len = pathU.Length + sizeof(WCHAR); okfile = CreateFileA("C:\\windows\\winetest_ntoskrnl_okfile", GENERIC_READ,
test_input = heap_alloc( offsetof( struct test_input, path[len / sizeof(WCHAR)]) ); FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL);
ok(okfile != INVALID_HANDLE_VALUE, "failed to create file, error %u\n", GetLastError());
test_input = heap_alloc( sizeof(*test_input) );
test_input->running_under_wine = !strcmp(winetest_platform, "wine"); test_input->running_under_wine = !strcmp(winetest_platform, "wine");
test_input->winetest_report_success = winetest_report_success; test_input->winetest_report_success = winetest_report_success;
test_input->winetest_debug = winetest_debug; test_input->winetest_debug = winetest_debug;
@ -391,16 +389,11 @@ static void main_test(void)
test_input->modified_value = &modified_value; test_input->modified_value = &modified_value;
modified_value = 0; modified_value = 0;
memcpy(test_input->path, pathU.Buffer, len); res = DeviceIoControl(device, IOCTL_WINETEST_MAIN_TEST, test_input, sizeof(*test_input),
res = DeviceIoControl(device, IOCTL_WINETEST_MAIN_TEST, test_input,
offsetof( struct test_input, path[len / sizeof(WCHAR)]),
&new_failures, sizeof(new_failures), &written, NULL); &new_failures, sizeof(new_failures), &written, NULL);
ok(res, "DeviceIoControl failed: %u\n", GetLastError()); ok(res, "DeviceIoControl failed: %u\n", GetLastError());
ok(written == sizeof(new_failures), "got size %x\n", written); ok(written == sizeof(new_failures), "got size %x\n", written);
okfile = CreateFileW(pathW, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
ok(okfile != INVALID_HANDLE_VALUE, "failed to create %s: %u\n", wine_dbgstr_w(pathW), GetLastError());
/* Print the ok/trace output and then add to our failure count. */ /* Print the ok/trace output and then add to our failure count. */
do { do {
ReadFile(okfile, buffer, sizeof(buffer), &read, NULL); ReadFile(okfile, buffer, sizeof(buffer), &read, NULL);
@ -408,10 +401,9 @@ static void main_test(void)
} while (read == sizeof(buffer)); } while (read == sizeof(buffer));
winetest_add_failures(new_failures); winetest_add_failures(new_failures);
pRtlFreeUnicodeString(&pathU);
heap_free(test_input); heap_free(test_input);
CloseHandle(okfile); CloseHandle(okfile);
DeleteFileW(pathW); DeleteFileA("C:\\windows\\winetest_ntoskrnl_okfile");
} }
static void test_basic_ioctl(void) static void test_basic_ioctl(void)