[ROSTESTS] Update test helpers to allow custom file/line info

This commit is contained in:
Mark Jansen 2020-01-05 00:51:13 +01:00
parent 2fc872895b
commit 2eb96f0c40
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
4 changed files with 46 additions and 37 deletions

View file

@ -1,8 +1,8 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Test for IACLCustomMRU objects
* COPYRIGHT: Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
* COPYRIGHT: Copyright 2017-2020 Mark Jansen (mark.jansen@reactos.org)
*/
#define _UNICODE
@ -22,7 +22,7 @@ ULONG DbgPrint(PCH Format,...);
#include <strsafe.h>
#include <initguid.h>
#define ok_hex_(file, line, key, expression, result) \
#define ok_hex2(file, line, key, expression, result) \
do { \
int _value = (expression); \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x for %c\n", \
@ -84,7 +84,7 @@ static void verify_mru_(const char* file, int line, IACLCustomMRU* mru, PCWSTR M
CStringW tmp;
tmp += Key;
LSTATUS Status = key.QueryStringValue(tmp, Value, &nChars);
ok_hex_(file, line, Key, Status, ERROR_SUCCESS);
ok_hex2(file, line, Key, Status, ERROR_SUCCESS);
if (Status == ERROR_SUCCESS)
{
ok_(file, line)(!wcscmp(Value, Entry), "Expected value %c to be %S, was %S\n", (char)Key, Entry, Value);
@ -98,7 +98,7 @@ static void verify_mru_(const char* file, int line, IACLCustomMRU* mru, PCWSTR M
WCHAR Value[MAX_PATH];
ULONG nChars = _countof(Value);
LSTATUS Status = key.QueryStringValue(L"MRUList", Value, &nChars);
ok_hex_(file, line, Key, Status, ERROR_SUCCESS);
ok_hex2(file, line, Key, Status, ERROR_SUCCESS);
if (Status == ERROR_SUCCESS)
{
ok_(file, line)(!wcscmp(Value, MRUString), "Expected MRUList to be %S, was %S\n", MRUString, Value);

View file

@ -1,15 +1,15 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPLv2+ - See COPYING in the top level directory
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Test for RtlNtPathNameToDosPathName
* PROGRAMMER: Mark Jansen
* COPYRIGHT: Copyright 2017-2020 Mark Jansen (mark.jansen@reactos.org)
*/
#include "precomp.h"
NTSTATUS (NTAPI *pRtlNtPathNameToDosPathName)(ULONG Flags, PRTL_UNICODE_STRING_BUFFER Path, PULONG Type, PULONG Unknown4);
#define ok_hex_(expression, result) \
#define ok_hex2(expression, result) \
do { \
int _value = (expression); \
winetest_ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
@ -17,14 +17,14 @@ NTSTATUS (NTAPI *pRtlNtPathNameToDosPathName)(ULONG Flags, PRTL_UNICODE_STRING_B
} while (0)
#define ok_ptr_(expression, result) \
#define ok_ptr2(expression, result) \
do { \
void *_value = (expression); \
winetest_ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
#expression, (void*)(result), _value); \
} while (0)
#define ok_wstr_(x, y) \
#define ok_wstr2(x, y) \
winetest_ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
@ -369,14 +369,14 @@ static void test_table(struct test_entry* Entry)
RtlEnsureBufferSize(RTL_SKIP_BUFFER_COPY, &Buffer.ByteBuffer, Buffer.String.MaximumLength);
memcpy(Buffer.ByteBuffer.Buffer, Buffer.String.Buffer, Buffer.String.MaximumLength);
ok_hex_(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
ok_hex2(pRtlNtPathNameToDosPathName(0, &Buffer, &Type, NULL), STATUS_SUCCESS);
ok_hex_(Type, Entry->Type);
ok_wstr_(Buffer.String.Buffer, Entry->OutputPath);
ok_hex2(Type, Entry->Type);
ok_wstr2(Buffer.String.Buffer, Entry->OutputPath);
/* If there is no change in the path, the pointer is unchanged */
if (!wcscmp(Entry->InputPath, Entry->OutputPath))
{
ok_ptr_(Buffer.String.Buffer, Entry->InputPath);
ok_ptr2(Buffer.String.Buffer, Entry->InputPath);
}
else
{
@ -385,16 +385,16 @@ static void test_table(struct test_entry* Entry)
(PUCHAR)Buffer.String.Buffer <= (Buffer.ByteBuffer.StaticBuffer + Buffer.ByteBuffer.StaticSize),
"Expected Buffer to point inside StaticBuffer\n");
}
ok_wstr_((const WCHAR *)Buffer.ByteBuffer.Buffer, Entry->OutputPath);
ok_wstr2((const WCHAR *)Buffer.ByteBuffer.Buffer, Entry->OutputPath);
ok_hex_(Buffer.MinimumStaticBufferForTerminalNul, 0);
ok_hex2(Buffer.MinimumStaticBufferForTerminalNul, 0);
/* For none of our tests should we exceed the StaticBuffer size! */
ok_ptr_(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
ok_hex_(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
ok_ptr2(Buffer.ByteBuffer.Buffer, Buffer.ByteBuffer.StaticBuffer);
ok_hex2(Buffer.ByteBuffer.Size, Buffer.ByteBuffer.StaticSize);
ok_hex_(Buffer.ByteBuffer.ReservedForAllocatedSize, 0);
ok_ptr_(Buffer.ByteBuffer.ReservedForIMalloc, NULL);
ok_hex2(Buffer.ByteBuffer.ReservedForAllocatedSize, 0);
ok_ptr2(Buffer.ByteBuffer.ReservedForIMalloc, NULL);
RtlFreeBuffer(&Buffer.ByteBuffer);
}

View file

@ -3,7 +3,7 @@
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
* PURPOSE: Test for CreateWindowEx
* PROGRAMMERS: Thomas Faber <thomas.faber@reactos.org>
* Mark Jansen
* Mark Jansen (mark.jansen@reactos.org)
*/
#include "precomp.h"
@ -94,6 +94,7 @@ DWORD g_ChildNcExpectExStyle = 0;
DWORD g_ChildExpectStyle = 0;
DWORD g_ChildExpectExStyle = 0;
#undef ok_hex_
#define ok_hex_(expression, result) \
do { \
int _value = (expression); \

View file

@ -821,47 +821,55 @@ int main( int argc, char **argv )
// Some helpful definitions
#define ok_hex(expression, result) \
#define ok_hex_(file, line, expression, result) \
do { \
int _value = (expression); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
#expression, (int)(result), _value); \
} while (0)
#define ok_hex(expression, result) ok_hex_(__FILE__, __LINE__, expression, result)
#define ok_dec(expression, result) \
#define ok_dec_(file, line, expression, result) \
do { \
int _value = (expression); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
#expression, (int)(result), _value); \
} while (0)
#define ok_dec(expression, result) ok_dec_(__FILE__, __LINE__, expression, result)
#define ok_ptr(expression, result) \
#define ok_ptr_(file, line, expression, result) \
do { \
void *_value = (expression); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
#expression, (void*)(result), _value); \
} while (0)
#define ok_ptr(expression, result) ok_ptr_(__FILE__, __LINE__, expression, result)
#define ok_size_t(expression, result) \
#define ok_size_t_(file, line, expression, result) \
do { \
size_t _value = (expression); \
ok(_value == (result), "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
ok_(file, line)(_value == (result), "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
#expression, (size_t)(result), _value); \
} while (0)
#define ok_size_t(expression, result) ok_size_t_(__FILE__, __LINE__, expression, result)
#define ok_char(expression, result) ok_hex(expression, result)
#define ok_err(error) \
ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
#define ok_err_(file, line, error) \
ok_(file, line)(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
#define ok_err(error) ok_err_(__FILE__, __LINE__, error)
#define ok_str(x, y) \
ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
#define ok_str_(file, line, x, y) \
ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
#define ok_str(x, y) ok_str_(__FILE__, __LINE__, x, y)
#define ok_wstr(x, y) \
ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
#define ok_wstr_(file, line, x, y) \
ok_(file, line)(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
#define ok_wstr(x, y) ok_wstr_(__FILE__, __LINE__, x, y)
#define ok_long(expression, result) ok_hex(expression, result)
#define ok_int(expression, result) ok_dec(expression, result)
#define ok_int_(file, line, expression, result) ok_dec_(file, line, expression, result)
#define ok_ntstatus(status, expected) ok_hex(status, expected)
#define ok_hdl ok_ptr