[PATCH v4 2/6] ntdll/tests: Move NtMapViewOfSection tests from kernel32/tests

Rémi Bernon rbernon at codeweavers.com
Thu Jun 20 08:09:21 CDT 2019


On Thu, 2019-06-20 at 10:51 +0100, Huw Davies wrote:
> On Wed, Jun 19, 2019 at 02:01:24PM +0200, Rémi Bernon wrote:
> > +static void test_MapViewOfSection(void)
> 
> Let's keep its name as test_NtMapViewofSection, since that's what
> we're testing.
> 
> > +{
> > +    static const char testfile[] = "testfile.xxx";
> > +    static const char data[] = "test data for NtMapViewOfSection";
> > +    char buffer[sizeof(data)];
> > +    HANDLE file, mapping, process;
> > +    void *ptr, *ptr2;
> > +    BOOL is_wow64, ret;
> > +    DWORD status, written;
> > +    SIZE_T size, result;
> > +    LARGE_INTEGER offset;
> > +    ULONG zero_bits;
> > +
> > +    file = CreateFileA(testfile, GENERIC_READ|GENERIC_WRITE, 0,
> > NULL, CREATE_ALWAYS, 0, 0);
> > +    ok(file != INVALID_HANDLE_VALUE, "Failed to create test
> > file\n");
> > +    WriteFile(file, data, sizeof(data), &written, NULL);
> > +    SetFilePointer(file, 4096, NULL, FILE_BEGIN);
> > +    SetEndOfFile(file);
> > +
> > +    /* read/write mapping */
> > +
> > +    mapping = CreateFileMappingA(file, NULL, PAGE_READWRITE, 0,
> > 4096, NULL);
> > +    ok(mapping != 0, "CreateFileMapping failed\n");
> > +
> > +    process = create_target_process("sleep");
> > +    ok(process != NULL, "Can't start process\n");
> > +
> > +    ptr = NULL;
> > +    size = 0;
> > +    offset.QuadPart = 0;
> > +    status = NtMapViewOfSection(mapping, process, &ptr, 0, 0,
> > &offset, &size, 1, 0, PAGE_READWRITE);
> > +    ok(status == STATUS_SUCCESS, "NtMapViewOfSection returned
> > %08x\n", status);
> > +    ok(!((ULONG_PTR)ptr & 0xffff), "returned memory %p is not
> > aligned to 64k\n", ptr);
> > +
> > +    ret = ReadProcessMemory(process, ptr, buffer, sizeof(buffer),
> > &result);
> > +    ok(ret, "ReadProcessMemory failed\n");
> > +    ok(result == sizeof(buffer), "ReadProcessMemory didn't read
> > all data (%lx)\n", result);
> > +    ok(!memcmp(buffer, data, sizeof(buffer) ), "Wrong data
> > read\n");
> > +
> > +    /* for some unknown reason NtMapViewOfSection fails with
> > STATUS_NO_MEMORY when zero_bits != 0 ? */
> > +    ptr2 = NULL;
> > +    size = 0;
> > +    offset.QuadPart = 0;
> > +    status = NtMapViewOfSection(mapping, process, &ptr2, 12, 0,
> > &offset, &size, 1, 0, PAGE_READWRITE);
> 
> This is not the same as the code you've removed from kernel32.  I
> suggest you regenerate this patch by gonig the cut-and-paste again.
> 
> Huw.

I thought the move was the occasion to keep the whole source file
consistent in style, as it wasn't before. I'm not sure what's the
policy about such changes.

I see however that there are also other test changes that I forgot to
backport here, so is it just about that or should the code style be
kept as well?
-- 
Rémi Bernon <rbernon at codeweavers.com>




More information about the wine-devel mailing list