Home | History | Annotate | Download | only in config
      1 page.title=Kernel Networking Unit 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 <p>Since Android 5.0, proper operation of the Android networking stack on Linux
     27 kernels requires a number of commits that were upstreamed relatively recently
     28 or have not yet made it upstream. It is not easy to manually verify the
     29 required kernel functionality or track the missing commits, so the Android team
     30 is sharing the tests it uses to ensure the kernel behaves as expected.</p>
     31 
     32 <h2 id=purpose>Why run the tests?</h2> <p>These tests exist for three main
     33 reasons:</p> <ol> <li>The exact version of the Linux kernel used on a device is
     34 typically device-specific, and it is difficult to know whether any kernel will
     35 work properly without running the tests.</li> <li>Forward-porting and
     36 back-porting the kernel patches to different kernel versions or different
     37 device trees may introduce subtle issues that can be impossible to spot without
     38 running the tests. For example, during development the initial versions of
     39 certain devices had UID routing patches forward-ported from android-3.4 instead
     40 of cherry-picked from android-3.10, and did not behave correctly.</li> <li>New
     41 networking features may require new kernel functionality or kernel bug
     42 fixes.</li> </ol> <p>If the tests do not pass, the device's network stack will
     43 behave incorrectly, causing user-visible connectivity bugs such as falling off
     44 Wi-Fi networks. The device will likely also fail Android Compatibility Test
     45 Suite (CTS) tests.</p>
     46 
     47 <h2 id=using>Using the tests</h2> <p>The tests use <a
     48 href="http://user-mode-linux.sourceforge.net/">User-Mode Linux</a> to boot the
     49 kernel as a process on a Linux host machine. See <a
     50 href="https://source.android.com/source/initializing.html">Establishing a Build
     51 Environment</a> for suitable operating system versions. The unit test framework
     52 boots the kernel with an appropriate disk image and runs the tests from the
     53 host file system. The tests are written in Python 2.x and use TAP interfaces to
     54 exercise kernel behaviour and the socket API.</p>
     55 
     56 <h3 id=compiling>Compiling the kernel for ARCH=um</h3> <p>For the tests to run,
     57 the kernel must compile for <code>ARCH=um SUBARCH=x86_64</code>. This is a
     58 supported architecture upstream and in the common Android kernel trees (e.g.,
     59 <code>android-3.10</code>, <code>android-3.18</code>). But sometimes device
     60 kernels do not compile in this mode because device trees contain
     61 device-specific or hardware-specific code in common files (e.g.,
     62 <code>sys/exit.c</code>).</p> <p>In many cases, it's sufficient to ensure that
     63 hardware-specific code is behind an <code>#ifdef</code>. Typically this should
     64 be an <code>#ifdef</code> on a configuration option that controls the specific
     65 feature relevant to the code. If there is no such configuration option, put
     66 hardware-specific code inside <code>#ifndef CONFIG_UML</code> blocks.</p> <p>In
     67 general, fixing this should be the responsibility of the kernel tree provider
     68 (e.g., chipset or SoC vendor). We're working with OEMs and vendors to ensure
     69 that current and future kernels will compile for <code>ARCH=um
     70 SUBARCH=x86_64</code> without requiring any changes.</p>
     71 
     72 <h3 id=running>Running the tests</h3> <p>The tests are at <a
     73 href="https://android.googlesource.com/kernel/tests/+/master/net/test"><code>kernel/tests/net/test</code></a>.
     74 It is recommended that the tests <b>be run from AOSP master</b> because they
     75 are the most up-to-date; in some cases, kernel features that are necessary for
     76 proper operation in a given Android release do not yet have full test coverage
     77 in the given release. For information on how to run the tests, see the <a
     78 href="https://android.googlesource.com/kernel/tests/+/master/net/test/README">kernel
     79 network test README file</a>. Basically, from the top of your kernel tree, run:</p>
     80 
     81 <pre>  &lt;android tree&gt;/kernel/tests/net/test/run_net_test.sh all_tests.sh</pre>
     82 
     83 <h3 id=passing>Passing the tests</h3> <p>The kernel network test Python
     84 source files contain comments that specify kernel commits that are known to be
     85 required to pass the tests. The tests should pass in the common kernel trees -
     86 at least the <code>android-3.10</code> and <code>android-3.18</code> branches
     87 in the <a
     88 href="https://android-review.googlesource.com/#/q/project:kernel/common"><code>kernel/common</code></a>
     89 project in AOSP. Therefore, passing the tests on a kernel tree that's derived
     90 from 3.10 or 3.18 should mostly be a matter of cherry-picking the patches from
     91 these trees.</p>
     92 
     93 <h2 id=contributing>Contributing</h2>
     94 
     95 <h3 id=reporting>Reporting issues</h3> <p>Please report any issues with
     96 the kernel network tests in the <a
     97 href="https://code.google.com/p/android/issues/entry?template=Developer%20bug%20report">Android
     98 issue tracker</a> with the <a
     99 href="https://code.google.com/p/android/issues/list?q=label%3AComponent-Networking">Component-Networking</a>
    100 label.</p>
    101 
    102 <h3 id=documenting>Documenting commits and adding tests</h3> <p>Please report
    103 issues as described above, and if possible upload a change to fix the issue,
    104 if:</p> <ul> <li>The tests do not pass on the common kernel trees</li> <li>You
    105 find a necessary commit that is not mentioned in the source comments,</li>
    106 <li>Getting the tests to pass on upstream kernels requires major changes</li>
    107 <li>You believe that the tests are overspecified, or the test fail on future
    108 kernels</li> <li>You'd like to add more tests or more coverage to existing
    109 tests.</li>
    110 </ul>
    111