From cd45552c57f12475cd23a761781c456150fba90a Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 17 May 2010 18:56:10 -0700 Subject: [PATCH] improve SharedBufferStack test Change-Id: I32683bfe0916918757280db89113595867acd5a7 --- .../SharedBufferStackTest.cpp | 58 ++++++++++++++----- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp b/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp index 67325806d..a50f4aea9 100644 --- a/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp +++ b/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp @@ -24,6 +24,33 @@ using namespace android; +void log(const char* prefix, int *b, size_t num); +void test0(SharedBufferServer& s, SharedBufferClient& c, size_t num, int* list); + +// ---------------------------------------------------------------------------- + +int main(int argc, char** argv) +{ + SharedClient client; + SharedBufferServer s(&client, 0, 4, 0); + SharedBufferClient c(&client, 0, 4, 0); + + printf("basic test 0\n"); + int list0[4] = {0, 1, 2, 3}; + test0(s, c, 4, list0); + + printf("basic test 1\n"); + int list1[4] = {2, 1, 0, 3}; + test0(s, c, 4, list1); + + printf("resize test\n"); + s.resize(5); + c.setBufferCount(5); + int list2[5] = {0, 1, 2, 4, 3}; + test0(s, c, 5, list2); + + return 0; +} void log(const char* prefix, int *b, size_t num) { @@ -34,18 +61,20 @@ void log(const char* prefix, int *b, size_t num) printf("\n"); } -int main(int argc, char** argv) +// ---------------------------------------------------------------------------- + +void test0( + SharedBufferServer& s, + SharedBufferClient& c, + size_t num, + int* list) { status_t err; - const size_t num = 4; - SharedClient client; - SharedBufferServer s(&client, 0, num, 0); - SharedBufferClient c(&client, 0, num, 0); int b[num], u[num], r[num]; for (size_t i=0 ; i