| Than McIntosh | 7e2f4e9 | 2015-03-05 11:05:02 -0500 | [diff] [blame^] | 1 | Native tests for 'perfprofd'. Please run with 'runtest perfprofd' |
| 2 | (a.k.a. "$ANDROID_BUILD_TOP"/development/testrunner/runtest.py). |
| 3 | |
| 4 | Notes: |
| 5 | |
| 6 | 1. One of the testpoints in this test suite performs a live 'perf' |
| 7 | run on the device; before invoking the test be sure that 'perf' |
| 8 | has been built and installed on the device in /system/bin/perf |
| 9 | |
| 10 | 2. The daemon under test, perfprofd, is broken into a main function, a |
| 11 | "core" library, and a "utils library. Picture: |
| 12 | |
| 13 | +-----------+ perfprofdmain.o |
| 14 | | perfprofd | |
| 15 | | main() | 1-liner; calls perfprofd_main() |
| 16 | +-----------+ |
| 17 | | |
| 18 | v |
| 19 | +-----------+ perfprofdcore.a |
| 20 | | perfprofd | |
| 21 | | core | most of the interesting code is here; |
| 22 | | | calls into utils library when for |
| 23 | +-----------+ operations such as sleep, log, etc |
| 24 | | |
| 25 | v |
| 26 | +-----------+ perfprofdutils.a |
| 27 | | perfprofd | |
| 28 | | utils | real implementations of perfprofd_sleep, |
| 29 | | | perfprofd_log_* etc |
| 30 | +-----------+ |
| 31 | |
| 32 | Because the daemon tends to spend a lot of time sleeping/waiting, |
| 33 | it is impractical to try to test it directly. Instead we insert a |
| 34 | mock utilities layer and then have a test driver that invokes the |
| 35 | daemon main function. Picture for perfprofd_test: |
| 36 | |
| 37 | +----------------+ perfprofd_test.cc |
| 38 | | perfprofd_test | |
| 39 | | | makes calls into perfprofd_main(), |
| 40 | +----------------+ then verifies behavior |
| 41 | | |
| 42 | v |
| 43 | +-----------+ perfprofdcore.a |
| 44 | | perfprofd | |
| 45 | | core | same as above |
| 46 | +-----------+ |
| 47 | | |
| 48 | v |
| 49 | +-----------+ perfprofdmockutils.a |
| 50 | | perfprofd | |
| 51 | | mockutils | mock implementations of perfprofd_sleep, |
| 52 | | | perfprofd_log_* etc |
| 53 | +-----------+ |
| 54 | |
| 55 | The mockup versions of perfprofd_sleep() and perfprofd_log_* do |
| 56 | simply log the fact that they are called; the test driver can |
| 57 | then examine the log to make sure that the daemon is doing |
| 58 | what it is supposed to be doing. |