Fix test initialization errors on Q
ConnectivityDiagnosticsManagerTest, MultinetworkApiTest,
NetworkAgentTest crashed before the runner could start them:
- Ignore ConnectivityDiagnosticsManagerTest on Q: it tests an API that
was introduced in R.
- Build JNI libraries used by MultinetworkApiTest against the NDK to
avoid errors loading the libraries on older platforms, when
transitive dependencies have been added.
- Do not attempt to override Handler#getLooper() (which is final) in
NetworkAgentTest; it appears to have been overridden by accident by
specifying "val looper" in the TestableNetworkAgent definition, which
generates a getter.
Test: atest CtsNetTestCasesLatestSdk:ConnectivityDiagnosticsManagerTest
atest CtsNetTestCasesLatestSdk:MultinetworkApiTest
atest CtsNetTestCasesLatestSdk:NetworkAgentTest
Bug: 150918852
Change-Id: I262b54c6897ed755adaeb2b118c638320634f7a1
diff --git a/tests/cts/net/jni/NativeDnsJni.c b/tests/cts/net/jni/NativeDnsJni.c
index 6d3d1c3..4ec800e 100644
--- a/tests/cts/net/jni/NativeDnsJni.c
+++ b/tests/cts/net/jni/NativeDnsJni.c
@@ -19,7 +19,12 @@
#include <netdb.h>
#include <stdio.h>
#include <string.h>
-#include <utils/Log.h>
+
+#include <android/log.h>
+
+#define LOG_TAG "NativeDns-JNI"
+#define LOGD(fmt, ...) \
+ __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, fmt, ##__VA_ARGS__)
const char *GoogleDNSIpV4Address="8.8.8.8";
const char *GoogleDNSIpV4Address2="8.8.4.4";
@@ -33,7 +38,7 @@
struct addrinfo *answer;
int res = getaddrinfo(node, service, NULL, &answer);
- ALOGD("getaddrinfo(www.google.com) gave res=%d (%s)", res, gai_strerror(res));
+ LOGD("getaddrinfo(www.google.com) gave res=%d (%s)", res, gai_strerror(res));
if (res != 0) return JNI_FALSE;
// check for v4 & v6
@@ -47,12 +52,12 @@
inet_ntop(current->ai_family, &((struct sockaddr_in *)current->ai_addr)->sin_addr,
buf, sizeof(buf));
foundv4 = 1;
- ALOGD(" %s", buf);
+ LOGD(" %s", buf);
} else if (current->ai_addr->sa_family == AF_INET6) {
inet_ntop(current->ai_family, &((struct sockaddr_in6 *)current->ai_addr)->sin6_addr,
buf, sizeof(buf));
foundv6 = 1;
- ALOGD(" %s", buf);
+ LOGD(" %s", buf);
}
current = current->ai_next;
}
@@ -60,14 +65,14 @@
freeaddrinfo(answer);
answer = NULL;
if (foundv4 != 1 && foundv6 != 1) {
- ALOGD("getaddrinfo(www.google.com) didn't find either v4 or v6 address");
+ LOGD("getaddrinfo(www.google.com) didn't find either v4 or v6 address");
return JNI_FALSE;
}
}
node = "ipv6.google.com";
res = getaddrinfo(node, service, NULL, &answer);
- ALOGD("getaddrinfo(ipv6.google.com) gave res=%d", res);
+ LOGD("getaddrinfo(ipv6.google.com) gave res=%d", res);
if (res != 0) return JNI_FALSE;
{
@@ -79,12 +84,12 @@
if (current->ai_addr->sa_family == AF_INET) {
inet_ntop(current->ai_family, &((struct sockaddr_in *)current->ai_addr)->sin_addr,
buf, sizeof(buf));
- ALOGD(" %s", buf);
+ LOGD(" %s", buf);
foundv4 = 1;
} else if (current->ai_addr->sa_family == AF_INET6) {
inet_ntop(current->ai_family, &((struct sockaddr_in6 *)current->ai_addr)->sin6_addr,
buf, sizeof(buf));
- ALOGD(" %s", buf);
+ LOGD(" %s", buf);
foundv6 = 1;
}
current = current->ai_next;
@@ -93,7 +98,7 @@
freeaddrinfo(answer);
answer = NULL;
if (foundv4 == 1 || foundv6 != 1) {
- ALOGD("getaddrinfo(ipv6.google.com) didn't find only v6");
+ LOGD("getaddrinfo(ipv6.google.com) didn't find only v6");
return JNI_FALSE;
}
}
@@ -116,12 +121,12 @@
res = getnameinfo((const struct sockaddr*)&sa4, sizeof(sa4), buf, sizeof(buf), NULL, 0, flags);
if (res != 0) {
- ALOGD("getnameinfo(%s (GoogleDNS) ) gave error %d (%s)", GoogleDNSIpV4Address, res,
+ LOGD("getnameinfo(%s (GoogleDNS) ) gave error %d (%s)", GoogleDNSIpV4Address, res,
gai_strerror(res));
return JNI_FALSE;
}
if (strstr(buf, "google.com") == NULL && strstr(buf, "dns.google") == NULL) {
- ALOGD("getnameinfo(%s (GoogleDNS) ) didn't return google.com or dns.google: %s",
+ LOGD("getnameinfo(%s (GoogleDNS) ) didn't return google.com or dns.google: %s",
GoogleDNSIpV4Address, buf);
return JNI_FALSE;
}
@@ -129,12 +134,12 @@
memset(buf, 0, sizeof(buf));
res = getnameinfo((const struct sockaddr*)&sa6, sizeof(sa6), buf, sizeof(buf), NULL, 0, flags);
if (res != 0) {
- ALOGD("getnameinfo(%s (GoogleDNS) ) gave error %d (%s)", GoogleDNSIpV6Address2,
+ LOGD("getnameinfo(%s (GoogleDNS) ) gave error %d (%s)", GoogleDNSIpV6Address2,
res, gai_strerror(res));
return JNI_FALSE;
}
if (strstr(buf, "google.com") == NULL && strstr(buf, "dns.google") == NULL) {
- ALOGD("getnameinfo(%s (GoogleDNS) ) didn't return google.com or dns.google: %s",
+ LOGD("getnameinfo(%s (GoogleDNS) ) didn't return google.com or dns.google: %s",
GoogleDNSIpV6Address2, buf);
return JNI_FALSE;
}
@@ -142,11 +147,11 @@
// gethostbyname
struct hostent *my_hostent = gethostbyname("www.youtube.com");
if (my_hostent == NULL) {
- ALOGD("gethostbyname(www.youtube.com) gave null response");
+ LOGD("gethostbyname(www.youtube.com) gave null response");
return JNI_FALSE;
}
if ((my_hostent->h_addr_list == NULL) || (*my_hostent->h_addr_list == NULL)) {
- ALOGD("gethostbyname(www.youtube.com) gave 0 addresses");
+ LOGD("gethostbyname(www.youtube.com) gave 0 addresses");
return JNI_FALSE;
}
{
@@ -154,7 +159,7 @@
while (*current != NULL) {
char buf[256];
inet_ntop(my_hostent->h_addrtype, *current, buf, sizeof(buf));
- ALOGD("gethostbyname(www.youtube.com) gave %s", buf);
+ LOGD("gethostbyname(www.youtube.com) gave %s", buf);
current++;
}
}
@@ -164,11 +169,11 @@
inet_pton(AF_INET6, GoogleDNSIpV6Address, addr6);
my_hostent = gethostbyaddr(addr6, sizeof(addr6), AF_INET6);
if (my_hostent == NULL) {
- ALOGD("gethostbyaddr(%s (GoogleDNS) ) gave null response", GoogleDNSIpV6Address);
+ LOGD("gethostbyaddr(%s (GoogleDNS) ) gave null response", GoogleDNSIpV6Address);
return JNI_FALSE;
}
- ALOGD("gethostbyaddr(%s (GoogleDNS) ) gave %s for name", GoogleDNSIpV6Address,
+ LOGD("gethostbyaddr(%s (GoogleDNS) ) gave %s for name", GoogleDNSIpV6Address,
my_hostent->h_name ? my_hostent->h_name : "null");
if (my_hostent->h_name == NULL) return JNI_FALSE;