From 73593d7eedc03a4ca2067bb480162eecdb87dd7b Mon Sep 17 00:00:00 2001
From: Hans Leidekker <hans@it.vu.nl>
Date: Mon, 15 Dec 2003 20:18:50 +0000
Subject: [PATCH] Check if a function exists before testing it.

---
 dlls/ntdll/tests/env.c       |  9 ++++++---
 dlls/ntdll/tests/large_int.c | 11 ++++++-----
 dlls/ntdll/tests/path.c      |  9 ++++++---
 dlls/ntdll/tests/rtl.c       | 38 +++++++++++++++++++++++-------------
 dlls/ntdll/tests/string.c    | 25 +++++++++++++++---------
 5 files changed, 58 insertions(+), 34 deletions(-)

diff --git a/dlls/ntdll/tests/env.c b/dlls/ntdll/tests/env.c
index b32a2e100d7..fc80ec984be 100644
--- a/dlls/ntdll/tests/env.c
+++ b/dlls/ntdll/tests/env.c
@@ -295,7 +295,10 @@ START_TEST(env)
     pRtlSetEnvironmentVariable = (void*)GetProcAddress(mod, "RtlSetEnvironmentVariable");
     pRtlExpandEnvironmentStrings_U = (void*)GetProcAddress(mod, "RtlExpandEnvironmentStrings_U");
 
-    testQuery();
-    testSet();
-    testExpand();
+    if (pRtlQueryEnvironmentVariable_U)
+        testQuery();
+    if (pRtlSetEnvironmentVariable)
+        testSet();
+    if (pRtlExpandEnvironmentStrings_U)
+        testExpand();
 }
diff --git a/dlls/ntdll/tests/large_int.c b/dlls/ntdll/tests/large_int.c
index cf4d219b75b..c337f47dcf0 100644
--- a/dlls/ntdll/tests/large_int.c
+++ b/dlls/ntdll/tests/large_int.c
@@ -421,9 +421,10 @@ START_TEST(large_int)
 {
     InitFunctionPtrs();
 
-    test_RtlExtendedMagicDivide();
-    if (pRtlInt64ToUnicodeString != NULL) {
-	test_RtlInt64ToUnicodeString();
-    } /* if */
-    test_RtlLargeIntegerToChar();
+    if (pRtlExtendedMagicDivide)
+        test_RtlExtendedMagicDivide();
+    if (pRtlInt64ToUnicodeString)
+	    test_RtlInt64ToUnicodeString();
+    if (pRtlLargeIntegerToChar)
+        test_RtlLargeIntegerToChar();
 }
diff --git a/dlls/ntdll/tests/path.c b/dlls/ntdll/tests/path.c
index fec515e4a90..c89a8d786c8 100644
--- a/dlls/ntdll/tests/path.c
+++ b/dlls/ntdll/tests/path.c
@@ -234,7 +234,10 @@ START_TEST(path)
     pRtlIsDosDeviceName_U = (void *)GetProcAddress(mod,"RtlIsDosDeviceName_U");
     pRtlOemStringToUnicodeString = (void *)GetProcAddress(mod,"RtlOemStringToUnicodeString");
     pRtlIsNameLegalDOS8Dot3 = (void *)GetProcAddress(mod,"RtlIsNameLegalDOS8Dot3");
-    test_RtlDetermineDosPathNameType();
-    test_RtlIsDosDeviceName();
-    test_RtlIsNameLegalDOS8Dot3();
+    if (pRtlDetermineDosPathNameType_U)
+        test_RtlDetermineDosPathNameType();
+    if (pRtlIsDosDeviceName_U)
+        test_RtlIsDosDeviceName();
+    if (pRtlIsNameLegalDOS8Dot3)
+        test_RtlIsNameLegalDOS8Dot3();
 }
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 986495ae9ab..62711442d51 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -827,18 +827,28 @@ START_TEST(rtl)
 {
     InitFunctionPtrs();
 
-    test_RtlCompareMemory();
-    test_RtlCompareMemoryUlong();
-    test_RtlMoveMemory();
-    test_RtlFillMemory();
-    test_RtlFillMemoryUlong();
-    test_RtlZeroMemory();
-    if (pRtlUlonglongByteSwap) {
-	test_RtlUlonglongByteSwap();
-    } /* if */
-    test_RtlUniform();
-    test_RtlRandom();
-    test_RtlAreAllAccessesGranted();
-    test_RtlAreAnyAccessesGranted();
-    test_RtlComputeCrc32();
+    if (pRtlCompareMemory)
+        test_RtlCompareMemory();
+    if (pRtlCompareMemoryUlong)
+        test_RtlCompareMemoryUlong();
+    if (pRtlMoveMemory)
+        test_RtlMoveMemory();
+    if (pRtlFillMemory)
+        test_RtlFillMemory();
+    if (pRtlFillMemoryUlong)
+        test_RtlFillMemoryUlong();
+    if (pRtlZeroMemory)
+        test_RtlZeroMemory();
+    if (pRtlUlonglongByteSwap)
+        test_RtlUlonglongByteSwap();
+    if (pRtlUniform)
+        test_RtlUniform();
+    if (pRtlRandom)
+        test_RtlRandom();
+    if (pRtlAreAllAccessesGranted)
+        test_RtlAreAllAccessesGranted();
+    if (pRtlAreAnyAccessesGranted)
+        test_RtlAreAnyAccessesGranted();
+    if (pRtlComputeCrc32)
+        test_RtlComputeCrc32();
 }
diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c
index 922999c2d5f..f076db6e8e3 100644
--- a/dlls/ntdll/tests/string.c
+++ b/dlls/ntdll/tests/string.c
@@ -1075,13 +1075,20 @@ START_TEST(string)
 {
     InitFunctionPtrs();
 
-    test_ulongtoa();
-    test_ulonglongtoa();
-    test_atoi64();
-
-    test_ulongtow();
-    test_ulonglongtow();
-    test_wtoi();
-    test_wtol();
-    test_wtoi64();
+    if (p_ultoa)
+        test_ulongtoa();
+    if (p_ui64toa)
+        test_ulonglongtoa();
+    if (p_atoi64)
+        test_atoi64();
+    if (p_ultow)
+        test_ulongtow();
+    if (p_ui64tow)
+        test_ulonglongtow();
+    if (p_wtoi)
+        test_wtoi();
+    if (p_wtol)
+        test_wtol();
+    if (p_wtoi64)
+        test_wtoi64();
 }
-- 
GitLab