Create an empty String8 to cause the first allocation
There is an optimization that allocates a static empty String8 the first
time it's needed. This caused this test case to behave differently when
it was run alone vs when run with the rest of the binderAllocationLimits
test cases.
Test: atest
binderAllocationLimits:binderAllocationLimits.BinderAllocation#SmallTransaction
Bug: 242614248
Change-Id: Idda3065796a23d0f0ec0a79dad34e2eeb554fe38
diff --git a/libs/binder/tests/binderAllocationLimits.cpp b/libs/binder/tests/binderAllocationLimits.cpp
index 60b3c94..a2ab8ab 100644
--- a/libs/binder/tests/binderAllocationLimits.cpp
+++ b/libs/binder/tests/binderAllocationLimits.cpp
@@ -27,6 +27,8 @@
#include <functional>
#include <vector>
+static android::String8 gEmpty(""); // make sure first allocation from optimization runs
+
struct DestructionAction {
DestructionAction(std::function<void()> f) : mF(std::move(f)) {}
~DestructionAction() { mF(); };