https://git.reactos.org/?p=reactos.git;a=commitdiff;h=520cf2294d6ee932ba68b…
commit 520cf2294d6ee932ba68bc07d357930a26da5e8a
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Thu Aug 11 14:06:02 2022 +0300
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Fri Nov 10 19:00:41 2023 +0200
[APITESTS] Share ok_eq_* macros between apitests and kmtests
This makes it possible to share sources between kmtest and apitests, e.g. for rtl.
---
modules/rostests/apitests/include/apitest.h | 32 ++++++++++++++++++++++
modules/rostests/apitests/ntdll/NtContinue.c | 5 ----
.../RtlDosApplyFileIsolationRedirection_Ustr.c | 3 --
.../apitests/ntdll/RtlDosSearchPath_Ustr.c | 4 ---
modules/rostests/kmtests/include/kmt_test.h | 3 ++
5 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/modules/rostests/apitests/include/apitest.h
b/modules/rostests/apitests/include/apitest.h
index 50bf98b5930..d0cfb711d18 100644
--- a/modules/rostests/apitests/include/apitest.h
+++ b/modules/rostests/apitests/include/apitest.h
@@ -54,4 +54,36 @@
#define ok_hr(status, expected) ok_hex(status, expected)
#define ok_hr_(file, line, status, expected) ok_hex_(file, line, status, expected)
+#define ok_eq_print(value, expected, spec) ok((value) == (expected), #value " =
" spec ", expected " spec "\n", value, expected)
+#define ok_eq_pointer(value, expected) ok_eq_print(value, expected, "%p")
+#define ok_eq_int(value, expected) ok_eq_print(value, expected, "%d")
+#define ok_eq_uint(value, expected) ok_eq_print(value, expected, "%u")
+#define ok_eq_long(value, expected) ok_eq_print(value, expected,
"%ld")
+#define ok_eq_ulong(value, expected) ok_eq_print(value, expected,
"%lu")
+#define ok_eq_longlong(value, expected) ok_eq_print(value, expected,
"%I64d")
+#define ok_eq_ulonglong(value, expected) ok_eq_print(value, expected,
"%I64u")
+#define ok_eq_char(value, expected) ok_eq_print(value, expected, "%c")
+#define ok_eq_wchar(value, expected) ok_eq_print(value, expected, "%C")
+#ifndef _WIN64
+#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected),
"%lu")
+#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected),
"%ld")
+#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected),
"%lu")
+#elif defined _WIN64
+#define ok_eq_size(value, expected) ok_eq_print(value, (SIZE_T)(expected),
"%I64u")
+#define ok_eq_longptr(value, expected) ok_eq_print(value, (LONG_PTR)(expected),
"%I64d")
+#define ok_eq_ulongptr(value, expected) ok_eq_print(value, (ULONG_PTR)(expected),
"%I64u")
+#endif /* defined _WIN64 */
+#define ok_eq_hex(value, expected) ok_eq_print(value, expected,
"0x%08lx")
+#define ok_bool_true(value, desc) ok((value) == TRUE, desc " FALSE,
expected TRUE\n")
+#define ok_bool_false(value, desc) ok((value) == FALSE, desc " TRUE,
expected FALSE\n")
+#define ok_eq_bool(value, expected) ok((value) == (expected), #value " = %s,
expected %s\n", \
+ (value) ? "TRUE" :
"FALSE", \
+ (expected) ? "TRUE" :
"FALSE")
+#define ok_eq_str(value, expected) ok(!strcmp(value, expected), #value " =
\"%s\", expected \"%s\"\n", value, expected)
+#define ok_eq_wstr(value, expected) ok(!wcscmp(value, expected), #value " =
\"%ls\", expected \"%ls\"\n", value, expected)
+#define ok_eq_tag(value, expected) ok_eq_print(value, expected,
"0x%08lx")
+
+#define ok_eq_hex64(value, expected) ok_eq_print(value, expected,
"%I64x")
+#define ok_eq_xmm(value, expected) ok((value).Low == (expected).Low, #value
" = %I64x'%08I64x, expected %I64x'%08I64x\n", (value).Low, (value).High,
(expected).Low, (expected).High)
+
#endif /* _APITEST_H */
diff --git a/modules/rostests/apitests/ntdll/NtContinue.c
b/modules/rostests/apitests/ntdll/NtContinue.c
index f159c7bf3f7..5d533f9f2ef 100644
--- a/modules/rostests/apitests/ntdll/NtContinue.c
+++ b/modules/rostests/apitests/ntdll/NtContinue.c
@@ -14,11 +14,6 @@
#pragma runtime_checks("s", off)
#endif
-#define ok_eq_print(value, expected, spec) ok((value) == (expected), #value " =
" spec ", expected " spec "\n", value, expected)
-#define ok_eq_hex(value, expected) ok_eq_print(value, expected,
"%lx")
-#define ok_eq_hex64(value, expected) ok_eq_print(value, expected,
"%I64x")
-#define ok_eq_xmm(value, expected) ok((value).Low == (expected).Low, #value
" = %I64x'%08I64x, expected %I64x'%08I64x\n", (value).Low, (value).High,
(expected).Low, (expected).High)
-
#ifdef _M_IX86
#define NTC_SEGMENT_BITS (0xFFFF)
#define NTC_EFLAGS_BITS (0x3C0CD5)
diff --git a/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
b/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
index 4dff2668bea..7ab2aa4af61 100644
--- a/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
+++ b/modules/rostests/apitests/ntdll/RtlDosApplyFileIsolationRedirection_Ustr.c
@@ -7,9 +7,6 @@
#include "precomp.h"
-#define ok_eq_hex(value, expected) ok((value) == (expected), #value " = 0x%lx,
expected 0x%lx\n", value, expected)
-#define ok_eq_pointer(value, expected) ok((value) == (expected), #value " = %p,
expected %p\n", value, expected)
-
#define EXPECT_IN_SAME_DIR (WCHAR*)0xdead
UNICODE_STRING DotDll = RTL_CONSTANT_STRING(L".DLL");
diff --git a/modules/rostests/apitests/ntdll/RtlDosSearchPath_Ustr.c
b/modules/rostests/apitests/ntdll/RtlDosSearchPath_Ustr.c
index 6a4de4ee8fe..29794bf4e8d 100644
--- a/modules/rostests/apitests/ntdll/RtlDosSearchPath_Ustr.c
+++ b/modules/rostests/apitests/ntdll/RtlDosSearchPath_Ustr.c
@@ -23,10 +23,6 @@ RtlDosSearchPath_Ustr(
);
*/
-#define ok_eq_ulong(value, expected) ok((value) == (expected), #value " = %lu,
expected %lu\n", value, expected)
-#define ok_eq_hex(value, expected) ok((value) == (expected), #value " = 0x%lx,
expected 0x%lx\n", value, expected)
-#define ok_eq_pointer(value, expected) ok((value) == (expected), #value " = %p,
expected %p\n", value, expected)
-
#define ok_eq_ustr(str1, str2) do {
\
ok((str1)->Buffer == (str2)->Buffer, "Buffer
modified\n"); \
ok((str1)->Length == (str2)->Length, "Length
modified\n"); \
diff --git a/modules/rostests/kmtests/include/kmt_test.h
b/modules/rostests/kmtests/include/kmt_test.h
index 4f25d6580b8..2f0315a48b5 100644
--- a/modules/rostests/kmtests/include/kmt_test.h
+++ b/modules/rostests/kmtests/include/kmt_test.h
@@ -264,6 +264,9 @@ VOID KmtFreeGuarded(PVOID Pointer);
#define ok_eq_wstr(value, expected) ok(!wcscmp(value, expected), #value " =
\"%ls\", expected \"%ls\"\n", value, expected)
#define ok_eq_tag(value, expected) ok_eq_print(value, expected,
"0x%08lx")
+#define ok_eq_hex64(value, expected) ok_eq_print(value, expected,
"%I64x")
+#define ok_eq_xmm(value, expected) ok((value).Low == (expected).Low, #value
" = %I64x'%08I64x, expected %I64x'%08I64x\n", (value).Low, (value).High,
(expected).Low, (expected).High)
+
#define KMT_MAKE_CODE(ControlCode) CTL_CODE(FILE_DEVICE_UNKNOWN, \
0xC00 + (ControlCode), \
METHOD_BUFFERED, \