diff options
author | Mathias Agopian <mathias@google.com> | 2010-05-17 18:56:10 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-05-17 18:56:10 -0700 |
commit | 662be102ee3a89645ca60650a6094003f35894e0 (patch) | |
tree | 1476092bbc6c60e1e588ad767b85e15e4b48bfc2 /libs | |
parent | be6c8fc4d5f8144cbfc715da0d2ef3c704db279d (diff) | |
download | frameworks_base-662be102ee3a89645ca60650a6094003f35894e0.zip frameworks_base-662be102ee3a89645ca60650a6094003f35894e0.tar.gz frameworks_base-662be102ee3a89645ca60650a6094003f35894e0.tar.bz2 |
improve SharedBufferStack test
Change-Id: I32683bfe0916918757280db89113595867acd5a7
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp | 58 |
1 files changed, 43 insertions, 15 deletions
diff --git a/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp b/libs/surfaceflinger_client/tests/SharedBufferStack/SharedBufferStackTest.cpp index 6732580..a50f4ae 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<num ; i++) { b[i] = c.dequeue(); - assert(b[i]==i); + assert(b[i]==list[i]); } log("DQ", b, num); @@ -64,7 +93,7 @@ int main(int argc, char** argv) for (size_t i=0 ; i<num-1 ; i++) { r[i] = s.retireAndLock(); - assert(r[i]==i); + assert(r[i]==list[i]); err = s.unlock(r[i]); assert(err == 0); } @@ -79,7 +108,7 @@ int main(int argc, char** argv) log(" Q", b+num-1, 1); r[num-1] = s.retireAndLock(); - assert(r[num-1]==num-1); + assert(r[num-1]==list[num-1]); err = s.unlock(r[num-1]); assert(err == 0); log("RT", r+num-1, 1); @@ -89,7 +118,7 @@ int main(int argc, char** argv) for (size_t i=0 ; i<num ; i++) { b[i] = c.dequeue(); - assert(b[i]==i); + assert(b[i]==list[i]); } log("DQ", b, num); @@ -102,7 +131,7 @@ int main(int argc, char** argv) for (size_t i=0 ; i<num-1 ; i++) { u[i] = b[num-2-i]; } - u[num-1] = num-1; + u[num-1] = b[num-1]; for (size_t i=0 ; i<num-1 ; i++) { err = c.queue(u[i]); @@ -127,7 +156,7 @@ int main(int argc, char** argv) log(" Q", b+num-1, 1); r[num-1] = s.retireAndLock(); - assert(r[num-1]==num-1); + assert(r[num-1]==list[num-1]); err = s.unlock(r[num-1]); assert(err == 0); log("RT", r+num-1, 1); @@ -170,7 +199,7 @@ int main(int argc, char** argv) log(" Q", u+num-1, 1); r[num-1] = s.retireAndLock(); - assert(r[num-1]==num-1); + assert(r[num-1]==u[num-1]); err = s.unlock(r[num-1]); assert(err == 0); log("RT", r+num-1, 1); @@ -224,10 +253,9 @@ int main(int argc, char** argv) log(" Q", u+num-1, 1); r[num-1] = s.retireAndLock(); - assert(r[num-1]==num-1); + assert(r[num-1]==u[num-1]); err = s.unlock(r[num-1]); assert(err == 0); log("RT", r+num-1, 1); - - return 0; + printf("\n"); } |