Home | History | Annotate | Download | only in cts
      1 page.title=Running CTS tests
      2 @jd:body
      3 
      4 <!--
      5     Copyright 2015 The Android Open Source Project
      6 
      7     Licensed under the Apache License, Version 2.0 (the "License");
      8     you may not use this file except in compliance with the License.
      9     You may obtain a copy of the License at
     10 
     11         http://www.apache.org/licenses/LICENSE-2.0
     12 
     13     Unless required by applicable law or agreed to in writing, software
     14     distributed under the License is distributed on an "AS IS" BASIS,
     15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16     See the License for the specific language governing permissions and
     17     limitations under the License.
     18 -->
     19 <div id="qv-wrapper">
     20   <div id="qv">
     21     <h2>In this document</h2>
     22     <ol id="auto-toc">
     23     </ol>
     24   </div>
     25 </div>
     26 
     27 <h2 id=cts_tradefed>Getting started with CTS tradefed</h2>
     28 <p>See the <a
     29 href="{@docRoot}devices/tech/test_infra/tradefed/index.html">Trade Federation
     30 Overview</a> for an explanation of the Trade Federation (tradefed or TF for
     31 short) continuous test framework.</p>
     32 
     33 <p>To run a test plan:</p>
     34 <ol>
     35   <li>Connect at least one device.
     36   <li>Press the <strong>home</strong> button to set the device to the home screen at the start of CTS.
     37   <li>While a device is running tests, it must not be used for any other tasks
     38     and must be kept in a stationary position (to avoid triggering sensor activity)
     39     with the cameras pointing at an object that could be focused.
     40   <li>Do not press any keys on the device while the CTS is running. Pressing keys
     41     or touching the screen of a test device will interfere with the running tests
     42     and may lead to test failures.
     43   <li>Launch the CTS console by running the <em>cts-tradefed</em> script from
     44     the folder where the CTS package has been unzipped, e.g.
     45     <code>$ ./android-cts/tools/cts-tradefed</code>
     46   <li>You may start the default test plan (containing all of the test packages) by
     47     appending: <code>run cts --plan CTS</code> (or just <code>run cts</code> for v2).
     48     This kicks off all the CTS tests required for compatibility.
     49     Enter <code>list plans</code> to see a list of test plans in the repository.
     50     Enter <code>list packages</code> to see a list of test packages in the repository.
     51     See the CTS command
     52     reference or type help for a complete list of supported commands.
     53   <li>Alternately, you may run the CTS plan of your choosing from the command line
     54     using: <code>cts-tradefed run cts --plan
     55       <plan_name>
     56       </code>
     57   <li>View test progress and results reported on the console.
     58   <li>If your device is Android 5.0 or later and declares support for an ARM and a
     59     x86 ABI, you should run both the ARM and x86 CTS packages.
     60 </ol>
     61 
     62 <h2 id=using-cts-v1>Using the CTS v1 console</h2>
     63 
     64 <p>For Android 6.0 or earlier, you'll use CTS v1.</p>
     65 <h3 id=selecting_cts_plans>Selecting plans</h3>
     66 <p>The following test plans are available:</p>
     67 <ul>
     68   <li><em>CTS</em>all tests required for compatibility. </li>
     69   <li><em>Signature</em>the signature verification of all public APIs </li>
     70   <li><em>Android</em>tests for the Android APIs </li>
     71   <li><em>Java</em>tests for the Java core library </li>
     72   <li><em>VM</em>tests for ART or Dalvik </li>
     73   <li><em>Performance</em>performance tests for your implementation </li>
     74 </ul>
     75 <p>These can be executed with the <code>run cts</code>command.</p>
     76 <h3 id=cts_reference>CTS v1 console command reference</h3>
     77 
     78 <p class="table-caption" id="console-commands">
     79   <strong>Table 1.</strong> This table summarizes the CTS v1 console commands for
     80 various uses.</p>
     81 <table>
     82   <tbody>
     83     <tr>
     84       <th>Host</th>
     85       <th>Description</th>
     86     </tr>
     87     <tr>
     88       <td><code>help</code></td>
     89       <td>Display a summary of the most commonly used commands</td>
     90     </tr>
     91     <tr>
     92       <td><code>help all</code></td>
     93       <td>Display the complete list of available commands</td>
     94     </tr>
     95     <tr>
     96       <td><code>exit</code></td>
     97       <td>Gracefully exit the CTS console. Console will close when all currently running tests are finished</td>
     98     </tr>
     99     <tr>
    100       <th>Run</th>
    101       <th>Description</th>
    102     </tr>
    103     <tr>
    104       <td><code>run cts</code></td>
    105       <td>Run the specified tests and displays progress information. One of
    106 <code>--plan</code>, <code>--package</code>, <code>--class</code> or
    107 <code>--continue-session</code> needs to be specified
    108         <p>The CTS console can accept other commands while tests are in progress </p>
    109         <p>If no devices are connected, the CTS desktop machine (or host) will wait for a device to be connected before starting tests </p>
    110         <p>If more than one device is connected, the CTS host will choose a device automatically</p></td>
    111     </tr>
    112     <tr>
    113       <td><code>--plan &lt;test_plan_name&gt;</code></td>
    114       <td>Run the specified test plan</td>
    115     </tr>
    116     <tr>
    117       <td><code>-- package/-p &lt;test_package_name&gt; [--package/-p &lt;test_package2&gt;...]</code></td>
    118       <td>Run the specified test packages</td>
    119     </tr>
    120     <tr>
    121       <td><code>--class/-c &lt;class_name&gt; [--method/-m &lt;test_method_name&gt;</code></td>
    122       <td>Run the specified test class and/or method</td>
    123     </tr>
    124     <tr>
    125       <td><code>--continue-session</code></td>
    126       <td>Run all not executed tests from previous CTS session; the sessions testResult.xml will be updated with the new results</td>
    127     </tr>
    128     <tr>
    129       <td><code>--shards&lt;number_of_shards&gt;</code></td>
    130       <td>Shard a CTS run into given number of independent chunks, to run on multiple devices in parallel</td>
    131     </tr>
    132     <tr>
    133       <td><code>--serial/-s &lt;deviceID&gt;</code></td>
    134       <td>Run CTS on the specific device</td>
    135     </tr>
    136     <tr>
    137       <td><code>-t &lt;class_name&gt;#&lt;test_method_name&gt;</code></td>
    138       <td>Run a specific test method</td>
    139     </tr>
    140     <tr>
    141       <td><code>--force-abi 32|64</code></td>
    142       <td>On 64-bit devices, run the test against only the 32-bit or 64-bit ABI</td>
    143     </tr>
    144     <tr>
    145       <th>List</th>
    146       <th>Description</th>
    147     </tr>
    148     <tr>
    149       <td><code>list packages</code></td>
    150       <td>List all available test packages in the repository</td>
    151     </tr>
    152     <tr>
    153       <td><code>list plans</code></td>
    154       <td>List all available test plans in the repository</td>
    155     </tr>
    156     <tr>
    157       <td><code>list invocations</code></td>
    158       <td>List 'run' commands currently being executed on devices</td>
    159     </tr>
    160     <tr>
    161       <td><code>list commands</code></td>
    162       <td>List all 'run' commands currently in the queue waiting to be assigned to devices</td>
    163     </tr>
    164     <tr>
    165       <td><code>list results</code></td>
    166       <td>List CTS results currently stored in repository</td>
    167     </tr>
    168     <tr>
    169       <td><code>list devices</code></td>
    170       <td>List currently connected devices and their state
    171         <p> </p>
    172         <p>'Available' devices are functioning, idle devices, available for running tests</p>
    173         <p> </p>
    174         <p>'Unavailable' devices are devices visible via adb, but are not responding to adb commands and won't be allocated for tests</p>
    175         <p> </p>
    176         <p>'Allocated' devices are devices currently running tests</td>
    177     </tr>
    178     <tr>
    179       <th>Add</th>
    180       <th>Description</th>
    181     </tr>
    182     <tr>
    183       <td><code>add derivedplan --plan &lt;plan_name&gt;<br>
    184         --result/-r<br>
    185         [pass | fail | timeout | notExecuted]<br>
    186         [--session/-s &lt;session_id&gt;]</code></td>
    187       <td>Create a plan derived from given result session; use this option to rerun reports and validate test issues</td>
    188     </tr>
    189   </tbody>
    190 </table>
    191 
    192 <h2 id=using-cts-v2>Using the CTS v2 console</h2>
    193 
    194 <p>For Android 7.0 or later, you'll use CTS v2.</p>
    195 <h3 id=selecting_ctsv2_plans>Selecting plans</h3>
    196 <p>Available test plans include the following:</p>
    197 <ul>
    198   <li><em>cts</em>Runs CTS from an pre-existing CTS installation.</li>
    199   <li><em>cts-camera</em> Runs CTS-camera from a pre-existing CTS installation.</li>
    200   <li><em>cts-java</em> Runs Core Java Tests from a pre-existing CTS installation.</li>
    201   <li><em>cts-pdk</em> Runs Tests useful on validating a PDK fusion build.</li>
    202   <li><em>everything</em> Common config for Compatibility suites.</li>
    203 </ul>
    204 <p>Other available configurations include the following:</p>
    205 <ul>
    206   <li><em>basic-reporters</em> Configuration with basic CTS reporters.</li>
    207   <li><em>collect-tests-only</em>Runs CTS from a pre-existing CTS installation.</li>
    208   <li><em>common-compatibility-config</em> Common config for Compatibility suites.</li>
    209   <li><em>cts-filtered-sample</em> Common config for Compatibility suites.</li>
    210   <li><em>cts-known-failures</em> Configuration with CTS known failures.</li>
    211   <li><em>cts-preconditions</em> CTS precondition configs.</li>
    212   <li><em>host</em> Runs a single host-based test on an existing device.</li>
    213   <li><em>instrument</em> Runs a single Android instrumentation test on an existing device.</li>
    214   <li><em>native-benchmark</em> Runs a native stress test on an existing device.</li>
    215   <li><em>native-stress</em> Runs a native stress test on an existing device.</li>
    216   <li><em>recharge</em> A fake test that waits for nearly-discharged devices and holds them for charging.</li>
    217   <li><em>testdef</em> Runs tests contained in test_def.xml files on an existing device.</li>
    218   <li><em>util/wifi</em> Utility config to configure Wi-Fi on device.</li>
    219   <li><em>util/wipe</em> Wipes user data on device.</li>
    220 </ul>
    221 <p>All of these plans and configs can be executed with the <code>run cts</code>command.</p>
    222 
    223 <h3 id=ctsv2_reference>CTS v2 console command reference</h3>
    224 
    225 <p class="table-caption" id="console-commands">
    226   <strong>Table 1.</strong> This table summarizes the CTS V2 console commands for
    227 various uses.</p>
    228 <table>
    229   <tbody>
    230     <tr>
    231       <th>Host</th>
    232       <th>Description</th>
    233     </tr>
    234     <tr>
    235       <td><code>help</code></td>
    236       <td>Display a summary of the most commonly used commands</td>
    237     </tr>
    238     <tr>
    239       <td><code>help all</code></td>
    240       <td>Display the complete list of available commands</td>
    241     </tr>
    242     <tr>
    243       <td><code>version</code></td>
    244       <td>Show the version.</td>
    245     </tr>
    246     <tr>
    247       <td><code>exit</code></td>
    248       <td>Gracefully exit the CTS console. Console will close when all currently running tests are finished.</td>
    249     </tr>
    250     <tr>
    251       <th>Run</th>
    252       <th>Description</th>
    253     </tr>
    254     <tr>
    255       <td><code>run cts</code></td>
    256       <td><p>Run the default CTS plan (that is, the full CTS invocation).</p>
    257       <p>The CTS console can accept other commands while tests are in progress.</p>
    258         <p>If no devices are connected, the CTS desktop machine (or host) will wait
    259            for a device to be connected before starting tests.</p>
    260         <p>If more than one device is connected, the CTS host will choose a device automatically.</p></td>
    261     </tr>
    262     <tr>
    263       <td><code>--plan &lt;test_plan_name&gt;</code></td>
    264       <td>Run the specified test plan.</td>
    265     </tr>
    266     <tr>
    267       <td><code>-- module/-m &lt;test_module_name&gt; [--module/-m &lt;test_module2&gt;...]</code></td>
    268       <td>Run the specified test module or modules. For example, <code>run cts --module CtsGestureTestCases</code>
    269           executes the gesture test module (this can be shortened to <code>run cts -m Gesture</code>).</br>
    270           <code>run cts -m Gesture --test android.gesture.cts.GestureTest#testGetStrokes</code> runs the specific
    271           package, class, or test.</td>
    272     </tr>
    273     <tr>
    274       <td><code>-- module/-m &lt;test_module_name&gt; -- test &lt;test_name&gt;</code></td>
    275       <td>Run the specified module and test. For example,
    276         <code>run cts -m Gesture --test android.gesture.cts.GestureTest#testGetStrokes</code> runs the specific
    277          package, class, or test.</td>
    278     </tr>
    279     <tr>
    280       <td><code>--retry</code></td>
    281       <td>Retry all tests that failed or were not executed from the previous sessions.
    282           Use <code>list results</code> to get the session id.</td>
    283     </tr>
    284     <tr>
    285       <td><code>--shards&lt;number_of_shards&gt;</code></td>
    286       <td>Shard a CTS run into given number of independent chunks, to run on multiple devices in parallel.</td>
    287     </tr>
    288     <tr>
    289       <td><code>--serial/-s &lt;deviceID&gt;</code></td>
    290       <td>Run CTS on the specific device.</td>
    291     </tr>
    292     <tr>
    293       <td><code>--abi 32|64</code></td>
    294       <td>Forces the test to run on the given ABI. By default CTS runs a test once for each ABI the device supports.</td>
    295     </tr>
    296     <tr>
    297       <td><code>--logcat</code>, <code>--bugreport</code>, and <code>--screenshoot-on-failure</code></td>
    298       <td>Give more visibility into failures and can help with diagnostics.</td>
    299     </tr>
    300     <tr>
    301       <td><code>--device-token</code></td>
    302       <td>Specifies a given device has the given token eg. <code>--device-token 1a2b3c4d:sim-card.</code>.</td>
    303     </tr>
    304     <tr>
    305       <td><code>--skip-device-info</code></td>
    306       <td>Skips collection of information about the device. Note: do not use this option when running CTS for approval.</td>
    307     </tr>
    308     <tr>
    309       <td><code>--skip-preconditions</code></td>
    310       <td>Bypasses verification and setup of the device's configuration, such as pushing media files or checking for Wi-Fi connection.</td>
    311     </tr>
    312     <tr>
    313       <th>List</th>
    314       <th>Description</th>
    315     </tr>
    316     <tr>
    317       <td><code>list modules</code></td>
    318       <td>List all available test modules in the repository.</td.>
    319     </tr>
    320     <tr>
    321       <td><code>list plans</code> or <code>list configs</code></td>
    322       <td>List all available test plans (configs) in the repository.</td>
    323     </tr>
    324     <tr>
    325       <td><code>list invocations</code></td>
    326       <td>List 'run' commands currently being executed on devices.</td>
    327     </tr>
    328     <tr>
    329       <td><code>list commands</code></td>
    330       <td>List all 'run' commands currently in the queue waiting to be assigned to devices.</td>
    331     </tr>
    332     <tr>
    333       <td><code>list results</code></td>
    334       <td>List CTS results currently stored in repository.</td>
    335     </tr>
    336     <tr>
    337       <td><code>list devices</code></td>
    338       <td>List currently connected devices and their state.
    339         <p> </p>
    340         <p>'Available' devices are functioning, idle devices, available for running tests.</p>
    341         <p> </p>
    342         <p>'Unavailable' devices are devices visible via adb, but are not responding to adb commands and won't be allocated for tests.</p>
    343         <p> </p>
    344         <p>'Allocated' devices are devices currently running tests.</td>
    345     </tr>
    346     <tr>
    347       <th>Dump</th>
    348       <th>Description</th>
    349     </tr>
    350     <tr>
    351       <td><code>dump logs</code></td>
    352       <td>Dump the tradefed logs for all running invocations.</td>
    353     </tr>
    354   </tbody>
    355 </table>
    356