blob: c87e58878759a3c3459765a5d973b7d69135d583 [file] [log] [blame]
'''Module that contains the test TestCoordinates.'''
from __future__ import absolute_import
from harness.test_base_remote import TestBaseRemote
from harness.decorators import (
ordered_test,
cpp_only_test
)
class TestCoordinates(TestBaseRemote):
'''Tests the inspection of coordinates.
Tests the inspection of the range and dimension of coordinates as well
as the current coordinates.'''
bundle_target = {
'java': 'JavaDebugWaitAttach',
'jni': 'JNIDebugWaitAttach',
'cpp': 'CppDebugWaitAttach'
}
def setup(self, android):
'''This test requires to be run on one thread.
Args:
android: The android_util module.
'''
android.push_prop('debug.rs.max-threads', 1)
def teardown(self, android):
'''Reset the number of RS threads to the previous value.
Args:
android: The android_util module.
'''
android.pop_prop('debug.rs.max-threads')
@ordered_test(0)
def test_inspect_coordinates(self):
# pylint: disable=line-too-long
self.try_command('language renderscript status',
['Runtime Library discovered',
'Runtime Driver discovered'])
self.try_command('language renderscript kernel breakpoint set simple_kernel',
['Breakpoint(s) created',
'(pending)'])
# Check the initial conditions.
self._lldb_continue()
self._inspect_coordinates(0, 0, 0)
# Check two more steps.
self._lldb_continue()
self._inspect_coordinates(1, 0, 0)
self._lldb_continue()
self._inspect_coordinates(2, 0, 0)
# After eight more steps we should have advanced one step in the y dimension.
for _ in range(8):
self._lldb_continue()
self._inspect_coordinates(2, 1, 0)
@ordered_test('last')
@cpp_only_test()
def test_cpp_cleanup(self):
self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
self.try_command('process continue',
['exited with status = 0'])
def _lldb_continue(self):
'''Try 'continue' lldb command. Expect to hit a breakpoint.'''
self.try_command('process continue',
['resuming',
'stopped',
'stop reason = breakpoint'])
def _inspect_coordinates(self, x_coord, y_coord, z_coord):
'''Run lldb commands to inspect kernel size and coordinates
and match against expected values.
Args:
(x_coord, y_coord, z_coord): The expected coordinates (int triple)
Raises:
TestFail: One of the lldb commands did not provide the expected
output.
'''
self.try_command('language renderscript kernel coordinate',
['Coordinate: (%d, %d, %d)'
% (x_coord, y_coord, z_coord)])
self.try_command('frame select 1',
['librs.simple.so`simple_kernel.expand',
'at generated.rs:1'])
# Inspect the invocation length, should be the same every time.
self.try_command('expr p->dim',
['x = 8',
'y = 8',
'z = 0'])
# The X coordinate is in the rsIndex variable.
self.try_command('expr rsIndex',
['= ' + str(x_coord)])
# Inspect the Y and Z coordinates.
self.try_command('expr p->current',
['x = ' + str(0),
'y = ' + str(y_coord),
'z = ' + str(z_coord)])