Android--ubuntu "CTS" Test TV Real Machine

Source: Internet
Author: User
<span id="Label3"></p><p><p>Recently contacted cts, is rumored not to understand CTS is not counted as a qualified Android developer, I have not seen around who Used. As a product development android, I'm still too young ~<br></p></p><p><p><br></p></p><p><p><br>Writing is not easy, reproduced please specify the source: http://blog.csdn.net/jscese/article/details/40650001#t11</p></p><p><p><br></p></p>Concept:<br><p><p><span style="font-size:14px"><strong>compatibility test Suite (CTS)</strong></span> compatibility test Group. is a set of testing frameworks provided by Google. Contains very many test examples,</p></p><p><p>Frameworks are used to manage the execution of test cases on a real machine device or simulator, and those use cases are all written in Java apk, the results of the implementation of these apk to test system platform compatibility and Stability.</p></p><p><p><strong>compatibility definition Document (CDD)</strong> defines a standard that the system needs to comply with software and hardware-related Parameters.</p></p><p><p>You can send the test results to <span style="font-family:Calibri">[email protected]</span><span style="font-family:宋体">. When you submit a</span> <span style="font-family:Calibri">CTS</span> <span style="font-family:宋体">report. You can also ask for access to</span> <span style="font-family:Calibri">Android</span>Market<span style="font-family:宋体">. </span><br></p></p><p><p><br></p></p><p><p><br></p></p>Configuration:<br><p><p>With the Android source code can be directly under the source code make <strong>CTS</strong> , and finally generate <strong>/out/host/linux-x86/cts/android-cts</strong><br></p></p><p><p>You can also go to http://source.android.com/compatibility/downloads.html to download the CTS component of each version number provided by Google. Unzip it out <strong>android-cts</strong> folder need version number corresponding!</p></p><p><p>The folder structure is as Follows:</p></p><p><p></p></p><p><p>Watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvannjzxnl/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70 /gravity/center "><br></p></p><p><p><br></p></p><p><p>When Docs is empty,<br></p></p><p><p>the <strong>Repository</strong> folder has <strong>plans</strong> . <strong>testcases</strong><br></p></p><p><p><strong></strong> Tools folder is the tool pack that launches the CTS Console. Started by the <strong>cts-tradefed</strong> script. There's a <strong>README</strong> .</p></p><p><p>There are a variety of configurations Online. Look directly at this simple and straightforward:</p></p><p><p></p></p><pre code_snippet_id="503606" snippet_file_name="blog_20141031_1_8353799" name="code" class="html">Configuring cts-tradefed------------------------1. Ensure ' adb ' is in your current PATH. ADB can be found in Theandroid SDK available from http://developer.android.comExample:PATH= $PATH:/home/myuser/android-s dk-linux_x86/platform-tools2. Follow the ' Setting up your device ' steps documented in Thects User Manual. The CTS User Manual can be downloaded athttp://source.android.com/compatibility/downloads.html3. Connect the device to the host machine.4. Ensure device is the visible via ' adb devices ' Using cts-tradefed-------------------to run a test plan on a single device:1. Make sure least one device connected2. Launch the cts-tradefed console by running the ' cts-tradefed ' script atandroid-cts/tools/cts-tradefed3. Type: ' run Cts--plan CTS ' to run the default CTS plansome other useful commands Areto run a test package: ' run Cts--packag E <packagename> ' to run a test class: ' run Cts--class <full test class name> ' to Shard a plan test run on Multip Le devices ' run Cts--planCts--shards <number of Shards>note:all connected devices must is running the same buildfor more options: ' run cts- -help ' CTS tradefed development------------------------see http://source.android.com for instructions on obtaining the Androidplatform source code and setting up a build Environment. The source for the CTS extensions for tradefed can is found at<android source root>/cts/tools/tradefed-hostthe Sourc E for the tradefed framework can is found on the ' tradefed ' Branch. Perform these steps to build and run cts-tradefed from the DEVELOPMENTENVIRONMENT:CD <path to Android source Root>ma Ke ctscts-tradefed</pre><br>Google's Readme writing is very clear, the need for the terminal to use<strong><strong>adb</strong></strong>This is available in the SDK provided by google, and gives the download Link. Then set it to the environment variable in path!<p><p></p></p><p><p></p></p><p><p></p></p><p><p>The ability to see the <strong>cts-tradefed</strong> script:</p></p><p><p></p></p><pre code_snippet_id="503606" snippet_file_name="blog_20141031_2_5057998" name="code" class="python"><pre code_snippet_id="503606" snippet_file_name="blog_20141031_2_5057998" name="code" class="python">Checkpath adbcheckpath java# Check java versionjava_version=$ (java-version 2>&1 | head-n 1 | grep ' ["]1\.6[\." $$] if ["${java_version}" = = ""]; Then Echo "wrong java Version. 1.6 is Required. " Exitfi</pre></pre><br>Can see is the need<strong><strong>JDK 1.6</strong></strong>Supported by the Above.<br><p><p></p></p><p><p><strong>The CTS under Android source code may not be Up-to-date. So it is best to go to the above mentioned Google website to download the corresponding CTS components!<br></strong></p></p><p><p><br></p></p>Use:<br>Start:<p><p>First turn on the Tv's adb debug Switch. Ubuntu connects via ADB Connect tv_ip. Android-cts run the cts-tradefed script into the CTS console:<br></p></p><p><p><strong><br></strong></p></p><p><p><strong><br></strong></p></p><p><p>You can see the information about the device by using the l-d command under CTS-TF.<strong><br></strong></p></p><p><p><br></p></p>Command:<br><p><p>Use <strong></strong> Help to View:</p></p><p><p><strong><br></strong></p></p><p><p>Able to see the set of supported commands <strong>! </strong></p></p><p><p>The version number is 4.2_r4, defined in <strong>/cts/tools/tradefed-host/src/com/android/cts/tradefed/build/ctsbuildprovider.java</strong></p></p><p><p>Use L p to view a test plan:</p></p><p><p></p></p><pre code_snippet_id="503606" snippet_file_name="blog_20141031_3_1022225" name="code" class="html"><pre code_snippet_id="503606" snippet_file_name="blog_20141031_3_1022225" name="code" class="html">CTS-TF > L pcts-tfctsvm-tfappsecuritypdkjavaandroidsignature</pre></pre><br>These are the things that exist<strong><strong>Android-cts/repository/plans</strong></strong>Under<p><p></p></p><p><p>A plan includes multiple Package. Each run of the CTS will be assigned a Session number. Start from 0.</p></p><p><p><strong>L d</strong> displays the connected Devices. <strong>L Packages</strong> shows the test package, <strong>L R</strong> shows the recorded results</p></p><p><p><br></p></p><p><p><strong>Run cts-p package_name</strong> individual test package_name pack</p></p><p><p><br></p></p><p><p><strong>Run Cts--continue-session SessionID--disable-reboot</strong><br></p></p><p><p>According to SessionID continue to test, do not restart. The ADB was disconnected because of the restart!</p></p><p><p><br></p></p><p><p><strong>run cts-c com.class_name-m methmod_name</strong> Test A class by itself method-c followed by the class name full path –m followed by the method name<br></p></p><p><p><br></p></p><p><p>Other commands can look at the gaze without much explanation.</p></p><p><p><br></p></p>Get ready:<p><p>If you need to test <strong>media</strong> -related packages, you can download <strong>CTS Media 1.0</strong> to the SDcard Test folder on Google's Website.</p></p><p><p>Other preparations to be made are:</p></p><p><p>Installing the CTS test APK to target board: ctsdelegatingaccessibilityservice.apk,ctsdeviceadmin.apk<br>(these two apk can be found in the testcase of the CTS source code folder)<br><br>Configuration of the system setting<br>(if The project removes the default setting or depth changes, it can be set using Google's native setting instead of the original Setting)<br>Enter settings to open Wi-fi and connect to AP (ap needs to be connected to Extranet)<br>Enter Settings->security->screenlock set to None<br>Enter settings->security->deviceadministrators->enable two options<br>Enter Language&input->language set to 中文版 (unitedstates)<br>Enter Settings->display->sleep set to 30minutes or none<br>Enter settings->accessibility->enabledelegating accessibility Service<br>Enter settings->developeroptions->enable USB debugging, stay awake, allowmock Locations<br>Set the time manually and adjust the timezone to Beijing. Set the country to China</p></p><p><p>This enables the run CTS * to be tested!<br></p></p><p><p><br></p></p><p><p><br></p></p>Results:<br><p><p><strong></strong> After testing, the results are saved in <strong>/android-cts/repository/results/2014.10.31_11.53.42/testresult.xml</strong> .<br><strong></strong></p></p><p><p>You can see the results in four ways: [<strong>pass</strong>/<strong>fail</strong>/<strong>notexecuted</strong>/<strong>timeout</strong>]<br></p></p><p><p>Let's say we don't support a feature module on our Hardware. We can change result= "fail" to result= "notexecuted" in Testresult.xml</p></p><p><p>The assumption is that the fail must also have this additional information:</p></p><p><p></p></p><pre code_snippet_id="503606" snippet_file_name="blog_20141031_4_9843370" name="code" class="html"> <test name= "testPlay00" result= "fail" starttime= "week Grone 12:01:24 cst" endtime= "week Grone 12:01:26 cst" ; <failedscene message= "junit.framework.assertionfailederror:playback/mnt/sdcard/test/bbb_short/176x144/3gp_ H263_libfaac/bbb_short.ffmpeg.176x144.3gp.h263_300kbps_12fps.libfaac_mono_24kbps_11025hz.3gpat Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlayback (mediaplayerstresstest.java:161) "> < Stacktrace>junit.framework.assertionfailederror:playback/mnt/sdcard/test/bbb_short/176x144/3gp_h263_libfaac /bbb_short.ffmpeg.176x144.3gp.h263_300kbps_12fps.libfaac_mono_24kbps_11025hz.3gpat Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlayback (mediaplayerstresstest.java:161) at Android.mediastress.cts.MediaPlayerStressTest.doTestVideoPlaybackShort (mediaplayerstresstest.java:165) at Android.mediastress.cts.H263QcifShortPlayerTest.testPlay00 (h263qcifshortplayertest.java:49) at Java.lang.reflect.Method.invokeNative (NatIve METHOD) at Android.test.InstrumentationTestCase.runMethod (instrumentationtestcase.java:214) at Android.test.InstrumentationTestCase.runTest (instrumentationtestcase.java:199) at Android.test.AndroidTestRunner.runTest (androidtestrunner.java:190) at Android.test.AndroidTestRunner.runTest ( Androidtestrunner.java:175) at Android.test.InstrumentationTestRunner.onStart (instrumentationtestrunner.java:555 ) at Android.app.instrumentation$instrumentationthread.run (instrumentation.java:1661) </StackTrace> </ Failedscene> </Test></pre><br>You can see that there is also a stack of information that can be used to find the reason for asking Fail.<p><p></p></p><p><p><br></p></p><p><p><br></p></p>Join Testcase:<p><p>We can see all the testcase in the source code <span style="color:#000000"><span style="font-family:Calibri">/cts/tests/tests/</span></span> below</p></p><p><p>Web-based Approach. Here are borrowing records such as the Following:</p></p><p><p></p></p><span style="color:#000000"><span style="color:#000000"><span style="color:#000000"><strong>Configure TestCase</strong></span></span></span><span style="color:#000000"><span style="color:#000000">structures such as the following:</span></span><span style="color:#000000"><span style="color:#000000"><span style="font-family:Calibri">Example</span></span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> androidmanifest.xml</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> android.mk</span> </span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> src</span> </span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> </span> android <span style="font-family:Calibri"> </span></span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> </span> example <span style="font-family:Calibri"> </span></span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> </span> cts <span style="font-family:Calibri"> </span></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span>Steps:<span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">1,</span> under the <span style="font-family:Calibri">cts/tests/tests/</span> folder to create a own set of use cases (folder) name <span style="font-family:Calibri">XXX;</span> </span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">2.</span> constructs such as the following structure in this directory:</span></span><span style="color:#000000"><span style="color:#000000"><span style="font-family:Calibri">XXX</span></span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">Androidmanifest.xml (</span> able to copy <span style="font-family:Calibri">example</span> under this file <span style="font-family:Calibri">)</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> android.mk (</span> able to copy <span style="font-family:Calibri">example</span> under this file <span style="font-family:Calibri">)</span> </span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> src</span> </span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> </span> android <span style="font-family:Calibri"> </span></span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"></span> XXX <span style="font-family:Calibri"> </span></span></span><span style="color:#000000"><span style="color:#000000">└──<span style="font-family:Calibri"> </span> cts <span style="font-family:Calibri"> </span></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">3.</span> write test code</span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000">detailed operation:</span></span><span style="color:#000000"><span style="color:#000000">add your own use case under the <span style="font-family:Calibri">src/android/xxx/cts</span> folder (<span style="font-family:Calibri">XXX</span> is the name of your own test sample Set. Example: Test)</span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000">Detail Description:</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">1</span>.<span style="font-family:Calibri">Google</span> 's official <span style="font-family:Calibri">CTS</span> Test example, When testing a class, did not test all the methods of the class. instead, we tested some of the most frequently used methods in the class, so we were able to do it ourselves when we programmed our own test cases</span> .</span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">2</span>. The folder for the <span style="font-family:Calibri">res</span> resource file used in the "form control class" is <span style="font-family:Calibri">source_android4\cts\tests\res</span> </span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">3</span>, preferably written in <span style="font-family:Calibri">Eclipse</span> , need <span style="font-family:Calibri">res</span> file, can be copied to the current project, so that through the <span style="font-family:Calibri">eclipse</span> Check for syntax errors in programming;</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">4</span>. Format of package name: pack<span style="font-family:Calibri">android. xxx.cts;</span> </span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">4</span> . Change the <span style="font-family:Calibri">android.mk</span> file under the <span style="font-family:Calibri">xxx/</span> folder</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">local_package_name:= ctsxxxtestcases</span>(this variable is the name of the test sample set that defines itself; the <span style="font-family:Calibri">APK</span> file with the same name will be generated after Compilation)</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">local_instrumentation_for:= ctsteststubs</span>(this variable locates some of the test cases involving virtual Machines.) Use the <span style="font-family:Calibri">junit</span> Framework. <span style="font-family:Calibri">Teststubs</span> This class is under folder <span style="font-family:Calibri">cts\tools\vm-tests-tf\src\dot\junit\opcodes</span> )</span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">5</span>. Change the <span style="font-family:Calibri">androidmanifest.xml</span> file under the <span style="font-family:Calibri">xxx/</span> folder</span></span><pre code_snippet_id="503606" snippet_file_name="blog_20141031_5_8872259" name="code" class="html"><pre code_snippet_id="503606" snippet_file_name="blog_20141031_5_8872259" name="code" class="html"><manifestxmlns:android= "http://schemas.android.com/apk/res/android" package= "com.android.cts.XXX" > <uses-permissionandroid:name= "android.permission.DISABLE_KEYGUARD"/> <application> <uses-libraryandroid:name= "android.test.runner"/> </application> < Instrumentationandroid:name= "android.test.InstrumentationCtsTestRunner" android:targetpackage= " Com.android.cts.stub " android:label=" ctstests of Android.xxx "/></manifest></pre></pre><br><br><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">6</span>, change the <span style="font-family:Calibri">source_android4.2/cts</span> folder</span></span><strong><strong><span style="font-family:Calibri">ctstestcaselist.mk</span></strong></strong><span style="color:#000000"><span style="color:#000000">; (</span></span><strong><strong>Important</strong></strong><span style="color:#000000"><span style="color:#000000">)</span></span><span style="color:#000000"><span style="color:#000000">in this file, add your own test sample set name to the variable <span style="font-family:Calibri">cts_test_packages</span> <span style="font-family:Calibri">ctsxxxtestcases</span> </span></span><span style="color:#000000"><span style="color:#000000">description: The file will be compiled at the time of</span> the</span>Build/core/tasks/cts.mk<span style="color:#000000"><span style="color:#000000">called to generate the finally CTS Package. </span></span><span style="color:#000000"><span style="color:#000000">description of the <span style="font-family:Calibri">ctstestcaselist.mk</span> file:</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">cts_coverage_test_case_list</span>(core variable)</span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> cts_support_packages</span>(this variable includes some use cases for test dependencies, which are <span style="font-family:Calibri">cts/hostsidetests</span>for code folders)</span></span><span style="color:#000000"><span style="color:#000000">├── ctsaccelerationteststubs<span style="font-family:Calibri">\</span> <span style="font-family:Calibri"> </span></span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">ctsdelegatingaccessibilityservice \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">ctsdeviceadmin \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">ctsmonkeyapp \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">CtsMonkeyApp2 \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">ctssomeaccessibilityservices \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">ctsteststubs \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">signaturetest \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">testdevicesetup \</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri">$ (cts_security_apps_list)</span> </span></span><span style="color:#000000"><span style="color:#000000">├──<span style="font-family:Calibri"> cts_test_packages</span>(this variable corresponds to the test example under the <span style="font-family:Calibri">cts/tests/tests/</span> folder)<br><br><br></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><span style="color:#000000"><span style="color:#000000"><strong>compiling your own <span style="font-family:Calibri">CTS</span> package</strong></span></span><span style="color:#000000"><span style="color:#000000">Run Make <span style="font-family:Calibri">Cts-j4<br><br><br></span></span></span><span style="font-family:Calibri"><span style="font-family:Calibri"><span style="color:#000000"></span></span></span><strong><strong><span style="color:#000000">test on a real machine</span></strong></strong><span style="color:#000000"><span style="color:#000000">because it takes a long time to complete the <span style="font-family:Calibri">CTS</span> test, We are able to create a test plan Ourselves. Procedures such as the Following:</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">1</span>. Unzip the <span style="font-family:Calibri">CTS</span> package and create an <span style="font-family:Calibri">XML</span> named <span style="font-family:Calibri">XXX</span> under <span style="font-family:Calibri">android-cts\repository\plans</span> documents;</span></span><span style="color:#000000"><span style="color:#000000"> <span style="font-family:Calibri">2</span>. This <span style="font-family:Calibri">XML</span> file format is:</span></span><span style="color:#000000"><span style="color: #000000"><span style="font-family:calibri">  <?xmlversion= "1.0" encoding= "UTF-8 "? <p> </p> <p> ><span style="color: #000000"><span style="font-family:calibri"><testplan version= "1.0" > </span> </span> <span style="color: #000000"><span style="font-family:calibri">       <entry uri= "android.xxx"/> </span> </span> <span style="color: #000000"><span style="font-family:calibri"></ Testplan> </span> </span> <span style="color: #000000"><span style="font-family:calibri">3 </span>, <span style="font-family:calibri">cts </span> test run <span style="font-family:calibri">run  cts  --plan XXX <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </span> </span> </p> <p> </p> <p> Android--ubuntu "CTS" Test TV real Machine </p> </span> </span></span></span>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.