• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

host/23-Mar-2024-781465

platform/23-Mar-2024-4,1512,841

OWNERSD23-Mar-2024257 1310

README.mdD23-Mar-20243.8 KiB8758

README.md

1# Longevity Library
2
3This library serves as a test runner for longevity suites, which exercise test cases repeatedly in
4order to exercise or stress the device under test. Annotate a collection of JUnit test classes with
5a subclass of LongevitySuite, and voila...you now have longevity tests!
6
7## Examples
8
9There is both host-side (core) and device-side (platform) for longevity tests with only
10minor differences. All of the examples below use the sample suites bundled as part of the
11`LongevityHostLibSamples` and `LongevityPlatformLibSamples` modules under the `samples/` directory.
12Follow the samples directory to see how longevity suites are constructed.
13
14### Host
15
16**Template command with stubbed out options.**
17
18`java <options> -cp <jar> org.junit.runner.JUnitCore <suite>`
19
20**Run simple test suite 50 times, and quit when an error is encountered.**
21
22`java -Diterations=5 -Dquitter=true -cp out/host/linux-x86/framework/LongevityHostSamples.jar
23org.junit.runner.JUnitCore android.host.test.longevity.samples.SimpleSuite`
24
25**Run simple test suite 10 times, shuffle all tests, and quit after 30 minutes.**
26
27`java -Diterations=10 -Dsuite-timeout_msec=1800000 -Dshuffle=true -cp
28out/host/linux-x86/framework/LongevityHostSamples.jar
29org.junit.runner.JUnitCore android.host.test.longevity.samples.SimpleSuite`
30
31### Device
32
33**Template command with stubbed out options.**
34
35`adb shell am instrument -w -r -e <option> <value> -e class <suite>
36android.platform.test.longevity.samples/androidx.runner.AndroidJUnitRunner`
37
38**Run simple test suite 50 times, and quit when an error is encountered.**
39
40`adb shell am instrument -w -r -e iterations 50 -e quitter true
41-e class android.platform.test.longevity.samples.SimpleSuite
42android.platform.test.longevity.samples/androidx.test.runner.AndroidJUnitRunner`
43
44**Run simple test suite 10 times, shuffle all tests, and quit after 30 minutes.**
45
46`adb shell am instrument -w -r -e iterations 10 -e shuffle true -e suite-timeout_msec 1800000
47-e class android.platform.test.longevity.samples.SimpleSuite
48android.platform.test.longevity.samples/androidx.test.runner.AndroidJUnitRunner`
49
50**Run simple test suite 100 times, and quit when battery drops below 5%.**
51
52`adb shell am instrument -w -r -e iterations 100 -e min-battery 0.05
53-e class android.platform.test.longevity.samples.SimpleSuite
54android.platform.test.longevity.samples/androidx.test.runner.AndroidJUnitRunner`
55
56**Run a suite using the sample profile under assets/**
57
58`adb shell am instrument -w -r -e profile sample_profile
59-e class android.platform.test.longevity.samples.SimpleProfile
60android.platform.test.longevity.samples/androidx.test.runner.AndroidJUnitRunner`
61
62## Options
63
64*   `iterations <int>` - the number of times to repeat the suite.
65*   `min-battery <double>` - quit if battery falls below this threshold.
66*   `shuffle <bool>` - shuffles all test cases in the repeated suite.
67*   `suite-timeout_msec <long>` - an overall timeout for the suite.
68*   `timeout_msec <long>` - a timeout for individual test methods.
69*   `quitter <bool>` - quit the suite if any test errors are encountered.
70*   `profile <string>` - use a profile under assets/ or at your own path.
71*   `rename-iterations <bool>` - rename each iteration by appending the iteration number to the
72    class name.
73
74## Tests
75
76Host-side tests for the library can be built with the `LongevityHostLibTests` module under the
77`tests/` directory. Run them using `java out/host/linux-x86/framework/LongevityHostLibTests.jar
78org.junit.runner.JUnitCore <test class>`.
79
80Device-side tests for the library can be built with the `LongevityLibTests` module under the
81`tests/` directory. Run them using `adb shell am instrument -w -r
82android.platform.test.longevity.tests/androidx.test.runner.AndroidJUnitRunner`.
83
84## Issues
85
86If any issues are encountered, please send patches to recent contributors.
87