[Test] Run BlockDnsQuery only when dependency is fulfilled

Bug: 309164580
Test: atest PrivateDns/TransportParameterizedTest#BlockDnsQuery/DoH
Change-Id: I80a6e4499e71d901148cc35c0af3bf588756c4ef
diff --git a/tests/resolv_integration_test.cpp b/tests/resolv_integration_test.cpp
index cae91f8..38d5567 100644
--- a/tests/resolv_integration_test.cpp
+++ b/tests/resolv_integration_test.cpp
@@ -48,7 +48,6 @@
 
 #include <algorithm>
 #include <chrono>
-#include <filesystem>
 #include <functional>
 #include <iterator>
 #include <numeric>
diff --git a/tests/resolv_private_dns_test.cpp b/tests/resolv_private_dns_test.cpp
index 3e270c9..f62495e 100644
--- a/tests/resolv_private_dns_test.cpp
+++ b/tests/resolv_private_dns_test.cpp
@@ -552,6 +552,8 @@
 
 TEST_P(TransportParameterizedTest, BlockDnsQuery) {
     SKIP_IF_BEFORE_T;
+    SKIP_IF_DEPENDENT_LIB_DOES_NOT_EXIST(DNS_HELPER);
+
     constexpr char ptr_name[] = "v4v6.example.com.";
     // PTR record for IPv6 address 2001:db8::102:304
     constexpr char ptr_addr_v6[] =
diff --git a/tests/resolv_test_utils.h b/tests/resolv_test_utils.h
index 03926aa..540dd2b 100644
--- a/tests/resolv_test_utils.h
+++ b/tests/resolv_test_utils.h
@@ -20,6 +20,7 @@
 #include <arpa/nameser.h>
 #include <netdb.h>
 
+#include <filesystem>
 #include <functional>
 #include <string>
 #include <vector>
@@ -442,3 +443,9 @@
         android::bpf::isUserspace64bit()
                 ? "/apex/com.android.tethering/lib64/libcom.android.tethering.dns_helper.so"
                 : "/apex/com.android.tethering/lib/libcom.android.tethering.dns_helper.so";
+
+#define SKIP_IF_DEPENDENT_LIB_DOES_NOT_EXIST(libPath)                  \
+    do {                                                               \
+        if (!std::filesystem::exists(libPath))                         \
+            GTEST_SKIP() << "Required " << (libPath) << " not found."; \
+    } while (0)