From 2f51ad7b86839d00dcef29c62e761673e8db013a Mon Sep 17 00:00:00 2001 From: Jeffrey Huang Date: Wed, 22 Apr 2020 17:09:30 -0700 Subject: [PATCH] Tag libstatspull and libstatssocket tests as MTS create both 32 and 64 bit variants fixes libstatssocket_test for 32 bit devices Bug: 154652564 Test: make mts, adb push, adb shell all 4 tests Change-Id: Ia6b51686c06e786b38cb3713315977533f1bb819 --- libstats/pull/Android.bp | 10 +++++++++- libstats/socket/Android.bp | 10 +++++++++- libstats/socket/tests/stats_event_test.cpp | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/libstats/pull/Android.bp b/libstats/pull/Android.bp index ef1c5c5bd..c9f13a3fd 100644 --- a/libstats/pull/Android.bp +++ b/libstats/pull/Android.bp @@ -84,7 +84,15 @@ cc_test { "libstatspull", "libstatssocket", ], - test_suites: ["general-tests"], + test_suites: ["general-tests", "mts"], + //TODO(b/153588990): Remove when the build system properly separates + //32bit and 64bit architectures. + compile_multilib: "both", + multilib: { + lib64: { + suffix: "64", + } + }, cflags: [ "-Wall", "-Werror", diff --git a/libstats/socket/Android.bp b/libstats/socket/Android.bp index c86d65031..a31643220 100644 --- a/libstats/socket/Android.bp +++ b/libstats/socket/Android.bp @@ -121,5 +121,13 @@ cc_test { "libcutils", "libutils", ], - test_suites: ["device-tests"], + test_suites: ["device-tests", "mts"], + //TODO(b/153588990): Remove when the build system properly separates + //32bit and 64bit architectures. + compile_multilib: "both", + multilib: { + lib64: { + suffix: "64", + } + }, } diff --git a/libstats/socket/tests/stats_event_test.cpp b/libstats/socket/tests/stats_event_test.cpp index 6e47e3dd3..80ef145ae 100644 --- a/libstats/socket/tests/stats_event_test.cpp +++ b/libstats/socket/tests/stats_event_test.cpp @@ -53,7 +53,12 @@ using std::vector; // Side-effect: this function moves the start of the buffer past the read value template T readNext(uint8_t** buffer) { - T value = *(T*)(*buffer); + T value; + if ((reinterpret_cast(*buffer) % alignof(T)) == 0) { + value = *(T*)(*buffer); + } else { + memcpy(&value, *buffer, sizeof(T)); + } *buffer += sizeof(T); return value; }