Home | History | Annotate | Download | only in testcases
      1 # Copyright (C) 2016 The Android Open Source Project
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
      4 # you may not use this file except in compliance with the License.
      5 # You may obtain a copy of the License at
      6 #
      7 #      http://www.apache.org/licenses/LICENSE-2.0
      8 #
      9 # Unless required by applicable law or agreed to in writing, software
     10 # distributed under the License is distributed on an "AS IS" BASIS,
     11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     14 
     15 '''Module that contains the test TestLanguageSubcmdsNoDebug.'''
     16 
     17 from __future__ import absolute_import
     18 
     19 import os
     20 
     21 from harness.test_base_remote import TestBaseRemote
     22 from harness.decorators import (
     23     cpp_only_test,
     24     ordered_test,
     25 )
     26 
     27 
     28 class TestLanguageSubcmdsNoDebug(TestBaseRemote):
     29     '''Tests the 'language renderscript' subcommands without debug info.
     30 
     31     In particular, module dump should report missing debug info.
     32     '''
     33 
     34     bundle_target = {
     35         'java': 'JavaNoDebugWaitAttach',
     36         'jni': 'JNINoDebugWaitAttach',
     37         'cpp': 'CppNoDebugWaitAttach'
     38     }
     39 
     40     def _pkg_name(self):
     41         return {
     42             'java': 'com.android.rs.waitattachnodebug',
     43             'jni': 'com.android.rs.jninodebugwaitattach',
     44             'cpp': 'com.android.rs.cppwaitattach'
     45         }[self.app_type]
     46 
     47     @ordered_test(0)
     48     def test_language_subcommands_no_debug(self):
     49         # pylint: disable=line-too-long
     50         self.try_command('language renderscript status',
     51                          ['Runtime Library discovered',
     52                           'Runtime Driver discovered'])
     53 
     54         self.try_command('language renderscript kernel breakpoint set simple_kernel'
     55                          '',
     56                          ['(pending)'])
     57 
     58         self.try_command('process continue',
     59                          [])
     60 
     61         self.try_command('language renderscript kernel',
     62                          ['breakpoint',
     63                           'coordinate',
     64                           'list'])
     65 
     66         self.try_command('language renderscript kernel list',
     67                          ['RenderScript Kernels',
     68                           "Resource 'simple'",
     69                           'root',
     70                           'simple_kernel'])
     71 
     72         self.try_command('language renderscript context',
     73                          ['dump'])
     74 
     75         self.try_command('language renderscript context dump',
     76                          ['Inferred RenderScript Contexts',
     77                           '1 script instances'])
     78 
     79         self.try_command('language renderscript allocation',
     80                          ['list',
     81                           'load',
     82                           'save',
     83                           'dump',
     84                           'refresh'])
     85 
     86         self.try_command('language renderscript allocation list',
     87                          ['RenderScript Allocations:'])
     88 
     89         self.try_command('language renderscript allocation list -i 0',
     90                          ['RenderScript Allocations:'])
     91 
     92         self.try_command('language renderscript allocation list --id 0',
     93                          ['RenderScript Allocations:'])
     94 
     95         self.try_command('language renderscript allocation dump 1',
     96                          ['Data (X, Y, Z):'])
     97 
     98         output_file = self.get_tmp_file_path()
     99         self.try_command('language renderscript allocation dump 1 -f ' +
    100                          output_file,
    101                          ["Results written to '%s'" % output_file])
    102 
    103         if os.path.isfile(output_file):
    104             os.remove(output_file)
    105 
    106         self.try_command('language renderscript allocation dump 1 --file ' +
    107                          output_file,
    108                          ["Results written to '%s'" % output_file])
    109 
    110         self.try_command('language renderscript allocation save 1 ' +
    111                          output_file,
    112                          ["Allocation written to file '%s'" % output_file])
    113 
    114         self.try_command('language renderscript allocation load 1 ' +
    115                          output_file,
    116                          ["Contents of file '%s' read into allocation 1" %
    117                           output_file])
    118 
    119         self.try_command('language renderscript allocation refresh',
    120                          ['All allocations successfully recomputed'])
    121 
    122         # C++ tests have an additional kernel `other_kernel`
    123         kernel_count = 3 if self.app_type == 'cpp' else 2
    124         self.try_command('language renderscript module',
    125                          ['dump'])
    126 
    127         self.try_command('language renderscript module dump',
    128                          ['RenderScript Modules:',
    129                           'librs.simple.so',
    130                           'Debug info does not exist.',
    131                           'Globals: 1',
    132                           'gColor - variable identified, but not found in '
    133                             'binary (symbol exists)',
    134                           'Kernels: %s' % kernel_count,
    135                           'root',
    136                           'simple_kernel',
    137                           '',
    138                           'java_package_name: %s' % self._pkg_name(),
    139                           'version'])
    140 
    141     @ordered_test('last')
    142     @cpp_only_test()
    143     def test_cpp_cleanup(self):
    144         self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
    145 
    146         self.try_command('process continue', ['exited with status = 0'])
    147