Python test suite for debugging a RenderScript app using lldb.
Includes testing for newly introduced lldb commands, which are subcommands
of "language renderscript". The targets ARM, AArch64, x86, x86-64 and
Mips32 are fully supported and should expect a 100% pass rate.
Change-Id: Ida882056b3627b380dfda880e22a121d68d79922
diff --git a/tests/lldb/.gitignore b/tests/lldb/.gitignore
new file mode 100644
index 0000000..b79973f
--- /dev/null
+++ b/tests/lldb/.gitignore
@@ -0,0 +1,65 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+*.swp
+
+*~
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+
+results.xml
+LLDBTestsuiteLog.txt
diff --git a/tests/lldb/Android.mk b/tests/lldb/Android.mk
new file mode 100644
index 0000000..95904a8
--- /dev/null
+++ b/tests/lldb/Android.mk
@@ -0,0 +1,4 @@
+LOCAL_PATH:=$(call my-dir)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
+
diff --git a/tests/lldb/README.txt b/tests/lldb/README.txt
new file mode 100644
index 0000000..4631f9c
--- /dev/null
+++ b/tests/lldb/README.txt
@@ -0,0 +1,308 @@
+- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
+- LLDB for Renderscript Test Suite
+-
+- 16/03/2016
+- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
+
+Overview:
+
+ The LLDB for Renderscript test suite is written in python and relies on
+ LLDB's python bindings. The test suite will push several test app's onto
+ a target device, and makes coordinated use of LLDB and ADB to run automated
+ debug sessions.
+
+Set up the test suite:
+
+ Check out the AOSP and build it for your target. Navigate to
+ /frameworks/rs/test/lldb and type mm. This should successfully build the
+ binaries that the testsuite uses. They will be placed in
+ <path to out folder>/target/product/<product code name>/data/app, system/lib
+ and system/bin.
+
+Prerequisite:
+
+ An lldb-server executable must be present on your device/emulator.
+ LLDB must be compiled on your host machine along with its python interface.
+ lldb-server and lldb should be built from the same source revisions.
+
+Running the test suite:
+
+ The test suite can be run via the following command:
+
+ > python run_tests.py [-h]
+ [--config path]
+ [--device DEVICE]
+ [--test path]
+ [--install-only]
+ [--no-install]
+ [--no-uninstall]
+ [--print-to-stdout]
+ [--verbose]
+ [--wimpy]
+ [--run-emu]
+ [--adb-path ADB_PATH]
+ [--aosp-product-path AOSP_PRODUCT_PATH]
+ [--blacklist BLACKLIST [BLACKLIST ...]]
+ [--device-port DEVICE_PORT]
+ [--emu-cmd EMU_CMD]
+ [--host-port HOST_PORT]
+ [--lldb-path LLDB_PATH]
+ [--lldb-server-path-device LLDB_SERVER_PATH_DEVICE]
+ [--lldb-server-path-host LLDB_SERVER_PATH_HOST]
+ [--log-file-path LOG_FILE_PATH]
+ [--results-file-path RESULTS_FILE_PATH]
+ [--timeout TIMEOUT]
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --config path, -c path
+ Path to a custom config file.
+ --device DEVICE, -d DEVICE
+ Specify the device id of the device to test on.
+ --test path, -t path Specify a specific test to run.
+ --install-only It only runs the pre-run stage of the test suite. It
+ installs the required APKs but does not execute the
+ tests.
+ --no-install, -n Stop the test suite installing apks to device.
+ --no-uninstall Stop the test suite uninstalling apks after
+ completion.
+ --print-to-stdout Print all logging information to standard out.
+ --verbose, -v Store extra info in the log.
+ --wimpy, -w Test only a core subset of features.
+ --run-emu Spawn an emulator and run the test suite on that.
+ Specify the emulator command line in the config file
+ or with -emu-cmd.
+ --adb-path ADB_PATH Path to android debug bridge on the host.
+ --aosp-product-path AOSP_PRODUCT_PATH
+ The path to the "out" folder of the AOSP repository.
+ --blacklist BLACKLIST [BLACKLIST ...]
+ Provide a test blacklist for skipping specific tests.
+ To specify the blacklist from the command line the
+ following can be used: --blacklist test1.py test2.py
+ ...
+ --device-port DEVICE_PORT
+ Specify the port number that lldb-server (on the
+ device) listens on. When lldb-server is spawned on the
+ device it will listen on this port. Each successive
+ test will increment onwards from this port.
+ --emu-cmd EMU_CMD The command line for the emulator (if using -run-emu).
+ --host-port HOST_PORT
+ Specify host port which lldb-server will be forwarded
+ to. Specify the starting host port number that lldb-
+ server (on the target) will be forwarded to on the
+ host. Each successive test will increment onwards from
+ this initial port.
+ --lldb-path LLDB_PATH
+ The path to lldb executable on the host.
+ --lldb-server-path-device LLDB_SERVER_PATH_DEVICE
+ Path to the lldb-server executable on the device.
+ --lldb-server-path-host LLDB_SERVER_PATH_HOST
+ Path to the lldb-server executable on host (if using
+ -run-emu).
+ --log-file-path LOG_FILE_PATH
+ The path to the folder where the log file will be
+ placed.
+ --results-file-path RESULTS_FILE_PATH
+ Output folder where junit results.xml file will be
+ placed.
+ --timeout TIMEOUT Timeout period for a single command, expressed in
+ seconds
+
+ An optional config file can be passed to the test suite which will provide
+ details of your specific environment. The user file should define a custom
+ class inheriting from Config in config.py. The class Config presents the
+ default set of options, available to be overridden.
+
+ All options in the config file can also be specified on the command line.
+
+ If your config and command line do not specify a path to the host lldb,
+ the PYTHONPATH environment variable must be set. The appropriate value to
+ set this to can be obtained by running the following command:
+
+ > lldb -P
+
+ This will print out a path to the lldb python bindings on your local machine.
+
+Build Requirements:
+
+
+ The following revisions are from the llvm git mirror:
+
+ llvm : 5786b73
+ clang: b6d0b32
+ lldb : 98712eb
+
+ lldb has the following dependencies:
+
+ Python2.7.6
+ swig2.0
+ lldb-server
+
+Building LLDB python bindings:
+
+ Linux:
+
+ Build instructions for Linux lldb can be found on the official lldb web
+ page:
+
+ http://lldb.llvm.org/build.html
+
+ The following CMake variables should be enabled when generating:
+
+ LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION = True
+
+ As a post build step, swig will generate the python bindings for lldb.
+
+ Windows:
+
+ Prerequisites:
+
+ Visual Studio 2015
+ Custom x64 Python2.7.10 package:
+ http://p-nand-q.com/python/2015.08.07-Python2710-x64-vs2015.7z
+ Swig Version 3.0.5 (Added to the $PATH)
+ Cmake 3.4.0 (So we can generate Visual Studio 2015 solutions)
+
+ Build Python for Windows:
+
+ http://p-nand-q.com/python/building-python-27-with-vs2010.html
+
+ The important thing here is that the above python distribution
+ contains debug versions of the libraries and is built with the same
+ Visual Studio version we are using so the runtimes do not conflict.
+
+ Build LLDB on Windows:
+
+ Select the Cmake generator "Microsoft Visual Studio 2015 Win64".
+ The following CMake variables should be enabled when generating:
+
+ LLDB_DISABLE_PYTHON=False
+ LLDB_RELOCATABLE_PYTHON=False
+ PYTHON_HOME=<path to the above python release>
+
+ Using cmake-gui is a good idea and lets you make sure that swig has
+ been correctly detected.
+
+ In the CMake configure step, you should see something similar to the
+ following:
+ -- Found Python version 2.7.9
+ -- LLDB Found PythonExecutable: E:/Python27/python.exe and
+ E:/Python27/python_d.exe
+ -- LLDB Found PythonLibs: E:/Python27/libs/python27.lib and
+ E:/Python27/libs/python27_d.lib
+ -- LLDB Found PythonDLL: E:/Python27/python27.dll and
+ E:/Python27/python27_d.dll
+ -- LLDB Found PythonIncludeDirs: E:/Python27/Include
+ LLDB version: 3.8.0
+ Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
+ Found PythonInterp:
+ $<$<CONFIG:Debug>:E:/Python27/python_d.exe>$<$<NOT:$<CONFIG:Debug>>:E:/Python27/python.exe>
+ (found version "1.4")
+
+ Build LLDB as a RelWithDebInfo build, because debug builds of lldb
+ produce an lldb_d.pyd file, but the __init__.py still refers to
+ lldb.pyd.
+
+ The LLDB python bindings should have built in
+ "llvm_build\RelWithDebInfo\lib\site-packages\lldb". Point the test
+ suite towards "llvm_build\RelWithDebInfo\bin\lldb.exe".
+ When running the test suite itself, make sure to use the python
+ executable from the custom package.
+
+A typical test transcript:
+
+ Located ADB
+ Located device ZX1G427S2S
+ Pushing all tests...
+ Pushed all tests
+ Pre run complete
+ Found 86 tests
+ Running test_allocation_dump_2_cpp.py: PASS
+ Running test_breakpoint_fileline_multiple_rs_files_cpp.py: PASS
+ Running test_read_local_cpp.py: PASS
+ Running test_breakpoint_kernel_multiple_rs_files_cpp.py: PASS
+ Running test_multiple_rs_files_cpp.py: PASS
+ Running test_breakpoint_kernel_all_multiple_rs_files_cpp.py: PASS
+ Running test_dwarf_lang_cpp.py: PASS
+ Running test_write_global_element_cpp.py: PASS
+ Running test_allocation_list_cpp.py: PASS
+ Running test_breakpoint_coordinate_cpp.py: PASS
+ Running test_rs_consts_cpp.py: PASS
+ Running test_allocation_file_cpp.py: PASS
+ Running test_allocation_dump_1_cpp.py: PASS
+ Running test_source_step_cpp.py: PASS
+ Running test_breakpoint_kernel_2_cpp.py: PASS
+ Running test_backtrace_cpp.py: PASS
+ Running test_language_subcmds_no_debug_cpp.py: PASS
+ Running test_breakpoint_kernel_1_cpp.py: PASS
+ Running test_language_subcmds_cpp.py: PASS
+ Running test_write_global_cpp.py: PASS
+ Running test_invoke_fun_cpp.py: PASS
+ Running test_breakpoint_fileline_cpp.py: PASS
+ Running test_write_local_cpp.py: PASS
+ Running test_breakpoint_kernel_all_cpp.py: PASS
+ Running test_write_local_element_cpp.py: PASS
+ Running test_call_api_funs_cpp.py: PASS
+ Running test_coordinates_cpp.py: PASS
+ Running test_read_global_cpp.py: PASS
+ Running test_language_subcmds.py: PASS
+ Running test_coordinates.py: PASS
+ Running test_language_subcmds_no_debug.py: PASS
+ Running test_read_local.py: PASS
+ Running test_call_api_funs.py: PASS
+ Running test_breakpoint_kernel_1.py: PASS
+ Running test_breakpoint_fileline.py: PASS
+ Running test_breakpoint_fileline_multiple_rs_files.py: PASS
+ Running test_rs_consts.py: PASS
+ Running test_invoke_fun.py: PASS
+ Running test_write_local_element.py: PASS
+ Running test_source_step.py: PASS
+ Running test_allocation_file.py: PASS
+ Running test_allocation_list.py: PASS
+ Running test_breakpoint_kernel_multiple_rs_files.py: PASS
+ Running test_allocation_dump_1.py: PASS
+ Running test_breakpoint_kernel_all.py: PASS
+ Running test_allocation_dump_2.py: PASS
+ Running test_allocation_dump_struct.py: PASS
+ Running test_read_global.py: PASS
+ Running test_language.py: PASS
+ Running test_dwarf_lang.py: PASS
+ Running test_breakpoint_coordinate.py: PASS
+ Running test_write_global.py: PASS
+ Running test_multiple_rs_files.py: PASS
+ Running test_write_global_element.py: PASS
+ Running test_breakpoint_kernel_all_multiple_rs_files.py: PASS
+ Running test_breakpoint_kernel_2.py: PASS
+ Running test_write_local.py: PASS
+ Running test_backtrace.py: PASS
+ Running test_call_api_funs_jni.py: PASS
+ Running test_invoke_fun_jni.py: PASS
+ Running test_allocation_dump_1_jni.py: PASS
+ Running test_breakpoint_fileline_multiple_rs_files_jni.py: PASS
+ Running test_allocation_file_jni.py: PASS
+ Running test_breakpoint_fileline_jni.py: PASS
+ Running test_source_step_jni.py: PASS
+ Running test_coordinates_jni.py: PASS
+ Running test_rs_consts_jni.py: PASS
+ Running test_breakpoint_kernel_all_multiple_rs_files_jni.py: PASS
+ Running test_multiple_rs_files_jni.py: PASS
+ Running test_allocation_dump_2_jni.py: PASS
+ Running test_allocation_list_jni.py: PASS
+ Running test_write_local_element_jni.py: PASS
+ Running test_breakpoint_kernel_all_jni.py: PASS
+ Running test_breakpoint_coordinate_jni.py: PASS
+ Running test_language_subcmds_no_debug_jni.py: PASS
+ Running test_read_local_jni.py: PASS
+ Running test_dwarf_lang_jni.py: PASS
+ Running test_breakpoint_kernel_2_jni.py: PASS
+ Running test_breakpoint_kernel_multiple_rs_files_jni.py: PASS
+ Running test_write_global_element_jni.py: PASS
+ Running test_breakpoint_kernel_1_jni.py: PASS
+ Running test_read_global_jni.py: PASS
+ Running test_language_subcmds_jni.py: PASS
+ Running test_write_global_jni.py: PASS
+ Running test_backtrace_jni.py: PASS
+ Running test_write_local_jni.py: PASS
+ Uninstalled/Deleted all tests
+ 86 of 86 passed
+ 100% rate
diff --git a/tests/lldb/config.py b/tests/lldb/config.py
new file mode 100644
index 0000000..db003a5
--- /dev/null
+++ b/tests/lldb/config.py
@@ -0,0 +1,99 @@
+'''LLDB-Renderscript test suite configuration file.
+
+This file contains the default test suite config which will be used in the
+case a developer did not supply a custom one.'''
+
+import os
+
+class Config(object):
+ '''Test suite configuration object.
+
+ The Config class is used by the test suite to abstract the specifics of a
+ user's local setup. This config can be overridden by specifying a custom
+ config on the command line.'''
+ # pylint: disable=no-self-use
+
+ @property
+ def adb_path(self):
+ '''Path to android debug bridge on the host.'''
+ return 'adb'
+
+ @property
+ def host_port(self):
+ '''Specify host port which lldb-server will be forwarded to.
+
+ Specify the starting host port number that lldb-server (on the target)
+ will be forwarded to on the host. Each successive test will increment
+ onwards from this initial port.'''
+ return 1234
+
+ @property
+ def device_port(self):
+ '''Specify the port number that lldb-server (on the device) listens on.
+
+ When lldb-server is spawned on the device it will listen on this port.
+ Each successive test will increment onwards from this port.'''
+ return 1234
+
+ @property
+ def lldb_server_path_device(self):
+ '''Path to the lldb-server executable on the device.'''
+ return '/data/lldb-server'
+
+ @property
+ def lldb_server_path_host(self):
+ '''Path to the lldb-server executable on host (if using -run-emu).'''
+ return 'lldb-server'
+
+ @property
+ def aosp_product_path(self):
+ '''The path to the "out" folder of the AOSP repository.'''
+ return os.getenv('ANDROID_PRODUCT_OUT')
+
+ @property
+ def log_file_path(self):
+ '''The path to the folder where the log file will be placed.'''
+ return os.path.join(os.getcwd(), 'LLDBTestsuiteLog.txt')
+
+ @property
+ def results_file_path(self):
+ '''Output folder where junit results.xml file will be placed.'''
+ return os.path.join(os.getcwd(), 'results.xml')
+
+ @property
+ def lldb_path(self):
+ '''The path to lldb executable on the host.'''
+ return 'lldb'
+
+ @property
+ def blacklist(self):
+ '''Provide a test blacklist for skipping specific tests.
+
+ To specify the blacklist from the command line the following can be
+ used: --blacklist test1.py test2.py ...'''
+ return []
+
+ @property
+ def verbose(self):
+ '''Flag to indicate whether to store extra output in the logs.'''
+ return False
+
+ @property
+ def device(self):
+ '''Specify the device id of the device to run on.
+
+ When multiple devices or emulators are present, a specific device to
+ use while testing can be indicated here.'''
+ return os.environ.get('ANDROID_SERIAL', None)
+
+ @property
+ def timeout(self):
+ '''Timeout period for a single command, expressed in seconds'''
+ return 60 * 15
+
+ @property
+ def emu_cmd(self):
+ '''The command line for the emulator (if using -run-emu).'''
+ return os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
+ 'prebuilts', 'android-emulator', 'linux-x86_64',
+ 'emulator')
diff --git a/tests/lldb/cpp/Allocations/Allocations.cpp b/tests/lldb/cpp/Allocations/Allocations.cpp
new file mode 100644
index 0000000..d6fc6ae
--- /dev/null
+++ b/tests/lldb/cpp/Allocations/Allocations.cpp
@@ -0,0 +1,403 @@
+#include <RenderScript.h>
+
+#include "ScriptC_allocs.h"
+
+using namespace android;
+using namespace RSC;
+
+sp<RS> mRS;
+sp<Allocation> mBoolAllocation; // boolean
+
+sp<Allocation> mCharAllocation; // char
+sp<Allocation> mChar2Allocation; // char2
+sp<Allocation> mChar3Allocation; // char3
+sp<Allocation> mChar4Allocation; // char4
+
+sp<Allocation> mUCharAllocation; // uchar
+sp<Allocation> mUChar2Allocation; // uchar2
+sp<Allocation> mUChar3Allocation; // uchar3
+sp<Allocation> mUChar4Allocation; // uchar4
+
+sp<Allocation> mShortAllocation; // short
+sp<Allocation> mShort2Allocation; // short2
+sp<Allocation> mShort3Allocation; // short3
+sp<Allocation> mShort4Allocation; // short4
+
+sp<Allocation> mUShortAllocation; // ushort
+sp<Allocation> mUShort2Allocation; // ushort2
+sp<Allocation> mUShort3Allocation; // ushort3
+sp<Allocation> mUShort4Allocation; // ushort4
+
+sp<Allocation> mIntAllocation; // int
+sp<Allocation> mInt2Allocation; // int2
+sp<Allocation> mInt3Allocation; // int3
+sp<Allocation> mInt4Allocation; // int4
+
+sp<Allocation> mUIntAllocation; // uint
+sp<Allocation> mUInt2Allocation; // uint2
+sp<Allocation> mUInt3Allocation; // uint3
+sp<Allocation> mUInt4Allocation; // uint4
+
+sp<Allocation> mLongAllocation; // long
+sp<Allocation> mLong2Allocation; // long2
+sp<Allocation> mLong3Allocation; // long3
+sp<Allocation> mLong4Allocation; // long4
+
+sp<Allocation> mULongAllocation; // ulong
+sp<Allocation> mULong2Allocation; // ulong2
+sp<Allocation> mULong3Allocation; // ulong3
+sp<Allocation> mULong4Allocation; // ulong4
+
+sp<Allocation> mHalfAllocation; // half
+sp<Allocation> mHalf2Allocation; // half2
+sp<Allocation> mHalf3Allocation; // half3
+sp<Allocation> mHalf4Allocation; // half4
+
+sp<Allocation> mFloatAllocation; // float
+sp<Allocation> mFloat2Allocation; // float2
+sp<Allocation> mFloat3Allocation; // float3
+sp<Allocation> mFloat4Allocation; // float4
+
+sp<Allocation> mDoubleAllocation; // double
+sp<Allocation> mDouble2Allocation; // double2
+sp<Allocation> mDouble3Allocation; // double3
+sp<Allocation> mDouble4Allocation; // double4
+
+const int mAllocSize = 24; // Needs to be < CHAR_MAX and divisible by 4.
+const int mBitmapSize = 64;
+
+void createSignedAllocations() {
+ Type::Builder typeI8Builder(mRS, Element::I8(mRS));
+ typeI8Builder.setX(1); // One element here to test 16 byte memory alignment
+ typeI8Builder.setY(3);
+ typeI8Builder.setZ(8);
+
+ mCharAllocation = Allocation::createTyped(mRS, typeI8Builder.create());
+ mChar2Allocation = Allocation::createSized(mRS, Element::I8_2(mRS), mAllocSize / 2);
+ mChar3Allocation = Allocation::createSized(mRS, Element::I8_3(mRS), mAllocSize / 4);
+ mChar4Allocation = Allocation::createSized(mRS, Element::I8_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI16_2Builder(mRS, Element::I16_2(mRS));
+ typeI16_2Builder.setX(6);
+ typeI16_2Builder.setY(1);
+ typeI16_2Builder.setZ(2);
+
+ mShortAllocation = Allocation::createSized(mRS, Element::I16(mRS), mAllocSize);
+ mShort2Allocation = Allocation::createTyped(mRS, typeI16_2Builder.create());
+ mShort3Allocation = Allocation::createSized(mRS, Element::I16_3(mRS), mAllocSize / 4);
+ mShort4Allocation = Allocation::createSized(mRS, Element::I16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI32_3Builder(mRS, Element::I32_3(mRS));
+ typeI32_3Builder.setX(3);
+ typeI32_3Builder.setY(2);
+
+ mIntAllocation = Allocation::createSized(mRS, Element::I32(mRS), mAllocSize);
+ mInt2Allocation = Allocation::createSized(mRS, Element::I32_2(mRS), mAllocSize / 2);
+ mInt3Allocation = Allocation::createTyped(mRS, typeI32_3Builder.create());
+ mInt4Allocation = Allocation::createSized(mRS, Element::I32_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI64_4Builder(mRS, Element::I64_4(mRS));
+ typeI64_4Builder.setX(1);
+ typeI64_4Builder.setY(6);
+
+ mLongAllocation = Allocation::createSized(mRS, Element::I64(mRS), mAllocSize);
+ mLong2Allocation = Allocation::createSized(mRS, Element::I64_2(mRS), mAllocSize / 2);
+ mLong3Allocation = Allocation::createSized(mRS, Element::I64_3(mRS), mAllocSize / 4);
+ mLong4Allocation = Allocation::createTyped(mRS, typeI64_4Builder.create());
+
+ mBoolAllocation = Allocation::createSized(mRS, Element::BOOLEAN(mRS), mAllocSize);
+}
+
+void initSignedAllocations() {
+ char *buffer_char = new char[mAllocSize];
+ short *buffer_short = new short[mAllocSize];
+ int *buffer_int = new int[mAllocSize];
+ int64_t *buffer_long = new int64_t[mAllocSize];
+ char *buffer_bool = new char[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (char) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (int64_t) i;
+ buffer_bool[i] = (char) (0x01 & i);
+ }
+
+ mCharAllocation->copy3DRangeFrom(0, 0, 0, 1, 3, 8, buffer_char);
+ mChar2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_char);
+ mChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+ mChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+
+ delete [] buffer_char;
+
+ mShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short);
+ mShort2Allocation->copy3DRangeFrom(0, 0, 0, 6, 1, 2, buffer_short);
+ mShort3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+ mShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+
+ delete [] buffer_short;
+
+ mIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int);
+ mInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int);
+ mInt3Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_int);
+ mInt4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int);
+
+ delete [] buffer_int;
+
+ mLongAllocation->copy1DRangeFrom(0, mAllocSize, buffer_long);
+ mLong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long);
+ mLong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+ mLong4Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_long);
+
+ delete [] buffer_long;
+
+ mBoolAllocation->copy1DRangeFrom(0, mAllocSize, buffer_bool);
+
+ delete [] buffer_bool;
+}
+
+void createUnsignedAllocations() {
+ Type::Builder typeU8_2Builder(mRS, Element::U8_2(mRS));
+ typeU8_2Builder.setX(2);
+ typeU8_2Builder.setY(6);
+
+ mUCharAllocation = Allocation::createSized(mRS, Element::U8(mRS), mAllocSize);
+ mUChar2Allocation = Allocation::createTyped(mRS, typeU8_2Builder.create());
+ mUChar3Allocation = Allocation::createSized(mRS, Element::U8_3(mRS), mAllocSize / 4);
+ mUChar4Allocation = Allocation::createSized(mRS, Element::U8_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeU16_3Builder(mRS, Element::U16_3(mRS));
+ typeU16_3Builder.setX(1);
+ typeU16_3Builder.setY(6);
+
+ mUShortAllocation = Allocation::createSized(mRS, Element::U16(mRS), mAllocSize);
+ mUShort2Allocation = Allocation::createSized(mRS, Element::U16_2(mRS), mAllocSize / 2);
+ mUShort3Allocation = Allocation::createTyped(mRS, typeU16_3Builder.create());
+ mUShort4Allocation = Allocation::createSized(mRS, Element::U16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeU32_4Builder(mRS, Element::U32_4(mRS));
+ typeU32_4Builder.setX(1);
+ typeU32_4Builder.setY(1);
+ typeU32_4Builder.setZ(6);
+
+ mUIntAllocation = Allocation::createSized(mRS, Element::U32(mRS), mAllocSize);
+ mUInt2Allocation = Allocation::createSized(mRS, Element::U32_2(mRS), mAllocSize / 2);
+ mUInt3Allocation = Allocation::createSized(mRS, Element::U32_3(mRS), mAllocSize / 4);
+ mUInt4Allocation = Allocation::createTyped(mRS, typeU32_4Builder.create());
+
+ Type::Builder typeU64Builder(mRS, Element::U64(mRS));
+ typeU64Builder.setX(4);
+ typeU64Builder.setY(3);
+ typeU64Builder.setZ(2);
+
+ mULongAllocation = Allocation::createTyped(mRS, typeU64Builder.create());
+ mULong2Allocation = Allocation::createSized(mRS, Element::U64_2(mRS), mAllocSize / 2);
+ mULong3Allocation = Allocation::createSized(mRS, Element::U64_3(mRS), mAllocSize / 4);
+ mULong4Allocation = Allocation::createSized(mRS, Element::U64_4(mRS), mAllocSize / 4);
+}
+
+void initUnsignedAllocations() {
+ char *buffer_char = new char[mAllocSize];
+ short *buffer_short = new short[mAllocSize];
+ int *buffer_int = new int[mAllocSize];
+ uint64_t *buffer_long = new uint64_t[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (char) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (uint64_t) i;
+ }
+
+ mUCharAllocation->copy1DRangeFrom(0, mAllocSize, buffer_char);
+ mUChar2Allocation->copy2DRangeFrom(0, 0, 2, 6, buffer_char);
+ mUChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+ mUChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+
+ delete [] buffer_char;
+
+ mUShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short);
+ mUShort2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_short);
+ mUShort3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_short);
+ mUShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+
+ delete [] buffer_short;
+
+ mUIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int);
+ mUInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int);
+ mUInt3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int);
+ mUInt4Allocation->copy3DRangeFrom(0, 0, 0, 1, 1, 6, buffer_int);
+
+ delete [] buffer_int;
+
+ mULongAllocation->copy3DRangeFrom(0, 0, 0, 4, 3, 2, buffer_long);
+ mULong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long);
+ mULong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+ mULong4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+
+ delete [] buffer_long;
+}
+
+void createFloatAllocations() {
+ Type::Builder typeF16_3Builder(mRS, Element::F16_3(mRS));
+ typeF16_3Builder.setX(1);
+ typeF16_3Builder.setY(6);
+
+ mHalfAllocation = Allocation::createSized(mRS, Element::F16(mRS), mAllocSize);
+ mHalf2Allocation = Allocation::createSized(mRS, Element::F16_2(mRS), mAllocSize / 2);
+ mHalf3Allocation = Allocation::createTyped(mRS, typeF16_3Builder.create());
+ mHalf4Allocation = Allocation::createSized(mRS, Element::F16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeF32_4Builder(mRS, Element::F32_4(mRS));
+ typeF32_4Builder.setX(3);
+ typeF32_4Builder.setY(2);
+
+ mFloatAllocation = Allocation::createSized(mRS, Element::F32(mRS), mAllocSize);
+ mFloat2Allocation = Allocation::createSized(mRS, Element::F32_2(mRS), mAllocSize / 2);
+ mFloat3Allocation = Allocation::createSized(mRS, Element::F32_3(mRS), mAllocSize / 4);
+ mFloat4Allocation = Allocation::createTyped(mRS, typeF32_4Builder.create());
+
+ Type::Builder typeF64_2Builder(mRS, Element::F64_2(mRS));
+ typeF64_2Builder.setX(4);
+ typeF64_2Builder.setY(1);
+ typeF64_2Builder.setZ(3);
+
+ mDoubleAllocation = Allocation::createSized(mRS, Element::F64(mRS), mAllocSize);
+ mDouble2Allocation = Allocation::createTyped(mRS, typeF64_2Builder.create());
+
+ Type::Builder typeF64_3Builder(mRS, Element::F64_3(mRS));
+ typeF64_3Builder.setX(1);
+ typeF64_3Builder.setY(2);
+ typeF64_3Builder.setZ(3);
+
+ Type::Builder typeF64_4Builder(mRS, Element::F64_4(mRS));
+ typeF64_4Builder.setX(1);
+ typeF64_4Builder.setY(2);
+ typeF64_4Builder.setZ(3);
+
+ mDouble3Allocation = Allocation::createTyped(mRS, typeF64_3Builder.create());
+ mDouble4Allocation = Allocation::createTyped(mRS, typeF64_4Builder.create());
+}
+
+void initFloatAllocations() {
+ __fp16 *buffer_half = new __fp16[mAllocSize];
+ float *buffer_float = new float[mAllocSize];
+ double *buffer_double = new double[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_half[i] = (__fp16) 1 / i;
+ buffer_float[i] = (float) 1 / i;
+ buffer_double[i] = (double) 1 / i;
+ }
+
+ mHalfAllocation->copy1DRangeFrom(0, mAllocSize, buffer_half);
+ mHalf2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_half);
+ mHalf3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_half);
+ mHalf4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_half);
+
+ delete [] buffer_half;
+
+ mFloatAllocation->copy1DRangeFrom(0, mAllocSize, buffer_float);
+ mFloat2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_float);
+ mFloat3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_float);
+ mFloat4Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_float);
+
+ delete [] buffer_float;
+
+ mDoubleAllocation->copy1DRangeFrom(0, mAllocSize, buffer_double);
+ mDouble2Allocation->copy3DRangeFrom(0, 0, 0, 4, 1, 3, buffer_double);
+ mDouble3Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double);
+ mDouble4Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double);
+
+ delete [] buffer_double;
+}
+
+int main()
+{
+ mRS = new RS();
+
+ mRS->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+
+ sp<ScriptC_allocs> mScript = new ScriptC_allocs(mRS);
+
+ Type::Builder typeRGBA_888Builder(mRS, Element::RGBA_8888(mRS));
+ typeRGBA_888Builder.setX(mBitmapSize);
+ typeRGBA_888Builder.setY(mBitmapSize);
+
+ sp<Allocation> mInAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create());
+
+ const int image_area = mBitmapSize*mBitmapSize;
+ const int image_size = image_area*sizeof(int);
+
+ char *zero_buffer = new char[image_size];
+ memset(zero_buffer, 0, image_size);
+ mInAllocation->copy1DRangeFrom(0, image_area, zero_buffer);
+ delete [] zero_buffer;
+
+ sp<Allocation> mOutAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create());
+ createSignedAllocations();
+ initSignedAllocations();
+
+ mRS->finish();
+ mScript->forEach_swizzle_kernel(mInAllocation, mOutAllocation);
+ mRS->finish();
+
+ mCharAllocation.clear();
+ mChar2Allocation.clear();
+ mChar3Allocation.clear();
+ mChar4Allocation.clear();
+
+ mShort2Allocation.clear();
+ mShort3Allocation.clear();
+ mShort4Allocation.clear();
+
+ mIntAllocation.clear();
+ mInt2Allocation.clear();
+ mInt3Allocation.clear();
+ mInt4Allocation.clear();
+
+ mLongAllocation.clear();
+ mLong2Allocation.clear();
+ mLong3Allocation.clear();
+ mLong4Allocation.clear();
+
+ mBoolAllocation.clear();
+
+ createUnsignedAllocations();
+ initUnsignedAllocations();
+
+ mInAllocation = mUShortAllocation; // Host side assignment
+
+ mRS->finish();
+ mScript->forEach_square_kernel(mInAllocation, mUIntAllocation);
+ mRS->finish();
+
+ mUCharAllocation.clear();
+ mUChar2Allocation.clear();
+ mUChar3Allocation.clear();
+ mUChar4Allocation.clear();
+
+ mUShortAllocation.clear();
+ mUShort2Allocation.clear();
+ mUShort3Allocation.clear();
+ mUShort4Allocation.clear();
+
+ mUInt2Allocation.clear();
+ mUInt3Allocation.clear();
+ mUInt4Allocation.clear();
+
+ mULongAllocation.clear();
+ mULong2Allocation.clear();
+ mULong3Allocation.clear();
+ mULong4Allocation.clear();
+
+ createFloatAllocations();
+ initFloatAllocations();
+
+ mRS->finish();
+ mScript->forEach_add_half_kernel(mDouble4Allocation, mDouble3Allocation);
+ mRS->finish();
+
+ return 0;
+}
+
diff --git a/tests/lldb/cpp/Allocations/Android.mk b/tests/lldb/cpp/Allocations/Android.mk
new file mode 100644
index 0000000..dec733b
--- /dev/null
+++ b/tests/lldb/cpp/Allocations/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppAllocations
+
+LOCAL_SRC_FILES := \
+ Allocations.cpp \
+ allocs.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static libcompiler_rt
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/lldb/cpp/Allocations/allocs.rs b/tests/lldb/cpp/Allocations/allocs.rs
new file mode 100644
index 0000000..f4ff5c1
--- /dev/null
+++ b/tests/lldb/cpp/Allocations/allocs.rs
@@ -0,0 +1,31 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppallocations)
+
+// Kernel performs basic vector swizzle
+uchar4 __attribute__((kernel)) swizzle_kernel(uchar4 in)
+{
+ return in.wzyx;
+}
+
+// Kernel squares every element in allocation
+uint __attribute__((kernel)) square_kernel(ushort in)
+{
+ uint result = (uint)in * (uint)in;
+ return result;
+}
+
+// Helper function adding 1/2 to passed in double
+static double half_helper(double in)
+{
+ return (in + 0.5);
+}
+
+// Kernel returns first 3 elements of a double4 plus 1/2
+double3 __attribute__((kernel)) add_half_kernel(double4 in)
+{
+ double3 result;
+ result.x = half_helper(in.x);
+ result.y = half_helper(in.y);
+ result.z = half_helper(in.z);
+ return result;
+}
diff --git a/tests/lldb/cpp/Android.mk b/tests/lldb/cpp/Android.mk
new file mode 100644
index 0000000..8338432
--- /dev/null
+++ b/tests/lldb/cpp/Android.mk
@@ -0,0 +1,2 @@
+include $(call all-subdir-makefiles)
+
diff --git a/tests/lldb/cpp/BranchingFunCalls/Android.mk b/tests/lldb/cpp/BranchingFunCalls/Android.mk
new file mode 100644
index 0000000..5bc597f
--- /dev/null
+++ b/tests/lldb/cpp/BranchingFunCalls/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppBranchingFunCalls
+
+LOCAL_SRC_FILES := \
+ BranchingFunCalls.cpp \
+ simple.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/lldb/cpp/BranchingFunCalls/BranchingFunCalls.cpp b/tests/lldb/cpp/BranchingFunCalls/BranchingFunCalls.cpp
new file mode 100644
index 0000000..df51382
--- /dev/null
+++ b/tests/lldb/cpp/BranchingFunCalls/BranchingFunCalls.cpp
@@ -0,0 +1,42 @@
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+int main()
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ rs->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+
+ auto e = Element::I32(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ int * input = new int[size*size];
+ for(int i = 0; i < size*size; ++i) {
+ input[i] = i - (size*size / 2);
+ }
+ a->copy2DRangeFrom(0, 0, size, size, input);
+ delete [] input;
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+ s->invoke_addToGlobal(234);
+ s->forEach_simple_kernel(a, b);
+ rs->finish();
+ int32_t * output = new int32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ return 0;
+}
+
diff --git a/tests/lldb/cpp/BranchingFunCalls/simple.rs b/tests/lldb/cpp/BranchingFunCalls/simple.rs
new file mode 100644
index 0000000..9b6dfe3
--- /dev/null
+++ b/tests/lldb/cpp/BranchingFunCalls/simple.rs
@@ -0,0 +1,60 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppbranchingfuncalls)
+
+static bool is_neg(int a)
+{
+ if(a < 0)
+ return true;
+ else
+ return false;
+}
+
+static bool is_pos(int a)
+{
+ if(a > 0)
+ return true;
+ else
+ return false;
+}
+
+static void set_i(int * a, int b)
+{
+ int tmp = b;
+ *a = tmp;
+}
+
+static void modify_f(float * f)
+{
+ *f *= 0.5f;
+}
+
+static void modify_i(int * i)
+{
+ int j = *i;
+ int cutoff = 2 << 6;
+ if(j > cutoff)
+ j = cutoff;
+ if(is_neg(j))
+ set_i(i, 0);
+ else if(is_pos(j))
+ set_i(i, j);
+ else
+ set_i(i, cutoff);
+}
+
+int __attribute__((kernel)) simple_kernel(int in)
+{
+ int i = in;
+ float f = (float) i;
+ modify_f(&f);
+ modify_i(&i);
+ int ret = (int) f;
+ return in * ret;
+}
+
+int glob = 123;
+
+void addToGlobal(int arg)
+{
+ glob += arg;
+}
diff --git a/tests/lldb/cpp/InfiniteLoop/Android.mk b/tests/lldb/cpp/InfiniteLoop/Android.mk
new file mode 100644
index 0000000..e4910bb
--- /dev/null
+++ b/tests/lldb/cpp/InfiniteLoop/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppInfiniteLoop
+
+LOCAL_SRC_FILES := \
+ InfiniteLoop.cpp \
+ simple.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/lldb/cpp/InfiniteLoop/InfiniteLoop.cpp b/tests/lldb/cpp/InfiniteLoop/InfiniteLoop.cpp
new file mode 100644
index 0000000..505fad5
--- /dev/null
+++ b/tests/lldb/cpp/InfiniteLoop/InfiniteLoop.cpp
@@ -0,0 +1,44 @@
+#include <thread>
+#include <chrono>
+
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+int main()
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ rs->init("/data/rscache", RS_INIT_LOW_LATENCY);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+
+ // Test is designed to loop forever, waits for two seconds
+ // between each invocation of the kernel
+ bool forever = true;
+ while(forever)
+ {
+ s->forEach_simple_kernel(a, b);
+ std::this_thread::sleep_for(std::chrono::seconds(2));
+ }
+
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ return 0;
+}
+
diff --git a/tests/lldb/cpp/InfiniteLoop/simple.rs b/tests/lldb/cpp/InfiniteLoop/simple.rs
new file mode 100644
index 0000000..a93d3a4
--- /dev/null
+++ b/tests/lldb/cpp/InfiniteLoop/simple.rs
@@ -0,0 +1,22 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppinfiniteloop)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 out = rsUnpackColor8888(in);
+
+ out.r = gColor.r;
+ out.g = gColor.g;
+ out.b = gColor.b;
+ out.a = gColor.a;
+
+ uchar4 result = rsPackColorTo8888(out);
+ return result;
+}
+
diff --git a/tests/lldb/cpp/KernelVariables/Android.mk b/tests/lldb/cpp/KernelVariables/Android.mk
new file mode 100644
index 0000000..52ed88f
--- /dev/null
+++ b/tests/lldb/cpp/KernelVariables/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppKernelVariables
+
+LOCAL_SRC_FILES := \
+ KernelVariables.cpp \
+ simple.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/lldb/cpp/KernelVariables/KernelVariables.cpp b/tests/lldb/cpp/KernelVariables/KernelVariables.cpp
new file mode 100644
index 0000000..25f7575
--- /dev/null
+++ b/tests/lldb/cpp/KernelVariables/KernelVariables.cpp
@@ -0,0 +1,74 @@
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+int main()
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ rs->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+
+ static const int buffer_int[] = {1, 2, 3, 4};
+ sp<Allocation> int_allocation = Allocation::createSized(rs, Element::I32(rs), 4);
+ int_allocation->copy1DRangeFrom(0, 4, buffer_int);
+ s->set_allocation_1D_global(int_allocation);
+
+ static const int buffer_int2[] = {5, 6, 7, 8};
+
+ Type::Builder typeI32Builder2D(rs, Element::I32(rs));
+ typeI32Builder2D.setX(2);
+ typeI32Builder2D.setY(2);
+
+ sp<Allocation> int_allocation2 = Allocation::createTyped(rs, typeI32Builder2D.create());
+ int_allocation2->copy2DRangeFrom(0, 0, 2, 2, buffer_int2);
+ s->set_allocation_1D_global2(int_allocation2);
+
+ s->set_allocation_2D_global(a);
+ s->set_allocation_2D_global2(b);
+
+ static const int buffer_int3[] = {9, 10, 11, 12, 13, 14, 15, 16};
+
+ Type::Builder typeI32Builder3D(rs, Element::I32(rs));
+ typeI32Builder3D.setX(2);
+ typeI32Builder3D.setY(2);
+ typeI32Builder3D.setZ(2);
+
+ sp<Allocation> int_allocation3 = Allocation::createTyped(rs, typeI32Builder3D.create());
+ int_allocation3->copy3DRangeFrom(0, 0, 0, 2, 2, 2, buffer_int3);
+ s->set_allocation_3D_global(int_allocation3);
+
+ Type::Builder yuvTypeBuilder(rs, Element::YUV(rs));
+ yuvTypeBuilder.setX(4);
+ yuvTypeBuilder.setY(4);
+ yuvTypeBuilder.setYuvFormat(RS_YUV_YV12);
+
+ sp<Allocation> yuv_allocation = Allocation::createTyped(rs, yuvTypeBuilder.create());
+ s->set_allocation_YUV_2D_global(yuv_allocation);
+
+ s->set_sampler_global(Sampler::CLAMP_LINEAR(rs));
+
+ // Script is executed once, then the data is copied back when finished
+ s->forEach_kernel(a, b);
+ rs->finish();
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ return 0;
+}
+
diff --git a/tests/lldb/cpp/KernelVariables/simple.rs b/tests/lldb/cpp/KernelVariables/simple.rs
new file mode 100644
index 0000000..572e1f4
--- /dev/null
+++ b/tests/lldb/cpp/KernelVariables/simple.rs
@@ -0,0 +1,160 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppkernelvariables)
+
+char char_global = 12;
+uchar uchar_global = 234;
+short short_global = -321;
+ushort ushort_global = 432;
+int int_global = 1234;
+uint uint_global = 2345;
+float float_global = 4.5f;
+long long_global = -77777;
+ulong ulong_global = 8888;
+double double_global = -456.5f;
+
+char2 char2_global = {11, -22};
+uchar2 uchar2_global = {33, 44};
+short2 short2_global = {-555, 666};
+ushort2 ushort2_global = {777, 888};
+int2 int2_global = {999, -1111};
+uint2 uint2_global = {2222, 3333};
+float2 float2_global = {4.5f, -5.0f};
+long2 long2_global = {-4444, 5555};
+ulong2 ulong2_global = {6666, 7777};
+double2 double2_global = {88.5f, -99.0f};
+
+char3 char3_global = {11, -22, -33};
+uchar3 uchar3_global = {33, 44, 55};
+short3 short3_global = {-555, 666, 777};
+ushort3 ushort3_global = {777, 888, 999};
+int3 int3_global = {999, -1111, 2222};
+uint3 uint3_global = {2222, 3333, 4444};
+float3 float3_global = {4.5f, -5.0f, -6.5f};
+long3 long3_global = {-4444, 5555, 6666};
+ulong3 ulong3_global = {6666, 7777, 8888};
+double3 double3_global = {88.5f, -99.0f, 111.5f};
+
+char4 char4_global = {55, 11, -22, -33};
+uchar4 uchar4_global = {222, 33, 44, 55};
+short4 short4_global = {-444, -555, 666, 777};
+ushort4 ushort4_global = {666, 777, 888, 999};
+int4 int4_global = {888, 999, -1111, 2222};
+uint4 uint4_global = {1111, 2222, 3333, 4444};
+float4 float4_global = {3.0f, 4.5f, -5.0f, -6.5f};
+long4 long4_global = {-3333, -4444, 5555, 6666};
+ulong4 ulong4_global = {5555, 6666, 7777, 8888};
+double4 double4_global = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+rs_matrix2x2 matrix2x2_global;
+rs_matrix3x3 matrix3x3_global;
+rs_matrix4x4 matrix4x4_global;
+
+rs_quaternion quaternion_global;
+
+rs_allocation allocation_1D_global;
+rs_allocation allocation_1D_global2;
+rs_allocation allocation_2D_global;
+rs_allocation allocation_2D_global2;
+rs_allocation allocation_3D_global;
+rs_allocation allocation_YUV_2D_global;
+
+rs_allocation_cubemap_face cubemap_face_global;
+rs_sampler sampler_global;
+
+uchar4 __attribute__((kernel)) kernel(uchar4 in)
+{
+ char char_local = 'a';
+ uchar uchar_local = 'b';
+ short short_local = -321;
+ ushort ushort_local = 432;
+ int int_local = 1234;
+ uint uint_local = 2345;
+ float float_local = 4.5f;
+ long long_local = -77777;
+ ulong ulong_local = 8888;
+ double double_local = -456.5f;
+
+ char2 char2_local = {-11, -22};
+ uchar2 uchar2_local = {33, 44};
+ short2 short2_local = {-555, 666};
+ ushort2 ushort2_local = {777, 888};
+ int2 int2_local = {999, -1111};
+ uint2 uint2_local = {2222, 3333};
+ float2 float2_local = {4.5f, -5.0f};
+ long2 long2_local = {-4444, 5555};
+ ulong2 ulong2_local = {6666, 7777};
+ double2 double2_local = {88.5f, -99.0f};
+
+ char3 char3_local = {11, -22, -33};
+ uchar3 uchar3_local = {33, 44, 55};
+ short3 short3_local = {-555, 666, 777};
+ ushort3 ushort3_local = {777, 888, 999};
+ int3 int3_local = {999, -1111, 2222};
+ uint3 uint3_local = {2222, 3333, 4444};
+ float3 float3_local = {4.5f, -5.0f, -6.5f};
+ long3 long3_local = {-4444, 5555, 6666};
+ ulong3 ulong3_local = {6666, 7777, 8888};
+ double3 double3_local = {88.5f, -99.0f, 111.5f};
+
+ char4 char4_local = {55, 11, -22, -33};
+ uchar4 uchar4_local = {22, 33, 44, 55};
+ short4 short4_local = {-444, -555, 666, 777};
+ ushort4 ushort4_local = {666, 777, 888, 999};
+ int4 int4_local = {888, 999, -1111, 2222};
+ uint4 uint4_local = {1111, 2222, 3333, 4444};
+ float4 float4_local = {3.0f, 4.5f, -5.0f, -6.5f};
+ long4 long4_local = {-3333, -4444, 5555, 6666};
+ ulong4 ulong4_local = {5555, 6666, 7777, 8888};
+ double4 double4_local = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+ rs_matrix2x2 matrix2x2_local = {{1., 2.5,
+ 3., 4.5}};
+ rs_matrix3x3 matrix3x3_local = {{5., 6.5, 7.,
+ 8.5, 9., 1.5,
+ 2., 3.5, 4.}};
+ rs_matrix4x4 matrix4x4_local = {{5.5, 6., 7.5, 8.,
+ 9., 1.5, 2., 3.5,
+ 4.5, 5.5, 6.5, 7.,
+ 8., 9.5, 1.5, 2.5}};
+
+ matrix2x2_global = matrix2x2_local;
+ matrix3x3_global = matrix3x3_local;
+ matrix4x4_global = matrix4x4_local;
+
+ rsQuaternionSet(&quaternion_global, 3.0, 4.5, 5.5, 6.0);
+
+ rs_quaternion quaternion_local;
+ rsQuaternionSet(&quaternion_local, 7.5, 8.0, 9.0, 0.5);
+
+ char char_combined = char_local + (char)uchar_local + char2_local.x +
+ (char)uchar2_local.x + char3_local.x - (char)uchar3_local.x +
+ char4_local.x + (char)uchar4_local.x;
+
+ short short_combined = short_local + (short)ushort_local + short2_local.x +
+ (short)ushort2_local.x + short3_local.x + (short)ushort3_local.x +
+ short4_local.x + (short)ushort4_local.x;
+
+ int int_combined = int_local + (int)uint_local + int2_local.x +
+ (int)uint2_local.x + int3_local.x + (int)uint3_local.x + int4_local.x +
+ (int)uint4_local.x;
+
+ float float_combined = float_local + float2_local.x + float3_local.x +
+ float4_local.x;
+
+ long long_combined = long_local + (long)ulong_local + long2_local.x +
+ (long)ulong2_local.x + long3_local.x + (long)ulong3_local.x +
+ long4_local.x + (long)ulong4_local.x;
+
+ double double_combined = double_local + double2_local.x + double3_local.x +
+ double4_local.x;
+
+ char_global = char_combined;
+ short_global = short_combined;
+ int_global = int_combined;
+ float_global = float_combined;
+ long_global = long_combined;
+ double_global = double_combined;
+
+ uchar4 result = {1,2,3,4};
+ return result;
+}
diff --git a/tests/lldb/cpp/MultipleRSFiles/Android.mk b/tests/lldb/cpp/MultipleRSFiles/Android.mk
new file mode 100644
index 0000000..f75ab9b
--- /dev/null
+++ b/tests/lldb/cpp/MultipleRSFiles/Android.mk
@@ -0,0 +1,28 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppMultipleRSFiles
+
+LOCAL_SRC_FILES := \
+ MultipleRSFiles.cpp \
+ first.rs \
+ second.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
diff --git a/tests/lldb/cpp/MultipleRSFiles/MultipleRSFiles.cpp b/tests/lldb/cpp/MultipleRSFiles/MultipleRSFiles.cpp
new file mode 100644
index 0000000..c009710
--- /dev/null
+++ b/tests/lldb/cpp/MultipleRSFiles/MultipleRSFiles.cpp
@@ -0,0 +1,38 @@
+#include <RenderScript.h>
+
+#include "ScriptC_first.h"
+#include "ScriptC_second.h"
+
+using namespace android;
+using namespace RSC;
+
+int main()
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ rs->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_first> s1 = new ScriptC_first(rs);
+ sp<ScriptC_second> s2 = new ScriptC_second(rs);
+
+ s1->forEach_first_kernel(a, b);
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ s2->forEach_second_kernel(a, b);
+
+ rs->finish();
+ return 0;
+}
diff --git a/tests/lldb/cpp/MultipleRSFiles/first.rs b/tests/lldb/cpp/MultipleRSFiles/first.rs
new file mode 100644
index 0000000..b86ec8c
--- /dev/null
+++ b/tests/lldb/cpp/MultipleRSFiles/first.rs
@@ -0,0 +1,16 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppmultiplersfiles)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) first_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
diff --git a/tests/lldb/cpp/MultipleRSFiles/second.rs b/tests/lldb/cpp/MultipleRSFiles/second.rs
new file mode 100644
index 0000000..d414ae5
--- /dev/null
+++ b/tests/lldb/cpp/MultipleRSFiles/second.rs
@@ -0,0 +1,9 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppmultiplersfiles)
+
+/* RenderScript kernel that just returns the swizzled input. */
+uchar4 __attribute__((kernel)) second_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/cpp/WaitAttach/Android.mk b/tests/lldb/cpp/WaitAttach/Android.mk
new file mode 100644
index 0000000..8edd8a1
--- /dev/null
+++ b/tests/lldb/cpp/WaitAttach/Android.mk
@@ -0,0 +1,53 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := CppDebugWaitAttach
+
+LOCAL_SRC_FILES := \
+ WaitAttach.cpp \
+ simple.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := CppNoDebugWaitAttach
+
+LOCAL_SRC_FILES := \
+ WaitAttach.cpp \
+ simple.rs
+
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+LOCAL_CFLAGS := --std=c++11
+
+LOCAL_RENDERSCRIPT_FLAGS := -O0 -target-api 0
+
+LOCAL_LDFLAGS := \
+ -ldl \
+ -llog
+
+intermediates := $(call intermediates-dir-for,STATIC_LIBRARIES,libRS,TARGET,)
+
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+LOCAL_C_INCLUDES += $(intermediates)
+
+include $(BUILD_EXECUTABLE)
+
diff --git a/tests/lldb/cpp/WaitAttach/WaitAttach.cpp b/tests/lldb/cpp/WaitAttach/WaitAttach.cpp
new file mode 100644
index 0000000..4da5e97
--- /dev/null
+++ b/tests/lldb/cpp/WaitAttach/WaitAttach.cpp
@@ -0,0 +1,35 @@
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+int main()
+{
+ static const int size = 8;
+ sp<RS> rs = new RS();
+
+ rs->init("/data/rscache", RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+ s->forEach_simple_kernel(a, b);
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ s->forEach_other_kernel(a, b);
+
+ rs->finish();
+ return 0;
+}
diff --git a/tests/lldb/cpp/WaitAttach/simple.rs b/tests/lldb/cpp/WaitAttach/simple.rs
new file mode 100644
index 0000000..97e17cf
--- /dev/null
+++ b/tests/lldb/cpp/WaitAttach/simple.rs
@@ -0,0 +1,23 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.cppwaitattach)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
+
+// Extra kernel to test lldb setting breakpoints on all the RS kernels.
+uchar4 __attribute__((kernel)) other_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/java/Allocations/Android.mk b/tests/lldb/java/Allocations/Android.mk
new file mode 100644
index 0000000..a62d3a6
--- /dev/null
+++ b/tests/lldb/java/Allocations/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := Allocations
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -Wno-unused -target-api 0
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/Allocations/AndroidManifest.xml b/tests/lldb/java/Allocations/AndroidManifest.xml
new file mode 100644
index 0000000..8650cb0
--- /dev/null
+++ b/tests/lldb/java/Allocations/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.allocations">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="Allocations"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/java/Allocations/res/layout/main_layout.xml b/tests/lldb/java/Allocations/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/java/Allocations/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/java/Allocations/src/com/android/rs/allocations/MainActivity.java b/tests/lldb/java/Allocations/src/com/android/rs/allocations/MainActivity.java
new file mode 100644
index 0000000..7cff9ae
--- /dev/null
+++ b/tests/lldb/java/Allocations/src/com/android/rs/allocations/MainActivity.java
@@ -0,0 +1,536 @@
+package com.android.rs.allocations;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.Bitmap;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private RenderScript mRS;
+
+ private Allocation mInAllocation; // script input
+ private Allocation mOutAllocation; // script output
+
+ private Allocation mStructInAlloc; // complexStruct input
+ private Allocation mStructOutAlloc; // complexStruct output
+
+ private Allocation mBoolAllocation; // boolean
+
+ private Allocation mCharAllocation; // char
+ private Allocation mChar2Allocation; // char2
+ private Allocation mChar3Allocation; // char3
+ private Allocation mChar4Allocation; // char4
+
+ private Allocation mUCharAllocation; // uchar
+ private Allocation mUChar2Allocation; // uchar2
+ private Allocation mUChar3Allocation; // uchar3
+ private Allocation mUChar4Allocation; // uchar4
+
+ private Allocation mShortAllocation; // short
+ private Allocation mShort2Allocation; // short2
+ private Allocation mShort3Allocation; // short3
+ private Allocation mShort4Allocation; // short4
+
+ private Allocation mUShortAllocation; // ushort
+ private Allocation mUShort2Allocation; // ushort2
+ private Allocation mUShort3Allocation; // ushort3
+ private Allocation mUShort4Allocation; // ushort4
+
+ private Allocation mIntAllocation; // int
+ private Allocation mInt2Allocation; // int2
+ private Allocation mInt3Allocation; // int3
+ private Allocation mInt4Allocation; // int4
+
+ private Allocation mUIntAllocation; // uint
+ private Allocation mUInt2Allocation; // uint2
+ private Allocation mUInt3Allocation; // uint3
+ private Allocation mUInt4Allocation; // uint4
+
+ private Allocation mLongAllocation; // long
+ private Allocation mLong2Allocation; // long2
+ private Allocation mLong3Allocation; // long3
+ private Allocation mLong4Allocation; // long4
+
+ private Allocation mULongAllocation; // ulong
+ private Allocation mULong2Allocation; // ulong2
+ private Allocation mULong3Allocation; // ulong3
+ private Allocation mULong4Allocation; // ulong4
+
+ private Allocation mHalfAllocation; // half
+ private Allocation mHalf2Allocation; // half2
+ private Allocation mHalf3Allocation; // half3
+ private Allocation mHalf4Allocation; // half4
+
+ private Allocation mFloatAllocation; // float
+ private Allocation mFloat2Allocation; // float2
+ private Allocation mFloat3Allocation; // float3
+ private Allocation mFloat4Allocation; // float4
+
+ private Allocation mDoubleAllocation; // double
+ private Allocation mDouble2Allocation; // double2
+ private Allocation mDouble3Allocation; // double3
+ private Allocation mDouble4Allocation; // double4
+
+ private ScriptC_allocs mScript;
+
+ private int mAllocSize = 24; // Chosen as allocation size since it's easily divisible
+
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ mBitmapIn = Bitmap.createBitmap(64, 64, Bitmap.Config.ARGB_8888);
+ mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(), mBitmapIn.getHeight(), mBitmapIn.getConfig());
+
+ createScript();
+ runScript();
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ mScript = new ScriptC_allocs(mRS);
+ }
+
+ private void createSignedAllocations() {
+ Type.Builder typeI8Builder = new Type.Builder(mRS, Element.I8(mRS));
+ typeI8Builder.setX(1); // One element here to test 16 byte memory alignment
+ typeI8Builder.setY(3);
+ typeI8Builder.setZ(8);
+
+ mCharAllocation = Allocation.createTyped(mRS, typeI8Builder.create());
+ mRS.finish();
+ mChar2Allocation = Allocation.createSized(mRS, Element.I8_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mChar3Allocation = Allocation.createSized(mRS, Element.I8_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mChar4Allocation = Allocation.createSized(mRS, Element.I8_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeI16_2Builder = new Type.Builder(mRS, Element.I16_2(mRS));
+ typeI16_2Builder.setX(6);
+ typeI16_2Builder.setY(1);
+ typeI16_2Builder.setZ(2);
+
+ mShortAllocation = Allocation.createSized(mRS, Element.I16(mRS), mAllocSize);
+ mRS.finish();
+ mShort2Allocation = Allocation.createTyped(mRS, typeI16_2Builder.create());
+ mRS.finish();
+ mShort3Allocation = Allocation.createSized(mRS, Element.I16_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mShort4Allocation = Allocation.createSized(mRS, Element.I16_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeI32_3Builder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeI32_3Builder.setX(3);
+ typeI32_3Builder.setY(2);
+
+ mIntAllocation = Allocation.createSized(mRS, Element.I32(mRS), mAllocSize);
+ mRS.finish();
+ mInt2Allocation = Allocation.createSized(mRS, Element.I32_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mInt3Allocation = Allocation.createTyped(mRS, typeI32_3Builder.create());
+ mRS.finish();
+ mInt4Allocation = Allocation.createSized(mRS, Element.I32_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeI64_4Builder = new Type.Builder(mRS, Element.I64_4(mRS));
+ typeI64_4Builder.setX(1);
+ typeI64_4Builder.setY(6);
+
+ mLongAllocation = Allocation.createSized(mRS, Element.I64(mRS), mAllocSize);
+ mRS.finish();
+ mLong2Allocation = Allocation.createSized(mRS, Element.I64_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mLong3Allocation = Allocation.createSized(mRS, Element.I64_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mLong4Allocation = Allocation.createTyped(mRS, typeI64_4Builder.create());
+ mRS.finish();
+
+ mBoolAllocation = Allocation.createSized(mRS, Element.BOOLEAN(mRS), mAllocSize);
+ mRS.finish();
+ }
+
+ private void initSignedAllocations() {
+ byte[] buffer_char = new byte[mAllocSize];
+ short[] buffer_short = new short[mAllocSize];
+ int[] buffer_int = new int[mAllocSize];
+ long[] buffer_long = new long[mAllocSize];
+ byte[] buffer_bool = new byte[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (byte) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (long) i;
+ buffer_bool[i] = (byte) (0x01 & i);
+ }
+
+ mCharAllocation.copyFrom(buffer_char);
+ mChar2Allocation.copyFrom(buffer_char);
+ mChar3Allocation.copyFrom(buffer_char);
+ mChar4Allocation.copyFrom(buffer_char);
+
+ mShortAllocation.copyFrom(buffer_short);
+ mShort2Allocation.copyFrom(buffer_short);
+ mShort3Allocation.copyFrom(buffer_short);
+ mShort4Allocation.copyFrom(buffer_short);
+
+ mIntAllocation.copyFrom(buffer_int);
+ mInt2Allocation.copyFrom(buffer_int);
+ mInt3Allocation.copyFrom(buffer_int);
+ mInt4Allocation.copyFrom(buffer_int);
+
+ mLongAllocation.copyFrom(buffer_long);
+ mLong2Allocation.copyFrom(buffer_long);
+ mLong3Allocation.copyFrom(buffer_long);
+ mLong4Allocation.copyFrom(buffer_long);
+
+ mBoolAllocation.copyFromUnchecked(buffer_bool);
+ }
+
+ private void createUnsignedAllocations() {
+ Type.Builder typeU8_2Builder = new Type.Builder(mRS, Element.U8_2(mRS));
+ typeU8_2Builder.setX(2);
+ typeU8_2Builder.setY(6);
+
+ mUCharAllocation = Allocation.createSized(mRS, Element.U8(mRS), mAllocSize);
+ mRS.finish();
+ mUChar2Allocation = Allocation.createTyped(mRS, typeU8_2Builder.create());
+ mRS.finish();
+ mUChar3Allocation = Allocation.createSized(mRS, Element.U8_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mUChar4Allocation = Allocation.createSized(mRS, Element.U8_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeU16_3Builder = new Type.Builder(mRS, Element.U16_3(mRS));
+ typeU16_3Builder.setX(1);
+ typeU16_3Builder.setY(6);
+
+ mUShortAllocation = Allocation.createSized(mRS, Element.U16(mRS), mAllocSize);
+ mRS.finish();
+ mUShort2Allocation = Allocation.createSized(mRS, Element.U16_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mUShort3Allocation = Allocation.createTyped(mRS, typeU16_3Builder.create());
+ mRS.finish();
+ mUShort4Allocation = Allocation.createSized(mRS, Element.U16_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeU32_4Builder = new Type.Builder(mRS, Element.U32_4(mRS));
+ typeU32_4Builder.setX(1);
+ typeU32_4Builder.setY(1);
+ typeU32_4Builder.setZ(6);
+
+ mUIntAllocation = Allocation.createSized(mRS, Element.U32(mRS), mAllocSize);
+ mRS.finish();
+ mUInt2Allocation = Allocation.createSized(mRS, Element.U32_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mUInt3Allocation = Allocation.createSized(mRS, Element.U32_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mUInt4Allocation = Allocation.createTyped(mRS, typeU32_4Builder.create());
+ mRS.finish();
+
+ Type.Builder typeU64Builder = new Type.Builder(mRS, Element.U64(mRS));
+ typeU64Builder.setX(4);
+ typeU64Builder.setY(3);
+ typeU64Builder.setZ(2);
+
+ mULongAllocation = Allocation.createTyped(mRS, typeU64Builder.create());
+ mRS.finish();
+ mULong2Allocation = Allocation.createSized(mRS, Element.U64_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mULong3Allocation = Allocation.createSized(mRS, Element.U64_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mULong4Allocation = Allocation.createSized(mRS, Element.U64_4(mRS), mAllocSize / 4);
+ mRS.finish();
+ }
+
+ private void initUnsignedAllocations() {
+ byte[] buffer_char = new byte[mAllocSize];
+ short[] buffer_short = new short[mAllocSize];
+ int[] buffer_int = new int[mAllocSize];
+ long[] buffer_long = new long[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (byte) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (long) i;
+ }
+
+ mUCharAllocation.copyFrom(buffer_char);
+ mUChar2Allocation.copyFrom(buffer_char);
+ mUChar3Allocation.copyFrom(buffer_char);
+ mUChar4Allocation.copyFrom(buffer_char);
+
+ mUShortAllocation.copyFrom(buffer_short);
+ mUShort2Allocation.copyFrom(buffer_short);
+ mUShort3Allocation.copyFrom(buffer_short);
+ mUShort4Allocation.copyFrom(buffer_short);
+
+ mUIntAllocation.copyFrom(buffer_int);
+ mUInt2Allocation.copyFrom(buffer_int);
+ mUInt3Allocation.copyFrom(buffer_int);
+ mUInt4Allocation.copyFrom(buffer_int);
+
+ mULongAllocation.copyFrom(buffer_long);
+ mULong2Allocation.copyFrom(buffer_long);
+ mULong3Allocation.copyFrom(buffer_long);
+ mULong4Allocation.copyFrom(buffer_long);
+ }
+
+ private void createFloatAllocations() {
+ Type.Builder typeF16_3Builder = new Type.Builder(mRS, Element.F16_3(mRS));
+ typeF16_3Builder.setX(1);
+ typeF16_3Builder.setY(6);
+
+ mHalfAllocation = Allocation.createSized(mRS, Element.F16(mRS), mAllocSize);
+ mRS.finish();
+ mHalf2Allocation = Allocation.createSized(mRS, Element.F16_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mHalf3Allocation = Allocation.createTyped(mRS, typeF16_3Builder.create());
+ mRS.finish();
+ mHalf4Allocation = Allocation.createSized(mRS, Element.F16_4(mRS), mAllocSize / 4);
+ mRS.finish();
+
+ Type.Builder typeF32_4Builder = new Type.Builder(mRS, Element.F32_4(mRS));
+ typeF32_4Builder.setX(3);
+ typeF32_4Builder.setY(2);
+
+ mFloatAllocation = Allocation.createSized(mRS, Element.F32(mRS), mAllocSize);
+ mRS.finish();
+ mFloat2Allocation = Allocation.createSized(mRS, Element.F32_2(mRS), mAllocSize / 2);
+ mRS.finish();
+ mFloat3Allocation = Allocation.createSized(mRS, Element.F32_3(mRS), mAllocSize / 4);
+ mRS.finish();
+ mFloat4Allocation = Allocation.createTyped(mRS, typeF32_4Builder.create());
+ mRS.finish();
+
+ Type.Builder typeF64_2Builder = new Type.Builder(mRS, Element.F64_2(mRS));
+ typeF64_2Builder.setX(4);
+ typeF64_2Builder.setY(1);
+ typeF64_2Builder.setZ(3);
+
+ mDoubleAllocation = Allocation.createSized(mRS, Element.F64(mRS), mAllocSize);
+ mRS.finish();
+ mDouble2Allocation = Allocation.createTyped(mRS, typeF64_2Builder.create());
+ mRS.finish();
+
+ Type.Builder typeF64_3Builder = new Type.Builder(mRS, Element.F64_3(mRS));
+ typeF64_3Builder.setX(1);
+ typeF64_3Builder.setY(2);
+ typeF64_3Builder.setZ(3);
+
+ Type.Builder typeF64_4Builder = new Type.Builder(mRS, Element.F64_4(mRS));
+ typeF64_4Builder.setX(1);
+ typeF64_4Builder.setY(2);
+ typeF64_4Builder.setZ(3);
+
+ mDouble3Allocation = Allocation.createTyped(mRS, typeF64_3Builder.create());
+ mRS.finish();
+ mDouble4Allocation = Allocation.createTyped(mRS, typeF64_4Builder.create());
+ mRS.finish();
+ }
+
+ private void initFloatAllocations() {
+ // No java type for half precision float, so bitcast 16-bit int
+ short[] buffer_half = new short[mAllocSize];
+ float[] buffer_float = new float[mAllocSize];
+ double[] buffer_double = new double[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ // Construct IEEE 754 half with increasing fraction.
+ byte mantissa = (byte)(i);
+ byte exponent = 0b00111100; // keep exponent constant at one
+ buffer_half[i] = (short)((exponent << 8) | mantissa);
+
+ buffer_float[i] = (float) 1 / i;
+ buffer_double[i] = (double) 1 / i;
+ }
+
+ mHalfAllocation.copyFromUnchecked(buffer_half);
+ mHalf2Allocation.copyFromUnchecked(buffer_half);
+ mHalf3Allocation.copyFromUnchecked(buffer_half);
+ mHalf4Allocation.copyFromUnchecked(buffer_half);
+
+ mFloatAllocation.copyFrom(buffer_float);
+ mFloat2Allocation.copyFrom(buffer_float);
+ mFloat3Allocation.copyFrom(buffer_float);
+ mFloat4Allocation.copyFrom(buffer_float);
+
+ mDoubleAllocation.copyFrom(buffer_double);
+ mDouble2Allocation.copyFrom(buffer_double);
+ mDouble3Allocation.copyFrom(buffer_double);
+ mDouble4Allocation.copyFrom(buffer_double);
+ }
+
+ private void createStructAllocations() {
+ ScriptField_complexStruct complex_struct;
+
+ complex_struct = new ScriptField_complexStruct(mRS, mAllocSize);
+ mRS.finish();
+ mScript.bind_g_complexStruct_in(complex_struct);
+ mRS.finish();
+ mStructInAlloc = complex_struct.getAllocation();
+ mRS.finish();
+
+ complex_struct = new ScriptField_complexStruct(mRS, mAllocSize);
+ mRS.finish();
+ mScript.bind_g_complexStruct_out(complex_struct);
+ mRS.finish();
+ mStructOutAlloc = complex_struct.getAllocation();
+ mRS.finish();
+ }
+
+ private void overwriteFloatAllocations() {
+ float[] buffer_float = new float[mAllocSize];
+
+ // Set float allocations to -1/n
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_float[i] = -1f / i;
+ }
+
+ mFloatAllocation.copyFrom(buffer_float);
+ mFloat2Allocation.copyFrom(buffer_float);
+ mFloat3Allocation.copyFrom(buffer_float);
+ mFloat4Allocation.copyFrom(buffer_float);
+ }
+
+ private void runScript() {
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mRS.finish();
+ mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
+ mRS.finish();
+
+
+ createSignedAllocations();
+ initSignedAllocations();
+
+ mRS.finish();
+ mScript.forEach_swizzle_kernel(mInAllocation, mOutAllocation);
+ mRS.finish();
+
+ mOutAllocation.copyTo(mBitmapOut);
+
+ mCharAllocation.destroy();
+ mRS.finish();
+ mChar2Allocation.destroy();
+ mRS.finish();
+ mChar3Allocation.destroy();
+ mRS.finish();
+ mChar4Allocation.destroy();
+ mRS.finish();
+
+ mShort2Allocation.destroy();
+ mRS.finish();
+ mShort3Allocation.destroy();
+ mRS.finish();
+ mShort4Allocation.destroy();
+ mRS.finish();
+
+ mIntAllocation.destroy();
+ mRS.finish();
+ mInt2Allocation.destroy();
+ mRS.finish();
+ mInt3Allocation.destroy();
+ mRS.finish();
+ mInt4Allocation.destroy();
+ mRS.finish();
+
+ mLongAllocation.destroy();
+ mRS.finish();
+ mLong2Allocation.destroy();
+ mRS.finish();
+ mLong3Allocation.destroy();
+ mRS.finish();
+ mLong4Allocation.destroy();
+ mRS.finish();
+
+ mBoolAllocation.destroy();
+ mRS.finish();
+
+
+ createUnsignedAllocations();
+ initUnsignedAllocations();
+
+ mInAllocation = mUShortAllocation; // Host side assignment
+
+ mRS.finish();
+ mScript.forEach_square_kernel(mInAllocation, mUIntAllocation);
+ mRS.finish();
+
+ mUCharAllocation.destroy();
+ mRS.finish();
+ mUChar2Allocation.destroy();
+ mRS.finish();
+ mUChar3Allocation.destroy();
+ mRS.finish();
+ mUChar4Allocation.destroy();
+ mRS.finish();
+
+ mUShortAllocation.destroy();
+ mRS.finish();
+ mUShort2Allocation.destroy();
+ mRS.finish();
+ mUShort3Allocation.destroy();
+ mRS.finish();
+ mUShort4Allocation.destroy();
+ mRS.finish();
+
+ mUInt2Allocation.destroy();
+ mRS.finish();
+ mUInt3Allocation.destroy();
+ mRS.finish();
+ mUInt4Allocation.destroy();
+ mRS.finish();
+
+ mULongAllocation.destroy();
+ mRS.finish();
+ mULong2Allocation.destroy();
+ mRS.finish();
+ mULong3Allocation.destroy();
+ mRS.finish();
+ mULong4Allocation.destroy();
+ mRS.finish();
+
+
+ createFloatAllocations();
+ initFloatAllocations();
+
+ mRS.finish();
+ mScript.forEach_add_half_kernel(mDouble4Allocation, mDouble3Allocation);
+ mRS.finish();
+
+ mHalfAllocation.destroy();
+ mRS.finish();
+ mHalf2Allocation.destroy();
+ mRS.finish();
+ mHalf3Allocation.destroy();
+ mRS.finish();
+ mHalf4Allocation.destroy();
+ mRS.finish();
+
+ mDoubleAllocation.destroy();
+ mRS.finish();
+ mDouble2Allocation.destroy();
+ mRS.finish();
+ mDouble4Allocation.destroy();
+ mRS.finish();
+
+ overwriteFloatAllocations();
+
+ createStructAllocations();
+
+ mRS.finish();
+ mScript.forEach_struct_kernel(mStructInAlloc, mStructOutAlloc);
+ mRS.finish();
+ }
+}
diff --git a/tests/lldb/java/Allocations/src/rs/allocs.rs b/tests/lldb/java/Allocations/src/rs/allocs.rs
new file mode 100644
index 0000000..361f091
--- /dev/null
+++ b/tests/lldb/java/Allocations/src/rs/allocs.rs
@@ -0,0 +1,66 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.allocations)
+
+struct simpleStruct {
+ int i;
+ unsigned int j;
+};
+
+struct complexStruct {
+ struct simpleStruct s;
+ uchar4 c;
+ float f[2];
+};
+
+struct complexStruct *g_complexStruct_in;
+struct complexStruct *g_complexStruct_out;
+
+// Kernel performs basic vector swizzle
+uchar4 __attribute__((kernel)) swizzle_kernel(uchar4 in)
+{
+ return in.wzyx;
+}
+
+// Kernel squares every element in allocation
+uint __attribute__((kernel)) square_kernel(ushort in)
+{
+ uint result = (uint)(in) * (uint)in;
+ return result;
+}
+
+// Helper function adding 1/2 to passed in double
+static double half_helper(double in)
+{
+ return (in + 0.5);
+}
+
+// Kernel returns first 3 elements of a double4 plus 1/2
+double3 __attribute__((kernel)) add_half_kernel(double4 in)
+{
+ double3 result;
+ result.x = half_helper(in.x);
+ result.y = half_helper(in.y);
+ result.z = half_helper(in.z);
+ return result;
+}
+
+// Kernel for testing structs
+struct complexStruct __attribute__((kernel))
+struct_kernel(struct complexStruct in, uint32_t x)
+{
+ struct complexStruct complex_out;
+ struct simpleStruct simple_out;
+ simple_out.i = (int) x;
+ simple_out.j = x;
+ complex_out.s = simple_out;
+
+ complex_out.f[0] = (float) x;
+ complex_out.f[1] = (float) x + 0.5;
+
+ complex_out.c.x = (uchar) (x % 128);
+ complex_out.c.y = 'A';
+ complex_out.c.z = 'B';
+ complex_out.c.w = 'C';
+
+ return complex_out;
+}
diff --git a/tests/lldb/java/Android.mk b/tests/lldb/java/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/tests/lldb/java/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/tests/lldb/java/BranchingFunCalls/Android.mk b/tests/lldb/java/BranchingFunCalls/Android.mk
new file mode 100644
index 0000000..ce6ebce
--- /dev/null
+++ b/tests/lldb/java/BranchingFunCalls/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+ $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := BranchingFunCalls
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/BranchingFunCalls/AndroidManifest.xml b/tests/lldb/java/BranchingFunCalls/AndroidManifest.xml
new file mode 100644
index 0000000..fb83a04
--- /dev/null
+++ b/tests/lldb/java/BranchingFunCalls/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.branchingfuncalls">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="BranchingFunCalls"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/java/BranchingFunCalls/res/layout/main_layout.xml b/tests/lldb/java/BranchingFunCalls/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/java/BranchingFunCalls/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/java/BranchingFunCalls/src/com/android/rs/branchingfuncalls/MainActivity.java b/tests/lldb/java/BranchingFunCalls/src/com/android/rs/branchingfuncalls/MainActivity.java
new file mode 100644
index 0000000..8263f57
--- /dev/null
+++ b/tests/lldb/java/BranchingFunCalls/src/com/android/rs/branchingfuncalls/MainActivity.java
@@ -0,0 +1,47 @@
+package com.android.rs.branchingfuncalls;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation mOutAllocation;
+ private ScriptC_scalars mScript;
+ private int mAllocSize = 256;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+ createScript();
+ runScript();
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ Element e = Element.I32(mRS);
+ mInAllocation = Allocation.createSized(mRS, e, mAllocSize);
+ mOutAllocation = Allocation.createSized(mRS, e, mAllocSize);
+
+ mScript = new ScriptC_scalars(mRS);
+ }
+
+ private void runScript() {
+ mScript.invoke_addToGlobal(234);
+
+ int[] init = new int[mAllocSize];
+ for(int i = 0; i < mAllocSize; ++i) {
+ init[i] = i - (mAllocSize / 2);
+ }
+ mInAllocation.copy1DRangeFrom(0, mAllocSize, init);
+ mScript.forEach_simple_kernel(mInAllocation, mOutAllocation);
+ }
+}
+
diff --git a/tests/lldb/java/BranchingFunCalls/src/rs/scalars.rs b/tests/lldb/java/BranchingFunCalls/src/rs/scalars.rs
new file mode 100644
index 0000000..743b5b0
--- /dev/null
+++ b/tests/lldb/java/BranchingFunCalls/src/rs/scalars.rs
@@ -0,0 +1,60 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.branchingfuncalls)
+
+static bool is_neg(int a)
+{
+ if(a < 0)
+ return true;
+ else
+ return false;
+}
+
+static bool is_pos(int a)
+{
+ if(a > 0)
+ return true;
+ else
+ return false;
+}
+
+static void set_i(int * a, int b)
+{
+ int tmp = b;
+ *a = tmp;
+}
+
+static void modify_f(float * f)
+{
+ *f *= 0.5f;
+}
+
+static void modify_i(int * i)
+{
+ int j = *i;
+ int cutoff = 2 << 6;
+ if(j > cutoff)
+ j = cutoff;
+ if(is_neg(j))
+ set_i(i, 0);
+ else if(is_pos(j))
+ set_i(i, j);
+ else
+ set_i(i, cutoff);
+}
+
+int __attribute__((kernel)) simple_kernel(int in)
+{
+ int i = in;
+ float f = (float) i;
+ modify_f(&f);
+ modify_i(&i);
+ int ret = (int) f;
+ return in * ret;
+}
+
+int glob = 123;
+
+void addToGlobal(int arg)
+{
+ glob += arg;
+}
diff --git a/tests/lldb/java/DebugWaitAttach/Android.mk b/tests/lldb/java/DebugWaitAttach/Android.mk
new file mode 100644
index 0000000..15f1dbc
--- /dev/null
+++ b/tests/lldb/java/DebugWaitAttach/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JavaDebugWaitAttach
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/DebugWaitAttach/AndroidManifest.xml b/tests/lldb/java/DebugWaitAttach/AndroidManifest.xml
new file mode 100644
index 0000000..862af28
--- /dev/null
+++ b/tests/lldb/java/DebugWaitAttach/AndroidManifest.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.waitattachdebug">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JavaDebugWaitAttach"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/java/DebugWaitAttach/res/layout/main_layout.xml b/tests/lldb/java/DebugWaitAttach/res/layout/main_layout.xml
new file mode 100644
index 0000000..4ef172f
--- /dev/null
+++ b/tests/lldb/java/DebugWaitAttach/res/layout/main_layout.xml
@@ -0,0 +1,14 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
diff --git a/tests/lldb/java/DebugWaitAttach/src/com/android/rs/waitattachdebug/MainActivity.java b/tests/lldb/java/DebugWaitAttach/src/com/android/rs/waitattachdebug/MainActivity.java
new file mode 100644
index 0000000..16dd43e
--- /dev/null
+++ b/tests/lldb/java/DebugWaitAttach/src/com/android/rs/waitattachdebug/MainActivity.java
@@ -0,0 +1,56 @@
+package com.android.rs.waitattachdebug;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+ private ImageView mImageView;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation mOutAllocation;
+ private ScriptC_simple mScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ mBitmapIn = Bitmap.createBitmap(8, 8, Bitmap.Config.ARGB_8888);
+ mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapOut);
+
+ createScript();
+ updateImage(1.0f);
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
+
+ mScript = new ScriptC_simple(mRS);
+ }
+
+
+ private void updateImage(final float f) {
+ mScript.set_gColor(new Float4(0.9f, 0.8f, 0.5f, 1.0f));
+ mScript.forEach_simple_kernel(mInAllocation, mOutAllocation);
+ mOutAllocation.copyTo(mBitmapOut);
+ mScript.forEach_other_kernel(mInAllocation, mOutAllocation);
+ }
+}
+
diff --git a/tests/lldb/java/DebugWaitAttach/src/rs/simple.rs b/tests/lldb/java/DebugWaitAttach/src/rs/simple.rs
new file mode 100644
index 0000000..26e11c4
--- /dev/null
+++ b/tests/lldb/java/DebugWaitAttach/src/rs/simple.rs
@@ -0,0 +1,23 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.waitattachdebug)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
+
+// Extra kernel to test lldb setting breakpoints on all the RS kernels.
+uchar4 __attribute__((kernel)) other_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/java/InfiniteLoop/Android.mk b/tests/lldb/java/InfiniteLoop/Android.mk
new file mode 100644
index 0000000..d8bb4e1
--- /dev/null
+++ b/tests/lldb/java/InfiniteLoop/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JavaInfiniteLoop
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
diff --git a/tests/lldb/java/InfiniteLoop/AndroidManifest.xml b/tests/lldb/java/InfiniteLoop/AndroidManifest.xml
new file mode 100644
index 0000000..ba846cd
--- /dev/null
+++ b/tests/lldb/java/InfiniteLoop/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.infiniteloop">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="InfiniteLoop"
+ android:hardwareAccelerated="true">
+
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/java/InfiniteLoop/res/layout/main_layout.xml b/tests/lldb/java/InfiniteLoop/res/layout/main_layout.xml
new file mode 100755
index 0000000..4ef172f
--- /dev/null
+++ b/tests/lldb/java/InfiniteLoop/res/layout/main_layout.xml
@@ -0,0 +1,14 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
diff --git a/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/MainActivity.java b/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/MainActivity.java
new file mode 100644
index 0000000..91fca6f
--- /dev/null
+++ b/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/MainActivity.java
@@ -0,0 +1,158 @@
+package com.android.rs.infiniteloop;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.renderscript.*;
+
+import java.util.Random;
+import java.util.Timer;
+import java.util.TimerTask;
+
+public class MainActivity extends Activity {
+ /* Number of bitmaps that are used for renderScript thread and UI thread synchronization.
+ Ideally, this can be reduced to 2, however in some devices, 2 buffers still showing tearing on UI.
+ */
+ private final int NUM_BITMAPS = 3;
+ private int mCurrentBitmap = 0;
+ private Bitmap mBitmapIn;
+ private Bitmap[] mBitmapsOut;
+ private ImageView mImageView;
+ private Random mRand;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation[] mOutAllocations;
+ private ScriptC_infiniteloop mScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+ mRand = new Random();
+
+ /*
+ * Initialize UI
+ */
+ mBitmapIn = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
+ mBitmapsOut = new Bitmap[NUM_BITMAPS];
+ for (int i = 0; i < NUM_BITMAPS; ++i) {
+ mBitmapsOut[i] = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+ }
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapsOut[mCurrentBitmap]);
+ mCurrentBitmap += (mCurrentBitmap + 1) % NUM_BITMAPS;
+
+ /*
+ * Create renderScript
+ */
+ createScript();
+
+ /*
+ * Invoke renderScript kernel and update imageView
+ */
+ updateImage(1.0f);
+
+ Timer t = new Timer();
+ t.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ updateImage(1.f);
+ }
+ }, 2000, 2000);
+ }
+
+ /*
+ * Initialize RenderScript
+ * In the sample, it creates RenderScript kernel that performs saturation manipulation.
+ */
+ private void createScript() {
+ // Initialize RS
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY);
+
+ // Allocate buffers
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocations = new Allocation[NUM_BITMAPS];
+ for (int i = 0; i < NUM_BITMAPS; ++i) {
+ mOutAllocations[i] = Allocation.createFromBitmap(mRS, mBitmapsOut[i]);
+ }
+
+ // Load script
+ mScript = new ScriptC_infiniteloop(mRS);
+ }
+
+ /*
+ * In the AsyncTask, it invokes a simple RenderScript kernel.
+ * After the kernel is done, an operation blocks at Allocation.copyTo() in AsyncTask thread.
+ * Once operations are finished and we reach onPostExecute() in the UI thread,
+ * it can invalidate and update the ImageView UI.
+ */
+ private class RenderScriptTask extends AsyncTask<Float, Integer, Integer> {
+ Boolean issued = false;
+
+ protected Integer doInBackground(Float... values) {
+ int index = -1;
+ if (isCancelled() == false) {
+ issued = true;
+ index = mCurrentBitmap;
+
+ /*
+ * Set global variable in RS
+ */
+ mScript.set_gColour(new Float4(mRand.nextFloat(), mRand.nextFloat(),
+ mRand.nextFloat(), 1.f));
+
+ /*
+ * Invoke saturation filter kernel
+ */
+ mScript.forEach_simple_kernel(mInAllocation, mOutAllocations[index]);
+
+ /*
+ * Copy to bitmap and invalidate image view
+ */
+ mOutAllocations[index].copyTo(mBitmapsOut[index]);
+ mCurrentBitmap = (mCurrentBitmap + 1) % NUM_BITMAPS;
+ }
+ return index;
+ }
+
+ void updateView(Integer result) {
+ if (result != -1) {
+ // Request UI update
+ mImageView.setImageBitmap(mBitmapsOut[result]);
+ mImageView.invalidate();
+ }
+ }
+
+ protected void onPostExecute(Integer result) {
+ updateView(result);
+ }
+
+ protected void onCancelled(Integer result) {
+ if (issued) {
+ updateView(result);
+ }
+ }
+ }
+
+ RenderScriptTask currentTask = null;
+
+ /*
+ * Invoke AsyncTask and cancel the previous task.
+ * When AsyncTasks are piled up (typically in slow device with heavy kernel),
+ * only the latest (and already started) task invokes RenderScript operation.
+ */
+ private void updateImage(final float f) {
+ if (currentTask != null)
+ currentTask.cancel(false);
+ currentTask = new RenderScriptTask();
+ currentTask.execute(f);
+ }
+}
diff --git a/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/infiniteloop.rs b/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/infiniteloop.rs
new file mode 100644
index 0000000..8866dd9
--- /dev/null
+++ b/tests/lldb/java/InfiniteLoop/src/com/android/rs/infiniteloop/infiniteloop.rs
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.infiniteloop)
+#pragma rs_fp_relaxed
+
+float4 gColour = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColour;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
diff --git a/tests/lldb/java/KernelVariables/Android.mk b/tests/lldb/java/KernelVariables/Android.mk
new file mode 100644
index 0000000..c562e76
--- /dev/null
+++ b/tests/lldb/java/KernelVariables/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := KernelVariables
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/KernelVariables/AndroidManifest.xml b/tests/lldb/java/KernelVariables/AndroidManifest.xml
new file mode 100644
index 0000000..a1e2a74
--- /dev/null
+++ b/tests/lldb/java/KernelVariables/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.kernelvariables">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="KernelVariables"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/java/KernelVariables/res/layout/main_layout.xml b/tests/lldb/java/KernelVariables/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/java/KernelVariables/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/java/KernelVariables/src/com/android/rs/kernelvariables/MainActivity.java b/tests/lldb/java/KernelVariables/src/com/android/rs/kernelvariables/MainActivity.java
new file mode 100644
index 0000000..3f167b4
--- /dev/null
+++ b/tests/lldb/java/KernelVariables/src/com/android/rs/kernelvariables/MainActivity.java
@@ -0,0 +1,94 @@
+package com.android.rs.kernelvariables;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.ImageFormat;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+ private ImageView mImageView;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation mOutAllocation;
+ private ScriptC_simple mScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ mBitmapIn = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
+ mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapOut);
+
+ createScript();
+ updateImage();
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
+
+ mScript = new ScriptC_simple(mRS);
+ }
+
+ private void updateImage() {
+ int[] buffer_int = {1, 2, 3, 4};
+ Allocation int_allocation = Allocation.createSized(mRS, Element.I32(mRS), 4);
+ int_allocation.copyFrom(buffer_int);
+ mScript.set_allocation_1D_global(int_allocation);
+
+ int[] buffer_int2 = {5, 6, 7, 8};
+
+ Type.Builder typeI32Builder2D = new Type.Builder(mRS, Element.I32(mRS));
+ typeI32Builder2D.setX(2);
+ typeI32Builder2D.setY(2);
+
+ Allocation int_allocation2 = Allocation.createTyped(mRS, typeI32Builder2D.create());
+ int_allocation2.copyFrom(buffer_int2);
+ mScript.set_allocation_1D_global2(int_allocation2);
+
+ mScript.set_allocation_2D_global(mInAllocation);
+ mScript.set_allocation_2D_global2(mOutAllocation);
+
+ int[] buffer_int3 = new int[64];
+
+ for (int i=0; i<4*4*4; ++i)
+ buffer_int3[i] = 9 + i;
+
+ Type.Builder typeI32Builder3D = new Type.Builder(mRS, Element.I32(mRS));
+ typeI32Builder3D.setX(4);
+ typeI32Builder3D.setY(4);
+ typeI32Builder3D.setZ(4);
+
+ Allocation int_allocation3 = Allocation.createTyped(mRS, typeI32Builder3D.create());
+ int_allocation3.copyFrom(buffer_int3);
+ mScript.set_allocation_3D_global(int_allocation3);
+
+ Type.Builder yuvTypeBuilder = new Type.Builder(mRS, Element.YUV(mRS));
+ yuvTypeBuilder.setX(4);
+ yuvTypeBuilder.setY(4);
+ yuvTypeBuilder.setYuvFormat(ImageFormat.YV12);
+ Allocation yuv_allocation = Allocation.createTyped(mRS, yuvTypeBuilder.create());
+ mScript.set_allocation_YUV_2D_global(yuv_allocation);
+
+ mScript.set_sampler_global(Sampler.CLAMP_LINEAR(mRS));
+
+ mScript.forEach_kernel(mInAllocation, mOutAllocation);
+ mOutAllocation.copyTo(mBitmapOut);
+ }
+}
diff --git a/tests/lldb/java/KernelVariables/src/rs/simple.rs b/tests/lldb/java/KernelVariables/src/rs/simple.rs
new file mode 100644
index 0000000..5f55ae8
--- /dev/null
+++ b/tests/lldb/java/KernelVariables/src/rs/simple.rs
@@ -0,0 +1,160 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.kernelvariables)
+
+char char_global = 12;
+uchar uchar_global = 234;
+short short_global = -321;
+ushort ushort_global = 432;
+int int_global = 1234;
+uint uint_global = 2345;
+float float_global = 4.5f;
+long long_global = -77777;
+ulong ulong_global = 8888;
+double double_global = -456.5f;
+
+char2 char2_global = {11, -22};
+uchar2 uchar2_global = {33, 44};
+short2 short2_global = {-555, 666};
+ushort2 ushort2_global = {777, 888};
+int2 int2_global = {999, -1111};
+uint2 uint2_global = {2222, 3333};
+float2 float2_global = {4.5f, -5.0f};
+long2 long2_global = {-4444, 5555};
+ulong2 ulong2_global = {6666, 7777};
+double2 double2_global = {88.5f, -99.0f};
+
+char3 char3_global = {11, -22, -33};
+uchar3 uchar3_global = {33, 44, 55};
+short3 short3_global = {-555, 666, 777};
+ushort3 ushort3_global = {777, 888, 999};
+int3 int3_global = {999, -1111, 2222};
+uint3 uint3_global = {2222, 3333, 4444};
+float3 float3_global = {4.5f, -5.0f, -6.5f};
+long3 long3_global = {-4444, 5555, 6666};
+ulong3 ulong3_global = {6666, 7777, 8888};
+double3 double3_global = {88.5f, -99.0f, 111.5f};
+
+char4 char4_global = {55, 11, -22, -33};
+uchar4 uchar4_global = {222, 33, 44, 55};
+short4 short4_global = {-444, -555, 666, 777};
+ushort4 ushort4_global = {666, 777, 888, 999};
+int4 int4_global = {888, 999, -1111, 2222};
+uint4 uint4_global = {1111, 2222, 3333, 4444};
+float4 float4_global = {3.0f, 4.5f, -5.0f, -6.5f};
+long4 long4_global = {-3333, -4444, 5555, 6666};
+ulong4 ulong4_global = {5555, 6666, 7777, 8888};
+double4 double4_global = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+rs_matrix2x2 matrix2x2_global;
+rs_matrix3x3 matrix3x3_global;
+rs_matrix4x4 matrix4x4_global;
+
+rs_quaternion quaternion_global;
+
+rs_allocation allocation_1D_global;
+rs_allocation allocation_1D_global2;
+rs_allocation allocation_2D_global;
+rs_allocation allocation_2D_global2;
+rs_allocation allocation_3D_global;
+rs_allocation allocation_YUV_2D_global;
+
+rs_allocation_cubemap_face cubemap_face_global;
+rs_sampler sampler_global;
+
+uchar4 __attribute__((kernel)) kernel(uchar4 in)
+{
+ char char_local = 'a';
+ uchar uchar_local = 'b';
+ short short_local = -321;
+ ushort ushort_local = 432;
+ int int_local = 1234;
+ uint uint_local = 2345;
+ float float_local = 4.5f;
+ long long_local = -77777;
+ ulong ulong_local = 8888;
+ double double_local = -456.5f;
+
+ char2 char2_local = {-11, -22};
+ uchar2 uchar2_local = {33, 44};
+ short2 short2_local = {-555, 666};
+ ushort2 ushort2_local = {777, 888};
+ int2 int2_local = {999, -1111};
+ uint2 uint2_local = {2222, 3333};
+ float2 float2_local = {4.5f, -5.0f};
+ long2 long2_local = {-4444, 5555};
+ ulong2 ulong2_local = {6666, 7777};
+ double2 double2_local = {88.5f, -99.0f};
+
+ char3 char3_local = {11, -22, -33};
+ uchar3 uchar3_local = {33, 44, 55};
+ short3 short3_local = {-555, 666, 777};
+ ushort3 ushort3_local = {777, 888, 999};
+ int3 int3_local = {999, -1111, 2222};
+ uint3 uint3_local = {2222, 3333, 4444};
+ float3 float3_local = {4.5f, -5.0f, -6.5f};
+ long3 long3_local = {-4444, 5555, 6666};
+ ulong3 ulong3_local = {6666, 7777, 8888};
+ double3 double3_local = {88.5f, -99.0f, 111.5f};
+
+ char4 char4_local = {55, 11, -22, -33};
+ uchar4 uchar4_local = {22, 33, 44, 55};
+ short4 short4_local = {-444, -555, 666, 777};
+ ushort4 ushort4_local = {666, 777, 888, 999};
+ int4 int4_local = {888, 999, -1111, 2222};
+ uint4 uint4_local = {1111, 2222, 3333, 4444};
+ float4 float4_local = {3.0f, 4.5f, -5.0f, -6.5f};
+ long4 long4_local = {-3333, -4444, 5555, 6666};
+ ulong4 ulong4_local = {5555, 6666, 7777, 8888};
+ double4 double4_local = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+ rs_matrix2x2 matrix2x2_local = {{1., 2.5,
+ 3., 4.5}};
+ rs_matrix3x3 matrix3x3_local = {{5., 6.5, 7.,
+ 8.5, 9., 1.5,
+ 2., 3.5, 4.}};
+ rs_matrix4x4 matrix4x4_local = {{5.5, 6., 7.5, 8.,
+ 9., 1.5, 2., 3.5,
+ 4.5, 5.5, 6.5, 7.,
+ 8., 9.5, 1.5, 2.5}};
+
+ matrix2x2_global = matrix2x2_local;
+ matrix3x3_global = matrix3x3_local;
+ matrix4x4_global = matrix4x4_local;
+
+ rsQuaternionSet(&quaternion_global, 3.0, 4.5, 5.5, 6.0);
+
+ rs_quaternion quaternion_local;
+ rsQuaternionSet(&quaternion_local, 7.5, 8.0, 9.0, 0.5);
+
+ char char_combined = char_local + (char)uchar_local + char2_local.x +
+ (char)uchar2_local.x + char3_local.x - (char)uchar3_local.x +
+ char4_local.x + (char)uchar4_local.x;
+
+ short short_combined = short_local + (short)ushort_local + short2_local.x +
+ (short)ushort2_local.x + short3_local.x + (short)ushort3_local.x +
+ short4_local.x + (short)ushort4_local.x;
+
+ int int_combined = int_local + (int)uint_local + int2_local.x +
+ (int)uint2_local.x + int3_local.x + (int)uint3_local.x + int4_local.x +
+ (int)uint4_local.x;
+
+ float float_combined = float_local + float2_local.x + float3_local.x +
+ float4_local.x;
+
+ long long_combined = long_local + (long)ulong_local + long2_local.x +
+ (long)ulong2_local.x + long3_local.x + (long)ulong3_local.x +
+ long4_local.x + (long)ulong4_local.x;
+
+ double double_combined = double_local + double2_local.x + double3_local.x +
+ double4_local.x;
+
+ char_global = char_combined;
+ short_global = short_combined;
+ int_global = int_combined;
+ float_global = float_combined;
+ long_global = long_combined;
+ double_global = double_combined;
+
+ uchar4 result = {1,2,3,4};
+ return result;
+}
diff --git a/tests/lldb/java/MultipleRSFiles/Android.mk b/tests/lldb/java/MultipleRSFiles/Android.mk
new file mode 100644
index 0000000..cd2295b
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/Android.mk
@@ -0,0 +1,13 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := MultipleRSFiles
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/MultipleRSFiles/AndroidManifest.xml b/tests/lldb/java/MultipleRSFiles/AndroidManifest.xml
new file mode 100644
index 0000000..5a83901
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/AndroidManifest.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.multiplersfiles">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="MultipleRSFiles"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/java/MultipleRSFiles/res/layout/main_layout.xml b/tests/lldb/java/MultipleRSFiles/res/layout/main_layout.xml
new file mode 100644
index 0000000..4ef172f
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/res/layout/main_layout.xml
@@ -0,0 +1,14 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
diff --git a/tests/lldb/java/MultipleRSFiles/src/com/android/rs/multiplersfiles/MainActivity.java b/tests/lldb/java/MultipleRSFiles/src/com/android/rs/multiplersfiles/MainActivity.java
new file mode 100644
index 0000000..522adce
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/src/com/android/rs/multiplersfiles/MainActivity.java
@@ -0,0 +1,58 @@
+package com.android.rs.multiplersfiles;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+ private ImageView mImageView;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation mOutAllocation;
+ private ScriptC_first mFirstScript;
+ private ScriptC_second mSecondScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ mBitmapIn = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
+ mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapOut);
+
+ createScript();
+ updateImage(1.0f);
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
+
+ mFirstScript = new ScriptC_first(mRS);
+ mSecondScript = new ScriptC_second(mRS);
+ }
+
+
+ private void updateImage(final float f) {
+ mFirstScript.set_gColor(new Float4(0.9f, 0.8f, 0.5f, 1.0f));
+ mFirstScript.forEach_first_kernel(mInAllocation, mOutAllocation);
+ mOutAllocation.copyTo(mBitmapOut);
+ mSecondScript.forEach_second_kernel(mInAllocation, mOutAllocation);
+ }
+}
+
diff --git a/tests/lldb/java/MultipleRSFiles/src/rs/first.rs b/tests/lldb/java/MultipleRSFiles/src/rs/first.rs
new file mode 100644
index 0000000..c0c37d5
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/src/rs/first.rs
@@ -0,0 +1,16 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.multiplersfiles)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) first_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
diff --git a/tests/lldb/java/MultipleRSFiles/src/rs/second.rs b/tests/lldb/java/MultipleRSFiles/src/rs/second.rs
new file mode 100644
index 0000000..6b33289
--- /dev/null
+++ b/tests/lldb/java/MultipleRSFiles/src/rs/second.rs
@@ -0,0 +1,9 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.multiplersfiles)
+
+/* RenderScript kernel that just returns the swizzled input. */
+uchar4 __attribute__((kernel)) second_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/java/NoDebugWaitAttach/Android.mk b/tests/lldb/java/NoDebugWaitAttach/Android.mk
new file mode 100644
index 0000000..64e32ed
--- /dev/null
+++ b/tests/lldb/java/NoDebugWaitAttach/Android.mk
@@ -0,0 +1,11 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JavaNoDebugWaitAttach
+
+include $(BUILD_PACKAGE)
+
diff --git a/tests/lldb/java/NoDebugWaitAttach/AndroidManifest.xml b/tests/lldb/java/NoDebugWaitAttach/AndroidManifest.xml
new file mode 100644
index 0000000..dbc31a5
--- /dev/null
+++ b/tests/lldb/java/NoDebugWaitAttach/AndroidManifest.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.waitattachnodebug">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JavaNoDebugWaitAttach"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/java/NoDebugWaitAttach/res/layout/main_layout.xml b/tests/lldb/java/NoDebugWaitAttach/res/layout/main_layout.xml
new file mode 100644
index 0000000..4ef172f
--- /dev/null
+++ b/tests/lldb/java/NoDebugWaitAttach/res/layout/main_layout.xml
@@ -0,0 +1,14 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
diff --git a/tests/lldb/java/NoDebugWaitAttach/src/com/android/rs/waitattachnodebug/MainActivity.java b/tests/lldb/java/NoDebugWaitAttach/src/com/android/rs/waitattachnodebug/MainActivity.java
new file mode 100644
index 0000000..3b69f05
--- /dev/null
+++ b/tests/lldb/java/NoDebugWaitAttach/src/com/android/rs/waitattachnodebug/MainActivity.java
@@ -0,0 +1,55 @@
+package com.android.rs.waitattachnodebug;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.renderscript.*;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+ private ImageView mImageView;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation mOutAllocation;
+ private ScriptC_simple mScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ mBitmapIn = Bitmap.createBitmap(8, 8, Bitmap.Config.ARGB_8888);
+ mBitmapOut = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapOut);
+
+ createScript();
+ updateImage(1.0f);
+ }
+
+ private void createScript() {
+ mRS = RenderScript.create(this,
+ RenderScript.ContextType.NORMAL,
+ RenderScript.CREATE_FLAG_LOW_LATENCY |
+ RenderScript.CREATE_FLAG_WAIT_FOR_ATTACH);
+
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocation = Allocation.createFromBitmap(mRS, mBitmapOut);
+
+ mScript = new ScriptC_simple(mRS);
+ }
+
+
+ private void updateImage(final float f) {
+ mScript.set_gColor(new Float4(0.9f, 0.8f, 0.5f, 1.0f));
+ mScript.forEach_simple_kernel(mInAllocation, mOutAllocation);
+ mOutAllocation.copyTo(mBitmapOut);
+ }
+}
+
diff --git a/tests/lldb/java/NoDebugWaitAttach/src/rs/simple.rs b/tests/lldb/java/NoDebugWaitAttach/src/rs/simple.rs
new file mode 100644
index 0000000..bacbd23
--- /dev/null
+++ b/tests/lldb/java/NoDebugWaitAttach/src/rs/simple.rs
@@ -0,0 +1,17 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.waitattachnodebug)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
+
diff --git a/tests/lldb/jni/Allocations/Android.mk b/tests/lldb/jni/Allocations/Android.mk
new file mode 100644
index 0000000..81695a0
--- /dev/null
+++ b/tests/lldb/jni/Allocations/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIAllocations
+
+LOCAL_JNI_SHARED_LIBRARIES := libjniallocations
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jniallocations/Android.mk
+
diff --git a/tests/lldb/jni/Allocations/AndroidManifest.xml b/tests/lldb/jni/Allocations/AndroidManifest.xml
new file mode 100644
index 0000000..e73799f
--- /dev/null
+++ b/tests/lldb/jni/Allocations/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jniallocations">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIAllocations"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/jni/Allocations/jniallocations/Android.mk b/tests/lldb/jni/Allocations/jniallocations/Android.mk
new file mode 100644
index 0000000..5fc1580
--- /dev/null
+++ b/tests/lldb/jni/Allocations/jniallocations/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjniallocations
+
+LOCAL_SRC_FILES := jniallocations.cpp allocs.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static libcompiler_rt
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/Allocations/jniallocations/allocs.rs b/tests/lldb/jni/Allocations/jniallocations/allocs.rs
new file mode 100644
index 0000000..65d98f4
--- /dev/null
+++ b/tests/lldb/jni/Allocations/jniallocations/allocs.rs
@@ -0,0 +1,31 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jniallocations)
+
+// Kernel performs basic vector swizzle
+uchar4 __attribute__((kernel)) swizzle_kernel(uchar4 in)
+{
+ return in.wzyx;
+}
+
+// Kernel squares every element in allocation
+uint __attribute__((kernel)) square_kernel(ushort in)
+{
+ uint result = (uint)(in) * (uint)in;
+ return result;
+}
+
+// Helper function adding 1/2 to passed in double
+static double half_helper(double in)
+{
+ return (in + 0.5);
+}
+
+// Kernel returns first 3 elements of a double4 plus 1/2
+double3 __attribute__((kernel)) add_half_kernel(double4 in)
+{
+ double3 result;
+ result.x = half_helper(in.x);
+ result.y = half_helper(in.y);
+ result.z = half_helper(in.z);
+ return result;
+}
diff --git a/tests/lldb/jni/Allocations/jniallocations/jniallocations.cpp b/tests/lldb/jni/Allocations/jniallocations/jniallocations.cpp
new file mode 100644
index 0000000..ef66237
--- /dev/null
+++ b/tests/lldb/jni/Allocations/jniallocations/jniallocations.cpp
@@ -0,0 +1,411 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_allocs.h"
+
+using namespace android;
+using namespace RSC;
+
+sp<RS> mRS;
+
+sp<Allocation> mBoolAllocation; // boolean
+
+sp<Allocation> mCharAllocation; // char
+sp<Allocation> mChar2Allocation; // char2
+sp<Allocation> mChar3Allocation; // char3
+sp<Allocation> mChar4Allocation; // char4
+
+sp<Allocation> mUCharAllocation; // uchar
+sp<Allocation> mUChar2Allocation; // uchar2
+sp<Allocation> mUChar3Allocation; // uchar3
+sp<Allocation> mUChar4Allocation; // uchar4
+
+sp<Allocation> mShortAllocation; // short
+sp<Allocation> mShort2Allocation; // short2
+sp<Allocation> mShort3Allocation; // short3
+sp<Allocation> mShort4Allocation; // short4
+
+sp<Allocation> mUShortAllocation; // ushort
+sp<Allocation> mUShort2Allocation; // ushort2
+sp<Allocation> mUShort3Allocation; // ushort3
+sp<Allocation> mUShort4Allocation; // ushort4
+
+sp<Allocation> mIntAllocation; // int
+sp<Allocation> mInt2Allocation; // int2
+sp<Allocation> mInt3Allocation; // int3
+sp<Allocation> mInt4Allocation; // int4
+
+sp<Allocation> mUIntAllocation; // uint
+sp<Allocation> mUInt2Allocation; // uint2
+sp<Allocation> mUInt3Allocation; // uint3
+sp<Allocation> mUInt4Allocation; // uint4
+
+sp<Allocation> mLongAllocation; // long
+sp<Allocation> mLong2Allocation; // long2
+sp<Allocation> mLong3Allocation; // long3
+sp<Allocation> mLong4Allocation; // long4
+
+sp<Allocation> mULongAllocation; // ulong
+sp<Allocation> mULong2Allocation; // ulong2
+sp<Allocation> mULong3Allocation; // ulong3
+sp<Allocation> mULong4Allocation; // ulong4
+
+sp<Allocation> mHalfAllocation; // half
+sp<Allocation> mHalf2Allocation; // half2
+sp<Allocation> mHalf3Allocation; // half3
+sp<Allocation> mHalf4Allocation; // half4
+
+sp<Allocation> mFloatAllocation; // float
+sp<Allocation> mFloat2Allocation; // float2
+sp<Allocation> mFloat3Allocation; // float3
+sp<Allocation> mFloat4Allocation; // float4
+
+sp<Allocation> mDoubleAllocation; // double
+sp<Allocation> mDouble2Allocation; // double2
+sp<Allocation> mDouble3Allocation; // double3
+sp<Allocation> mDouble4Allocation; // double4
+
+const int mAllocSize = 24; // Needs to be < CHAR_MAX and divisible by 4.
+const int mBitmapSize = 64;
+
+void createSignedAllocations() {
+ Type::Builder typeI8Builder(mRS, Element::I8(mRS));
+ typeI8Builder.setX(1); // One element here to test 16 byte memory alignment
+ typeI8Builder.setY(3);
+ typeI8Builder.setZ(8);
+
+ mCharAllocation = Allocation::createTyped(mRS, typeI8Builder.create());
+ mChar2Allocation = Allocation::createSized(mRS, Element::I8_2(mRS), mAllocSize / 2);
+ mChar3Allocation = Allocation::createSized(mRS, Element::I8_3(mRS), mAllocSize / 4);
+ mChar4Allocation = Allocation::createSized(mRS, Element::I8_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI16_2Builder(mRS, Element::I16_2(mRS));
+ typeI16_2Builder.setX(6);
+ typeI16_2Builder.setY(1);
+ typeI16_2Builder.setZ(2);
+
+ mShortAllocation = Allocation::createSized(mRS, Element::I16(mRS), mAllocSize);
+ mShort2Allocation = Allocation::createTyped(mRS, typeI16_2Builder.create());
+ mShort3Allocation = Allocation::createSized(mRS, Element::I16_3(mRS), mAllocSize / 4);
+ mShort4Allocation = Allocation::createSized(mRS, Element::I16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI32_3Builder(mRS, Element::I32_3(mRS));
+ typeI32_3Builder.setX(3);
+ typeI32_3Builder.setY(2);
+
+ mIntAllocation = Allocation::createSized(mRS, Element::I32(mRS), mAllocSize);
+ mInt2Allocation = Allocation::createSized(mRS, Element::I32_2(mRS), mAllocSize / 2);
+ mInt3Allocation = Allocation::createTyped(mRS, typeI32_3Builder.create());
+ mInt4Allocation = Allocation::createSized(mRS, Element::I32_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeI64_4Builder(mRS, Element::I64_4(mRS));
+ typeI64_4Builder.setX(1);
+ typeI64_4Builder.setY(6);
+
+ mLongAllocation = Allocation::createSized(mRS, Element::I64(mRS), mAllocSize);
+ mLong2Allocation = Allocation::createSized(mRS, Element::I64_2(mRS), mAllocSize / 2);
+ mLong3Allocation = Allocation::createSized(mRS, Element::I64_3(mRS), mAllocSize / 4);
+ mLong4Allocation = Allocation::createTyped(mRS, typeI64_4Builder.create());
+
+ mBoolAllocation = Allocation::createSized(mRS, Element::BOOLEAN(mRS), mAllocSize);
+}
+
+void initSignedAllocations() {
+ char *buffer_char = new char[mAllocSize];
+ short *buffer_short = new short[mAllocSize];
+ int *buffer_int = new int[mAllocSize];
+ int64_t *buffer_long = new int64_t[mAllocSize];
+ char *buffer_bool = new char[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (char) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (int64_t) i;
+ buffer_bool[i] = (char) (0x01 & i);
+ }
+
+ mCharAllocation->copy3DRangeFrom(0, 0, 0, 1, 3, 8, buffer_char);
+ mChar2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_char);
+ mChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+ mChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+
+ delete [] buffer_char;
+
+ mShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short);
+ mShort2Allocation->copy3DRangeFrom(0, 0, 0, 6, 1, 2, buffer_short);
+ mShort3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+ mShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+
+ delete [] buffer_short;
+
+ mIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int);
+ mInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int);
+ mInt3Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_int);
+ mInt4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int);
+
+ delete [] buffer_int;
+
+ mLongAllocation->copy1DRangeFrom(0, mAllocSize, buffer_long);
+ mLong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long);
+ mLong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+ mLong4Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_long);
+
+ delete [] buffer_long;
+
+ mBoolAllocation->copy1DRangeFrom(0, mAllocSize, buffer_bool);
+
+ delete [] buffer_bool;
+}
+
+void createUnsignedAllocations() {
+ Type::Builder typeU8_2Builder(mRS, Element::U8_2(mRS));
+ typeU8_2Builder.setX(2);
+ typeU8_2Builder.setY(6);
+
+ mUCharAllocation = Allocation::createSized(mRS, Element::U8(mRS), mAllocSize);
+ mUChar2Allocation = Allocation::createTyped(mRS, typeU8_2Builder.create());
+ mUChar3Allocation = Allocation::createSized(mRS, Element::U8_3(mRS), mAllocSize / 4);
+ mUChar4Allocation = Allocation::createSized(mRS, Element::U8_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeU16_3Builder(mRS, Element::U16_3(mRS));
+ typeU16_3Builder.setX(1);
+ typeU16_3Builder.setY(6);
+
+ mUShortAllocation = Allocation::createSized(mRS, Element::U16(mRS), mAllocSize);
+ mUShort2Allocation = Allocation::createSized(mRS, Element::U16_2(mRS), mAllocSize / 2);
+ mUShort3Allocation = Allocation::createTyped(mRS, typeU16_3Builder.create());
+ mUShort4Allocation = Allocation::createSized(mRS, Element::U16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeU32_4Builder(mRS, Element::U32_4(mRS));
+ typeU32_4Builder.setX(1);
+ typeU32_4Builder.setY(1);
+ typeU32_4Builder.setZ(6);
+
+ mUIntAllocation = Allocation::createSized(mRS, Element::U32(mRS), mAllocSize);
+ mUInt2Allocation = Allocation::createSized(mRS, Element::U32_2(mRS), mAllocSize / 2);
+ mUInt3Allocation = Allocation::createSized(mRS, Element::U32_3(mRS), mAllocSize / 4);
+ mUInt4Allocation = Allocation::createTyped(mRS, typeU32_4Builder.create());
+
+ Type::Builder typeU64Builder(mRS, Element::U64(mRS));
+ typeU64Builder.setX(4);
+ typeU64Builder.setY(3);
+ typeU64Builder.setZ(2);
+
+ mULongAllocation = Allocation::createTyped(mRS, typeU64Builder.create());
+ mULong2Allocation = Allocation::createSized(mRS, Element::U64_2(mRS), mAllocSize / 2);
+ mULong3Allocation = Allocation::createSized(mRS, Element::U64_3(mRS), mAllocSize / 4);
+ mULong4Allocation = Allocation::createSized(mRS, Element::U64_4(mRS), mAllocSize / 4);
+}
+
+void initUnsignedAllocations() {
+ char *buffer_char = new char[mAllocSize];
+ short *buffer_short = new short[mAllocSize];
+ int *buffer_int = new int[mAllocSize];
+ uint64_t *buffer_long = new uint64_t[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_char[i] = (char) i;
+ buffer_short[i] = (short) i;
+ buffer_int[i] = (int) i;
+ buffer_long[i] = (uint64_t) i;
+ }
+
+ mUCharAllocation->copy1DRangeFrom(0, mAllocSize, buffer_char);
+ mUChar2Allocation->copy2DRangeFrom(0, 0, 2, 6, buffer_char);
+ mUChar3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+ mUChar4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_char);
+
+ delete [] buffer_char;
+
+ mUShortAllocation->copy1DRangeFrom(0, mAllocSize, buffer_short);
+ mUShort2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_short);
+ mUShort3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_short);
+ mUShort4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_short);
+
+ delete [] buffer_short;
+
+ mUIntAllocation->copy1DRangeFrom(0, mAllocSize, buffer_int);
+ mUInt2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_int);
+ mUInt3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_int);
+ mUInt4Allocation->copy3DRangeFrom(0, 0, 0, 1, 1, 6, buffer_int);
+
+ delete [] buffer_int;
+
+ mULongAllocation->copy3DRangeFrom(0, 0, 0, 4, 3, 2, buffer_long);
+ mULong2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_long);
+ mULong3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+ mULong4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_long);
+
+ delete [] buffer_long;
+}
+
+void createFloatAllocations() {
+ Type::Builder typeF16_3Builder(mRS, Element::F16_3(mRS));
+ typeF16_3Builder.setX(1);
+ typeF16_3Builder.setY(6);
+
+ mHalfAllocation = Allocation::createSized(mRS, Element::F16(mRS), mAllocSize);
+ mHalf2Allocation = Allocation::createSized(mRS, Element::F16_2(mRS), mAllocSize / 2);
+ mHalf3Allocation = Allocation::createTyped(mRS, typeF16_3Builder.create());
+ mHalf4Allocation = Allocation::createSized(mRS, Element::F16_4(mRS), mAllocSize / 4);
+
+ Type::Builder typeF32_4Builder(mRS, Element::F32_4(mRS));
+ typeF32_4Builder.setX(3);
+ typeF32_4Builder.setY(2);
+
+ mFloatAllocation = Allocation::createSized(mRS, Element::F32(mRS), mAllocSize);
+ mFloat2Allocation = Allocation::createSized(mRS, Element::F32_2(mRS), mAllocSize / 2);
+ mFloat3Allocation = Allocation::createSized(mRS, Element::F32_3(mRS), mAllocSize / 4);
+ mFloat4Allocation = Allocation::createTyped(mRS, typeF32_4Builder.create());
+
+ Type::Builder typeF64_2Builder(mRS, Element::F64_2(mRS));
+ typeF64_2Builder.setX(4);
+ typeF64_2Builder.setY(1);
+ typeF64_2Builder.setZ(3);
+
+ mDoubleAllocation = Allocation::createSized(mRS, Element::F64(mRS), mAllocSize);
+ mDouble2Allocation = Allocation::createTyped(mRS, typeF64_2Builder.create());
+
+ Type::Builder typeF64_3Builder(mRS, Element::F64_3(mRS));
+ typeF64_3Builder.setX(1);
+ typeF64_3Builder.setY(2);
+ typeF64_3Builder.setZ(3);
+
+ Type::Builder typeF64_4Builder(mRS, Element::F64_4(mRS));
+ typeF64_4Builder.setX(1);
+ typeF64_4Builder.setY(2);
+ typeF64_4Builder.setZ(3);
+
+ mDouble3Allocation = Allocation::createTyped(mRS, typeF64_3Builder.create());
+ mDouble4Allocation = Allocation::createTyped(mRS, typeF64_4Builder.create());
+}
+
+void initFloatAllocations() {
+ __fp16 *buffer_half = new __fp16[mAllocSize];
+ float *buffer_float = new float[mAllocSize];
+ double *buffer_double = new double[mAllocSize];
+
+ for(int i = 0; i < mAllocSize; ++i) {
+ buffer_half[i] = (__fp16) 1 / i;
+ buffer_float[i] = (float) 1 / i;
+ buffer_double[i] = (double) 1 / i;
+ }
+
+ mHalfAllocation->copy1DRangeFrom(0, mAllocSize, buffer_half);
+ mHalf2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_half);
+ mHalf3Allocation->copy2DRangeFrom(0, 0, 1, 6, buffer_half);
+ mHalf4Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_half);
+
+ delete [] buffer_half;
+
+ mFloatAllocation->copy1DRangeFrom(0, mAllocSize, buffer_float);
+ mFloat2Allocation->copy1DRangeFrom(0, mAllocSize/2, buffer_float);
+ mFloat3Allocation->copy1DRangeFrom(0, mAllocSize/4, buffer_float);
+ mFloat4Allocation->copy2DRangeFrom(0, 0, 3, 2, buffer_float);
+
+ delete [] buffer_float;
+
+ mDoubleAllocation->copy1DRangeFrom(0, mAllocSize, buffer_double);
+ mDouble2Allocation->copy3DRangeFrom(0, 0, 0, 4, 1, 3, buffer_double);
+ mDouble3Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double);
+ mDouble4Allocation->copy3DRangeFrom(0, 0, 0, 1, 2, 3, buffer_double);
+
+ delete [] buffer_double;
+}
+
+extern "C" void JNICALL
+Java_com_android_rs_jniallocations_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ mRS = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ mRS->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ sp<ScriptC_allocs> mScript = new ScriptC_allocs(mRS);
+
+ Type::Builder typeRGBA_888Builder(mRS, Element::RGBA_8888(mRS));
+ typeRGBA_888Builder.setX(mBitmapSize);
+ typeRGBA_888Builder.setY(mBitmapSize);
+
+ sp<Allocation> mInAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create());
+
+ const int image_area = mBitmapSize*mBitmapSize;
+ const int image_size = image_area*sizeof(int);
+
+ char *zero_buffer = new char[image_size];
+ memset(zero_buffer, 0, image_size);
+ mInAllocation->copy1DRangeFrom(0, image_area, zero_buffer);
+ delete [] zero_buffer;
+
+ sp<Allocation> mOutAllocation = Allocation::createTyped(mRS, typeRGBA_888Builder.create());
+ createSignedAllocations();
+ initSignedAllocations();
+
+ mRS->finish();
+ mScript->forEach_swizzle_kernel(mInAllocation, mOutAllocation);
+ mRS->finish();
+
+ mCharAllocation.clear();
+ mChar2Allocation.clear();
+ mChar3Allocation.clear();
+ mChar4Allocation.clear();
+
+ mShort2Allocation.clear();
+ mShort3Allocation.clear();
+ mShort4Allocation.clear();
+
+ mIntAllocation.clear();
+ mInt2Allocation.clear();
+ mInt3Allocation.clear();
+ mInt4Allocation.clear();
+
+ mLongAllocation.clear();
+ mLong2Allocation.clear();
+ mLong3Allocation.clear();
+ mLong4Allocation.clear();
+
+ mBoolAllocation.clear();
+
+ createUnsignedAllocations();
+ initUnsignedAllocations();
+
+ mInAllocation = mUShortAllocation; // Host side assignment
+
+ mRS->finish();
+ mScript->forEach_square_kernel(mInAllocation, mUIntAllocation);
+ mRS->finish();
+
+ mUCharAllocation.clear();
+ mUChar2Allocation.clear();
+ mUChar3Allocation.clear();
+ mUChar4Allocation.clear();
+
+ mUShortAllocation.clear();
+ mUShort2Allocation.clear();
+ mUShort3Allocation.clear();
+ mUShort4Allocation.clear();
+
+ mUInt2Allocation.clear();
+ mUInt3Allocation.clear();
+ mUInt4Allocation.clear();
+
+ mULongAllocation.clear();
+ mULong2Allocation.clear();
+ mULong3Allocation.clear();
+ mULong4Allocation.clear();
+
+ createFloatAllocations();
+ initFloatAllocations();
+
+ mRS->finish();
+ mScript->forEach_add_half_kernel(mDouble4Allocation, mDouble3Allocation);
+ mRS->finish();
+}
+
diff --git a/tests/lldb/jni/Allocations/res/layout/main_layout.xml b/tests/lldb/jni/Allocations/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/Allocations/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/Allocations/src/com/android/rs/jniallocations/MainActivity.java b/tests/lldb/jni/Allocations/src/com/android/rs/jniallocations/MainActivity.java
new file mode 100644
index 0000000..c6d741c
--- /dev/null
+++ b/tests/lldb/jni/Allocations/src/com/android/rs/jniallocations/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jniallocations;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jniallocations");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/jni/Android.mk b/tests/lldb/jni/Android.mk
new file mode 100644
index 0000000..5053e7d
--- /dev/null
+++ b/tests/lldb/jni/Android.mk
@@ -0,0 +1 @@
+include $(call all-subdir-makefiles)
diff --git a/tests/lldb/jni/BranchingFunCalls/Android.mk b/tests/lldb/jni/BranchingFunCalls/Android.mk
new file mode 100644
index 0000000..48fa26c
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIBranchingFunCalls
+
+LOCAL_JNI_SHARED_LIBRARIES := libjnibranchingfuncalls
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jnibranchingfuncalls/Android.mk
+
diff --git a/tests/lldb/jni/BranchingFunCalls/AndroidManifest.xml b/tests/lldb/jni/BranchingFunCalls/AndroidManifest.xml
new file mode 100644
index 0000000..3b616fa
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jnibranchingfuncalls">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIBranchingFunCalls"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/Android.mk b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/Android.mk
new file mode 100644
index 0000000..3024195
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjnibranchingfuncalls
+
+LOCAL_SRC_FILES := jnibranchingfuncalls.cpp simple.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/jnibranchingfuncalls.cpp b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/jnibranchingfuncalls.cpp
new file mode 100644
index 0000000..e16724b
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/jnibranchingfuncalls.cpp
@@ -0,0 +1,49 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jnibranchingfuncalls_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::I32(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ int * input = new int[size*size];
+ for(int i = 0; i < size*size; ++i) {
+ input[i] = i - (size*size / 2);
+ }
+ a->copy2DRangeFrom(0, 0, size, size, input);
+ delete [] input;
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+ s->invoke_addToGlobal(234);
+ s->forEach_simple_kernel(a, b);
+ rs->finish();
+ int32_t * output = new int32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+}
+
diff --git a/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/simple.rs b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/simple.rs
new file mode 100644
index 0000000..1596ed9
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/jnibranchingfuncalls/simple.rs
@@ -0,0 +1,60 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jnibranchingfuncalls)
+
+static bool is_neg(int a)
+{
+ if(a < 0)
+ return true;
+ else
+ return false;
+}
+
+static bool is_pos(int a)
+{
+ if(a > 0)
+ return true;
+ else
+ return false;
+}
+
+static void set_i(int * a, int b)
+{
+ int tmp = b;
+ *a = tmp;
+}
+
+static void modify_f(float * f)
+{
+ *f *= 0.5f;
+}
+
+static void modify_i(int * i)
+{
+ int j = *i;
+ int cutoff = 2 << 6;
+ if(j > cutoff)
+ j = cutoff;
+ if(is_neg(j))
+ set_i(i, 0);
+ else if(is_pos(j))
+ set_i(i, j);
+ else
+ set_i(i, cutoff);
+}
+
+int __attribute__((kernel)) simple_kernel(int in)
+{
+ int i = in;
+ float f = (float) i;
+ modify_f(&f);
+ modify_i(&i);
+ int ret = (int) f;
+ return in * ret;
+}
+
+int glob = 123;
+
+void addToGlobal(int arg)
+{
+ glob += arg;
+}
diff --git a/tests/lldb/jni/BranchingFunCalls/res/layout/main_layout.xml b/tests/lldb/jni/BranchingFunCalls/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/BranchingFunCalls/src/com/android/rs/jnibranchingfuncalls/MainActivity.java b/tests/lldb/jni/BranchingFunCalls/src/com/android/rs/jnibranchingfuncalls/MainActivity.java
new file mode 100644
index 0000000..a1a5be3
--- /dev/null
+++ b/tests/lldb/jni/BranchingFunCalls/src/com/android/rs/jnibranchingfuncalls/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jnibranchingfuncalls;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jnibranchingfuncalls");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/jni/DebugWaitAttach/Android.mk b/tests/lldb/jni/DebugWaitAttach/Android.mk
new file mode 100644
index 0000000..5e57728
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIDebugWaitAttach
+
+LOCAL_JNI_SHARED_LIBRARIES := libjnidebugwaitattach
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jnidebugwaitattach/Android.mk
+
diff --git a/tests/lldb/jni/DebugWaitAttach/AndroidManifest.xml b/tests/lldb/jni/DebugWaitAttach/AndroidManifest.xml
new file mode 100644
index 0000000..12e544b
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jnidebugwaitattach">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIDebugWaitAttach"
+ android:hardwareAccelerated="true">
+
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/Android.mk b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/Android.mk
new file mode 100644
index 0000000..519a32d
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjnidebugwaitattach
+
+LOCAL_SRC_FILES := jnidebugwaitattach.cpp simple.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/jnidebugwaitattach.cpp b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/jnidebugwaitattach.cpp
new file mode 100644
index 0000000..2de68a5
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/jnidebugwaitattach.cpp
@@ -0,0 +1,44 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jnidebugwaitattach_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 8;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+ s->forEach_simple_kernel(a, b);
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ s->forEach_other_kernel(a, b);
+
+ rs->finish();
+}
+
diff --git a/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/simple.rs b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/simple.rs
new file mode 100644
index 0000000..99a42e8
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/jnidebugwaitattach/simple.rs
@@ -0,0 +1,23 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jnidebugwaitattach)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
+
+// Extra kernel to test lldb setting breakpoints on all the RS kernels.
+uchar4 __attribute__((kernel)) other_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/jni/DebugWaitAttach/res/layout/main_layout.xml b/tests/lldb/jni/DebugWaitAttach/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/DebugWaitAttach/src/com/android/rs/jniwaitattachdebug/MainActivity.java b/tests/lldb/jni/DebugWaitAttach/src/com/android/rs/jniwaitattachdebug/MainActivity.java
new file mode 100644
index 0000000..923a3e8
--- /dev/null
+++ b/tests/lldb/jni/DebugWaitAttach/src/com/android/rs/jniwaitattachdebug/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jnidebugwaitattach;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jnidebugwaitattach");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/jni/InfiniteLoop/Android.mk b/tests/lldb/jni/InfiniteLoop/Android.mk
new file mode 100644
index 0000000..4d37171
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIInfiniteLoop
+
+LOCAL_JNI_SHARED_LIBRARIES := libjniinfiniteloop
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jniinfiniteloop/Android.mk
+
diff --git a/tests/lldb/jni/InfiniteLoop/AndroidManifest.xml b/tests/lldb/jni/InfiniteLoop/AndroidManifest.xml
new file mode 100644
index 0000000..23031f0
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jniinfiniteloop">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIInfiniteLoop"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/Android.mk b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/Android.mk
new file mode 100644
index 0000000..ef5ba12
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjniinfiniteloop
+
+LOCAL_SRC_FILES := jniinfiniteloop.cpp infiniteLoop.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/infiniteLoop.rs b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/infiniteLoop.rs
new file mode 100644
index 0000000..ac05bb8
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/infiniteLoop.rs
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jniinfiniteLoop)
+#pragma rs_fp_relaxed
+
+float4 gColour = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColour;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
diff --git a/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/jniinfiniteloop.cpp b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/jniinfiniteloop.cpp
new file mode 100644
index 0000000..2b58339
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/jniinfiniteloop/jniinfiniteloop.cpp
@@ -0,0 +1,49 @@
+#include <memory>
+#include <unistd.h>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_infiniteLoop.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jniinfiniteloop_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ sp<ScriptC_infiniteLoop> s = new ScriptC_infiniteLoop(rs);
+
+ // Test is designed to loop forever, waits for two seconds
+ // between each invocation of the kernel
+ bool forever = true;
+ while(forever)
+ {
+ s->forEach_simple_kernel(a, b);
+ sleep(2);
+ }
+
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+}
+
diff --git a/tests/lldb/jni/InfiniteLoop/res/layout/main_layout.xml b/tests/lldb/jni/InfiniteLoop/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/InfiniteLoop/src/com/android/rs/jniinfiniteloop/MainActivity.java b/tests/lldb/jni/InfiniteLoop/src/com/android/rs/jniinfiniteloop/MainActivity.java
new file mode 100644
index 0000000..94478f2
--- /dev/null
+++ b/tests/lldb/jni/InfiniteLoop/src/com/android/rs/jniinfiniteloop/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jniinfiniteloop;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jniinfiniteloop");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/jni/KernelVariables/Android.mk b/tests/lldb/jni/KernelVariables/Android.mk
new file mode 100644
index 0000000..2d47134
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIKernelVariables
+
+LOCAL_JNI_SHARED_LIBRARIES := libjnikernelvariables
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jnikernelvariables/Android.mk
+
diff --git a/tests/lldb/jni/KernelVariables/AndroidManifest.xml b/tests/lldb/jni/KernelVariables/AndroidManifest.xml
new file mode 100644
index 0000000..b719892
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jnikernelvariables">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIKernelVariables"
+ android:hardwareAccelerated="true">
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
+
diff --git a/tests/lldb/jni/KernelVariables/jnikernelvariables/Android.mk b/tests/lldb/jni/KernelVariables/jnikernelvariables/Android.mk
new file mode 100644
index 0000000..9862a5b
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/jnikernelvariables/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjnikernelvariables
+
+LOCAL_SRC_FILES := jnikernelvariables.cpp simple.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/KernelVariables/jnikernelvariables/jnikernelvariables.cpp b/tests/lldb/jni/KernelVariables/jnikernelvariables/jnikernelvariables.cpp
new file mode 100644
index 0000000..9a17fdc
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/jnikernelvariables/jnikernelvariables.cpp
@@ -0,0 +1,81 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jnikernelvariables_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+
+ static const int buffer_int[] = {1, 2, 3, 4};
+ sp<Allocation> int_allocation = Allocation::createSized(rs, Element::I32(rs), 4);
+ int_allocation->copy1DRangeFrom(0, 4, buffer_int);
+ s->set_allocation_1D_global(int_allocation);
+
+ static const int buffer_int2[] = {5, 6, 7, 8};
+
+ Type::Builder typeI32Builder2D(rs, Element::I32(rs));
+ typeI32Builder2D.setX(2);
+ typeI32Builder2D.setY(2);
+
+ sp<Allocation> int_allocation2 = Allocation::createTyped(rs, typeI32Builder2D.create());
+ int_allocation2->copy2DRangeFrom(0, 0, 2, 2, buffer_int2);
+ s->set_allocation_1D_global2(int_allocation2);
+
+ s->set_allocation_2D_global(a);
+ s->set_allocation_2D_global2(b);
+
+ static const int buffer_int3[] = {9, 10, 11, 12, 13, 14, 15, 16};
+
+ Type::Builder typeI32Builder3D(rs, Element::I32(rs));
+ typeI32Builder3D.setX(2);
+ typeI32Builder3D.setY(2);
+ typeI32Builder3D.setZ(2);
+
+ sp<Allocation> int_allocation3 = Allocation::createTyped(rs, typeI32Builder3D.create());
+ int_allocation3->copy3DRangeFrom(0, 0, 0, 2, 2, 2, buffer_int3);
+ s->set_allocation_3D_global(int_allocation3);
+
+ Type::Builder yuvTypeBuilder(rs, Element::YUV(rs));
+ yuvTypeBuilder.setX(4);
+ yuvTypeBuilder.setY(4);
+ yuvTypeBuilder.setYuvFormat(RS_YUV_YV12);
+
+ sp<Allocation> yuv_allocation = Allocation::createTyped(rs, yuvTypeBuilder.create());
+ s->set_allocation_YUV_2D_global(yuv_allocation);
+
+ s->set_sampler_global(Sampler::CLAMP_LINEAR(rs));
+
+ // Script is executed once, then the data is copied back when finished
+ s->forEach_kernel(a, b);
+ rs->finish();
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+}
+
diff --git a/tests/lldb/jni/KernelVariables/jnikernelvariables/simple.rs b/tests/lldb/jni/KernelVariables/jnikernelvariables/simple.rs
new file mode 100644
index 0000000..592b37b
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/jnikernelvariables/simple.rs
@@ -0,0 +1,160 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jnikernelvariables)
+
+char char_global = 12;
+uchar uchar_global = 234;
+short short_global = -321;
+ushort ushort_global = 432;
+int int_global = 1234;
+uint uint_global = 2345;
+float float_global = 4.5f;
+long long_global = -77777;
+ulong ulong_global = 8888;
+double double_global = -456.5f;
+
+char2 char2_global = {11, -22};
+uchar2 uchar2_global = {33, 44};
+short2 short2_global = {-555, 666};
+ushort2 ushort2_global = {777, 888};
+int2 int2_global = {999, -1111};
+uint2 uint2_global = {2222, 3333};
+float2 float2_global = {4.5f, -5.0f};
+long2 long2_global = {-4444, 5555};
+ulong2 ulong2_global = {6666, 7777};
+double2 double2_global = {88.5f, -99.0f};
+
+char3 char3_global = {11, -22, -33};
+uchar3 uchar3_global = {33, 44, 55};
+short3 short3_global = {-555, 666, 777};
+ushort3 ushort3_global = {777, 888, 999};
+int3 int3_global = {999, -1111, 2222};
+uint3 uint3_global = {2222, 3333, 4444};
+float3 float3_global = {4.5f, -5.0f, -6.5f};
+long3 long3_global = {-4444, 5555, 6666};
+ulong3 ulong3_global = {6666, 7777, 8888};
+double3 double3_global = {88.5f, -99.0f, 111.5f};
+
+char4 char4_global = {55, 11, -22, -33};
+uchar4 uchar4_global = {222, 33, 44, 55};
+short4 short4_global = {-444, -555, 666, 777};
+ushort4 ushort4_global = {666, 777, 888, 999};
+int4 int4_global = {888, 999, -1111, 2222};
+uint4 uint4_global = {1111, 2222, 3333, 4444};
+float4 float4_global = {3.0f, 4.5f, -5.0f, -6.5f};
+long4 long4_global = {-3333, -4444, 5555, 6666};
+ulong4 ulong4_global = {5555, 6666, 7777, 8888};
+double4 double4_global = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+rs_matrix2x2 matrix2x2_global;
+rs_matrix3x3 matrix3x3_global;
+rs_matrix4x4 matrix4x4_global;
+
+rs_quaternion quaternion_global;
+
+rs_allocation allocation_1D_global;
+rs_allocation allocation_1D_global2;
+rs_allocation allocation_2D_global;
+rs_allocation allocation_2D_global2;
+rs_allocation allocation_3D_global;
+rs_allocation allocation_YUV_2D_global;
+
+rs_allocation_cubemap_face cubemap_face_global;
+rs_sampler sampler_global;
+
+uchar4 __attribute__((kernel)) kernel(uchar4 in)
+{
+ char char_local = 'a';
+ uchar uchar_local = 'b';
+ short short_local = -321;
+ ushort ushort_local = 432;
+ int int_local = 1234;
+ uint uint_local = 2345;
+ float float_local = 4.5f;
+ long long_local = -77777;
+ ulong ulong_local = 8888;
+ double double_local = -456.5f;
+
+ char2 char2_local = {-11, -22};
+ uchar2 uchar2_local = {33, 44};
+ short2 short2_local = {-555, 666};
+ ushort2 ushort2_local = {777, 888};
+ int2 int2_local = {999, -1111};
+ uint2 uint2_local = {2222, 3333};
+ float2 float2_local = {4.5f, -5.0f};
+ long2 long2_local = {-4444, 5555};
+ ulong2 ulong2_local = {6666, 7777};
+ double2 double2_local = {88.5f, -99.0f};
+
+ char3 char3_local = {11, -22, -33};
+ uchar3 uchar3_local = {33, 44, 55};
+ short3 short3_local = {-555, 666, 777};
+ ushort3 ushort3_local = {777, 888, 999};
+ int3 int3_local = {999, -1111, 2222};
+ uint3 uint3_local = {2222, 3333, 4444};
+ float3 float3_local = {4.5f, -5.0f, -6.5f};
+ long3 long3_local = {-4444, 5555, 6666};
+ ulong3 ulong3_local = {6666, 7777, 8888};
+ double3 double3_local = {88.5f, -99.0f, 111.5f};
+
+ char4 char4_local = {55, 11, -22, -33};
+ uchar4 uchar4_local = {22, 33, 44, 55};
+ short4 short4_local = {-444, -555, 666, 777};
+ ushort4 ushort4_local = {666, 777, 888, 999};
+ int4 int4_local = {888, 999, -1111, 2222};
+ uint4 uint4_local = {1111, 2222, 3333, 4444};
+ float4 float4_local = {3.0f, 4.5f, -5.0f, -6.5f};
+ long4 long4_local = {-3333, -4444, 5555, 6666};
+ ulong4 ulong4_local = {5555, 6666, 7777, 8888};
+ double4 double4_local = {-77.0f, 88.5f, -99.0f, 111.5f};
+
+ rs_matrix2x2 matrix2x2_local = {{1., 2.5,
+ 3., 4.5}};
+ rs_matrix3x3 matrix3x3_local = {{5., 6.5, 7.,
+ 8.5, 9., 1.5,
+ 2., 3.5, 4.}};
+ rs_matrix4x4 matrix4x4_local = {{5.5, 6., 7.5, 8.,
+ 9., 1.5, 2., 3.5,
+ 4.5, 5.5, 6.5, 7.,
+ 8., 9.5, 1.5, 2.5}};
+
+ matrix2x2_global = matrix2x2_local;
+ matrix3x3_global = matrix3x3_local;
+ matrix4x4_global = matrix4x4_local;
+
+ rsQuaternionSet(&quaternion_global, 3.0, 4.5, 5.5, 6.0);
+
+ rs_quaternion quaternion_local;
+ rsQuaternionSet(&quaternion_local, 7.5, 8.0, 9.0, 0.5);
+
+ char char_combined = char_local + (char)uchar_local + char2_local.x +
+ (char)uchar2_local.x + char3_local.x - (char)uchar3_local.x +
+ char4_local.x + (char)uchar4_local.x;
+
+ short short_combined = short_local + (short)ushort_local + short2_local.x +
+ (short)ushort2_local.x + short3_local.x + (short)ushort3_local.x +
+ short4_local.x + (short)ushort4_local.x;
+
+ int int_combined = int_local + (int)uint_local + int2_local.x +
+ (int)uint2_local.x + int3_local.x + (int)uint3_local.x + int4_local.x +
+ (int)uint4_local.x;
+
+ float float_combined = float_local + float2_local.x + float3_local.x +
+ float4_local.x;
+
+ long long_combined = long_local + (long)ulong_local + long2_local.x +
+ (long)ulong2_local.x + long3_local.x + (long)ulong3_local.x +
+ long4_local.x + (long)ulong4_local.x;
+
+ double double_combined = double_local + double2_local.x + double3_local.x +
+ double4_local.x;
+
+ char_global = char_combined;
+ short_global = short_combined;
+ int_global = int_combined;
+ float_global = float_combined;
+ long_global = long_combined;
+ double_global = double_combined;
+
+ uchar4 result = {1,2,3,4};
+ return result;
+}
diff --git a/tests/lldb/jni/KernelVariables/res/layout/main_layout.xml b/tests/lldb/jni/KernelVariables/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/KernelVariables/src/com/android/rs/jnikernelvariables/MainActivity.java b/tests/lldb/jni/KernelVariables/src/com/android/rs/jnikernelvariables/MainActivity.java
new file mode 100644
index 0000000..7e87b9b
--- /dev/null
+++ b/tests/lldb/jni/KernelVariables/src/com/android/rs/jnikernelvariables/MainActivity.java
@@ -0,0 +1,26 @@
+package com.android.rs.jnikernelvariables;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jnikernelvariables");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
diff --git a/tests/lldb/jni/MultipleRSFiles/Android.mk b/tests/lldb/jni/MultipleRSFiles/Android.mk
new file mode 100644
index 0000000..00fad61
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNIMultipleRSFiles
+
+LOCAL_JNI_SHARED_LIBRARIES := libjnimultiplersfiles
+
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jnimultiplersfiles/Android.mk
+
diff --git a/tests/lldb/jni/MultipleRSFiles/AndroidManifest.xml b/tests/lldb/jni/MultipleRSFiles/AndroidManifest.xml
new file mode 100644
index 0000000..19bb65c
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jnimultiplersfiles">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNIMultipleRSFiles"
+ android:hardwareAccelerated="true">
+
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/Android.mk b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/Android.mk
new file mode 100644
index 0000000..7e61fcb
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjnimultiplersfiles
+
+LOCAL_SRC_FILES := jnimultiplersfiles.cpp first.rs second.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -g -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/first.rs b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/first.rs
new file mode 100644
index 0000000..7104f9c
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/first.rs
@@ -0,0 +1,16 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jnimultiplersfiles)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) first_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
diff --git a/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/jnimultiplersfiles.cpp b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/jnimultiplersfiles.cpp
new file mode 100644
index 0000000..462292e
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/jnimultiplersfiles.cpp
@@ -0,0 +1,47 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_first.h"
+#include "ScriptC_second.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jnimultiplersfiles_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 64;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_first> s1 = new ScriptC_first(rs);
+ sp<ScriptC_second> s2 = new ScriptC_second(rs);
+
+ s1->forEach_first_kernel(a, b);
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ s2->forEach_second_kernel(a, b);
+
+ rs->finish();
+}
+
diff --git a/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/second.rs b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/second.rs
new file mode 100644
index 0000000..6691f2f
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/jnimultiplersfiles/second.rs
@@ -0,0 +1,9 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jnimultiplersfiles)
+
+/* RenderScript kernel that just returns the swizzled input. */
+uchar4 __attribute__((kernel)) second_kernel(uchar4 in)
+{
+ uchar4 result = in.wzyx;
+ return result;
+}
diff --git a/tests/lldb/jni/MultipleRSFiles/res/layout/main_layout.xml b/tests/lldb/jni/MultipleRSFiles/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/MultipleRSFiles/src/com/android/rs/jnimultiplersfiles/MainActivity.java b/tests/lldb/jni/MultipleRSFiles/src/com/android/rs/jnimultiplersfiles/MainActivity.java
new file mode 100644
index 0000000..a2b0cb2
--- /dev/null
+++ b/tests/lldb/jni/MultipleRSFiles/src/com/android/rs/jnimultiplersfiles/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jnimultiplersfiles;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jnimultiplersfiles");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/jni/NoDebugWaitAttach/Android.mk b/tests/lldb/jni/NoDebugWaitAttach/Android.mk
new file mode 100644
index 0000000..835140a
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/Android.mk
@@ -0,0 +1,17 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
+ $(call all-renderscript-files-under, src)
+
+LOCAL_PACKAGE_NAME := JNINoDebugWaitAttach
+
+LOCAL_JNI_SHARED_LIBRARIES := libjninodebugwaitattach
+
+LOCAL_RENDERSCRIPT_FLAGS := -O0 -target-api 0
+
+include $(BUILD_PACKAGE)
+include $(LOCAL_PATH)/jninodebugwaitattach/Android.mk
+
diff --git a/tests/lldb/jni/NoDebugWaitAttach/AndroidManifest.xml b/tests/lldb/jni/NoDebugWaitAttach/AndroidManifest.xml
new file mode 100644
index 0000000..846eddd
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/AndroidManifest.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.rs.jninodebugwaitattach">
+ <uses-sdk android:minSdkVersion="21" />
+ <application android:label="JNINoDebugWaitAttach"
+ android:hardwareAccelerated="true">
+
+ <activity android:name="MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/Android.mk b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/Android.mk
new file mode 100644
index 0000000..e8ee3ce
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/Android.mk
@@ -0,0 +1,26 @@
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_MODULE := libjninodebugwaitattach
+
+LOCAL_SRC_FILES := jninodebugwaitattach.cpp simple.rs
+
+LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
+LOCAL_C_INCLUDES += frameworks/rs/cpp
+LOCAL_C_INCLUDES += frameworks/rs
+
+LOCAL_CFLAGS := --std=c++11
+LOCAL_RENDERSCRIPT_FLAGS := -O0 -target-api 0
+
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_SHARED_LIBRARIES := libdl liblog
+LOCAL_STATIC_LIBRARIES := libRScpp_static
+
+LOCAL_SDK_VERSION := 23
+LOCAL_NDK_STL_VARIANT := c++_static
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/jninodebugwaitattach.cpp b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/jninodebugwaitattach.cpp
new file mode 100644
index 0000000..6a99f58
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/jninodebugwaitattach.cpp
@@ -0,0 +1,42 @@
+#include <memory>
+
+#include <jni.h>
+#include <RenderScript.h>
+
+#include "ScriptC_simple.h"
+
+using namespace android;
+using namespace RSC;
+
+extern "C" void JNICALL
+Java_com_android_rs_jninodebugwaitattach_MainActivity_nativeRS(
+ JNIEnv * env,
+ jclass,
+ jstring pathObj)
+{
+ static const int size = 8;
+ sp<RS> rs = new RS();
+
+ const char * path = env->GetStringUTFChars(pathObj, nullptr);
+ rs->init(path, RS_INIT_LOW_LATENCY | RS_INIT_WAIT_FOR_ATTACH);
+ env->ReleaseStringUTFChars(pathObj, path);
+
+ auto e = Element::RGBA_8888(rs);
+ Type::Builder tb(rs, e);
+ tb.setX(size);
+ tb.setY(size);
+ auto t = tb.create();
+
+ auto a = Allocation::createTyped(rs, t);
+ auto b = Allocation::createTyped(rs, t);
+
+ // Script is executed once, then the data is copied back when finished
+ sp<ScriptC_simple> s = new ScriptC_simple(rs);
+ s->forEach_simple_kernel(a, b);
+ uint32_t * output = new uint32_t[size*size];
+ b->copy2DRangeTo(0, 0, size, size, output);
+ delete [] output;
+
+ rs->finish();
+}
+
diff --git a/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/simple.rs b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/simple.rs
new file mode 100644
index 0000000..3ae111b
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/jninodebugwaitattach/simple.rs
@@ -0,0 +1,16 @@
+#pragma version(1)
+#pragma rs java_package_name(com.android.rs.jninodebugwaitattach)
+
+float4 gColor = {0.299f, 0.587f, 0.114f, 1.f};
+
+/* RenderScript kernel that just sets the colour of the screen and does some
+ * simple operations so it is not completely empty
+ * (and can therefore be debugged).
+ */
+uchar4 __attribute__((kernel)) simple_kernel(uchar4 in)
+{
+ float4 temp = rsUnpackColor8888(in);
+ temp = gColor;
+ uchar4 result = rsPackColorTo8888(temp);
+ return result;
+}
\ No newline at end of file
diff --git a/tests/lldb/jni/NoDebugWaitAttach/res/layout/main_layout.xml b/tests/lldb/jni/NoDebugWaitAttach/res/layout/main_layout.xml
new file mode 100644
index 0000000..131c3b5
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/res/layout/main_layout.xml
@@ -0,0 +1,15 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter" />
+
+</FrameLayout>
+
diff --git a/tests/lldb/jni/NoDebugWaitAttach/src/com/android/rs/jninodebugwaitattach/MainActivity.java b/tests/lldb/jni/NoDebugWaitAttach/src/com/android/rs/jninodebugwaitattach/MainActivity.java
new file mode 100644
index 0000000..6d96f31
--- /dev/null
+++ b/tests/lldb/jni/NoDebugWaitAttach/src/com/android/rs/jninodebugwaitattach/MainActivity.java
@@ -0,0 +1,27 @@
+package com.android.rs.jninodebugwaitattach;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.graphics.BitmapFactory;
+import android.graphics.Bitmap;
+import android.widget.ImageView;
+
+public class MainActivity extends Activity {
+ private Bitmap mBitmapIn;
+ private Bitmap mBitmapOut;
+
+ static {
+ System.loadLibrary("RS");
+ System.loadLibrary("jninodebugwaitattach");
+ }
+
+ native void nativeRS(String cacheDir);
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+ nativeRS(this.getCacheDir().toString());
+ }
+}
+
diff --git a/tests/lldb/run_tests.py b/tests/lldb/run_tests.py
new file mode 100755
index 0000000..0593c0e
--- /dev/null
+++ b/tests/lldb/run_tests.py
@@ -0,0 +1,797 @@
+#!/usr/bin/env python2.7
+'''Main test suite execution script.'''
+import argparse
+import inspect
+import logging
+import os
+import signal
+import subprocess
+import sys
+import time
+import xml.etree.ElementTree as ET
+
+from config import Config
+from tests.harness import util_constants
+from tests.harness import TestSuiteException
+from tests.harness import UtilAndroid
+from tests.harness import UtilBundle
+from tests.harness import util_log
+from tests.harness.util_functions import load_py_module
+
+# For some reason pylint is not able to understand the class returned by
+# from util_log.get_logger() and generates a lot of false warnings
+#pylint: disable=maybe-no-member
+
+EMU_PROC = None
+
+def _parse_args():
+ '''Parse the command line arguments.
+
+ Returns:
+ A namespace object that contains the options specified to run_tests on
+ the command line.
+ '''
+
+ parser = argparse.ArgumentParser(description='Run the test suite.')
+
+ parser.add_argument('--config', '-c',
+ metavar='path',
+ help='Path to a custom config file.')
+ parser.add_argument('--device', '-d',
+ help='Specify the device id of the device to test on.')
+ parser.add_argument('--test', '-t',
+ metavar='path',
+ help='Specify a specific test to run.')
+ parser.add_argument('--install-only',
+ action='store_true',
+ default=False,
+ help='It only runs the pre-run stage of the test suite.'
+ ' It installs the required APKs but does not '
+ 'execute the tests.',
+ dest='install_only')
+ parser.add_argument('--no-install', '-n',
+ action='store_true',
+ default=False,
+ help='Stop the test suite installing apks to device.',
+ dest='noinstall')
+ parser.add_argument('--no-uninstall',
+ action='store_true',
+ default=False,
+ help='Stop the test suite uninstalling apks after '
+ 'completion.',
+ dest='nouninstall')
+ parser.add_argument('--print-to-stdout',
+ action='store_true',
+ default=False,
+ help='Print all logging information to standard out.',
+ dest='print_to_stdout')
+ parser.add_argument('--verbose', '-v',
+ action='store_true',
+ default=None,
+ help='Store extra info in the log.')
+ parser.add_argument('--wimpy', '-w',
+ action='store_true',
+ default=None,
+ help='Test only a core subset of features.')
+ parser.add_argument('--run-emu',
+ action='store_true',
+ default=None,
+ help='Spawn an emulator and run the test suite on that.'
+ ' Specify the emulator command line in the config'
+ ' file or with -emu-cmd.',
+ dest='run_emu')
+
+ # Get the properties of the Config class and add a command line argument
+ # for each.
+ this_module = sys.modules[__name__]
+ for member_name, member_obj in inspect.getmembers(Config):
+ if (inspect.isdatadescriptor(member_obj) and
+ member_name not in ['__weakref__', 'device', 'verbose']):
+
+ # List type properties can take one or more arguments
+ num_args = None
+ if (isinstance(member_obj, property)
+ and isinstance(member_obj.fget(Config), list)):
+ num_args = '+'
+
+ opt_name = member_name.replace('_', '-')
+
+ setattr(this_module, opt_name, '')
+
+ parser.add_argument('--' + opt_name,
+ nargs=num_args,
+ help=member_obj.__doc__,
+ dest=member_name)
+
+ return parser.parse_args()
+
+
+def _choice(first_choice, second_choice):
+ '''Return first_choice if it is not None otherwise return second_choice.
+
+ Args:
+ first_choice: The first choice value.
+ second_choice: The alternative value.
+
+ Returns:
+ The first argument if it is not None, and the second otherwise.
+ '''
+ return first_choice if first_choice else second_choice
+
+
+class State(object):
+ '''This class manages all objects required by the test suite.'''
+
+ # pylint: disable=too-many-instance-attributes
+ # Since this is a state class many attributes are expected.
+
+ def __init__(self):
+ '''State constructor.
+
+ Raises:
+ TestSuiteException: When unable to load config file.
+
+ AssertionError: When assertions fail.
+ '''
+
+ # Parse the command line options
+ args = _parse_args()
+
+ # create a config instance
+ if args.config:
+ # use the user supplied
+ config = State.load_user_configuration(args.config)
+ else:
+ # use the default configuration
+ config = Config()
+
+ # save the test blacklist
+ self.blacklist = _choice(args.blacklist, config.blacklist)
+
+ # Allow any of the command line arguments to override the
+ # values in the config file.
+ self.adb_path = _choice(args.adb_path, config.adb_path)
+
+ self.host_port = int(_choice(args.host_port, config.host_port))
+
+ self.device = _choice(args.device, config.device)
+
+ self.user_specified_device = self.device
+
+ self.device_port = int(_choice(args.device_port, config.device_port))
+
+ self.lldb_server_path_device = _choice(args.lldb_server_path_device,
+ config.lldb_server_path_device)
+
+ self.lldb_server_path_host = _choice(args.lldb_server_path_host,
+ config.lldb_server_path_host)
+
+ self.aosp_product_path = _choice(args.aosp_product_path,
+ config.aosp_product_path)
+
+ self.log_file_path = _choice(args.log_file_path, config.log_file_path)
+
+ self.results_file_path = _choice(args.results_file_path,
+ config.results_file_path)
+
+ self.lldb_path = _choice(args.lldb_path, config.lldb_path)
+ self.print_to_stdout = args.print_to_stdout
+ self.verbose = _choice(args.verbose, config.verbose)
+ self.timeout = int(_choice(args.timeout, config.timeout))
+ self.wimpy = args.wimpy
+ self.emu_cmd = _choice(args.emu_cmd, config.emu_cmd)
+ self.run_emu = args.run_emu
+
+ # validate the param "verbose"
+ if not isinstance(self.verbose, bool):
+ raise TestSuiteException('The parameter "verbose" should be a '
+ 'boolean: {0}'.format(self.verbose))
+
+ # create result array
+ self.results = dict()
+ self.single_test = args.test
+
+ # initialise the logging facility
+ log_level = logging.INFO if not self.verbose else logging.DEBUG
+ util_log.initialise("driver",
+ print_to_stdout=self.print_to_stdout,
+ level=log_level,
+ file_mode='w', # open for write
+ file_path=self.log_file_path
+ )
+ log = util_log.get_logger()
+
+ if self.run_emu and not self.emu_cmd:
+ log.TestSuiteException('Need to specify --emu-cmd (or specify a'
+ ' value in the config file) if using --run-emu.')
+
+ # create a results file
+ self.results_file = open(self.results_file_path, 'w')
+
+ # create an android helper object
+ self.android = UtilAndroid(self.adb_path,
+ self.lldb_server_path_device,
+ self.device)
+ assert self.android
+
+ # create a test bundle
+ self.bundle = UtilBundle(self.android,
+ self.aosp_product_path)
+ assert self.bundle
+
+ # save the no pushing option
+ assert isinstance(args.noinstall, bool)
+ self.noinstall = args.noinstall
+
+ assert isinstance(args.nouninstall, bool)
+ self.nouninstall = args.nouninstall
+
+ # install only option
+ assert type(args.install_only) is bool
+ self.install_only = args.install_only
+ if self.install_only:
+ log.log_and_print('Option --install-only set. The test APKs will '
+ 'be installed on the device but the tests will '
+ 'not be executed.')
+ if self.noinstall:
+ raise TestSuiteException('Conflicting options given: '
+ '--install-only and --no-install')
+
+ # TCP port modifier which is used to increment the port number used for
+ # each test case to avoid collisions.
+ self.port_mod = 0
+
+ # total number of tests that will be executed
+ self.test_count = 0
+
+ def get_android(self):
+ '''Return the android ADB helper instance.
+
+ Returns:
+ The android ADB helper, instance of UtilAndroid.
+ '''
+ assert self.android
+ return self.android
+
+ def get_bundle(self):
+ '''Return the test executable bundle.
+
+ Returns:
+ The test exectable collection, instance of UtilBundle.
+ '''
+ return self.bundle
+
+ def add_result(self, name, result):
+ '''Add a test result to the collection.
+
+ Args:
+ name: String name of the test that has executed.
+ result: String result of the test, "pass", "fail", "error".
+ '''
+ self.results[name] = result
+
+ def get_single_test(self):
+ '''Get the name of the single test to run.
+
+ Returns:
+ A string that is the name of the python file containing the test to
+ be run. If all tests are to be run this returns None.
+ '''
+ return self.single_test
+
+ @staticmethod
+ def load_user_configuration(path):
+ '''Load the test suite config from the give path.
+
+ Instantiate the Config class found in the module at the given path.
+ If no suitable class is available, it raises a TestSuiteException.
+
+ Args:
+ path: String location of the module.
+
+ Returns:
+ an instance of the Config class, defined in the module.
+
+ Raises:
+ TestSuiteException: when unable to import the module or when a
+ subclass of Config is not found inside it.
+ '''
+
+ # load the module
+ config_module = load_py_module(path)
+ if not config_module:
+ raise TestSuiteException('Unable to import the module from "%s"'
+ % (path))
+
+ # look for a subclass of Config
+ for name, value in inspect.getmembers(config_module):
+ if (inspect.isclass(value)
+ and name != 'Config'
+ and issubclass(value, Config)):
+ # that's our candidate
+ return value()
+
+ # otherwise there are no valid candidates
+ raise TestSuiteException('The provided user configuration is not '
+ 'valid. The module must define a subclass '
+ 'of Config')
+
+
+def _kill_emulator():
+ ''' Kill the emulator process. '''
+ global EMU_PROC
+ if EMU_PROC:
+ try:
+ EMU_PROC.terminate()
+ except OSError:
+ # can't kill a dead proc
+ log = util_log.get_logger()
+ log.debug('Trying to kill an emulator but it is already dead.')
+
+
+def _check_emulator_terminated():
+ ''' Throw an exception if the emulator process has ended.
+
+ Raises:
+ TestSuiteException: If the emulator process has ended.
+ '''
+ global EMU_PROC
+ assert EMU_PROC
+ if EMU_PROC.poll():
+ stdout, stderr = EMU_PROC.communicate()
+ raise TestSuiteException('The emulator terminated with output:'
+ '\nstderr: {0}\nstdout: {1}.'.format(stderr, stdout))
+
+
+def _launch_emulator(state):
+ '''Launch the emulator and wait for it to boot.
+
+ Args:
+ emu_cmd: The command line to run the emulator.
+
+ Raises:
+ TestSuiteException: If an emulator already exists or the emulator
+ process terminated before we could connect to it, or
+ we failed to copy lldb-server to the emulator.
+ '''
+ global EMU_PROC
+ android = state.android
+ if state.user_specified_device:
+ if android.device_with_substring_exists(state.user_specified_device):
+ raise TestSuiteException(
+ 'A device with name {0} already exists.',
+ state.user_specified_device)
+ else:
+ if android.device_with_substring_exists('emulator'):
+ raise TestSuiteException('An emulator already exists.')
+
+ assert state.emu_cmd
+ EMU_PROC = subprocess.Popen(state.emu_cmd.split(),
+ stdout=None,
+ stderr=subprocess.STDOUT)
+
+ log = util_log.get_logger()
+ log.info('Launching emulator with command line {0}'.format(state.emu_cmd))
+
+ tries_number = 180
+ tries = tries_number
+ found_device = False
+ while not found_device:
+ try:
+ android.validate_device(False, 'emulator')
+ found_device = True
+ except TestSuiteException as ex:
+ tries -= 1
+ if tries == 0:
+ # Avoid infinitely looping if the emulator won't boot
+ log.warning(
+ 'Giving up trying to validate device after {0} tries.'
+ .format(tries_number))
+ raise ex
+ _check_emulator_terminated()
+ # wait a bit and try again, maybe it has now booted
+ time.sleep(10)
+
+ tries = 500
+ while not android.is_booted():
+ tries -= 1
+ if tries == 0:
+ # Avoid infinitely looping if the emulator won't boot
+ raise TestSuiteException('The emulator has failed to boot.')
+ _check_emulator_terminated()
+ time.sleep(5)
+
+ # Need to be root before we can push lldb-server
+ android.adb_root()
+ android.wait_for_device()
+
+ # Push the lldb-server executable to the device.
+ output = android.adb('push {0} {1}'.format(state.lldb_server_path_host,
+ state.lldb_server_path_device))
+
+ if 'failed to copy' in output or 'No such file or directory' in output:
+ raise TestSuiteException(
+ 'unable to push lldb-server to the emulator: {0}.'
+ .format(output))
+
+ output = android.shell('chmod a+x {0}'
+ .format(state.lldb_server_path_device))
+
+ if 'No such file or directory' in output:
+ raise TestSuiteException('Failed to copy lldb-server to the emulator.')
+
+
+def _restart_emulator(state):
+ '''Kill the emulator and start a new instance.
+
+ Args:
+ state: Test suite state collection, instance of State.
+ '''
+ _kill_emulator()
+ _launch_emulator(state)
+
+
+def _run_test(state, name):
+ '''Execute a single test case.
+
+ Args:
+ state: Test suite state collection, instance of State.
+ name: String file name of the test to execute.
+
+ Raises:
+ AssertionError: When assertion fails.
+ '''
+ assert isinstance(name, str)
+
+ try:
+ state.android.check_adb_alive()
+ except TestSuiteException as expt:
+ global EMU_PROC
+ if EMU_PROC:
+ _restart_emulator(state)
+ else:
+ raise expt
+
+ log = util_log.get_logger()
+ sys.stdout.write('Running {0}\r'.format(name))
+ sys.stdout.flush()
+ log.info('Running {0}'.format(name))
+
+ run_tests_dir = os.path.dirname(os.path.realpath(__file__))
+ run_test_path = os.path.join(run_tests_dir, 'tests', 'run_test.py')
+
+ # Forward port for lldb-server on the device to our host
+ hport = int(state.host_port) + state.port_mod
+ dport = int(state.device_port) + state.port_mod
+ state.android.forward_port(hport, dport)
+ state.port_mod += 1
+
+ log.debug('Giving up control to {0}...'.format(name))
+
+ params = [sys.executable,
+ run_test_path,
+ name,
+ state.log_file_path,
+ state.adb_path,
+ state.lldb_server_path_device,
+ state.aosp_product_path,
+ str(dport),
+ state.android.get_device_id(),
+ str(state.print_to_stdout),
+ str(state.verbose),
+ str(state.wimpy),
+ str(state.timeout)]
+
+ return_code = subprocess.call(params)
+
+ state.android.remove_port_forwarding()
+ log.seek_to_end()
+
+ # report in sys.stdout the result
+ print('Running {0}: {1}'.format(name,
+ ('PASS' if return_code == util_constants.RC_TEST_OK else 'FAIL')))
+
+ if return_code == util_constants.RC_TEST_OK:
+ state.add_result(name, 'pass')
+ log.info('Test {0} passed'.format(name))
+ elif return_code == util_constants.RC_TEST_TIMEOUT:
+ state.add_result(name, 'timeout')
+ log.error('Test {0} timed out'.format(name))
+ elif return_code == util_constants.RC_TEST_ERROR:
+ state.add_result(name, 'failure')
+ log.error('Test {0} failed'.format(name))
+ else: # unexpected result
+ state.add_result(name, 'error')
+ log.critical('Test {0} yielded an unexpected return code: {1}'
+ .format(name, return_code))
+
+ # print a running total pass rate
+ passes = sum(1 for key, value in state.results.iteritems() if value == 'pass')
+ log.info('Current pass rate: {0} of {1}.'.format(passes, len(state.results)))
+ if state.test_count:
+ percent = (len(state.results)*100) / state.test_count
+ log.info('Testing is {0}% complete.'.format(percent))
+
+
+def _check_lldbserver_exists(state):
+ '''Check lldb-server exists on the target device and it is executable.
+
+ Raises:
+ TestSuiteError: If lldb-server does not exist on the target.
+ '''
+ assert state
+
+ message = 'Unable to verify valid lldb-server on target'
+
+ android = state.get_android()
+ assert android
+
+ cmd = state.lldb_server_path_device
+ out = android.shell(cmd, False)
+ if not isinstance(out, str):
+ raise TestSuiteException(message)
+ if out.find('Usage:') < 0:
+ raise TestSuiteException(message)
+
+
+def _suite_pre_run(state):
+ '''This function is executed before the test cases are run (setup).
+
+ Args:
+ state: Test suite state collection, instance of State.
+
+ Return:
+ True if the pre_run step completes without error.
+ Checks made:
+ - Validating that adb exists and runs.
+ - Validating that a device is attached.
+ - We have root access to the device.
+ - All test binaries were pushed to the device.
+ - The port for lldb-server was forwarded correctly.
+
+ Raises:
+ AssertionError: When assertions fail.
+ '''
+ assert state
+ log = util_log.get_logger()
+
+ try:
+ android = state.get_android()
+ bundle = state.get_bundle()
+ assert android
+ assert bundle
+
+ # validate ADB helper class
+ android.validate_adb()
+ log.log_and_print('Located ADB')
+
+ if state.run_emu:
+ log.log_and_print('Launching emulator...')
+ _launch_emulator(state)
+ log.log_and_print('Started emulator ' + android.device)
+ else:
+ android.validate_device()
+ log.log_and_print('Located device ' + android.device)
+
+ if state.noinstall and not state.single_test:
+ bundle.check_apps_installed(state.wimpy)
+
+ # elevate to root user
+ android.adb_root()
+ android.wait_for_device()
+ # check that lldb-server exists on device
+ android.kill_servers()
+ _check_lldbserver_exists(state)
+
+ if not state.noinstall:
+ # push all tests to the device
+ log.log_and_print('Pushing all tests...')
+ bundle.push_all()
+ log.log_and_print('Pushed all tests')
+ log.log_and_print('Pre run complete')
+
+ except TestSuiteException as expt:
+ log.exception('Test suite pre run failure')
+
+ # Even if we are logging the error, it may be helpful and more
+ # immediate to find out the error into the terminal
+ log.log_and_print('ERROR: Unable to set up the test suite: %s\n'
+ % expt.message, logging.ERROR)
+
+ return False
+ return True
+
+
+def _suite_post_run(state):
+ '''This function is executed after the test cases have run (teardown).
+
+ Args:
+ state: Test suite state collection, instance of State.
+ '''
+ log = util_log.get_logger()
+
+ if not state.noinstall and not state.nouninstall:
+ if state.wimpy:
+ state.bundle.uninstall_all_apk()
+ else:
+ state.bundle.uninstall_all()
+ log.log_and_print('Uninstalled/Deleted all tests')
+
+ total = 0
+ passes = 0
+ failures = 0
+
+ results = ET.Element('testsuite')
+ results.attrib['name'] = 'LLDB RS Test Suite'
+
+ for key, value in state.results.iteritems():
+ total += 1
+ if value == 'pass':
+ passes += 1
+ else:
+ failures += 1
+
+ # test case name, followed by pass, failure or error elements
+ testcase = ET.Element('testcase')
+ testcase.attrib['name'] = key
+ result_element = ET.Element(value)
+ result_element.text = key
+ testcase.append(result_element)
+ results.append(testcase)
+
+ assert passes + failures == total, 'Invalid test results status'
+ if failures:
+ log.log_and_print(
+ 'The following failures occurred: \n{}'.format('\n'.join(
+ 'failed: ' + name
+ for name, result in state.results.items() if result != 'pass'
+ )))
+
+ log.log_and_print('{0} of {1} passed'.format(passes, total))
+ if total:
+ log.log_and_print('{0}% rate'.format((passes*100)/total))
+
+ results.attrib['tests'] = str(total)
+ state.results_file.write(ET.tostring(results, encoding='iso-8859-1'))
+
+
+def _discover_tests(state):
+ '''Discover all tests in the tests directory.
+
+ Returns:
+ List of strings, test file names from the 'tests' directory.
+ '''
+ tests = []
+
+ single_test = state.get_single_test()
+ if single_test is None:
+ file_dir = os.path.dirname(os.path.realpath(__file__))
+ tests_dir = os.path.join(file_dir, 'tests')
+
+ for sub_dir in os.listdir(tests_dir):
+ current_test_dir = os.path.join(tests_dir, sub_dir)
+ if os.path.isdir(current_test_dir):
+ dir_name = os.path.basename(current_test_dir)
+
+ if dir_name == 'harness':
+ continue
+
+ if state.wimpy and dir_name != 'java':
+ continue
+
+ for item in os.listdir(current_test_dir):
+ if (item.startswith('test')
+ and item.endswith('.py')
+ and not item in state.blacklist):
+ tests.append(item)
+ else:
+ if single_test.endswith('.py'):
+ tests.append(single_test)
+ else:
+ tests.append(single_test + '.py')
+
+ state.test_count = len(tests)
+ return tests
+
+
+def _deduce_python_path(state):
+ '''Try to deduce the PYTHONPATH environment variable via the LLDB binary.
+
+ Args:
+ state: Test suite state collection, instance of State.
+
+ Returns:
+ True if PYTHONPATH has been updated, False otherwise.
+
+ Raises:
+ TestSuiteException: If lldb path provided in the config or command line
+ is incorrect.
+ AssertionError: If an assertion fails.
+ '''
+
+ lldb_path = state.lldb_path
+ if not lldb_path:
+ # lldb may not be provided in preference of a manual $PYTHONPATH
+ return False
+
+ params = [lldb_path, '-P']
+
+ try:
+ proc = subprocess.Popen(params, stdout=subprocess.PIPE)
+ except OSError as err:
+ error_string = 'Could not run lldb at %s: %s' % (lldb_path, str(err))
+ raise TestSuiteException(error_string)
+
+ stdout = proc.communicate()[0]
+ if stdout:
+ os.environ['PYTHONPATH'] = stdout.strip()
+ return True
+
+ return False
+
+
+def main():
+ '''The lldb-renderscript test suite entry point.'''
+ log = None
+
+ try:
+ # parse the command line
+ state = State()
+ assert state
+
+ # logging is initialised in State()
+ log = util_log.get_logger()
+
+ # if we can, set PYTHONPATH for lldb bindings
+ if not _deduce_python_path(state):
+ log.log_and_print('Unable to deduce PYTHONPATH', logging.WARN)
+
+ # pre run step
+ if not _suite_pre_run(state):
+ raise TestSuiteException('Test suite pre-run step failed')
+ # discover all tests and execute them
+ tests = _discover_tests(state)
+ log.log_and_print('Found {0} tests'.format(len(tests)))
+ if state.install_only:
+ log.log_and_print('Test applications installed. Terminating due to '
+ '--install-only option')
+ else:
+ # run the tests
+ for item in tests:
+ _run_test(state, item)
+ # post run step
+ _suite_post_run(state)
+
+ # success
+ quit(0)
+
+ except AssertionError:
+ if log:
+ log.exception('Internal test suite error')
+
+ print 'Internal test suite error'
+ quit(1)
+
+ except TestSuiteException as error:
+ if log:
+ log.exception('Test suite exception')
+
+ print '{0}'.format(str(error))
+ quit(2)
+
+ finally:
+ _kill_emulator()
+ logging.shutdown()
+
+def signal_handler(_, _unused):
+ '''Signal handler for SIGINT, caused by the user typing Ctrl-C.'''
+ # pylint: disable=unused-argument
+ # pylint: disable=protected-access
+ print 'Ctrl+C!'
+ os._exit(1)
+
+
+# execution trampoline
+if __name__ == '__main__':
+ signal.signal(signal.SIGINT, signal_handler)
+ main()
diff --git a/tests/lldb/tests/__init__.py b/tests/lldb/tests/__init__.py
new file mode 100644
index 0000000..7bf5dc9
--- /dev/null
+++ b/tests/lldb/tests/__init__.py
@@ -0,0 +1,3 @@
+'''This module contains a test runner, tests and utility code'''
+
+import harness
diff --git a/tests/lldb/tests/cpp/test_allocation_dump_1_cpp.py b/tests/lldb/tests/cpp/test_allocation_dump_1_cpp.py
new file mode 100644
index 0000000..0180d32
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_allocation_dump_1_cpp.py
@@ -0,0 +1,326 @@
+'''Module that contains the test TestAllocationDump1Cpp.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationDump1Cpp(TestBaseRemote):
+ '''Tests printing the contents of allocations in NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return 'CppAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test dumping large allocations to file
+ output_file_1 = self.get_tmp_file_path()
+ output_file_2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file_1,
+ ["Results written to '%s'" % output_file_1])
+
+ self.try_command('language renderscript allocation dump 2 -f ' +
+ output_file_2,
+ ["Results written to '%s'" % output_file_2])
+
+ # Check files were created
+ self.test_assert(os.path.isfile(output_file_1))
+ self.test_assert(os.path.isfile(output_file_2))
+ os.remove(output_file_1)
+ os.remove(output_file_2)
+
+ # char
+ self.try_command('language renderscript allocation dump 3',
+ ['(0, 0, 0) = 0',
+ '(0, 1, 0) = 1',
+ '(0, 2, 0) = 2',
+ '(0, 0, 1) = 3',
+ '(0, 1, 1) = 4',
+ '(0, 2, 1) = 5',
+ '(0, 0, 2) = 6',
+ '(0, 1, 2) = 7',
+ '(0, 2, 2) = 8',
+ '(0, 0, 3) = 9',
+ '(0, 1, 3) = 10',
+ '(0, 2, 3) = 11',
+ '(0, 0, 4) = 12',
+ '(0, 1, 4) = 13',
+ '(0, 2, 4) = 14',
+ '(0, 0, 5) = 15',
+ '(0, 1, 5) = 16',
+ '(0, 2, 5) = 17',
+ '(0, 0, 6) = 18',
+ '(0, 1, 6) = 19',
+ '(0, 2, 6) = 20',
+ '(0, 0, 7) = 21',
+ '(0, 1, 7) = 22',
+ '(0, 2, 7) = 23'])
+
+ # char2
+ self.try_command('language renderscript allocation dump 4',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # char3
+ self.try_command('language renderscript allocation dump 5',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # char4
+ self.try_command('language renderscript allocation dump 6',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # short
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # short2
+ self.try_command('language renderscript allocation dump 8',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(0, 0, 1) = {12 13}',
+ '(1, 0, 1) = {14 15}',
+ '(2, 0, 1) = {16 17}',
+ '(3, 0, 1) = {18 19}',
+ '(4, 0, 1) = {20 21}',
+ '(5, 0, 1) = {22 23}'])
+
+ # short3
+ self.try_command('language renderscript allocation dump 9',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # short4
+ self.try_command('language renderscript allocation dump 10',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # int
+ self.try_command('language renderscript allocation dump 11',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # int2
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # int3
+ self.try_command('language renderscript allocation dump 13',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(0, 1, 0) = {12 13 14}',
+ '(1, 1, 0) = {16 17 18}',
+ '(2, 1, 0) = {20 21 22}'])
+ # int4
+ self.try_command('language renderscript allocation dump 14',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # long
+ self.try_command('language renderscript allocation dump 15',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # long2
+ self.try_command('language renderscript allocation dump 16',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # long3
+ self.try_command('language renderscript allocation dump 17',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # long4
+ self.try_command('language renderscript allocation dump 18',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(0, 1, 0) = {4 5 6 7}',
+ '(0, 2, 0) = {8 9 10 11}',
+ '(0, 3, 0) = {12 13 14 15}',
+ '(0, 4, 0) = {16 17 18 19}',
+ '(0, 5, 0) = {20 21 22 23}'])
+
+ # bool
+ self.try_command('language renderscript allocation dump 19',
+ ['(0, 0, 0) = false',
+ '(1, 0, 0) = true',
+ '(2, 0, 0) = false',
+ '(3, 0, 0) = true',
+ '(4, 0, 0) = false',
+ '(5, 0, 0) = true',
+ '(6, 0, 0) = false',
+ '(7, 0, 0) = true',
+ '(8, 0, 0) = false',
+ '(9, 0, 0) = true',
+ '(10, 0, 0) = false',
+ '(11, 0, 0) = true',
+ '(12, 0, 0) = false',
+ '(13, 0, 0) = true',
+ '(14, 0, 0) = false',
+ '(15, 0, 0) = true',
+ '(16, 0, 0) = false',
+ '(17, 0, 0) = true',
+ '(18, 0, 0) = false',
+ '(19, 0, 0) = true',
+ '(20, 0, 0) = false',
+ '(21, 0, 0) = true',
+ '(22, 0, 0) = false',
+ '(23, 0, 0) = true'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2', ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 3', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_allocation_dump_2_cpp.py b/tests/lldb/tests/cpp/test_allocation_dump_2_cpp.py
new file mode 100644
index 0000000..24bd64d
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_allocation_dump_2_cpp.py
@@ -0,0 +1,514 @@
+'''Module that contains the test TestAllocationDump2Cpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationDump2Cpp(TestBaseRemote):
+ '''Tests printing the contents of allocations in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # uchar
+ self.try_command('language renderscript allocation dump 20',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # uchar2
+ self.try_command('language renderscript allocation dump 21',
+ ['(0, 0, 0) = {0x00 0x01}',
+ '(1, 0, 0) = {0x02 0x03}',
+ '(0, 1, 0) = {0x04 0x05}',
+ '(1, 1, 0) = {0x06 0x07}',
+ '(0, 2, 0) = {0x08 0x09}',
+ '(1, 2, 0) = {0x0a 0x0b}',
+ '(0, 3, 0) = {0x0c 0x0d}',
+ '(1, 3, 0) = {0x0e 0x0f}',
+ '(0, 4, 0) = {0x10 0x11}',
+ '(1, 4, 0) = {0x12 0x13}',
+ '(0, 5, 0) = {0x14 0x15}',
+ '(1, 5, 0) = {0x16 0x17}'])
+
+ # uchar3
+ self.try_command('language renderscript allocation dump 22',
+ ['(0, 0, 0) = {0x00 0x01 0x02}',
+ '(1, 0, 0) = {0x04 0x05 0x06}',
+ '(2, 0, 0) = {0x08 0x09 0x0a}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e}',
+ '(4, 0, 0) = {0x10 0x11 0x12}',
+ '(5, 0, 0) = {0x14 0x15 0x16}'])
+
+ # uchar4
+ self.try_command('language renderscript allocation dump 23',
+ ['(0, 0, 0) = {0x00 0x01 0x02 0x03}',
+ '(1, 0, 0) = {0x04 0x05 0x06 0x07}',
+ '(2, 0, 0) = {0x08 0x09 0x0a 0x0b}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e 0x0f}',
+ '(4, 0, 0) = {0x10 0x11 0x12 0x13}',
+ '(5, 0, 0) = {0x14 0x15 0x16 0x17}'])
+
+ # ushort
+ self.try_command('language renderscript allocation dump 24',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # ushort2
+ self.try_command('language renderscript allocation dump 25',
+ ['(0, 0, 0) = {0x0000 0x0001}',
+ '(1, 0, 0) = {0x0002 0x0003}',
+ '(2, 0, 0) = {0x0004 0x0005}',
+ '(3, 0, 0) = {0x0006 0x0007}',
+ '(4, 0, 0) = {0x0008 0x0009}',
+ '(5, 0, 0) = {0x000a 0x000b}',
+ '(6, 0, 0) = {0x000c 0x000d}',
+ '(7, 0, 0) = {0x000e 0x000f}',
+ '(8, 0, 0) = {0x0010 0x0011}',
+ '(9, 0, 0) = {0x0012 0x0013}',
+ '(10, 0, 0) = {0x0014 0x0015}',
+ '(11, 0, 0) = {0x0016 0x0017}'])
+
+ # ushort3
+ self.try_command('language renderscript allocation dump 26',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002}',
+ '(0, 1, 0) = {0x0004 0x0005 0x0006}',
+ '(0, 2, 0) = {0x0008 0x0009 0x000a}',
+ '(0, 3, 0) = {0x000c 0x000d 0x000e}',
+ '(0, 4, 0) = {0x0010 0x0011 0x0012}',
+ '(0, 5, 0) = {0x0014 0x0015 0x0016}'])
+
+ # ushort4
+ self.try_command('language renderscript allocation dump 27',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002 0x0003}',
+ '(1, 0, 0) = {0x0004 0x0005 0x0006 0x0007}',
+ '(2, 0, 0) = {0x0008 0x0009 0x000a 0x000b}',
+ '(3, 0, 0) = {0x000c 0x000d 0x000e 0x000f}',
+ '(4, 0, 0) = {0x0010 0x0011 0x0012 0x0013}',
+ '(5, 0, 0) = {0x0014 0x0015 0x0016 0x0017}'])
+
+ # uint
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # uint2
+ self.try_command('language renderscript allocation dump 29',
+ ['(0, 0, 0) = {0x00000000 0x00000001}',
+ '(1, 0, 0) = {0x00000002 0x00000003}',
+ '(2, 0, 0) = {0x00000004 0x00000005}',
+ '(3, 0, 0) = {0x00000006 0x00000007}',
+ '(4, 0, 0) = {0x00000008 0x00000009}',
+ '(5, 0, 0) = {0x0000000a 0x0000000b}',
+ '(6, 0, 0) = {0x0000000c 0x0000000d}',
+ '(7, 0, 0) = {0x0000000e 0x0000000f}',
+ '(8, 0, 0) = {0x00000010 0x00000011}',
+ '(9, 0, 0) = {0x00000012 0x00000013}',
+ '(10, 0, 0) = {0x00000014 0x00000015}',
+ '(11, 0, 0) = {0x00000016 0x00000017}'])
+
+ # uint3
+ self.try_command('language renderscript allocation dump 30',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002}',
+ '(1, 0, 0) = {0x00000004 0x00000005 0x00000006}',
+ '(2, 0, 0) = {0x00000008 0x00000009 0x0000000a}',
+ '(3, 0, 0) = {0x0000000c 0x0000000d 0x0000000e}',
+ '(4, 0, 0) = {0x00000010 0x00000011 0x00000012}',
+ '(5, 0, 0) = {0x00000014 0x00000015 0x00000016}'])
+
+ # uint4
+ self.try_command('language renderscript allocation dump 31',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002 0x00000003}',
+ '(0, 0, 1) = {0x00000004 0x00000005 0x00000006 0x00000007}',
+ '(0, 0, 2) = {0x00000008 0x00000009 0x0000000a 0x0000000b}',
+ '(0, 0, 3) = {0x0000000c 0x0000000d 0x0000000e 0x0000000f}',
+ '(0, 0, 4) = {0x00000010 0x00000011 0x00000012 0x00000013}',
+ '(0, 0, 5) = {0x00000014 0x00000015 0x00000016 0x00000017}'])
+
+ # ulong
+ self.try_command('language renderscript allocation dump 32',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(0, 1, 0) = 4',
+ '(1, 1, 0) = 5',
+ '(2, 1, 0) = 6',
+ '(3, 1, 0) = 7',
+ '(0, 2, 0) = 8',
+ '(1, 2, 0) = 9',
+ '(2, 2, 0) = 10',
+ '(3, 2, 0) = 11',
+ '(0, 0, 1) = 12',
+ '(1, 0, 1) = 13',
+ '(2, 0, 1) = 14',
+ '(3, 0, 1) = 15',
+ '(0, 1, 1) = 16',
+ '(1, 1, 1) = 17',
+ '(2, 1, 1) = 18',
+ '(3, 1, 1) = 19',
+ '(0, 2, 1) = 20',
+ '(1, 2, 1) = 21',
+ '(2, 2, 1) = 22',
+ '(3, 2, 1) = 23'])
+
+ # ulong2
+ self.try_command('language renderscript allocation dump 33',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001}',
+ '(1, 0, 0) = {0x0000000000000002 0x0000000000000003}',
+ '(2, 0, 0) = {0x0000000000000004 0x0000000000000005}',
+ '(3, 0, 0) = {0x0000000000000006 0x0000000000000007}',
+ '(4, 0, 0) = {0x0000000000000008 0x0000000000000009}',
+ '(5, 0, 0) = {0x000000000000000a 0x000000000000000b}',
+ '(6, 0, 0) = {0x000000000000000c 0x000000000000000d}',
+ '(7, 0, 0) = {0x000000000000000e 0x000000000000000f}',
+ '(8, 0, 0) = {0x0000000000000010 0x0000000000000011}',
+ '(9, 0, 0) = {0x0000000000000012 0x0000000000000013}',
+ '(10, 0, 0) = {0x0000000000000014 0x0000000000000015}',
+ '(11, 0, 0) = {0x0000000000000016 0x0000000000000017}'])
+
+ # ulong3
+ self.try_command('language renderscript allocation dump 34',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 0x0000000000000002}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 0x0000000000000006}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 0x000000000000000a}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d 0x000000000000000e}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 0x0000000000000012}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 0x0000000000000016}'])
+
+ # ulong4
+ self.try_command('language renderscript allocation dump 35',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 '
+ '0x0000000000000002 0x0000000000000003}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 '
+ '0x0000000000000006 0x0000000000000007}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 '
+ '0x000000000000000a 0x000000000000000b}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d '
+ '0x000000000000000e 0x000000000000000f}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 '
+ '0x0000000000000012 0x0000000000000013}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 '
+ '0x0000000000000016 0x0000000000000017}'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ # half
+ self.try_command('language renderscript allocation dump 36',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333252',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.199951',
+ '(6, 0, 0) = 0.166626',
+ '(7, 0, 0) = 0.142822',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111084',
+ '(10, 0, 0) = 0.0999756',
+ '(11, 0, 0) = 0.0908813',
+ '(12, 0, 0) = 0.083313',
+ '(13, 0, 0) = 0.0769043',
+ '(14, 0, 0) = 0.0714111',
+ '(15, 0, 0) = 0.0666504',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588379',
+ '(18, 0, 0) = 0.055542',
+ '(19, 0, 0) = 0.0526428',
+ '(20, 0, 0) = 0.0499878',
+ '(21, 0, 0) = 0.0476074',
+ '(22, 0, 0) = 0.0454407',
+ '(23, 0, 0) = 0.0434875'])
+
+ # half2
+ self.try_command('language renderscript allocation dump 37',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333252}',
+ '(2, 0, 0) = {0.25 0.199951}',
+ '(3, 0, 0) = {0.166626 0.142822}',
+ '(4, 0, 0) = {0.125 0.111084}',
+ '(5, 0, 0) = {0.0999756 0.0908813}',
+ '(6, 0, 0) = {0.083313 0.0769043}',
+ '(7, 0, 0) = {0.0714111 0.0666504}',
+ '(8, 0, 0) = {0.0625 0.0588379}',
+ '(9, 0, 0) = {0.055542 0.0526428}',
+ '(10, 0, 0) = {0.0499878 0.0476074}',
+ '(11, 0, 0) = {0.0454407 0.0434875}'])
+
+ # half3
+ self.try_command('language renderscript allocation dump 38',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(0, 1, 0) = {0.25 0.199951 0.166626}',
+ '(0, 2, 0) = {0.125 0.111084 0.0999756}',
+ '(0, 3, 0) = {0.083313 0.0769043 0.0714111}',
+ '(0, 4, 0) = {0.0625 0.0588379 0.055542}',
+ '(0, 5, 0) = {0.0499878 0.0476074 0.0454407}'])
+
+ # half4
+ self.try_command('language renderscript allocation dump 39',
+ ['(0, 0, 0) = {inf 1 0.5 0.333252}',
+ '(1, 0, 0) = {0.25 0.199951 0.166626 0.142822}',
+ '(2, 0, 0) = {0.125 0.111084 0.0999756 0.0908813}',
+ '(3, 0, 0) = {0.083313 0.0769043 0.0714111 0.0666504}',
+ '(4, 0, 0) = {0.0625 0.0588379 0.055542 0.0526428}',
+ '(5, 0, 0) = {0.0499878 0.0476074 0.0454407 0.0434875}'])
+
+ # float
+ self.try_command('language renderscript allocation dump 40',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166667',
+ '(7, 0, 0) = 0.142857',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909091',
+ '(12, 0, 0) = 0.0833333',
+ '(13, 0, 0) = 0.0769231',
+ '(14, 0, 0) = 0.0714286',
+ '(15, 0, 0) = 0.0666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235',
+ '(18, 0, 0) = 0.0555556',
+ '(19, 0, 0) = 0.0526316',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.047619',
+ '(22, 0, 0) = 0.0454545',
+ '(23, 0, 0) = 0.0434783'])
+
+ # float2
+ self.try_command('language renderscript allocation dump 41',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166667 0.142857}',
+ '(4, 0, 0) = {0.125 0.111111}',
+ '(5, 0, 0) = {0.1 0.0909091}',
+ '(6, 0, 0) = {0.0833333 0.0769231}',
+ '(7, 0, 0) = {0.0714286 0.0666667}',
+ '(8, 0, 0) = {0.0625 0.0588235}',
+ '(9, 0, 0) = {0.0555556 0.0526316}',
+ '(10, 0, 0) = {0.05 0.047619}',
+ '(11, 0, 0) = {0.0454545 0.0434783}'])
+
+ # float3
+ self.try_command('language renderscript allocation dump 42',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(1, 0, 0) = {0.25 0.2 0.166667}',
+ '(2, 0, 0) = {0.125 0.111111 0.1}',
+ '(3, 0, 0) = {0.0833333 0.0769231 0.0714286}',
+ '(4, 0, 0) = {0.0625 0.0588235 0.0555556}',
+ '(5, 0, 0) = {0.05 0.047619 0.0454545}'])
+
+ # float4
+ self.try_command('language renderscript allocation dump 43',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333}',
+ '(1, 0, 0) = {0.25 0.2 0.166667 0.142857}',
+ '(2, 0, 0) = {0.125 0.111111 0.1 0.0909091}',
+ '(0, 1, 0) = {0.0833333 0.0769231 0.0714286 0.0666667}',
+ '(1, 1, 0) = {0.0625 0.0588235 0.0555556 0.0526316}',
+ '(2, 1, 0) = {0.05 0.047619 0.0454545 0.0434783}'])
+
+ # double
+ self.try_command('language renderscript allocation dump 44',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333333333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166666666666667',
+ '(7, 0, 0) = 0.142857142857143',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111111111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909090909090909',
+ '(12, 0, 0) = 0.0833333333333333',
+ '(13, 0, 0) = 0.0769230769230769',
+ '(14, 0, 0) = 0.0714285714285714',
+ '(15, 0, 0) = 0.0666666666666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235294117647',
+ '(18, 0, 0) = 0.0555555555555556',
+ '(19, 0, 0) = 0.0526315789473684',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.0476190476190476',
+ '(22, 0, 0) = 0.0454545454545455',
+ '(23, 0, 0) = 0.0434782608695652'])
+
+ # double2
+ self.try_command('language renderscript allocation dump 45',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333333333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111}',
+ '(1, 0, 1) = {0.1 0.0909090909090909}',
+ '(2, 0, 1) = {0.0833333333333333 0.0769230769230769}',
+ '(3, 0, 1) = {0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647}',
+ '(1, 0, 2) = {0.0555555555555556 0.0526315789473684}',
+ '(2, 0, 2) = {0.05 0.0476190476190476}',
+ '(3, 0, 2) = {0.0454545454545455 0.0434782608695652}'])
+
+ # double3
+ self.try_command('language renderscript allocation dump 46',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 0.0555555555555556}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 0.0454545454545455}'])
+
+ # double4
+ self.try_command('language renderscript allocation dump 47',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333333333333}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1 0.0909090909090909}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 '
+ '0.0555555555555556 0.0526315789473684}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 '
+ '0.0454545454545455 0.0434782608695652}'])
+
+ # Delete kernel breakpoint on add_half_kernel
+ self.try_command('breakpoint del 3',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_allocation_file_cpp.py b/tests/lldb/tests/cpp/test_allocation_file_cpp.py
new file mode 100644
index 0000000..f676716
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_allocation_file_cpp.py
@@ -0,0 +1,195 @@
+'''Module that contains the test TestAllocationFileCpp.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationFileCpp(TestBaseRemote):
+ '''Tests saving the contents of allocs in a NDK app and reloading them.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of int2 allocation
+ file_int2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 12 ' +
+ file_int2,
+ ["Allocation written to file '%s'" % file_int2])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_int2))
+
+ # Load the file we just created, to assert the allocation contents are
+ # the same
+ self.try_command('language renderscript allocation load 12 ' +
+ file_int2,
+ ["Contents of file '%s' read into allocation 12" %
+ file_int2])
+ os.remove(file_int2)
+
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of uint allocation
+ file_uint = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 28 ' +
+ file_uint,
+ ["Allocation written to file '%s'" % file_uint])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_uint))
+
+ # Test loading file into allocation with an incompatible type 'short'
+ self.try_command('language renderscript allocation load 7 ' + file_uint,
+ ["Contents of file '%s' read into allocation 7" %
+ file_uint,
+ "Warning: Mismatched Element sizes",
+ "Warning: Mismatched Types",
+ "Warning: Mismatched allocation sizes"])
+
+ # Check result of size inconsistency, mapping 4-byte unsigned to 2-byte
+ # int
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 0',
+ '(2, 0, 0) = 1',
+ '(3, 0, 0) = 0',
+ '(4, 0, 0) = 2',
+ '(5, 0, 0) = 0',
+ '(6, 0, 0) = 3',
+ '(7, 0, 0) = 0',
+ '(8, 0, 0) = 4',
+ '(9, 0, 0) = 0',
+ '(10, 0, 0) = 5',
+ '(11, 0, 0) = 0',
+ '(12, 0, 0) = 6',
+ '(13, 0, 0) = 0',
+ '(14, 0, 0) = 7',
+ '(15, 0, 0) = 0',
+ '(16, 0, 0) = 8',
+ '(17, 0, 0) = 0',
+ '(18, 0, 0) = 9',
+ '(19, 0, 0) = 0',
+ '(20, 0, 0) = 10',
+ '(21, 0, 0) = 0',
+ '(22, 0, 0) = 11',
+ '(23, 0, 0) = 0'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ # Load uint allocation from save before square_kernel had been run
+ self.try_command('language renderscript allocation load 28 ' +
+ file_uint,
+ ["Contents of file '%s' read into allocation 28" %
+ file_uint])
+ os.remove(file_uint)
+
+ # Check contents are back to original
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ self.try_command('breakpoint delete 3', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_allocation_list_cpp.py b/tests/lldb/tests/cpp/test_allocation_list_cpp.py
new file mode 100644
index 0000000..59b4448
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_allocation_list_cpp.py
@@ -0,0 +1,444 @@
+'''Module that contains the test TestAllocationListCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationListCpp(TestBaseRemote):
+ '''Tests printing the details of all allocations in an ndk app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=anomalous-backslash-in-string
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test command line flag for single allocation
+ self.try_command('language renderscript allocation list -i 3',
+ [],
+ ['3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User',
+ '4:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: char2\n'
+ ' Data Kind: User',
+ '5:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char3\n'
+ ' Data Kind: User',
+ '6:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char4\n'
+ ' Data Kind: User',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '8:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 1, 2\)\n'
+ ' Data Type: short2\n'
+ ' Data Kind: User',
+ '9:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short3\n'
+ ' Data Kind: User',
+ '10:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short4\n'
+ ' Data Kind: User',
+ '11:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: int\n'
+ ' Data Kind: User',
+ '12:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: int2\n'
+ ' Data Kind: User',
+ '13:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: int3\n'
+ ' Data Kind: User',
+ '14:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: int4\n'
+ ' Data Kind: User',
+ '15:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: long\n'
+ ' Data Kind: User',
+ '16:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: long2\n'
+ ' Data Kind: User',
+ '17:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: long3\n'
+ ' Data Kind: User',
+ '18:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: long4\n'
+ ' Data Kind: User',
+ '19:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: bool\n'
+ ' Data Kind: User'
+ ])
+
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '20:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uchar\n'
+ ' Data Kind: User',
+ '21:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(2, 6, 0\)\n'
+ ' Data Type: uchar2\n'
+ ' Data Kind: User',
+ '22:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar3\n'
+ ' Data Kind: User',
+ '23:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: User',
+ '24:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: ushort\n'
+ ' Data Kind: User',
+ '25:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ushort2\n'
+ ' Data Kind: User',
+ '26:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: ushort3\n'
+ ' Data Kind: User',
+ '27:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ushort4\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '29:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: uint2\n'
+ ' Data Kind: User',
+ '30:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uint3\n'
+ ' Data Kind: User',
+ '31:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 1, 6\)\n'
+ ' Data Type: uint4\n'
+ ' Data Kind: User',
+ '32:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 3, 2\)\n'
+ ' Data Type: ulong\n'
+ ' Data Kind: User',
+ '33:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ulong2\n'
+ ' Data Kind: User',
+ '34:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong3\n'
+ ' Data Kind: User',
+ '35:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong4\n'
+ ' Data Kind: User'
+ ])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '36:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: half\n'
+ ' Data Kind: User',
+ '37:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: half2\n'
+ ' Data Kind: User',
+ '38:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: half3\n'
+ ' Data Kind: User',
+ '39:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: half4\n'
+ ' Data Kind: User',
+ '40:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: float\n'
+ ' Data Kind: User',
+ '41:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: float2\n'
+ ' Data Kind: User',
+ '42:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: float3\n'
+ ' Data Kind: User',
+ '43:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: float4\n'
+ ' Data Kind: User',
+ '44:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: double\n'
+ ' Data Kind: User',
+ '45:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 1, 3\)\n'
+ ' Data Type: double2\n'
+ ' Data Kind: User',
+ '46:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double3\n'
+ ' Data Kind: User',
+ '47:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double4\n'
+ ' Data Kind: User'
+ ])
+
+ self.try_command('breakpoint delete 3', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_backtrace_cpp.py b/tests/lldb/tests/cpp/test_backtrace_cpp.py
new file mode 100644
index 0000000..43fbc48
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_backtrace_cpp.py
@@ -0,0 +1,78 @@
+'''Module that contains the test TestBacktraceCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBacktraceCpp(TestBaseRemote):
+ '''Tests viewing the call stack of an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppBranchingFunCalls'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see three functions in bt:
+ # libRSCpuRef, kernel.expand and the kernel
+ 'frame #2:',
+ 'librs.simple',
+ 'simple_kernel'],
+ [r'simple\.rs:4[567]'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('b set_i',
+ ['Breakpoint 2',
+ 'set_i'],
+ [r'simple.rs:2[012]'])
+
+ self.try_command('breakpoint list',
+ ['set_i', 'resolved'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see five functions in bt:
+ # libRSCpuRef, kernel.expand, kernel and two functions
+ 'frame #4:',
+ 'librs.simple',
+ 'modify_i',
+ 'set_i'],
+ [r'simple\.rs:2[012]'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_coordinate_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_coordinate_cpp.py
new file mode 100644
index 0000000..8a581c0
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_coordinate_cpp.py
@@ -0,0 +1,161 @@
+'''Module that contains the test TestBreakpointCoordinateCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointCoordinateCpp(TestBaseRemote):
+ '''Tests breaking on a specific kernel invocation in a NDK app
+
+ Uses the -c option to specify the coordinate.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppAllocations'
+
+ def test_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 test_shutdown(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')
+
+ def _check_coordinates(self, (x_coord, y_coord, z_coord), kernel):
+ '''Run lldb commands to check that coordinates match expected values.
+
+ Args:
+ (x_coord, y_coord, z_coord): The expected coordinates.
+ kernel: String that is the name of the kernel function.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.allocs',
+ kernel])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (%d, %d, %d)' % (x_coord, y_coord,
+ z_coord)])
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # Test conditional coordinate in a two dimensions
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 3,7',
+ ['Conditional kernel breakpoint on coordinate 3, 7, 0',
+ 'Breakpoint(s) created'])
+
+ # We will delete this breakpoint before we hit it.
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 199,199',
+ ['Conditional kernel breakpoint on coordinate 199, 199, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((3, 7, 0), 'swizzle_kernel')
+
+ # Check breakpoints that have been hit are disabled
+ self.try_command('breakpoint list',
+ ["1: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1 Options: disabled",
+ "2: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on 199,199,0
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ # Test conditional coordinate in a single dimension
+ self.try_command('language renderscript kernel breakpoint set square_kernel -c 8',
+ ['Conditional kernel breakpoint on coordinate 8, 0, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((8, 0, 0), 'square_kernel')
+
+ # Test conditional coordinate in three dimensions
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,0,1',
+ ['Conditional kernel breakpoint on coordinate 0, 0, 1',
+ 'Breakpoint(s) created'])
+
+ # Test we can set more than one conditional kernel breakpoint and both
+ # will be hit
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,1,2',
+ ['Conditional kernel breakpoint on coordinate 0, 1, 2',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 0, 1), 'add_half_kernel')
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'add_half_kernel')
+
+ # Check we can see the coordinate from a function invoked by the kernel
+ self.try_command('break set -n half_helper',
+ ['librs.allocs.so`half_helper'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'half_helper')
+
+ # Delete helper function breakpoint
+ self.try_command('breakpoint delete 6',
+ ['1 breakpoints deleted'])
+
+ # Delete breakpoint which has already been disabled
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ # Check our delete breakpoints have been removed
+ self.try_command('breakpoint list',
+ ["3: RenderScript kernel breakpoint for 'square_kernel', locations = 1 Options: disabled",
+ "4: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled",
+ "5: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled"])
+
+ self.try_command('breakpoint delete 3', ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 4', ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 5', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_fileline_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_fileline_cpp.py
new file mode 100644
index 0000000..89de397
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_fileline_cpp.py
@@ -0,0 +1,52 @@
+'''Module that contains the test TestBreakpointFileLineCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointFileLineCpp(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a specific line of a RS file.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('bt',
+ ['librs.simple',
+ 'simple_kernel',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ['simple.rs',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_fileline_multiple_rs_files_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_fileline_multiple_rs_files_cpp.py
new file mode 100644
index 0000000..f44d7ef
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_fileline_multiple_rs_files_cpp.py
@@ -0,0 +1,68 @@
+'''Module that contains the test TestBreakpointFileLineMultipleRSFilesCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointFileLineMultipleRSFilesCpp(TestBaseRemote):
+ '''Tests setting a breakpoint on one of multiple RS files in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ 'at first.rs:12',
+ "name = 'CppMultipleRSFi'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('breakpoint set --file second.rs --line 7',
+ ['Breakpoint 2',
+ 'librs.second.so`second_kernel',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint list',
+ ['first.rs',
+ 'second.rs',
+ 'resolved = 1',
+ 'first.rs:12',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.second.so`second_kernel',
+ 'at second.rs:7',
+ "name = 'CppMultipleRSFi'",
+ 'stop reason = breakpoint 2'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 2', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_kernel_1_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_kernel_1_cpp.py
new file mode 100644
index 0000000..a7d29b3
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_kernel_1_cpp.py
@@ -0,0 +1,80 @@
+'''Module that contains the test TestBreakpointKernel1Cpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernel1Cpp(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel on an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ # Try set a breakpoint on a kernel which doesn't exist
+ self.try_command('language renderscript kernel breakpoint set imaginary_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 0 (pending)",
+ "'imaginary_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.simple',
+ 'simple_kernel'])
+
+ self.try_command('breakpoint list',
+ ["'imaginary_kernel', locations = 0 (pending)",
+ "'simple_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on kernel which doesn't exist
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_kernel_2_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_kernel_2_cpp.py
new file mode 100644
index 0000000..0a6ddb5
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_kernel_2_cpp.py
@@ -0,0 +1,48 @@
+'''Module that contains the test TestBreakpointKernel2Cpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernel2Cpp(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel on an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppInfiniteLoop'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.simple.so',
+ 'simple_kernel'],
+ [r'simple\.rs:1[01]'])
+
+ self.try_command('breakpoint list',
+ ['simple_kernel',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ '.so`simple_kernel',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_kernel_all_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_kernel_all_cpp.py
new file mode 100644
index 0000000..0f529c6
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_kernel_all_cpp.py
@@ -0,0 +1,81 @@
+'''Module that contains the test TestBreakpointKernelAllCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelAllCpp(TestBaseRemote):
+ '''Tests setting breakpoints on every RS kernel on an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 4',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_kernel_all_multiple_rs_files_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_kernel_all_multiple_rs_files_cpp.py
new file mode 100644
index 0000000..d7d9a1c
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_kernel_all_multiple_rs_files_cpp.py
@@ -0,0 +1,80 @@
+'''Module that contains the test TestBreakpointKernelAllMultipleRSFilesCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelAllMultipleRSFilesCpp(TestBaseRemote):
+ '''Tests setting bp's on all kernels in >1 kernel files in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 4', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_breakpoint_kernel_multiple_rs_files_cpp.py b/tests/lldb/tests/cpp/test_breakpoint_kernel_multiple_rs_files_cpp.py
new file mode 100644
index 0000000..e5baa29
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_breakpoint_kernel_multiple_rs_files_cpp.py
@@ -0,0 +1,74 @@
+'''Module that contains the test TestBreakpointKernelMultipleRSFilesCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelMultipleRSFilesCPP(TestBaseRemote):
+ '''Tests setting a breakpoint on kernels in multiple files in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set first_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first',
+ 'first_kernel',
+ "name = 'CppMultipleRSFi'",
+ 'stop reason = breakpoint 1'],
+ [r'at first\.rs:1[012]'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('language renderscript kernel breakpoint set second_kernel',
+ ['Breakpoint(s) created',
+ 'Breakpoint 2',
+ 'Breakpoint(s) created'],
+ [r"librs\.second\.so`second_kernel at second\.rs:[56]",])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint',
+ "librs.second.so`second_kernel"],
+ [r'second\.rs:[56]'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_call_api_funs_cpp.py b/tests/lldb/tests/cpp/test_call_api_funs_cpp.py
new file mode 100644
index 0000000..0d787ec
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_call_api_funs_cpp.py
@@ -0,0 +1,144 @@
+'''Module that contains the test TestCallApiFunsCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+from harness import RS_funs
+
+
+class TestCallApiFunsCpp(TestBaseRemote):
+ '''Tests calling of some RS API functions in an NDK app.
+
+ This tests that JITing works.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test
+ can be run with.
+ '''
+ return "CppKernelVariables"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test the atomics separately because we want to check the output
+ # AtomicAdd(1234, 2)
+ self.try_command('expr rsAtomicAdd(&int_global, 2)',
+ ['1234'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '1236'])
+
+ # AtomicAnd(2345, 333)
+ self.try_command('expr rsAtomicAnd(&uint_global, 333)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '265'])
+
+ # AtomicCas(1236, 1236, 2345)
+ self.try_command('expr rsAtomicCas(&int_global, 1236, 2345)',
+ ['1236'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2345'])
+
+ # AtomicDec(265)
+ self.try_command('expr rsAtomicDec(&uint_global)',
+ ['265'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '264'])
+
+ # AtomicInc(2345)
+ self.try_command('expr rsAtomicInc(&int_global)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2346'])
+
+ # AtomicMax(264, 3456)
+ self.try_command('expr rsAtomicMax(&uint_global, 3456)',
+ ['264'],
+ [r'\(uint(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3456'])
+
+ # AtomicMin(2346, 3)
+ self.try_command('expr rsAtomicMin(&int_global, 3)',
+ ['2346'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '3'])
+
+ # AtomicOr(3, 456)
+ self.try_command('expr rsAtomicOr(&int_global, 456)',
+ ['3'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '459'])
+
+ # AtomicSub(3456, 7)
+ self.try_command('expr rsAtomicSub(&uint_global, 7)',
+ ['3456'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3449'])
+
+ # AtomicXor(459, 89)
+ self.try_command('expr rsAtomicXor(&int_global, 89)',
+ ['459'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '402'])
+
+ for line in RS_funs.FUNC_LIST:
+ # build the expression
+ ret, expr = RS_funs.build_expr(line)
+ # query return type table
+ if ret in RS_funs.TYPE_MAP:
+ # evaluate the expression
+ self.try_command(expr, [], [RS_funs.TYPE_MAP[ret]])
+ else:
+ # evaluate the expression
+ self.try_command(expr, '('+ret+')')
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_coordinates_cpp.py b/tests/lldb/tests/cpp/test_coordinates_cpp.py
new file mode 100644
index 0000000..247d8b1
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_coordinates_cpp.py
@@ -0,0 +1,113 @@
+'''Module that contains the test TestCoordinatesCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestCoordinatesCpp(TestBaseRemote):
+ '''Tests the inspection of coordinates in an NDK app.
+
+ Tests the inspection of the range and dimension of coordinates as well
+ as the current coordinates.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_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 test_shutdown(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')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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))
+
+ 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', '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)])
diff --git a/tests/lldb/tests/cpp/test_dwarf_lang_cpp.py b/tests/lldb/tests/cpp/test_dwarf_lang_cpp.py
new file mode 100644
index 0000000..dd6df64
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_dwarf_lang_cpp.py
@@ -0,0 +1,29 @@
+'''Module that contains the test DWARF language attribute test for NDK.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestDWARFLangCpp(TestBaseRemote):
+ '''Tests the DWARF language attribute is present in RS kernels in a NDK.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status', [])
+ self.try_command('b simple_kernel', [])
+ self.try_command('process continue', [])
+
+ self.assert_lang_renderscript()
diff --git a/tests/lldb/tests/cpp/test_invoke_fun_cpp.py b/tests/lldb/tests/cpp/test_invoke_fun_cpp.py
new file mode 100644
index 0000000..971c31d
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_invoke_fun_cpp.py
@@ -0,0 +1,58 @@
+'''Module that contains the test TestInvokeFunCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestInvokeFunCpp(TestBaseRemote):
+ '''Tests debugging a function executed from C++ using invoke_*.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return "CppBranchingFunCalls"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --name addToGlobal',
+ ['Breakpoint 1', '(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint'],
+ [r'simple\.rs:5[789]'])
+
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint 2', 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'simple_kernel'],
+ [r'simple\.rs:4[567]'])
+
+ self.try_command('expr glob',
+ ['(int)',
+ '357'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_language_subcmds_cpp.py b/tests/lldb/tests/cpp/test_language_subcmds_cpp.py
new file mode 100644
index 0000000..782c96c
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_language_subcmds_cpp.py
@@ -0,0 +1,138 @@
+'''Module that contains the test TestLanguageSubcmdsCpp.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestLanguageSubcmdsCpp(TestBaseRemote):
+ '''Tests the 'language renderscript' subcommands on an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppDebugWaitAttach'
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ self.try_command('language',
+ [])
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked',
+ 'rsdAllocationInit',
+ 'rsdAllocationRead2D',
+ 'rsdScriptInit',
+ 'rsdScriptInvokeForEach',
+ 'rsdScriptInvokeForEachMulti',
+ 'rsdScriptSetGlobalVar'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel breakpoint',
+ ['all',
+ 'set'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (0, 0, 0)'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 3',
+ 'root',
+ 'simple_kernel',
+ 'other_kernel',
+ 'java_package_name: com.android.rs.cppwaitattach',
+ 'version:'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_language_subcmds_no_debug_cpp.py b/tests/lldb/tests/cpp/test_language_subcmds_no_debug_cpp.py
new file mode 100644
index 0000000..60e0e50
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_language_subcmds_no_debug_cpp.py
@@ -0,0 +1,120 @@
+'''Module that contains the test TestLanguageSubcmdsNoDebugCpp.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestLanguageSubcmdsNoDebugCpp(TestBaseRemote):
+ '''Tests the 'renderscript' subcommands on an NDK app without debug info.
+
+ In particular, module dump should report missing debug info.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppNoDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ # 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'
+ '',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info does not exist.',
+ 'Globals: 1',
+ 'gColor - variable identified, but not found in '
+ 'binary (symbol exists)',
+ 'Kernels: 3',
+ 'root',
+ 'simple_kernel',
+ 'other_kernel',
+ 'java_package_name: com.android.rs.cppwaitattach',
+ 'version'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_multiple_rs_files_cpp.py b/tests/lldb/tests/cpp/test_multiple_rs_files_cpp.py
new file mode 100644
index 0000000..700b3df
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_multiple_rs_files_cpp.py
@@ -0,0 +1,66 @@
+'''Module that contains the test TestMultipleRSFilesCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestMultipleRSFilesCpp(TestBaseRemote):
+ '''Tests some commands on an apk which has two rs files in a NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'CppMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first',
+ 'first_kernel',
+ 'at first.rs:12',
+ "name = 'CppMultipleRSFi'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'first'",
+ "Resource 'second'",
+ 'root',
+ 'first_kernel',
+ 'second_kernel'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '2 script instances'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.first.so',
+ 'librs.second.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 2',
+ 'root',
+ 'first_kernel',
+ 'second_kernel',
+ 'java_package_name: com.android.rs.cppmultiplersfiles',
+ 'version:'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_read_global_cpp.py b/tests/lldb/tests/cpp/test_read_global_cpp.py
new file mode 100644
index 0000000..48a3fcf
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_read_global_cpp.py
@@ -0,0 +1,313 @@
+'''Module that contains the test TestReadGlobalCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestReadGlobalCpp(TestBaseRemote):
+ '''Tests inspecting global variables of all types on an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output,
+ expected_regex=None):
+ '''Inspect a global and check for the output.
+
+ Run the "expr" and "target variable" commands on a given global and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + global_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('target variable',
+ ['Global variables for',
+ 'librs.simple',
+ "(uchar) uchar_global = '\\xea'",
+ '(short) short_global = -321',
+ '(ushort) ushort_global = 432',
+ '(int) int_global = 1234',
+ '(uint) uint_global = 2345',
+ '(float) float_global = 4.5',
+ '(ulong) ulong_global = 8888',
+ '(double) double_global = -456.5',
+ '(char2) char2_global = (11, -22)',
+ '(uchar2) uchar2_global = (0x21, 0x2c)',
+ '(short2) short2_global = (-555, 666)',
+ '(ushort2) ushort2_global = (777, 888)',
+ '(int2) int2_global = (999, -1111)',
+ '(uint2) uint2_global = (2222, 3333)',
+ '(float2) float2_global = (4.5, -5)',
+ '(long2) long2_global = (-4444, 5555)',
+ '(ulong2) ulong2_global = (6666, 7777)',
+ '(double2) double2_global = (88.5, -99)',
+ '(char3) char3_global = (11, -22, -33,',
+ '(uchar3) uchar3_global = (0x21, 0x2c, 0x37,',
+ '(short3) short3_global = (-555, 666, 777,',
+ '(ushort3) ushort3_global = (777, 888, 999,',
+ '(int3) int3_global = (999, -1111, 2222,',
+ '(uint3) uint3_global = (2222, 3333, 4444,',
+ '(float3) float3_global = (4.5, -5, -6.5,',
+ '(long3) long3_global = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_global = (6666, 7777, 8888,',
+ '(double3) double3_global = (88.5, -99, 111.5,',
+ '(char4) char4_global = (55, 11, -22, -33)',
+ '(uchar4) uchar4_global = (0xde, 0x21, 0x2c, 0x37)',
+ '(short4) short4_global = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_global = (666, 777, 888, 999)',
+ '(int4) int4_global = (888, 999, -1111, 2222)',
+ '(uint4) uint4_global = (1111, 2222, 3333, 4444)',
+ '(float4) float4_global = (3, 4.5, -5, -6.5)',
+ '(long4) long4_global = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_global = (5555, 6666, 7777, 8888)',
+ '(double4) double4_global = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_global = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_global = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_global = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_global = (4.5, 5.5, 6, 3)'],
+ [r"\((signed )?char\) char_global = '\\f'",
+ r'\((long )?long\) long_global = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_global('char_global',
+ ["'\\f'"],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_global('uchar_global',
+ ['(uchar)', "'\\xea'"])
+
+ self._try_inspecting_global('short_global',
+ ['(short)', '-321'])
+
+ self._try_inspecting_global('ushort_global',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_global('int_global',
+ ['(int)', '1234'])
+
+ self._try_inspecting_global('uint_global',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_global('float_global',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_global('long_global',
+ ['-77777'],
+ [r'\((long )?long\)'])
+
+ self._try_inspecting_global('ulong_global',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_global('double_global',
+ ['(double)', '-456.5'])
+
+
+ self._try_inspecting_global('char2_global',
+ ['(char2)', '(11, -22)'])
+
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
+
+ self._try_inspecting_global('matrix2x2_global',
+ ['(rs_matrix2x2)',
+ '= (m = (1, 2.5, 3, 4.5))'])
+
+ self._try_inspecting_global('matrix3x3_global',
+ ['(rs_matrix3x3)',
+ '= {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)'])
+
+ self._try_inspecting_global('matrix4x4_global',
+ ['(rs_matrix4x4)',
+ '= {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n'])
+
+ self._try_inspecting_global('quaternion_global',
+ ['(rs_quaternion)',
+ '(4.5, 5.5, 6, 3)'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_read_local_cpp.py b/tests/lldb/tests/cpp/test_read_local_cpp.py
new file mode 100644
index 0000000..80873fa
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_read_local_cpp.py
@@ -0,0 +1,309 @@
+'''Module that contains the test TestReadLocalCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestReadLocalCpp(TestBaseRemote):
+ '''Tests inspecting local variables of all types in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output,
+ expected_regex=None):
+ '''Inspect a local and check for the output.
+
+ Run the "expr" and "frame variable" commands on a given local and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ local_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + local_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('frame variable',
+ ["(uchar) uchar_local = 'b'",
+ '(short) short_local = -321',
+ '(ushort) ushort_local = 432',
+ '(int) int_local = 1234',
+ '(uint) uint_local = 2345',
+ '(float) float_local = 4.5',
+ '(ulong) ulong_local = 8888',
+ '(double) double_local = -456.5',
+ '(char2) char2_local = (-11, -22)',
+ '(uchar2) uchar2_local = (0x21, 0x2c)',
+ '(short2) short2_local = (-555, 666)',
+ '(ushort2) ushort2_local = (777, 888)',
+ '(int2) int2_local = (999, -1111)',
+ '(uint2) uint2_local = (2222, 3333)',
+ '(float2) float2_local = (4.5, -5)',
+ '(long2) long2_local = (-4444, 5555)',
+ '(ulong2) ulong2_local = (6666, 7777)',
+ '(double2) double2_local = (88.5, -99)',
+ '(char3) char3_local = (11, -22, -33,',
+ '(uchar3) uchar3_local = (0x21, 0x2c, 0x37,',
+ '(short3) short3_local = (-555, 666, 777,',
+ '(ushort3) ushort3_local = (777, 888, 999,',
+ '(int3) int3_local = (999, -1111, 2222,',
+ '(uint3) uint3_local = (2222, 3333, 4444,',
+ '(float3) float3_local = (4.5, -5, -6.5,',
+ '(long3) long3_local = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_local = (6666, 7777, 8888,',
+ '(double3) double3_local = (88.5, -99, 111.5,',
+ '(char4) char4_local = (55, 11, -22, -33)',
+ '(uchar4) uchar4_local = (0x16, 0x21, 0x2c, 0x37)',
+ '(short4) short4_local = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_local = (666, 777, 888, 999)',
+ '(int4) int4_local = (888, 999, -1111, 2222)',
+ '(uint4) uint4_local = (1111, 2222, 3333, 4444)',
+ '(float4) float4_local = (3, 4.5, -5, -6.5)',
+ '(long4) long4_local = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_local = (5555, 6666, 7777, 8888)',
+ '(double4) double4_local = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_local = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_local = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_local = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_local = (8, 9, 0.5, 7.5)'],
+ [r"\((signed )?char\) char_local = 'a'",
+ r'\((long )?long\) long_local = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_local('char_local',
+ ["'a'"],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('uchar_local',
+ ['(uchar)', "'b'"])
+
+ self._try_inspecting_local('short_local',
+ ['(short)', '-321'])
+
+ self._try_inspecting_local('ushort_local',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_local('int_local',
+ ['(int)', '1234'])
+
+ self._try_inspecting_local('uint_local',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_local('float_local',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_local('long_local',
+ ['-77777'], [r'\((long )?long\)'])
+
+ self._try_inspecting_local('ulong_local',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_local('double_local',
+ ['(double)', '-456.5'])
+
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(-11, -22)'])
+
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
+
+ self._try_inspecting_local('matrix2x2_local',
+ ['(rs_matrix2x2)',
+ '= (m = (1, 2.5, 3, 4.5))'])
+
+ self._try_inspecting_local('matrix3x3_local',
+ ['(rs_matrix3x3)',
+ '= {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)'])
+
+ self._try_inspecting_local('matrix4x4_local',
+ ['(rs_matrix4x4)',
+ '= {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n'])
+
+ self._try_inspecting_local('quaternion_local',
+ ['(rs_quaternion)',
+ '(8, 9, 0.5, 7.5)'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_rs_consts_cpp.py b/tests/lldb/tests/cpp/test_rs_consts_cpp.py
new file mode 100644
index 0000000..8370a17
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_rs_consts_cpp.py
@@ -0,0 +1,81 @@
+'''Module that contains the test TestRSConstsCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestRSConstsCpp(TestBaseRemote):
+ '''Tests examining the RenderScript constants in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('language renderscript kernel breakpoint set kernel',
+ [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Constants
+ self.try_command('expr M_1_PI',
+ ['0.318309'])
+
+ self.try_command('expr M_2_PI',
+ ['0.636619'])
+
+ self.try_command('expr M_2_SQRTPI',
+ ['1.128379'])
+
+ self.try_command('expr M_E',
+ ['2.718281'])
+
+ self.try_command('expr M_LN10',
+ ['2.302585'])
+
+ self.try_command('expr M_LN2',
+ ['0.693147'])
+
+ self.try_command('expr M_LOG10E',
+ ['0.434294'])
+
+ self.try_command('expr M_LOG2E',
+ ['1.442695'])
+
+ self.try_command('expr M_PI',
+ ['3.141592'])
+
+ self.try_command('expr M_PI_2',
+ ['1.570796'])
+
+ self.try_command('expr M_PI_4',
+ ['0.785398'])
+
+ self.try_command('expr M_SQRT1_2',
+ ['0.707106'])
+
+ self.try_command('expr M_SQRT2',
+ ['1.414213'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_source_step_cpp.py b/tests/lldb/tests/cpp/test_source_step_cpp.py
new file mode 100644
index 0000000..1125ef1
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_source_step_cpp.py
@@ -0,0 +1,90 @@
+'''Module that contains the test TestSourceStepCpp.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestSourceStepCpp(TestBaseRemote):
+ '''Test stepping through the source in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppBranchingFunCalls"
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 47',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'simple.rs:47'])
+
+ # set the source mapping
+ file_dir = os.path.dirname(os.path.realpath(__file__))
+ new_dir = os.path.join(file_dir, '..', '..', 'cpp', 'BranchingFunCalls')
+ self.set_src_map('simple.rs', new_dir)
+
+ self.try_command('process status',
+ ['-> 47',
+ 'int i = in;'])
+
+ #47 int i = in;
+ self.try_command('thread step-in',
+ ['-> 48'])
+ #48 float f = (float) i;
+ self.try_command('thread step-in',
+ ['-> 49'])
+ #49 modify_f(&f);
+ self.try_command('thread step-over',
+ ['-> 50'])
+ #50 modify_i(&i);
+ self.try_command('thread step-in',
+ ['-> 33'])
+ #33 int j = *i;
+ self.try_command('b -f simple.rs -l 38',
+ ['modify_i',
+ 'simple.rs:38'])
+ self.try_command('c',
+ ['stop reason = breakpoint',
+ 'simple.rs:38',
+ '-> 38'])
+ #38 set_i(i, 0);
+ # For the line number anything between #20 and #22 is fine
+ self.try_command('thread step-in',
+ [],
+ [r'-> 2[012]'])
+ #22 int tmp = b;
+ self.try_command('thread step-out',
+ ['-> 38'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_write_global_cpp.py b/tests/lldb/tests/cpp/test_write_global_cpp.py
new file mode 100644
index 0000000..8edfba9
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_write_global_cpp.py
@@ -0,0 +1,208 @@
+'''Module that contains the test TestWriteGlobalCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteGlobalCpp(TestBaseRemote):
+ '''Tests modifying global variables of all types in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_modifying_global(self, global_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-arguments
+ self.try_command('expr %s = %s%s' %
+ (global_name, data_type_in, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char_global', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ self._try_modifying_global('uchar_global', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_global('short_global', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_global('ushort_global', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_global('int_global', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_global('uint_global', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_global('float_global', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_global('long_global', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_global('ulong_global', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_global('double_global', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+
+ self._try_modifying_global('char2_global', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_global('uchar2_global', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ self._try_modifying_global('short2_global', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_global('ushort2_global', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_global('int2_global', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_global('uint2_global', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_global('float2_global', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_global('long2_global', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_global('ulong2_global', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_global('double2_global', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_global('char3_global', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_global('uchar3_global', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_global('short3_global', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ self._try_modifying_global('ushort3_global', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_global('int3_global', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_global('uint3_global', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_global('float3_global', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_global('long3_global', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_global('ulong3_global', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_global('double3_global', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_global('char4_global', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_global('uchar4_global', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_global('short4_global', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_global('ushort4_global', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ self._try_modifying_global('int4_global', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_global('uint4_global', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_global('float4_global', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_global('long4_global', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_global('ulong4_global', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_global('double4_global', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_write_global_element_cpp.py b/tests/lldb/tests/cpp/test_write_global_element_cpp.py
new file mode 100644
index 0000000..5317e49
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_write_global_element_cpp.py
@@ -0,0 +1,268 @@
+'''Module that contains the test TestWriteGlobalElementCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteGlobalElementCpp(TestBaseRemote):
+ '''Tests modifying elements of global vars of all types in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output):
+ '''Run the "expr" command on a given global and with a given output.
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + global_name, expected_output)
+
+ def _try_modifying_global(self, global_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (global_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-statements
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char2_global[0]', '2',
+ ['\'\\x02\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char2_global', ['(char2)', '(2, -22)'])
+
+ self._try_modifying_global('uchar2_global[1]', '3',
+ ['\'\\x03\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_global('short2_global[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_global('ushort2_global[1]', '55',
+ ['55'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_global('int2_global[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_global('uint2_global[1]', '777',
+ ['777'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_global('float2_global[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_global('long2_global[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_global('ulong2_global[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_global('double2_global[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -11)'])
+
+
+ self._try_modifying_global('char3_global[0]', '12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self._try_modifying_global('uchar3_global[1]', '\'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ self._try_modifying_global('short3_global[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_global('ushort3_global[0]', '1414',
+ ['1414'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_global('int3_global[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_global('uint3_global[1]', '161616',
+ ['161616'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_global('float3_global[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_global('long3_global[0]', '-181818181818',
+ ['-181818181818'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_global('ulong3_global[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_global('double3_global[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self._try_modifying_global('char4_global[0]', '-21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self._try_modifying_global('uchar4_global[1]', '22',
+ ['\'\\x16\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_global('short4_global[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ self._try_modifying_global('ushort4_global[3]', '24',
+ ['24'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_global('int4_global[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_global('uint4_global[1]', '26262',
+ ['26262'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_global('float4_global[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_global('long4_global[3]', '-28282828282',
+ ['-28282828282'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_global('ulong4_global[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_global('double4_global[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
+
+ self.try_command('breakpoint delete 1', ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['exited with status = 0'])
diff --git a/tests/lldb/tests/cpp/test_write_local_cpp.py b/tests/lldb/tests/cpp/test_write_local_cpp.py
new file mode 100644
index 0000000..f10e306
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_write_local_cpp.py
@@ -0,0 +1,202 @@
+'''Module that contains the test TestWriteLocalCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteLocalCpp(TestBaseRemote):
+ '''Tests modifying local variables of all types in an NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_modifying_local(self, local_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Try getting lldb to modify a local and check the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-arguments
+ self.try_command('expr %s = %s%s' % (local_name, data_type_in,
+ new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char_local', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ self._try_modifying_local('uchar_local', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_local('short_local', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_local('ushort_local', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_local('int_local', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_local('uint_local', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_local('float_local', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_local('long_local', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_local('ulong_local', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_local('double_local', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+ self._try_modifying_local('char2_local', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_local('uchar2_local', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ self._try_modifying_local('short2_local', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_local('ushort2_local', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_local('int2_local', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_local('uint2_local', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_local('float2_local', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_local('long2_local', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_local('ulong2_local', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_local('double2_local', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_local('char3_local', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_local('uchar3_local', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_local('short3_local', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ self._try_modifying_local('ushort3_local', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_local('int3_local', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_local('uint3_local', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_local('float3_local', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_local('long3_local', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_local('ulong3_local', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_local('double3_local', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_local('char4_local', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_local('uchar4_local', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_local('short4_local', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_local('ushort4_local', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ self._try_modifying_local('int4_local', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_local('uint4_local', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_local('float4_local', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_local('long4_local', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_local('ulong4_local', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_local('double4_local', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
diff --git a/tests/lldb/tests/cpp/test_write_local_element_cpp.py b/tests/lldb/tests/cpp/test_write_local_element_cpp.py
new file mode 100644
index 0000000..7099ce6
--- /dev/null
+++ b/tests/lldb/tests/cpp/test_write_local_element_cpp.py
@@ -0,0 +1,272 @@
+'''Module that contains the test TestWriteLocalElementCpp.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteLocalElementCpp(TestBaseRemote):
+ '''Tests modifying elements of local variables of all types in a NDK app.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "CppKernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output):
+ '''Run the "expr" command on a given local and with a given output.
+
+ Args:
+ local_name: String which is the name of the local to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + local_name, expected_output)
+
+ def _try_modifying_local(self, local_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a local and check for the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (local_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-statements
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char2_local[0]', '2',
+ ['2'], [r'\((signed )?char\)'])
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(2, -22)'])
+
+ self._try_modifying_local('uchar2_local[1]', '3',
+ ['3'], [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_local('short2_local[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_local('ushort2_local[1]', '55',
+ ['55'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_local('int2_local[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_local('uint2_local[1]', '777',
+ ['777'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_local('float2_local[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_local('long2_local[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_local('ulong2_local[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_local('double2_local[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -11)'])
+
+ # For some reason the result of some char and uchar expr is in hex and
+ # that of frame variable in decimal, so calling _try_modifying_local
+ # doesn't work, because it reuses the expected output for both commands.
+ self.try_command('expr char3_local[0] = 12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char3_local[0]',
+ ['12'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self.try_command('expr uchar3_local[1] = \'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar3_local[1]',
+ ['0x64'],
+ [r'\(u(nsigned )?char\)'])
+
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ self._try_modifying_local('short3_local[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_local('ushort3_local[0]', '1414',
+ ['1414'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_local('int3_local[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_local('uint3_local[1]', '161616',
+ ['161616'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_local('float3_local[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_local('long3_local[0]', '-181818181818',
+ ['-181818181818'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_local('ulong3_local[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_local('double3_local[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self.try_command('expr char4_local[0] = -21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char4_local[0]',
+ ['-21'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self.try_command('expr uchar4_local[1] = 22',
+ ['\'\\x16\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar4_local[1]',
+ ['0x16'],
+ [r'\(u(nsigned )?char\)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_local('short4_local[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ self._try_modifying_local('ushort4_local[3]', '24',
+ ['24'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_local('int4_local[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_local('uint4_local[1]', '26262',
+ ['26262'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_local('float4_local[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_local('long4_local[3]', '-28282828282',
+ ['-28282828282'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_local('ulong4_local[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_local('double4_local[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/harness/RS_funs.py b/tests/lldb/tests/harness/RS_funs.py
new file mode 100644
index 0000000..a6492af
--- /dev/null
+++ b/tests/lldb/tests/harness/RS_funs.py
@@ -0,0 +1,1385 @@
+'''A list of signatures for RS builtin functions and util functions for them.
+
+Function signature syntax is usually C-like, however, fixed values can also be
+specified for those functions where the input range is restricted.
+Lines in the function table beginning with - are comments.
+Also contains utility functions to build an LLDB expression from a single
+function line.
+'''
+
+import re
+
+# Remove blank and comment lines using a lambda.
+FUNC_LIST = filter(lambda line: line.strip()
+ and not line.strip().startswith('-'), '''
+- math functions
+
+uchar abs(char v);
+uchar2 abs(char2 v);
+uchar3 abs(char3 v);
+uchar4 abs(char4 v);
+uint abs(int v);
+uint2 abs(int2 v);
+uint3 abs(int3 v);
+uint4 abs(int4 v);
+ushort abs(short v);
+ushort2 abs(short2 v);
+ushort3 abs(short3 v);
+ushort4 abs(short4 v);
+
+float acos(float v);
+float2 acos(float2 v);
+float3 acos(float3 v);
+float4 acos(float4 v);
+
+float acosh(float v);
+float2 acosh(float2 v);
+float3 acosh(float3 v);
+float4 acosh(float4 v);
+
+float acospi(float v);
+float2 acospi(float2 v);
+float3 acospi(float3 v);
+float4 acospi(float4 v);
+
+float asin(float v);
+float2 asin(float2 v);
+float3 asin(float3 v);
+float4 asin(float4 v);
+
+float asinh(float v);
+float2 asinh(float2 v);
+float3 asinh(float3 v);
+float4 asinh(float4 v);
+
+float asinpi(float v);
+float2 asinpi(float2 v);
+float3 asinpi(float3 v);
+float4 asinpi(float4 v);
+
+float atan(float v);
+float2 atan(float2 v);
+float3 atan(float3 v);
+float4 atan(float4 v);
+
+float atan2(float numerator, float denominator);
+float2 atan2(float2 numerator, float2 denominator);
+float3 atan2(float3 numerator, float3 denominator);
+float4 atan2(float4 numerator, float4 denominator);
+
+float atan2pi(float numerator, float denominator);
+float2 atan2pi(float2 numerator, float2 denominator);
+float3 atan2pi(float3 numerator, float3 denominator);
+float4 atan2pi(float4 numerator, float4 denominator);
+
+float atanh(float v);
+float2 atanh(float2 v);
+float3 atanh(float3 v);
+float4 atanh(float4 v);
+
+float atanpi(float v);
+float2 atanpi(float2 v);
+float3 atanpi(float3 v);
+float4 atanpi(float4 v);
+
+float cbrt(float v);
+float2 cbrt(float2 v);
+float3 cbrt(float3 v);
+float4 cbrt(float4 v);
+
+float ceil(float v);
+float2 ceil(float2 v);
+float3 ceil(float3 v);
+float4 ceil(float4 v);
+
+char clamp(char value, char min_value, char max_value);
+char2 clamp(char2 value, char min_value, char max_value);
+char2 clamp(char2 value, char2 min_value, char2 max_value);
+char3 clamp(char3 value, char min_value, char max_value);
+char3 clamp(char3 value, char3 min_value, char3 max_value);
+char4 clamp(char4 value, char min_value, char max_value);
+char4 clamp(char4 value, char4 min_value, char4 max_value);
+float clamp(float value, float min_value, float max_value);
+float2 clamp(float2 value, float min_value, float max_value);
+float2 clamp(float2 value, float2 min_value, float2 max_value);
+float3 clamp(float3 value, float min_value, float max_value);
+float3 clamp(float3 value, float3 min_value, float3 max_value);
+float4 clamp(float4 value, float min_value, float max_value);
+float4 clamp(float4 value, float4 min_value, float4 max_value);
+int clamp(int value, int min_value, int max_value);
+int2 clamp(int2 value, int min_value, int max_value);
+int2 clamp(int2 value, int2 min_value, int2 max_value);
+int3 clamp(int3 value, int min_value, int max_value);
+int3 clamp(int3 value, int3 min_value, int3 max_value);
+int4 clamp(int4 value, int min_value, int max_value);
+int4 clamp(int4 value, int4 min_value, int4 max_value);
+long clamp(long value, long min_value, long max_value);
+long2 clamp(long2 value, long min_value, long max_value);
+long2 clamp(long2 value, long2 min_value, long2 max_value);
+long3 clamp(long3 value, long min_value, long max_value);
+long3 clamp(long3 value, long3 min_value, long3 max_value);
+long4 clamp(long4 value, long min_value, long max_value);
+long4 clamp(long4 value, long4 min_value, long4 max_value);
+short clamp(short value, short min_value, short max_value);
+short2 clamp(short2 value, short min_value, short max_value);
+short2 clamp(short2 value, short2 min_value, short2 max_value);
+short3 clamp(short3 value, short min_value, short max_value);
+short3 clamp(short3 value, short3 min_value, short3 max_value);
+short4 clamp(short4 value, short min_value, short max_value);
+short4 clamp(short4 value, short4 min_value, short4 max_value);
+uchar clamp(uchar value, uchar min_value, uchar max_value);
+uchar2 clamp(uchar2 value, uchar min_value, uchar max_value);
+uchar2 clamp(uchar2 value, uchar2 min_value, uchar2 max_value);
+uchar3 clamp(uchar3 value, uchar min_value, uchar max_value);
+uchar3 clamp(uchar3 value, uchar3 min_value, uchar3 max_value);
+uchar4 clamp(uchar4 value, uchar min_value, uchar max_value);
+uchar4 clamp(uchar4 value, uchar4 min_value, uchar4 max_value);
+uint clamp(uint value, uint min_value, uint max_value);
+uint2 clamp(uint2 value, uint min_value, uint max_value);
+uint2 clamp(uint2 value, uint2 min_value, uint2 max_value);
+uint3 clamp(uint3 value, uint min_value, uint max_value);
+uint3 clamp(uint3 value, uint3 min_value, uint3 max_value);
+uint4 clamp(uint4 value, uint min_value, uint max_value);
+uint4 clamp(uint4 value, uint4 min_value, uint4 max_value);
+ulong clamp(ulong value, ulong min_value, ulong max_value);
+ulong2 clamp(ulong2 value, ulong min_value, ulong max_value);
+ulong2 clamp(ulong2 value, ulong2 min_value, ulong2 max_value);
+ulong3 clamp(ulong3 value, ulong min_value, ulong max_value);
+ulong3 clamp(ulong3 value, ulong3 min_value, ulong3 max_value);
+ulong4 clamp(ulong4 value, ulong min_value, ulong max_value);
+ulong4 clamp(ulong4 value, ulong4 min_value, ulong4 max_value);
+ushort clamp(ushort value, ushort min_value, ushort max_value);
+ushort2 clamp(ushort2 value, ushort min_value, ushort max_value);
+ushort2 clamp(ushort2 value, ushort2 min_value, ushort2 max_value);
+ushort3 clamp(ushort3 value, ushort min_value, ushort max_value);
+ushort3 clamp(ushort3 value, ushort3 min_value, ushort3 max_value);
+ushort4 clamp(ushort4 value, ushort min_value, ushort max_value);
+ushort4 clamp(ushort4 value, ushort4 min_value, ushort4 max_value);
+
+char clz(char value);
+char2 clz(char2 value);
+char3 clz(char3 value);
+char4 clz(char4 value);
+int clz(int value);
+int2 clz(int2 value);
+int3 clz(int3 value);
+int4 clz(int4 value);
+short clz(short value);
+short2 clz(short2 value);
+short3 clz(short3 value);
+short4 clz(short4 value);
+uchar clz(uchar value);
+uchar2 clz(uchar2 value);
+uchar3 clz(uchar3 value);
+uchar4 clz(uchar4 value);
+uint clz(uint value);
+uint2 clz(uint2 value);
+uint3 clz(uint3 value);
+uint4 clz(uint4 value);
+ushort clz(ushort value);
+ushort2 clz(ushort2 value);
+ushort3 clz(ushort3 value);
+ushort4 clz(ushort4 value);
+
+float copysign(float magnitude_value, float sign_value);
+float2 copysign(float2 magnitude_value, float2 sign_value);
+float3 copysign(float3 magnitude_value, float3 sign_value);
+float4 copysign(float4 magnitude_value, float4 sign_value);
+
+float cos(float v);
+float2 cos(float2 v);
+float3 cos(float3 v);
+float4 cos(float4 v);
+
+float cosh(float v);
+float2 cosh(float2 v);
+float3 cosh(float3 v);
+float4 cosh(float4 v);
+
+float cospi(float v);
+float2 cospi(float2 v);
+float3 cospi(float3 v);
+float4 cospi(float4 v);
+
+float erf(float v);
+float2 erf(float2 v);
+float3 erf(float3 v);
+float4 erf(float4 v);
+
+float erfc(float v);
+float2 erfc(float2 v);
+float3 erfc(float3 v);
+float4 erfc(float4 v);
+
+float exp(float v);
+float2 exp(float2 v);
+float3 exp(float3 v);
+float4 exp(float4 v);
+
+float exp10(float v);
+float2 exp10(float2 v);
+float3 exp10(float3 v);
+float4 exp10(float4 v);
+
+float exp2(float v);
+float2 exp2(float2 v);
+float3 exp2(float3 v);
+float4 exp2(float4 v);
+
+float expm1(float v);
+float2 expm1(float2 v);
+float3 expm1(float3 v);
+float4 expm1(float4 v);
+
+float fabs(float v);
+float2 fabs(float2 v);
+float3 fabs(float3 v);
+float4 fabs(float4 v);
+
+float fdim(float a, float b);
+float2 fdim(float2 a, float2 b);
+float3 fdim(float3 a, float3 b);
+float4 fdim(float4 a, float4 b);
+
+float floor(float v);
+float2 floor(float2 v);
+float3 floor(float3 v);
+float4 floor(float4 v);
+
+float fma(float multiplicand1, float multiplicand2, float offset);
+float2 fma(float2 multiplicand1, float2 multiplicand2, float2 offset);
+float3 fma(float3 multiplicand1, float3 multiplicand2, float3 offset);
+float4 fma(float4 multiplicand1, float4 multiplicand2, float4 offset);
+
+float fmax(float a, float b);
+float2 fmax(float2 a, float b);
+float2 fmax(float2 a, float2 b);
+float3 fmax(float3 a, float b);
+float3 fmax(float3 a, float3 b);
+float4 fmax(float4 a, float b);
+float4 fmax(float4 a, float4 b);
+
+float fmin(float a, float b);
+float2 fmin(float2 a, float b);
+float2 fmin(float2 a, float2 b);
+float3 fmin(float3 a, float b);
+float3 fmin(float3 a, float3 b);
+float4 fmin(float4 a, float b);
+float4 fmin(float4 a, float4 b);
+
+float fmod(float numerator, float denominator);
+float2 fmod(float2 numerator, float2 denominator);
+float3 fmod(float3 numerator, float3 denominator);
+float4 fmod(float4 numerator, float4 denominator);
+
+float fract(float v, float* floor);
+float2 fract(float2 v, float2* floor);
+float3 fract(float3 v, float3* floor);
+float4 fract(float4 v, float4* floor);
+
+float frexp(float v, int* exponent);
+float2 frexp(float2 v, int2* exponent);
+float3 frexp(float3 v, int3* exponent);
+float4 frexp(float4 v, int4* exponent);
+
+float half_recip(float v);
+float2 half_recip(float2 v);
+float3 half_recip(float3 v);
+float4 half_recip(float4 v);
+
+float half_rsqrt(float v);
+float2 half_rsqrt(float2 v);
+float3 half_rsqrt(float3 v);
+float4 half_rsqrt(float4 v);
+
+float half_sqrt(float v);
+float2 half_sqrt(float2 v);
+float3 half_sqrt(float3 v);
+float4 half_sqrt(float4 v);
+
+float hypot(float a, float b);
+float2 hypot(float2 a, float2 b);
+float3 hypot(float3 a, float3 b);
+float4 hypot(float4 a, float4 b);
+
+int ilogb(float v);
+int2 ilogb(float2 v);
+int3 ilogb(float3 v);
+int4 ilogb(float4 v);
+
+float ldexp(float mantissa, int exponent);
+float2 ldexp(float2 mantissa, int exponent);
+float2 ldexp(float2 mantissa, int2 exponent);
+float3 ldexp(float3 mantissa, int exponent);
+float3 ldexp(float3 mantissa, int3 exponent);
+float4 ldexp(float4 mantissa, int exponent);
+float4 ldexp(float4 mantissa, int4 exponent);
+
+float lgamma(float v);
+float lgamma(float v, int* sign_of_gamma);
+float2 lgamma(float2 v);
+float2 lgamma(float2 v, int2* sign_of_gamma);
+float3 lgamma(float3 v);
+float3 lgamma(float3 v, int3* sign_of_gamma);
+float4 lgamma(float4 v);
+float4 lgamma(float4 v, int4* sign_of_gamma);
+
+float log(float v);
+float2 log(float2 v);
+float3 log(float3 v);
+float4 log(float4 v);
+
+float log10(float v);
+float2 log10(float2 v);
+float3 log10(float3 v);
+float4 log10(float4 v);
+
+float log1p(float v);
+float2 log1p(float2 v);
+float3 log1p(float3 v);
+float4 log1p(float4 v);
+
+float log2(float v);
+float2 log2(float2 v);
+float3 log2(float3 v);
+float4 log2(float4 v);
+
+float logb(float v);
+float2 logb(float2 v);
+float3 logb(float3 v);
+float4 logb(float4 v);
+
+float mad(float multiplicand1, float multiplicand2, float offset);
+float2 mad(float2 multiplicand1, float2 multiplicand2, float2 offset);
+float3 mad(float3 multiplicand1, float3 multiplicand2, float3 offset);
+float4 mad(float4 multiplicand1, float4 multiplicand2, float4 offset);
+
+char max(char a, char b);
+char2 max(char2 a, char2 b);
+char3 max(char3 a, char3 b);
+char4 max(char4 a, char4 b);
+float max(float a, float b);
+float2 max(float2 a, float2 b);
+float3 max(float3 a, float3 b);
+float4 max(float4 a, float4 b);
+int max(int a, int b);
+int2 max(int2 a, int2 b);
+int3 max(int3 a, int3 b);
+int4 max(int4 a, int4 b);
+long max(long a, long b);
+long2 max(long2 a, long2 b);
+long3 max(long3 a, long3 b);
+long4 max(long4 a, long4 b);
+short max(short a, short b);
+short2 max(short2 a, short2 b);
+short3 max(short3 a, short3 b);
+short4 max(short4 a, short4 b);
+uchar max(uchar a, uchar b);
+uchar2 max(uchar2 a, uchar2 b);
+uchar3 max(uchar3 a, uchar3 b);
+uchar4 max(uchar4 a, uchar4 b);
+uint max(uint a, uint b);
+uint2 max(uint2 a, uint2 b);
+uint3 max(uint3 a, uint3 b);
+uint4 max(uint4 a, uint4 b);
+ulong max(ulong a, ulong b);
+ulong2 max(ulong2 a, ulong2 b);
+ulong3 max(ulong3 a, ulong3 b);
+ulong4 max(ulong4 a, ulong4 b);
+ushort max(ushort a, ushort b);
+ushort2 max(ushort2 a, ushort2 b);
+ushort3 max(ushort3 a, ushort3 b);
+ushort4 max(ushort4 a, ushort4 b);
+
+char min(char a, char b);
+char2 min(char2 a, char2 b);
+char3 min(char3 a, char3 b);
+char4 min(char4 a, char4 b);
+float min(float a, float b);
+float2 min(float2 a, float2 b);
+float3 min(float3 a, float3 b);
+float4 min(float4 a, float4 b);
+int min(int a, int b);
+int2 min(int2 a, int2 b);
+int3 min(int3 a, int3 b);
+int4 min(int4 a, int4 b);
+long min(long a, long b);
+long2 min(long2 a, long2 b);
+long3 min(long3 a, long3 b);
+long4 min(long4 a, long4 b);
+short min(short a, short b);
+short2 min(short2 a, short2 b);
+short3 min(short3 a, short3 b);
+short4 min(short4 a, short4 b);
+uchar min(uchar a, uchar b);
+uchar2 min(uchar2 a, uchar2 b);
+uchar3 min(uchar3 a, uchar3 b);
+uchar4 min(uchar4 a, uchar4 b);
+uint min(uint a, uint b);
+uint2 min(uint2 a, uint2 b);
+uint3 min(uint3 a, uint3 b);
+uint4 min(uint4 a, uint4 b);
+ulong min(ulong a, ulong b);
+ulong2 min(ulong2 a, ulong2 b);
+ulong3 min(ulong3 a, ulong3 b);
+ulong4 min(ulong4 a, ulong4 b);
+ushort min(ushort a, ushort b);
+ushort2 min(ushort2 a, ushort2 b);
+ushort3 min(ushort3 a, ushort3 b);
+ushort4 min(ushort4 a, ushort4 b);
+
+float mix(float start, float stop, float fraction);
+float2 mix(float2 start, float2 stop, float fraction);
+float2 mix(float2 start, float2 stop, float2 fraction);
+float3 mix(float3 start, float3 stop, float fraction);
+float3 mix(float3 start, float3 stop, float3 fraction);
+float4 mix(float4 start, float4 stop, float fraction);
+float4 mix(float4 start, float4 stop, float4 fraction);
+
+float modf(float v, float* integral_part);
+float2 modf(float2 v, float2* integral_part);
+float3 modf(float3 v, float3* integral_part);
+float4 modf(float4 v, float4* integral_part);
+
+float nan(uint v);
+
+float native_acos(float v);
+float2 native_acos(float2 v);
+float3 native_acos(float3 v);
+float4 native_acos(float4 v);
+
+float native_acosh(float v);
+float2 native_acosh(float2 v);
+float3 native_acosh(float3 v);
+float4 native_acosh(float4 v);
+
+float native_acospi(float v);
+float2 native_acospi(float2 v);
+float3 native_acospi(float3 v);
+float4 native_acospi(float4 v);
+
+float native_asin(float v);
+float2 native_asin(float2 v);
+float3 native_asin(float3 v);
+float4 native_asin(float4 v);
+
+float native_asinh(float v);
+float2 native_asinh(float2 v);
+float3 native_asinh(float3 v);
+float4 native_asinh(float4 v);
+
+float native_asinpi(float v);
+float2 native_asinpi(float2 v);
+float3 native_asinpi(float3 v);
+float4 native_asinpi(float4 v);
+
+float native_atan(float v);
+float2 native_atan(float2 v);
+float3 native_atan(float3 v);
+float4 native_atan(float4 v);
+
+float native_atan2(float numerator, float denominator);
+float2 native_atan2(float2 numerator, float2 denominator);
+float3 native_atan2(float3 numerator, float3 denominator);
+float4 native_atan2(float4 numerator, float4 denominator);
+
+float native_atan2pi(float numerator, float denominator);
+float2 native_atan2pi(float2 numerator, float2 denominator);
+float3 native_atan2pi(float3 numerator, float3 denominator);
+float4 native_atan2pi(float4 numerator, float4 denominator);
+
+float native_atanh(float v);
+float2 native_atanh(float2 v);
+float3 native_atanh(float3 v);
+float4 native_atanh(float4 v);
+
+float native_atanpi(float v);
+float2 native_atanpi(float2 v);
+float3 native_atanpi(float3 v);
+float4 native_atanpi(float4 v);
+
+float native_cbrt(float v);
+float2 native_cbrt(float2 v);
+float3 native_cbrt(float3 v);
+float4 native_cbrt(float4 v);
+
+float native_cos(float v);
+float2 native_cos(float2 v);
+float3 native_cos(float3 v);
+float4 native_cos(float4 v);
+
+float native_cosh(float v);
+float2 native_cosh(float2 v);
+float3 native_cosh(float3 v);
+float4 native_cosh(float4 v);
+
+float native_cospi(float v);
+float2 native_cospi(float2 v);
+float3 native_cospi(float3 v);
+float4 native_cospi(float4 v);
+
+float native_divide(float left_vector, float right_vector);
+float2 native_divide(float2 left_vector, float2 right_vector);
+float3 native_divide(float3 left_vector, float3 right_vector);
+float4 native_divide(float4 left_vector, float4 right_vector);
+
+float native_exp(float v);
+float2 native_exp(float2 v);
+float3 native_exp(float3 v);
+float4 native_exp(float4 v);
+
+float native_exp10(float v);
+float2 native_exp10(float2 v);
+float3 native_exp10(float3 v);
+float4 native_exp10(float4 v);
+
+float native_exp2(float v);
+float2 native_exp2(float2 v);
+float3 native_exp2(float3 v);
+float4 native_exp2(float4 v);
+
+float native_expm1(float v);
+float2 native_expm1(float2 v);
+float3 native_expm1(float3 v);
+float4 native_expm1(float4 v);
+
+float native_hypot(float a, float b);
+float2 native_hypot(float2 a, float2 b);
+float3 native_hypot(float3 a, float3 b);
+float4 native_hypot(float4 a, float4 b);
+
+float native_log(float v);
+float2 native_log(float2 v);
+float3 native_log(float3 v);
+float4 native_log(float4 v);
+
+float native_log10(float v);
+float2 native_log10(float2 v);
+float3 native_log10(float3 v);
+float4 native_log10(float4 v);
+
+float native_log1p(float v);
+float2 native_log1p(float2 v);
+float3 native_log1p(float3 v);
+float4 native_log1p(float4 v);
+
+float native_log2(float v);
+float2 native_log2(float2 v);
+float3 native_log2(float3 v);
+float4 native_log2(float4 v);
+
+float native_powr(float base, float exponent);
+float2 native_powr(float2 base, float2 exponent);
+float3 native_powr(float3 base, float3 exponent);
+float4 native_powr(float4 base, float4 exponent);
+
+float native_recip(float v);
+float2 native_recip(float2 v);
+float3 native_recip(float3 v);
+float4 native_recip(float4 v);
+
+float native_rootn(float v, int n);
+float2 native_rootn(float2 v, int2 n);
+float3 native_rootn(float3 v, int3 n);
+float4 native_rootn(float4 v, int4 n);
+
+float native_rsqrt(float v);
+float2 native_rsqrt(float2 v);
+float3 native_rsqrt(float3 v);
+float4 native_rsqrt(float4 v);
+
+float native_sin(float v);
+float2 native_sin(float2 v);
+float3 native_sin(float3 v);
+float4 native_sin(float4 v);
+
+float native_sincos(float v, float* cos);
+float2 native_sincos(float2 v, float2* cos);
+float3 native_sincos(float3 v, float3* cos);
+float4 native_sincos(float4 v, float4* cos);
+
+float native_sinh(float v);
+float2 native_sinh(float2 v);
+float3 native_sinh(float3 v);
+float4 native_sinh(float4 v);
+
+float native_sinpi(float v);
+float2 native_sinpi(float2 v);
+float3 native_sinpi(float3 v);
+float4 native_sinpi(float4 v);
+
+float native_sqrt(float v);
+float2 native_sqrt(float2 v);
+float3 native_sqrt(float3 v);
+float4 native_sqrt(float4 v);
+
+float native_tan(float v);
+float2 native_tan(float2 v);
+float3 native_tan(float3 v);
+float4 native_tan(float4 v);
+
+float native_tanh(float v);
+float2 native_tanh(float2 v);
+float3 native_tanh(float3 v);
+float4 native_tanh(float4 v);
+
+float native_tanpi(float v);
+float2 native_tanpi(float2 v);
+float3 native_tanpi(float3 v);
+float4 native_tanpi(float4 v);
+
+float nextafter(float v, float target);
+float2 nextafter(float2 v, float2 target);
+float3 nextafter(float3 v, float3 target);
+float4 nextafter(float4 v, float4 target);
+
+float pow(float base, float exponent);
+float2 pow(float2 base, float2 exponent);
+float3 pow(float3 base, float3 exponent);
+float4 pow(float4 base, float4 exponent);
+
+float pown(float base, int exponent);
+float2 pown(float2 base, int2 exponent);
+float3 pown(float3 base, int3 exponent);
+float4 pown(float4 base, int4 exponent);
+
+float powr(float base, float exponent);
+float2 powr(float2 base, float2 exponent);
+float3 powr(float3 base, float3 exponent);
+float4 powr(float4 base, float4 exponent);
+
+float radians(float v);
+float2 radians(float2 v);
+float3 radians(float3 v);
+float4 radians(float4 v);
+
+float remainder(float numerator, float denominator);
+float2 remainder(float2 numerator, float2 denominator);
+float3 remainder(float3 numerator, float3 denominator);
+float4 remainder(float4 numerator, float4 denominator);
+
+float remquo(float numerator, float denominator, int* quotient);
+float2 remquo(float2 numerator, float2 denominator, int2* quotient);
+float3 remquo(float3 numerator, float3 denominator, int3* quotient);
+float4 remquo(float4 numerator, float4 denominator, int4* quotient);
+
+float rint(float v);
+float2 rint(float2 v);
+float3 rint(float3 v);
+float4 rint(float4 v);
+
+float rootn(float v, int n);
+float2 rootn(float2 v, int2 n);
+float3 rootn(float3 v, int3 n);
+float4 rootn(float4 v, int4 n);
+
+float round(float v);
+float2 round(float2 v);
+float3 round(float3 v);
+float4 round(float4 v);
+
+char rsClamp(char amount, char low, char high);
+int rsClamp(int amount, int low, int high);
+short rsClamp(short amount, short low, short high);
+uchar rsClamp(uchar amount, uchar low, uchar high);
+uint rsClamp(uint amount, uint low, uint high);
+ushort rsClamp(ushort amount, ushort low, ushort high);
+
+float rsFrac(float v);
+
+float rsRand(float max_value);
+float rsRand(float min_value, float max_value);
+int rsRand(int max_value);
+int rsRand(int min_value, int max_value);
+
+float rsqrt(float v);
+float2 rsqrt(float2 v);
+float3 rsqrt(float3 v);
+float4 rsqrt(float4 v);
+
+float sign(float v);
+float2 sign(float2 v);
+float3 sign(float3 v);
+float4 sign(float4 v);
+
+float sin(float v);
+float2 sin(float2 v);
+float3 sin(float3 v);
+float4 sin(float4 v);
+
+float sincos(float v, float* cos);
+float2 sincos(float2 v, float2* cos);
+float3 sincos(float3 v, float3* cos);
+float4 sincos(float4 v, float4* cos);
+
+float sinh(float v);
+float2 sinh(float2 v);
+float3 sinh(float3 v);
+float4 sinh(float4 v);
+
+float sinpi(float v);
+float2 sinpi(float2 v);
+float3 sinpi(float3 v);
+float4 sinpi(float4 v);
+
+float sqrt(float v);
+float2 sqrt(float2 v);
+float3 sqrt(float3 v);
+float4 sqrt(float4 v);
+
+float step(float edge, float v);
+float2 step(float edge, float2 v);
+float2 step(float2 edge, float v);
+float2 step(float2 edge, float2 v);
+float3 step(float edge, float3 v);
+float3 step(float3 edge, float v);
+float3 step(float3 edge, float3 v);
+float4 step(float edge, float4 v);
+float4 step(float4 edge, float v);
+float4 step(float4 edge, float4 v);
+
+float tan(float v);
+float2 tan(float2 v);
+float3 tan(float3 v);
+float4 tan(float4 v);
+
+float tanh(float v);
+float2 tanh(float2 v);
+float3 tanh(float3 v);
+float4 tanh(float4 v);
+
+float tanpi(float v);
+float2 tanpi(float2 v);
+float3 tanpi(float3 v);
+float4 tanpi(float4 v);
+
+float tgamma(float v);
+float2 tgamma(float2 v);
+float3 tgamma(float3 v);
+float4 tgamma(float4 v);
+
+float trunc(float v);
+float2 trunc(float2 v);
+float3 trunc(float3 v);
+float4 trunc(float4 v);
+
+uchar4 rsPackColorTo8888(float r, float g, float b);
+uchar4 rsPackColorTo8888(float r, float g, float b, float a);
+uchar4 rsPackColorTo8888(float3 color);
+uchar4 rsPackColorTo8888(float4 color);
+float4 rsUnpackColor8888(uchar4 c);
+
+float4 rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
+uchar4 rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
+
+- vector functions
+
+float3 cross(float3 left_vector, float3 right_vector);
+float4 cross(float4 left_vector, float4 right_vector);
+
+float distance(float left_vector, float right_vector);
+float distance(float2 left_vector, float2 right_vector);
+float distance(float3 left_vector, float3 right_vector);
+float distance(float4 left_vector, float4 right_vector);
+
+float dot(float left_vector, float right_vector);
+float dot(float2 left_vector, float2 right_vector);
+float dot(float3 left_vector, float3 right_vector);
+float dot(float4 left_vector, float4 right_vector);
+
+float fast_distance(float left_vector, float right_vector);
+float fast_distance(float2 left_vector, float2 right_vector);
+float fast_distance(float3 left_vector, float3 right_vector);
+float fast_distance(float4 left_vector, float4 right_vector);
+
+float fast_length(float v);
+float fast_length(float2 v);
+float fast_length(float3 v);
+float fast_length(float4 v);
+
+float fast_normalize(float v);
+float2 fast_normalize(float2 v);
+float3 fast_normalize(float3 v);
+float4 fast_normalize(float4 v);
+
+float length(float v);
+float length(float2 v);
+float length(float3 v);
+float length(float4 v);
+
+float native_distance(float left_vector, float right_vector);
+float native_distance(float2 left_vector, float2 right_vector);
+float native_distance(float3 left_vector, float3 right_vector);
+float native_distance(float4 left_vector, float4 right_vector);
+
+float native_length(float v);
+float native_length(float2 v);
+float native_length(float3 v);
+float native_length(float4 v);
+
+float native_normalize(float v);
+float2 native_normalize(float2 v);
+float3 native_normalize(float3 v);
+float4 native_normalize(float4 v);
+
+float normalize(float v);
+float2 normalize(float2 v);
+float3 normalize(float3 v);
+float4 normalize(float4 v);
+
+- conversion functions
+
+char2 convert_char2(char2 v);
+char2 convert_char2(double2 v);
+char2 convert_char2(float2 v);
+char2 convert_char2(int2 v);
+char2 convert_char2(long2 v);
+char2 convert_char2(short2 v);
+char2 convert_char2(uchar2 v);
+char2 convert_char2(uint2 v);
+char2 convert_char2(ulong2 v);
+char2 convert_char2(ushort2 v);
+
+char3 convert_char3(char3 v);
+char3 convert_char3(double3 v);
+char3 convert_char3(float3 v);
+char3 convert_char3(int3 v);
+char3 convert_char3(long3 v);
+char3 convert_char3(short3 v);
+char3 convert_char3(uchar3 v);
+char3 convert_char3(uint3 v);
+char3 convert_char3(ulong3 v);
+char3 convert_char3(ushort3 v);
+
+char4 convert_char4(char4 v);
+char4 convert_char4(double4 v);
+char4 convert_char4(float4 v);
+char4 convert_char4(int4 v);
+char4 convert_char4(long4 v);
+char4 convert_char4(short4 v);
+char4 convert_char4(uchar4 v);
+char4 convert_char4(uint4 v);
+char4 convert_char4(ulong4 v);
+char4 convert_char4(ushort4 v);
+
+double2 convert_double2(char2 v);
+double2 convert_double2(double2 v);
+double2 convert_double2(float2 v);
+double2 convert_double2(int2 v);
+double2 convert_double2(long2 v);
+double2 convert_double2(short2 v);
+double2 convert_double2(uchar2 v);
+double2 convert_double2(uint2 v);
+double2 convert_double2(ulong2 v);
+double2 convert_double2(ushort2 v);
+
+double3 convert_double3(char3 v);
+double3 convert_double3(double3 v);
+double3 convert_double3(float3 v);
+double3 convert_double3(int3 v);
+double3 convert_double3(long3 v);
+double3 convert_double3(short3 v);
+double3 convert_double3(uchar3 v);
+double3 convert_double3(uint3 v);
+double3 convert_double3(ulong3 v);
+double3 convert_double3(ushort3 v);
+
+double4 convert_double4(char4 v);
+double4 convert_double4(double4 v);
+double4 convert_double4(float4 v);
+double4 convert_double4(int4 v);
+double4 convert_double4(long4 v);
+double4 convert_double4(short4 v);
+double4 convert_double4(uchar4 v);
+double4 convert_double4(uint4 v);
+double4 convert_double4(ulong4 v);
+double4 convert_double4(ushort4 v);
+
+float2 convert_float2(char2 v);
+float2 convert_float2(double2 v);
+float2 convert_float2(float2 v);
+float2 convert_float2(int2 v);
+float2 convert_float2(long2 v);
+float2 convert_float2(short2 v);
+float2 convert_float2(uchar2 v);
+float2 convert_float2(uint2 v);
+float2 convert_float2(ulong2 v);
+float2 convert_float2(ushort2 v);
+
+float3 convert_float3(char3 v);
+float3 convert_float3(double3 v);
+float3 convert_float3(float3 v);
+float3 convert_float3(int3 v);
+float3 convert_float3(long3 v);
+float3 convert_float3(short3 v);
+float3 convert_float3(uchar3 v);
+float3 convert_float3(uint3 v);
+float3 convert_float3(ulong3 v);
+float3 convert_float3(ushort3 v);
+
+float4 convert_float4(char4 v);
+float4 convert_float4(double4 v);
+float4 convert_float4(float4 v);
+float4 convert_float4(int4 v);
+float4 convert_float4(long4 v);
+float4 convert_float4(short4 v);
+float4 convert_float4(uchar4 v);
+float4 convert_float4(uint4 v);
+float4 convert_float4(ulong4 v);
+float4 convert_float4(ushort4 v);
+
+int2 convert_int2(char2 v);
+int2 convert_int2(double2 v);
+int2 convert_int2(float2 v);
+int2 convert_int2(int2 v);
+int2 convert_int2(long2 v);
+int2 convert_int2(short2 v);
+int2 convert_int2(uchar2 v);
+int2 convert_int2(uint2 v);
+int2 convert_int2(ulong2 v);
+int2 convert_int2(ushort2 v);
+
+int3 convert_int3(char3 v);
+int3 convert_int3(double3 v);
+int3 convert_int3(float3 v);
+int3 convert_int3(int3 v);
+int3 convert_int3(long3 v);
+int3 convert_int3(short3 v);
+int3 convert_int3(uchar3 v);
+int3 convert_int3(uint3 v);
+int3 convert_int3(ulong3 v);
+int3 convert_int3(ushort3 v);
+
+int4 convert_int4(char4 v);
+int4 convert_int4(double4 v);
+int4 convert_int4(float4 v);
+int4 convert_int4(int4 v);
+int4 convert_int4(long4 v);
+int4 convert_int4(short4 v);
+int4 convert_int4(uchar4 v);
+int4 convert_int4(uint4 v);
+int4 convert_int4(ulong4 v);
+int4 convert_int4(ushort4 v);
+
+long2 convert_long2(char2 v);
+long2 convert_long2(double2 v);
+long2 convert_long2(float2 v);
+long2 convert_long2(int2 v);
+long2 convert_long2(long2 v);
+long2 convert_long2(short2 v);
+long2 convert_long2(uchar2 v);
+long2 convert_long2(uint2 v);
+long2 convert_long2(ulong2 v);
+long2 convert_long2(ushort2 v);
+
+long3 convert_long3(char3 v);
+long3 convert_long3(double3 v);
+long3 convert_long3(float3 v);
+long3 convert_long3(int3 v);
+long3 convert_long3(long3 v);
+long3 convert_long3(short3 v);
+long3 convert_long3(uchar3 v);
+long3 convert_long3(uint3 v);
+long3 convert_long3(ulong3 v);
+long3 convert_long3(ushort3 v);
+
+long4 convert_long4(char4 v);
+long4 convert_long4(double4 v);
+long4 convert_long4(float4 v);
+long4 convert_long4(int4 v);
+long4 convert_long4(long4 v);
+long4 convert_long4(short4 v);
+long4 convert_long4(uchar4 v);
+long4 convert_long4(uint4 v);
+long4 convert_long4(ulong4 v);
+long4 convert_long4(ushort4 v);
+
+short2 convert_short2(char2 v);
+short2 convert_short2(double2 v);
+short2 convert_short2(float2 v);
+short2 convert_short2(int2 v);
+short2 convert_short2(long2 v);
+short2 convert_short2(short2 v);
+short2 convert_short2(uchar2 v);
+short2 convert_short2(uint2 v);
+short2 convert_short2(ulong2 v);
+short2 convert_short2(ushort2 v);
+
+short3 convert_short3(char3 v);
+short3 convert_short3(double3 v);
+short3 convert_short3(float3 v);
+short3 convert_short3(int3 v);
+short3 convert_short3(long3 v);
+short3 convert_short3(short3 v);
+short3 convert_short3(uchar3 v);
+short3 convert_short3(uint3 v);
+short3 convert_short3(ulong3 v);
+short3 convert_short3(ushort3 v);
+
+short4 convert_short4(char4 v);
+short4 convert_short4(double4 v);
+short4 convert_short4(float4 v);
+short4 convert_short4(int4 v);
+short4 convert_short4(long4 v);
+short4 convert_short4(short4 v);
+short4 convert_short4(uchar4 v);
+short4 convert_short4(uint4 v);
+short4 convert_short4(ulong4 v);
+short4 convert_short4(ushort4 v);
+
+uchar2 convert_uchar2(char2 v);
+uchar2 convert_uchar2(double2 v);
+uchar2 convert_uchar2(float2 v);
+uchar2 convert_uchar2(int2 v);
+uchar2 convert_uchar2(long2 v);
+uchar2 convert_uchar2(short2 v);
+uchar2 convert_uchar2(uchar2 v);
+uchar2 convert_uchar2(uint2 v);
+uchar2 convert_uchar2(ulong2 v);
+uchar2 convert_uchar2(ushort2 v);
+
+uchar3 convert_uchar3(char3 v);
+uchar3 convert_uchar3(double3 v);
+uchar3 convert_uchar3(float3 v);
+uchar3 convert_uchar3(int3 v);
+uchar3 convert_uchar3(long3 v);
+uchar3 convert_uchar3(short3 v);
+uchar3 convert_uchar3(uchar3 v);
+uchar3 convert_uchar3(uint3 v);
+uchar3 convert_uchar3(ulong3 v);
+uchar3 convert_uchar3(ushort3 v);
+
+uchar4 convert_uchar4(char4 v);
+uchar4 convert_uchar4(double4 v);
+uchar4 convert_uchar4(float4 v);
+uchar4 convert_uchar4(int4 v);
+uchar4 convert_uchar4(long4 v);
+uchar4 convert_uchar4(short4 v);
+uchar4 convert_uchar4(uchar4 v);
+uchar4 convert_uchar4(uint4 v);
+uchar4 convert_uchar4(ulong4 v);
+uchar4 convert_uchar4(ushort4 v);
+
+uint2 convert_uint2(char2 v);
+uint2 convert_uint2(double2 v);
+uint2 convert_uint2(float2 v);
+uint2 convert_uint2(int2 v);
+uint2 convert_uint2(long2 v);
+uint2 convert_uint2(short2 v);
+uint2 convert_uint2(uchar2 v);
+uint2 convert_uint2(uint2 v);
+uint2 convert_uint2(ulong2 v);
+uint2 convert_uint2(ushort2 v);
+
+uint3 convert_uint3(char3 v);
+uint3 convert_uint3(double3 v);
+uint3 convert_uint3(float3 v);
+uint3 convert_uint3(int3 v);
+uint3 convert_uint3(long3 v);
+uint3 convert_uint3(short3 v);
+uint3 convert_uint3(uchar3 v);
+uint3 convert_uint3(uint3 v);
+uint3 convert_uint3(ulong3 v);
+uint3 convert_uint3(ushort3 v);
+
+uint4 convert_uint4(char4 v);
+uint4 convert_uint4(double4 v);
+uint4 convert_uint4(float4 v);
+uint4 convert_uint4(int4 v);
+uint4 convert_uint4(long4 v);
+uint4 convert_uint4(short4 v);
+uint4 convert_uint4(uchar4 v);
+uint4 convert_uint4(uint4 v);
+uint4 convert_uint4(ulong4 v);
+uint4 convert_uint4(ushort4 v);
+
+ulong2 convert_ulong2(char2 v);
+ulong2 convert_ulong2(double2 v);
+ulong2 convert_ulong2(float2 v);
+ulong2 convert_ulong2(int2 v);
+ulong2 convert_ulong2(long2 v);
+ulong2 convert_ulong2(short2 v);
+ulong2 convert_ulong2(uchar2 v);
+ulong2 convert_ulong2(uint2 v);
+ulong2 convert_ulong2(ulong2 v);
+ulong2 convert_ulong2(ushort2 v);
+
+ulong3 convert_ulong3(char3 v);
+ulong3 convert_ulong3(double3 v);
+ulong3 convert_ulong3(float3 v);
+ulong3 convert_ulong3(int3 v);
+ulong3 convert_ulong3(long3 v);
+ulong3 convert_ulong3(short3 v);
+ulong3 convert_ulong3(uchar3 v);
+ulong3 convert_ulong3(uint3 v);
+ulong3 convert_ulong3(ulong3 v);
+ulong3 convert_ulong3(ushort3 v);
+
+ulong4 convert_ulong4(char4 v);
+ulong4 convert_ulong4(double4 v);
+ulong4 convert_ulong4(float4 v);
+ulong4 convert_ulong4(int4 v);
+ulong4 convert_ulong4(long4 v);
+ulong4 convert_ulong4(short4 v);
+ulong4 convert_ulong4(uchar4 v);
+ulong4 convert_ulong4(uint4 v);
+ulong4 convert_ulong4(ulong4 v);
+ulong4 convert_ulong4(ushort4 v);
+
+ushort2 convert_ushort2(char2 v);
+ushort2 convert_ushort2(double2 v);
+ushort2 convert_ushort2(float2 v);
+ushort2 convert_ushort2(int2 v);
+ushort2 convert_ushort2(long2 v);
+ushort2 convert_ushort2(short2 v);
+ushort2 convert_ushort2(uchar2 v);
+ushort2 convert_ushort2(uint2 v);
+ushort2 convert_ushort2(ulong2 v);
+ushort2 convert_ushort2(ushort2 v);
+
+ushort3 convert_ushort3(char3 v);
+ushort3 convert_ushort3(double3 v);
+ushort3 convert_ushort3(float3 v);
+ushort3 convert_ushort3(int3 v);
+ushort3 convert_ushort3(long3 v);
+ushort3 convert_ushort3(short3 v);
+ushort3 convert_ushort3(uchar3 v);
+ushort3 convert_ushort3(uint3 v);
+ushort3 convert_ushort3(ulong3 v);
+ushort3 convert_ushort3(ushort3 v);
+
+ushort4 convert_ushort4(char4 v);
+ushort4 convert_ushort4(double4 v);
+ushort4 convert_ushort4(float4 v);
+ushort4 convert_ushort4(int4 v);
+ushort4 convert_ushort4(long4 v);
+ushort4 convert_ushort4(short4 v);
+ushort4 convert_ushort4(uchar4 v);
+ushort4 convert_ushort4(uint4 v);
+ushort4 convert_ushort4(ulong4 v);
+ushort4 convert_ushort4(ushort4 v);
+
+uchar4 rsPackColorTo8888(float r, float g, float b);
+uchar4 rsPackColorTo8888(float r, float g, float b, float a);
+uchar4 rsPackColorTo8888(float3 color);
+uchar4 rsPackColorTo8888(float4 color);
+
+float4 rsUnpackColor8888(uchar4 c);
+
+float4 rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
+
+uchar4 rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
+
+- matrix functions, some of these are not supported yet
+
+-bool rsMatrixInverse(rs_matrix4x4* m);
+
+-bool rsMatrixInverseTranspose(rs_matrix4x4* m);
+
+-void rsMatrixLoad(rs_matrix2x2* destination, float* array);
+-void rsMatrixLoad(rs_matrix2x2* destination, rs_matrix2x2* source);
+-void rsMatrixLoad(rs_matrix3x3* destination, float* array);
+-void rsMatrixLoad(rs_matrix3x3* destination, rs_matrix3x3* source);
+-void rsMatrixLoad(rs_matrix4x4* destination, float* array);
+-void rsMatrixLoad(rs_matrix4x4* destination, rs_matrix2x2* source);
+-void rsMatrixLoad(rs_matrix4x4* destination, rs_matrix3x3* source);
+-void rsMatrixLoad(rs_matrix4x4* destination, rs_matrix4x4* source);
+
+-void rsMatrixLoadFrustum(rs_matrix4x4* m, float left, float right, float bottom, float top, float near, float far);
+
+-void rsMatrixLoadIdentity(rs_matrix2x2* m);
+-void rsMatrixLoadIdentity(rs_matrix3x3* m);
+-void rsMatrixLoadIdentity(rs_matrix4x4* m);
+
+-void rsMatrixLoadMultiply(rs_matrix2x2* m, rs_matrix2x2* lhs, rs_matrix2x2* rhs);
+-void rsMatrixLoadMultiply(rs_matrix3x3* m, rs_matrix3x3* lhs, rs_matrix3x3* rhs);
+-void rsMatrixLoadMultiply(rs_matrix4x4* m, rs_matrix4x4* lhs, rs_matrix4x4* rhs);
+
+-void rsMatrixLoadOrtho(rs_matrix4x4* m, float left, float right, float bottom, float top, float near, float far);
+
+-void rsMatrixLoadPerspective(rs_matrix4x4* m, float fovy, float aspect, float near, float far);
+
+-void rsMatrixLoadRotate(rs_matrix4x4* m, float rot, float x, float y, float z);
+
+-void rsMatrixLoadScale(rs_matrix4x4* m, float x, float y, float z);
+
+-void rsMatrixLoadTranslate(rs_matrix4x4* m, float x, float y, float z);
+
+float2 rsMatrixMultiply(rs_matrix2x2* m, float2 in);
+float3 rsMatrixMultiply(rs_matrix3x3* m, float2 in);
+float3 rsMatrixMultiply(rs_matrix3x3* m, float3 in);
+float4 rsMatrixMultiply(rs_matrix4x4* m, float2 in);
+float4 rsMatrixMultiply(rs_matrix4x4* m, float3 in);
+float4 rsMatrixMultiply(rs_matrix4x4* m, float4 in);
+void rsMatrixMultiply(rs_matrix2x2* m, rs_matrix2x2* rhs);
+void rsMatrixMultiply(rs_matrix3x3* m, rs_matrix3x3* rhs);
+void rsMatrixMultiply(rs_matrix4x4* m, rs_matrix4x4* rhs);
+
+-void rsMatrixRotate(rs_matrix4x4* m, float rot, float x, float y, float z);
+
+-void rsMatrixScale(rs_matrix4x4* m, float x, float y, float z);
+
+void rsMatrixSet(rs_matrix2x2* m, 0, 1, float v);
+void rsMatrixSet(rs_matrix3x3* m, 2, 0, float v);
+void rsMatrixSet(rs_matrix4x4* m, 1, 3, float v);
+
+-void rsMatrixTranslate(rs_matrix4x4* m, float x, float y, float z);
+
+-void rsMatrixTranspose(rs_matrix2x2* m);
+-void rsMatrixTranspose(rs_matrix3x3* m);
+-void rsMatrixTranspose(rs_matrix4x4* m);
+
+- quaternion functions
+
+void rsQuaternionAdd(rs_quaternion* q, rs_quaternion* rhs);
+
+void rsQuaternionConjugate(rs_quaternion* q);
+
+float rsQuaternionDot(rs_quaternion* q0, rs_quaternion* q1);
+
+void rsQuaternionGetMatrixUnit(rs_matrix4x4* m, rs_quaternion* q);
+
+void rsQuaternionLoadRotate(rs_quaternion* q, float rot, float x, float y, float z);
+
+void rsQuaternionLoadRotateUnit(rs_quaternion* q, float rot, float x, float y, float z);
+
+void rsQuaternionMultiply(rs_quaternion* q, rs_quaternion* rhs);
+void rsQuaternionMultiply(rs_quaternion* q, float scalar);
+
+void rsQuaternionNormalize(rs_quaternion* q);
+
+void rsQuaternionSet(rs_quaternion* q, rs_quaternion* rhs);
+void rsQuaternionSet(rs_quaternion* q, float w, float x, float y, float z);
+
+void rsQuaternionSlerp(rs_quaternion* q, rs_quaternion* q0, rs_quaternion* q1, float t);
+
+- allocation data access functions, this is a subset, since we don't have all types of allocations
+
+-void rsAllocationCopy1DRange(allocation_1D_global, uint dstOff, uint dstMip, uint count, allocation_1D_global2, uint srcOff, uint srcMip);
+
+-void rsAllocationCopy2DRange(allocation_2D_global, uint dstXoff, uint dstYoff, uint dstMip, rs_allocation_cubemap_face dstFace, uint width, uint height, allocation_2D_global2, uint srcXoff, uint srcYoff, uint srcMip, rs_allocation_cubemap_face srcFace);
+
+int2 rsAllocationVLoadX_int2(allocation_1D_global, 0);
+int2 rsAllocationVLoadX_int2(allocation_2D_global, 24, 25);
+int2 rsAllocationVLoadX_int2(allocation_3D_global, 0, 1, 0);
+int3 rsAllocationVLoadX_int3(allocation_1D_global, 1);
+int3 rsAllocationVLoadX_int3(allocation_2D_global, 27, 28);
+int3 rsAllocationVLoadX_int3(allocation_3D_global, 1, 0, 1);
+int4 rsAllocationVLoadX_int4(allocation_1D_global, 0);
+int4 rsAllocationVLoadX_int4(allocation_2D_global, 29, 30);
+int4 rsAllocationVLoadX_int4(allocation_3D_global, 0, 1, 0);
+
+void rsAllocationVStoreX_int2(allocation_1D_global, int2 val, 2);
+void rsAllocationVStoreX_int2(allocation_2D_global, int2 val, 6, 7);
+void rsAllocationVStoreX_int2(allocation_3D_global, int2 val, 0, 1, 0);
+void rsAllocationVStoreX_int3(allocation_1D_global, int3 val, 1);
+void rsAllocationVStoreX_int3(allocation_2D_global, int3 val, 12, 13);
+void rsAllocationVStoreX_int3(allocation_3D_global, int3 val, 1, 0, 1);
+void rsAllocationVStoreX_int4(allocation_1D_global, int4 val, 0);
+void rsAllocationVStoreX_int4(allocation_2D_global, int4 val, 18, 19);
+void rsAllocationVStoreX_int4(allocation_3D_global, int4 val, 0, 1, 0);
+
+void* rsGetElementAt(allocation_1D_global, 0);
+void* rsGetElementAt(allocation_2D_global, 20, 21);
+void* rsGetElementAt(allocation_3D_global, 1, 0, 1);
+int rsGetElementAt_int(allocation_1D_global, 1);
+int rsGetElementAt_int(allocation_2D_global, 22, 23);
+int rsGetElementAt_int(allocation_3D_global, 0, 1, 0);
+
+uchar rsGetElementAtYuv_uchar_U(allocation_YUV_2D_global, 0, 1);
+
+uchar rsGetElementAtYuv_uchar_V(allocation_YUV_2D_global, 2, 3);
+
+uchar rsGetElementAtYuv_uchar_Y(allocation_YUV_2D_global, 0, 1);
+
+float4 rsSample(allocation_1D_global, rs_sampler s, float location);
+float4 rsSample(allocation_1D_global, rs_sampler s, float location, float lod);
+float4 rsSample(allocation_1D_global, rs_sampler s, float2 location);
+float4 rsSample(allocation_1D_global, rs_sampler s, float2 location, float lod);
+
+void rsSetElementAt(allocation_1D_global, int* ptr, 2);
+void rsSetElementAt(allocation_2D_global, int* ptr, 24, 25);
+void rsSetElementAt_int(allocation_1D_global, int val, 0);
+void rsSetElementAt_int(allocation_2D_global, int val, 26, 27);
+void rsSetElementAt_int(allocation_3D_global, int val, 1, 0, 1);
+'''.splitlines())
+
+
+TYPE_MAP = {
+ 'void' : '',
+ 'char' : r'\((signed )?char\)',
+ 'uchar' : r'\(uchar\)',
+ 'short' : r'\(short\)',
+ 'ushort' : r'\(ushort\)',
+ 'int' : r'\(int\)',
+ 'uint' : r'\(uint\)',
+ 'long' : r'\((long )?long\)',
+ 'ulong' : r'\(ulong\)',
+ 'float' : r'\(float\)',
+ 'float2' : r'\(float2\)',
+ 'float3' : r'\(float3\)',
+ 'float4' : r'\(float4\)'
+ }
+
+
+def _build_arg(token):
+ '''Given a C argument construct an lldb expression for the argument.
+
+ Given a token, which represents a single argument of a C function
+ declaration, construct an lldb expression for the argument.
+
+ Args:
+ token: A string representing a single argument to a function. This
+ can be either [type][name] (e.g. int arg) or [value] (e.g. 5).
+
+ Returns:
+ The string that is the lldb expression for that argument, e.g.
+ int_global or 5.
+ '''
+ if len(token.split()) == 1:
+ # This is a fixed constant. Just take that as output.
+ return token
+
+ result = token.split()[0]
+
+ # Remove the rs_ prefix, because our globals' names don't have them
+ if result[:3] == 'rs_':
+ result = result[3:]
+
+ # If the function expects a pointer, take the address of the global
+ if result[-1] == '*':
+ result = '&' + result
+ result = result[:-1]
+
+ result += '_global'
+ return result
+
+
+def build_expr(line):
+ '''Build an lldb expression given a function prototype.
+
+ Given a function declaration, this function will construct an lldb
+ expression to call it.
+
+ Args:
+ line: A string representing a function declaration.
+
+ Returns:
+ The string that is the lldb expression.
+ '''
+ tokens = re.findall(r"[^(),;]+", line)
+ assert len(tokens) > 0
+ ret_name = tokens[0].split()
+ ret = ret_name[0]
+ name = ret_name[1]
+ expr = 'expr {0}('.format(name)
+
+ first = True
+ for tok in tokens[1:]:
+ if not first:
+ expr += ', '
+ expr += _build_arg(tok)
+ first = False
+
+ expr += ')'
+ return ret, expr
diff --git a/tests/lldb/tests/harness/__init__.py b/tests/lldb/tests/harness/__init__.py
new file mode 100644
index 0000000..3390144
--- /dev/null
+++ b/tests/lldb/tests/harness/__init__.py
@@ -0,0 +1,9 @@
+'''This module contains utility code used by the test suite'''
+
+import exception
+import util_constants
+from exception import TestSuiteException
+from test_base import TestBase
+from util_android import UtilAndroid
+from util_bundle import UtilBundle
+import RS_funs
\ No newline at end of file
diff --git a/tests/lldb/tests/harness/exception.py b/tests/lldb/tests/harness/exception.py
new file mode 100644
index 0000000..9f826d6
--- /dev/null
+++ b/tests/lldb/tests/harness/exception.py
@@ -0,0 +1,15 @@
+'''Module that contains TestSuiteException.'''
+
+class TestSuiteException(Exception):
+ '''Exception that is thrown whenever an internal error is encountered.
+
+ Just contains a message.
+ '''
+ pass
+
+class DisconnectedException(Exception):
+ '''Exception that is thrown if lldb-server unexpectedly disconnected.
+
+ Just contains a message.
+ '''
+ pass
diff --git a/tests/lldb/tests/harness/test_base.py b/tests/lldb/tests/harness/test_base.py
new file mode 100644
index 0000000..61913ea
--- /dev/null
+++ b/tests/lldb/tests/harness/test_base.py
@@ -0,0 +1,257 @@
+'''Module that contains TestBase, the base class of all tests.'''
+
+import logging
+import os
+import re
+import tempfile
+import traceback
+
+from exception import DisconnectedException
+
+from . import util_log
+
+class TestBase(object):
+ '''Base class for all tests. Provides some common functionality.'''
+
+ def __init__(self, device_port, device, timer):
+ # Keep argument names for documentation purposes. This method is
+ # overwritten by test_base_remote.
+ # pylint: disable=unused-argument
+ self._lldb = None # handle to the lldb module
+ self._ci = None # instance of the lldb command interpreter for this test
+ self._timer = timer # timer instance, to check whether the test froze
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ raise NotImplementedError
+
+ def test_setup(self, android):
+ '''Set up environment for the test.
+
+ Override to specify commands to be run before the test APK launch.
+ Useful for setting Android properties or environment variables. See also
+ the test_shutdown method.
+
+ Args:
+ android: Handler to the android device, see the UtilAndroid class.
+ '''
+ pass
+
+ def test_shutdown(self, android):
+ '''Clean up environment after test.
+
+ Override this procedure to specify commands to be run after the test has
+ finished. This method is run regardless the outcome of the test.
+ Ideally, it should revert the changes introduced by test_setup.
+
+ Args:
+ android: Handler to the android device, see the UtilAndroid class.
+ '''
+ pass
+
+ def run(self, dbg, remote_pid, lldb, wimpy):
+ '''Execute the actual test.
+
+ Args:
+ dbg: The instance of the SBDebugger that is used to test commands.
+ remote_pid: The integer that is the process id of the binary that
+ the debugger is attached to.
+ lldb: A handle to the lldb module.
+ wimpy: Boolean to specify only a subset of the commands be executed.
+
+ Returns:
+ True if the test passed, or False if not.
+ '''
+ raise NotImplementedError
+
+ def post_run(self):
+ '''Clean up after test execution.'''
+ pass
+
+ class TestFail(Exception):
+ '''Exception that is thrown when a line in a test fails.
+
+ This exception is thrown if a lldb command does not return the expected
+ string.
+ '''
+ pass
+
+ def test_assert(self, cond):
+ '''Check a given condition and raise TestFail if it is False.
+
+ Args:
+ cond: The boolean condition to check.
+
+ Raises:
+ TestFail: The condition was false.
+ '''
+ if not cond:
+ raise self.TestFail()
+
+ def assert_lang_renderscript(self):
+ '''Check that LLDB is stopped in a RenderScript frame
+
+ Use the LLDB API to check that the language of the current frame
+ is RenderScript, fail otherwise.
+
+ Raises:
+ TestFail: Detected language not RenderScript.
+ '''
+ assert self._lldb
+ assert self._ci
+
+ proc = self._ci.GetProcess()
+ frame = proc.GetSelectedThread().GetSelectedFrame()
+ lang = frame.GetCompileUnit().GetLanguage()
+
+ if lang != self._lldb.eLanguageTypeExtRenderScript:
+ raise self.TestFail('Frame language not RenderScript, instead {0}'
+ .format(lang))
+
+ def do_command(self, cmd):
+ '''Run an lldb command and return the output.
+
+ Args:
+ cmd: The string representing the lldb command to run.
+
+ Raises:
+ TestFail: The lldb command failed.
+ '''
+ assert self._lldb
+ assert self._ci
+
+ log = util_log.get_logger()
+ res = self._lldb.SBCommandReturnObject()
+
+ log.info('[Command] {0}'.format(cmd))
+
+ # before issuing the command, restart the current timer to check
+ # whether the command is going to freeze the test
+ if self._timer:
+ self._timer.reset()
+
+ self._ci.HandleCommand(cmd, res)
+
+ if not res.Succeeded():
+ error = res.GetError()
+ raise self.TestFail('The command "{0}" failed with the error: {1}'
+ .format(cmd, error if error else '<N/a>'))
+
+ output = res.GetOutput()
+ log.debug('[Output] {0}'.format(output.rstrip()))
+
+ return output
+
+ def try_command(self, cmd, expected, expected_regex=None):
+ '''Run an lldb command and match the expected response.
+
+ Args:
+ cmd: The string representing the lldb command to run.
+ expected: A list of strings that should be present in lldb's
+ output.
+ expected_regex: A list of regular expressions that should
+ match lldb's output.
+
+ Raises:
+ TestFail: One of the expected strings were not found in the lldb
+ output.
+ '''
+ assert self._lldb
+ assert self._ci
+
+ log = util_log.get_logger()
+ output = ''
+ try:
+ output = self.do_command(cmd)
+
+ if 'lost connection' in output:
+ raise DisconnectedException('Lost connection to lldb-server.')
+
+ # check the expected strings
+ self._match_literals(output, expected)
+
+ # check the regexp patterns
+ if expected_regex:
+ self._match_regexp_patterns(output, expected_regex)
+
+ except self.TestFail as exception:
+ # if the command failed, ensure the output retrieved from the
+ # command is printed even in verbose mode
+ if log.getEffectiveLevel() > logging.DEBUG:
+ log.error('[Output] {0}'.format(output.rstrip() if output
+ else '<empty>'))
+
+ # print the back trace, it should help to identify the error in
+ # the test
+ backtrace = ['[Back trace]']
+ for (filename, line, function, text) in \
+ traceback.extract_stack()[:-1]:
+ backtrace.append(' [{0} line: {2} fn: {1}] {3}'.format(
+ filename, function, line, text
+ )
+ )
+ log.error('\n'.join(backtrace))
+ log.error('[TEST ERROR] {0}'.format(exception.message))
+ raise # pass through
+
+ def _match_literals(self, text, literals):
+ '''Checks the text against the array of literals.
+
+ Raises a TestFail exception in case one of the literals is not contained
+ in the text.
+
+ Args:
+ text: String, it represents the text to match.
+ literals: an array of string literals to match in the output.
+
+ Throws: self.TestFail: if it cannot match one of the literals in
+ the output.
+ '''
+ for string in literals:
+ if string not in text:
+ raise self.TestFail('Cannot find "{0}" in the output'
+ .format(string))
+
+ def _match_regexp_patterns(self, text, patterns):
+ '''Checks the text against the array of regular expression patterns.
+
+ Raises a TestFail exception in case one of the patterns is not matched
+ in the given text.
+
+ Args:
+ text: String, it represents the text to match.
+ patterns: an array of strings, each of them representing a regular
+ expression to match in text.
+
+ Throws: self.TestFail: if it cannot match one of the literals in
+ the output.
+ '''
+ log = util_log.get_logger()
+
+ for regex in patterns:
+ match = re.search(regex, text)
+ if not match:
+ raise self.TestFail('Cannot match the regexp "{0}" in '
+ 'the output'.format(regex))
+ else:
+ msg = 'Found match to regex {0}: {1}'.format(regex,
+ match.group())
+ log.debug(msg)
+
+ @staticmethod
+ def get_tmp_file_path():
+ '''Get the path of a temporary file that is then deleted.
+
+ Returns:
+ A string that is the path to a temporary file.
+ '''
+ file_desc, name = tempfile.mkstemp()
+ os.close(file_desc)
+ os.remove(name)
+ return name
+
diff --git a/tests/lldb/tests/harness/test_base_remote.py b/tests/lldb/tests/harness/test_base_remote.py
new file mode 100644
index 0000000..acb2ba1
--- /dev/null
+++ b/tests/lldb/tests/harness/test_base_remote.py
@@ -0,0 +1,171 @@
+'''Module that contains the base class TestBaseRemote'''
+
+import os
+import re
+
+from test_base import TestBase
+from . import util_log
+
+
+class TestBaseRemote(TestBase):
+ '''Base class for all tests that connect to a remote device.
+
+ Provides common functionality to set up the connection and tear it down.
+ '''
+
+ def __init__(self, device_port, device, timer):
+ super(TestBaseRemote, self).__init__(device_port, device, timer)
+ # port used by lldb-server on the device.
+ self._device_port = device_port
+ self._platform = None
+ # id of the device that adb will communicate with.
+ self._device = device
+
+ def set_src_map(self, file_name, new_src_path):
+ '''Call lldb to set the source mapping of a given file.
+
+ Set lldb's source mapping of a given file to a given path. This can be
+ used to make the test suite independent of where an APK was compiled.
+
+ Args:
+ file_name: String, which is the name of the file whose mapping is
+ to be changed
+ new_src_path: String which is the new absolute path to the source
+ file.
+ '''
+ line_table = self.do_command('target modules dump line-table '
+ + file_name)
+
+ lines = line_table.split('\n')
+ if 'Line table for' not in lines[0]:
+ raise self.TestFail('Could not determine source path of '
+ + file_name)
+
+ # Expecting output like:
+ # (lldb) target modules dump line-table scalars.rs
+ # Line table for /home/jenkins/workspace/grd-aosp-parameterised-build/
+ # merge_151216/frameworks/rs/tests/lldb/java/BranchingFunCalls/src/rs/
+ # frameworks/rs/tests/lldb/java/BranchingFunCalls/src/rs/scalars.rs in
+ # `librs.scalars.so
+ # 0xb30f2374: /home/jenkins/workspace/grd-aosp-parameterised-build/
+ # merge_151216/frameworks/rs/tests/lldb/java/BranchingFunCalls/src/rs/
+ # scalars.rs:46
+ # ...
+ # For some reason the first line contains a mangled path?
+ old_path = re.findall(r"[^ :]+", lines[1])[1]
+ old_dir = os.path.dirname(old_path)
+
+ self.try_command('settings set target.source-map %s %s'
+ % (old_dir, new_src_path), [''])
+
+ def post_run(self):
+ '''Clean up after execution.'''
+ if self._platform:
+ self._platform.DisconnectRemote()
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ raise NotImplementedError
+
+ def _connect_to_platform(self, lldb_module, dbg, remote_pid):
+ '''Connect to an lldb platform that has been started elsewhere.
+
+ Args:
+ lldb_module: A handle to the lldb module.
+ dbg: The instance of the SBDebugger that should connect to the
+ server.
+ remote_pid: The integer that is the process id of the binary that
+ the debugger should attach to.
+
+ Returns:
+ True if the debugger successfully attached to the server and
+ process.
+ '''
+ # pylint: disable=too-many-return-statements
+ remote_pid = str(remote_pid)
+
+ log = util_log.get_logger()
+
+ err1 = dbg.SetCurrentPlatform('remote-android')
+ if err1.Fail():
+ log.fatal(err1.GetCString())
+ return False
+
+ self._platform = dbg.GetSelectedPlatform()
+ if not self._platform:
+ return False
+
+ connect_string = \
+ 'adb://{0}:{1}'.format(self._device, self._device_port)
+ opts = lldb_module.SBPlatformConnectOptions(connect_string)
+
+ for _ in range(2):
+ err2 = self._platform.ConnectRemote(opts)
+ if err2.Fail():
+ log.error(err2.GetCString())
+
+ if 'Connection refused' in err2.GetCString():
+ log.warning('Connection to lldb server was refused. '
+ 'Trying again.')
+ else:
+ # Unknown error. Don't try again.
+ return False
+ else:
+ # Success
+ break
+ else:
+ log.fatal('Not trying again, maximum retries exceeded.')
+ return False
+
+ target = dbg.CreateTarget(None)
+ if not target:
+ return False
+
+ dbg.SetSelectedTarget(target)
+ listener = lldb_module.SBListener()
+ err3 = lldb_module.SBError()
+ process = target.AttachToProcessWithID(listener, int(remote_pid), err3)
+ if err3.Fail() or not process:
+ log.fatal(err3.GetCString())
+ return False
+
+ return True
+
+ def run(self, dbg, remote_pid, lldb, wimpy):
+ '''Execute the actual test.
+
+ Args:
+ dbg: The instance of the SBDebugger that is used to test commands.
+ remote_pid: The integer that is the process id of the binary that
+ the debugger is attached to.
+ lldb: A handle to the lldb module.
+ wimpy: Boolean to specify only a subset of the commands be executed.
+
+ Returns:
+ True if the test passed, or False if not.
+ '''
+ assert dbg
+ assert remote_pid
+ assert lldb
+
+ self._lldb = lldb
+
+ try:
+ self.test_assert(self._connect_to_platform(lldb, dbg, remote_pid))
+ self._ci = dbg.GetCommandInterpreter()
+ assert self._ci
+
+ self.test_assert(self._ci.IsValid())
+ self.test_assert(self._ci.HasCommands())
+
+ self.test_case(wimpy)
+
+ except self.TestFail:
+ return False
+
+ return True
diff --git a/tests/lldb/tests/harness/util_android.py b/tests/lldb/tests/harness/util_android.py
new file mode 100644
index 0000000..cbc928d
--- /dev/null
+++ b/tests/lldb/tests/harness/util_android.py
@@ -0,0 +1,715 @@
+'''Module that contains the class UtilAndroid, providing utility method to
+interface with Android ADB.'''
+
+import logging
+import re
+import subprocess
+import time
+import collections
+import multiprocessing
+import Queue
+from exception import TestSuiteException
+from . import util_log
+
+
+class UtilAndroid(object):
+ '''Provides some utility methods that interface with Android using adb.'''
+ # pylint: disable=too-many-public-methods
+
+ def __init__(self, adb_path, lldb_server_path_device, device):
+ # The path to the adb binary on the local machine
+ self._path_adb = adb_path
+ # The path to the lldb server binary on the device
+ self._path_lldbserver = lldb_server_path_device
+ self._log = util_log.get_logger()
+ self.device = device
+ self._prop_stacks = collections.defaultdict(list)
+ return
+
+ @staticmethod
+ def _validate_string(string):
+ '''Check that a string is valid and not empty.
+
+ Args:
+ string: The string to be checked.
+ '''
+ assert isinstance(string, str)
+ assert len(string) > 0
+
+ def adb(self, args, async=False, device=True, timeout=None):
+ '''Run an adb command (async optional).
+
+ Args:
+ args: The command (including arguments) to run in adb.
+ async: Boolean to specify whether adb should run the command
+ asynchronously.
+ device: boolean to specify whether the serial id of the android
+ device should be inserted in the adb command.
+ timeout: it specifies the number of seconds to wait for
+ a synchronous invocation before aborting. If unspecified or
+ None it waits indefinitely for the command to complete.
+
+ Raises:
+ ValueError: it can be caused by any of the following situations:
+ - when both the combination async=True and timeout are
+ given.
+ - when a timeout <= 0 is specified.
+
+ Returns:
+ If adb was synchronously run and the command completed by the
+ specified timeout, a string which is the output (standard out and
+ error) from adb. Otherwise it returns None.
+ '''
+
+ # Form the command
+ if device:
+ cmd = '{0} -s {1} {2}'.format(self._path_adb, self.device, args)
+ else:
+ cmd = '{0} {1}'.format(self._path_adb, args)
+
+ self._log.debug('Execute ADB: %s', cmd)
+
+ if timeout is None:
+ # local invocation
+ return_code, output = UtilAndroid._execute_command_local(cmd, async)
+
+ else:
+ # remote invocation
+ if async:
+ raise ValueError('Invalid combination: asynchronous invocation '
+ 'with timeout specified')
+
+ return_code, output = UtilAndroid._execute_command_remote(cmd,
+ timeout)
+
+ if return_code is None:
+ self._log.warn('[ADB] The command timed out: %s', cmd)
+
+ # log the output message
+ if output is not None:
+ self._adb_log_output(cmd, output, return_code)
+
+ return output
+
+ def adb_retry(self, args, max_num_attempts, timeout):
+ '''Attempt to execute the given adb command a certain number of times.
+
+ The function executes the given command through adb, waiting for its
+ completion up to 'timeout' seconds. If the command completes then it
+ returns its output. Otherwise it aborts the execution of the adb
+ command and re-issues it anew with the same parameters. In case of
+ timeout this process is repeated up to 'max_num_attempts'.
+
+ The purpose of this function is to handle the cases when, for some
+ reason, a command sent to 'adb' freezes, blocking the whole test suite
+ indefinitely.
+
+ Args:
+ args: The command (including arguments) to run in adb.
+ max_num_attempts: the max number of attempts to repeat the command
+ in case of timeout.
+ timeout: it specifies the number of seconds to wait for the adb
+ command to complete.
+
+ Raises:
+ ValueError: when the parameter timeout is invalid (None or <= 0).
+
+ Returns:
+ If adb was synchronously run and the command completes by the
+ specified timeout, a string which is the output (standard out and
+ error) from adb. Otherwise it returns None.
+ '''
+ if timeout is None or timeout <= 0:
+ raise ValueError('Invalid value for timeout')
+
+ output = None
+
+ for attempt in range(max_num_attempts):
+ self._log.debug('[ADB] Attempt #%d: %s', attempt + 1, args)
+ output = self.adb(args, False, True, timeout)
+ if output:
+ break
+
+ return output
+
+ def _adb_log_output(self, cmd, output, return_code):
+ '''Save in the log the command & output from `adb`.
+
+ Internal function, helper to record in the log the issued adb command
+ together with its output and return code.
+
+ Params:
+ cmd: string, the command issued to `adb`.
+ output: string, the output retrieved from `adb`.
+ return_code: int, the return code from `adb`.
+ '''
+
+ message = output.strip()
+
+ # if return_code != 0, we wish to also record the command executed
+ # (which occurs if and only if we are in verbose mode)
+ is_warning = return_code != 0
+ threshold = self._log.getEffectiveLevel()
+ if is_warning and threshold > logging.DEBUG:
+ self._log.warn("[ADB] Command executed: {0}".format(cmd))
+
+ level = logging.WARNING if is_warning else logging.DEBUG
+ if message:
+ # if message is composed by multiple lines, then print it after
+ # the log preamble
+ if re.search('\n', message):
+ message = '\n' + message
+ else:
+ message = '<empty>'
+
+ self._log.log(level, 'RC: {0}, Output: {1}'.format(return_code,
+ message))
+
+ def check_adb_alive(self):
+ '''Ping the device and raise an exception in case of timeout.
+
+ It sends a ping message through 'adb shell'. The emulator/device should
+ echo the same message back by one minute. If it does not, it raises
+ a TestSuiteException.
+
+ Purpose of this method is to check whether 'adb' became frozen or
+ stuck.
+
+ Raises:
+ TestSuiteException: in case the device/emulator does not reply by
+ one minute or the `ping' message is not echoed
+ back.
+ '''
+ token = 'PING'
+ log = util_log.get_logger()
+ cmd = "echo {0}".format(token)
+
+ tries = 10
+ try_number = tries
+ while try_number > 0:
+ log.debug('Sending a ping through "adb shell" (try #%s)...',
+ try_number)
+ output = self.shell(cmd, False, 60)
+
+ if output is None:
+ raise TestSuiteException(
+ 'Timeout when pinging the device/emulator through '
+ '"adb shell". Is "adb" stuck or dead?')
+ elif token not in output:
+ log.debug('Ping failed. Cannot match the token "%s" in "adb '
+ 'shell %s"', token, cmd)
+ else:
+ log.debug('Pong message received')
+ return
+
+ try_number -= 1
+ time.sleep(5)
+
+ raise TestSuiteException('Cannot ping the device/emulator through '
+ '"adb shell". Tried %s times. Is "adb" stuck '
+ 'or dead?' % tries)
+
+ def shell(self, cmd, async=False, timeout=None):
+ '''Run a command via the adb shell.
+
+ Args:
+ cmd: The command (including arguments) to run in the adb shell.
+ async: Boolean to specify whether adb should run the command
+ asynchronously.
+ timeout: it specifies the number of seconds to wait for
+ a synchronous invocation before aborting. If unspecified or
+ None it waits indefinitely for the command to complete
+
+ Returns:
+ If adb was synchronously run, a string which is the output (standard
+ out and error) from adb. Otherwise None.
+ '''
+ return self.adb('shell "{0}"'.format(cmd), async, True, timeout)
+
+ def find_app_pid(self, process_name):
+ '''Find the process ID of a process with a given name.
+
+ If more than one instance of the process is running return the first pid
+ it finds.
+
+ Args:
+ process_name: A string representing the name of the package or
+ binary for which the id should be found. I.e. the
+ string or part of the string that shows up in the "ps"
+ command.
+
+ Returns:
+ An integer representing the id of the process, or None if it was not
+ found.
+ '''
+ self._validate_string(process_name)
+
+ pid_output = self.shell('pidof ' + process_name)
+ pid_output = re.sub(r'\*.+\*', '', pid_output)
+ pids = pid_output.split()
+
+ if len(pids) < 1:
+ self._log.warn('Unable to find pid of: {0}'.format(process_name))
+ return None
+
+ if len(pids) > 1:
+ self._log.warn('Found multiple instances of {0} running: {1}'
+ .format(process_name, pids))
+
+ try:
+ pid = int(pids[0])
+ self._log.info('App pid found: {0}'.format(pids[0]))
+ return pid
+ except ValueError:
+ return None
+
+ def adb_root(self):
+ '''Set adb to be in root mode.'''
+ self.adb('root')
+
+ def _adb_remount(self):
+ '''Remount the filesystem of the device.'''
+ self.adb('remount')
+
+ def validate_adb(self):
+ '''Validate adb that it can be run.
+
+ Raises:
+ TestSuiteException: Unable to validate that adb exists and runs
+ successfully.
+ '''
+ out = self.adb('version', False, False)
+ if out and 'Android' in out and 'version' in out:
+ self._log.info('adb found: {0}'.format(out))
+ return None
+ raise TestSuiteException('unable to validate adb')
+
+ def is_booted(self):
+ ''' Check if the device/emulator has finished booting.
+
+ Returns: True if the property sys.boot_completed is true, False
+ otherwise.
+ '''
+ return self._get_prop('sys.boot_completed').strip() == '1'
+
+ def validate_device(self, check_boot=True, device_substring=''):
+ '''Validate that there is at least one device.
+
+ Args:
+ check_boot: Boolean to specify whether to check whether the device
+ has finished booting as well as being present.
+ device_substring: String that needs to be part of the name of the
+ device.
+
+ Raises:
+ TestSuiteException: There was a failure to run adb to list the
+ devices or there is no device connected or
+ multiple devices connected without the user
+ having specified the device to use.
+ '''
+
+ out = self.adb('devices', False, False)
+ if not 'List of devices attached' in out:
+ raise TestSuiteException('Unable to list devices')
+
+ lines = out.split('\n')
+ found_device = False # True if the specified device is found
+ devices = []
+
+ for line in lines[1:]:
+ if '\tdevice' in line and device_substring in line:
+ device = line.split()[0]
+ devices.append(device)
+ if self.device:
+ if self.device == device:
+ found_device = True
+
+ if len(devices) == 0:
+ raise TestSuiteException('adb is unable to find a connected '
+ 'device/emulator to test.')
+
+ if not self.device:
+ if len(devices) == 1:
+ self.device = devices[0]
+ else:
+ raise TestSuiteException('Multiple devices connected,'
+ 'specify -d device id.')
+ else:
+ if not found_device:
+ raise TestSuiteException('Couldn\'t find the device {0} that '
+ 'was specified, please check -d '
+ 'argument'.format(self.device))
+
+ if check_boot and not self.is_booted():
+ raise TestSuiteException(
+ 'The device {0} has not yet finished booting.'
+ .format(self.device))
+
+ def device_with_substring_exists(self, device_substring):
+ '''Check whether a device exists whose name contains a given string.
+
+ Args:
+ device_substring: String that is part of the name of the device to
+ look for.
+
+ Raises:
+ TestSuiteException: There was a failure to run adb to list the
+ devices.
+ '''
+ out = self.adb('devices', False, False)
+ if not 'List of devices attached' in out:
+ raise TestSuiteException('Unable to list devices')
+
+ lines = out.split('\n')
+
+ for line in lines[1:]:
+ if '\tdevice' in line:
+ device = line.split()[0]
+ if device.find(device_substring) != -1:
+ return True
+
+ return False
+
+ def get_device_id(self):
+ '''Return ID of the device that will be used for running the tests on.
+
+ Returns:
+ String representing device ID.
+ '''
+ return self.device
+
+ def _kill_pid(self, pid):
+ '''Kill a process identified by its pid by issuing a "kill" command.
+
+ Args:
+ pid: The integer that is the process id of the process to be killed.
+ '''
+ self.shell('kill -9 ' + str(pid))
+
+ def stop_app(self, package_name):
+ '''Terminate an app by calling am force-stop.
+
+ Args:
+ package_name: The string representing the name of the package of the
+ app that is to be stopped.
+ '''
+ self._validate_string(package_name)
+ self.shell('am force-stop ' + package_name)
+
+ def kill_process(self, name):
+ '''Kill a process identified by its name (package name in case of apk).
+
+ Issues the "kill" command.
+
+ Args:
+ name: The string representing the name of the binary of the process
+ that is to be killed.
+
+ Returns:
+ True if the kill command was executed, False if it could not be
+ found.
+ '''
+ pid = self.find_app_pid(name)
+ if pid:
+ self._kill_pid(pid)
+ return True
+ return False
+
+ def kill_all_processes(self, name):
+ '''Repeatedly try to call "kill" on a process to ensure it is gone.
+
+ If the process is still there after 5 attempts reboot the device.
+
+ Args:
+ name: The string representing the name of the binary of the process
+ that is to be killed.
+
+ Raises:
+ TestSuiteException: If the process could not be killed after 5
+ attempts and the device then failed to boot
+ after rebooting.
+ '''
+
+ # try 5 times to kill this process
+ for _ in range(1, 5):
+ if not self.kill_process(name):
+ return
+ # stalled process must reboot
+ self._reboot_device()
+
+ def kill_servers(self):
+ '''Kill all gdbserver and lldb-server instances.
+
+ Raises:
+ TestSuiteException: If gdbserver or lldb-server could not be killed
+ after 5 attempts and the device then failed to
+ boot after rebooting.
+ '''
+ self.kill_all_processes('gdbserver')
+ self.kill_all_processes('lldb-server')
+
+ def launch_elf(self, binary_name):
+ '''Launch a binary (compiled with the NDK).
+
+ Args:
+ binary_name: The string representing the name of the binary that is
+ to be launched.
+
+ Returns:
+ Boolean, failure if the app is not installed, success otherwise.
+ '''
+ # Ensure the apk is actually installed.
+ output = self.shell('ls /data/ | grep ' + binary_name)
+ if binary_name not in output:
+ return False
+
+ stdout = self.shell('exec /data/' + binary_name, True)
+ self._log.info(str(stdout))
+
+ return True
+
+ def wait_for_device(self):
+ '''Ask ADB to wait for a device to become ready.'''
+ self.adb('wait-for-device')
+
+ def _reboot_device(self):
+ '''Reboot the remote device.
+
+ Raises:
+ TestSuiteException: If the device failed to boot after rebooting.
+ '''
+ self.adb('reboot')
+ self.wait_for_device()
+ # Allow 20 mins boot time to give emulators such as MIPS enough time
+ sleeping_countdown = 60*20
+ while not self.is_booted():
+ time.sleep(1)
+ sleeping_countdown -= 1
+ if sleeping_countdown == 0:
+ raise TestSuiteException('Failed to reboot. Terminating.')
+
+ self.adb_root()
+ self.wait_for_device()
+ self._adb_remount()
+ self.wait_for_device()
+
+ def launch_app(self, name, activity):
+ '''Launch a Renderscript application.
+
+ Args:
+ name: The string representing the name of the app that is to be
+ launched.
+ activity: The string representing the activity of the app that is to
+ be started.
+
+ Returns:
+ Boolean, failure if the apk is not installed, success otherwise.
+ '''
+ assert name and activity
+
+ # Ensure the apk is actually installed.
+ output = self.shell('pm list packages ' + name)
+ if not output:
+ return False
+
+ cmd = 'am start -S -n {0}/{0}.{1}'.format(name, activity)
+ stdout = self.shell(cmd)
+
+ self._log.info(str(stdout))
+
+ return True
+
+ def launch_lldb_platform(self, port):
+ '''Launch lldb server and attach to target app.
+
+ Args:
+ port: The integer that is the port on which lldb should listen.
+ '''
+ cmd = "export LLDB_DEBUGSERVER_PATH='{0}';{0} p --listen {1}"\
+ .format(self._path_lldbserver, port)
+ self.shell(cmd, True)
+ time.sleep(5)
+
+ def forward_port(self, local, remote):
+ '''Use adb to forward a device port onto the local machine.
+
+ Args:
+ local: The integer that is the local port to forward.
+ remote: The integer that is the remote port to which to forward.
+ '''
+ cmd = 'forward tcp:%s tcp:%s' % (str(local), str(remote))
+ self.adb(cmd)
+
+ def remove_port_forwarding(self):
+ '''Remove all of the forward socket connections open in adb.
+
+ Avoids a windows adb error where we can't bind to a listener
+ because too many files are open.
+ '''
+ self.adb('forward --remove-all')
+
+ def _get_prop(self, name):
+ '''Get the value of an Android system property.
+
+ Args:
+ name: Name of the property of interest [string].
+
+ Returns:
+ Current value of the property [string].
+ '''
+ return self.shell('getprop %s' % str(name))
+
+ def _set_prop(self, name, value):
+ '''Set the value of an Android system property.
+
+ Args:
+ name: Name of the property of interest [string].
+ value: Desired new value for the property [string or integer].
+ '''
+ self.shell("setprop %s '%s'" % (str(name), str(value)))
+
+ def push_prop(self, name, new_value):
+ '''Save the value of an Android system property and set a new value.
+
+ Saves the old value onto a stack so it can be restored later.
+
+ Args:
+ name: Name of the property of interest [string].
+ new_value: Desired new value for the property [string or integer].
+ '''
+ old_value = self._get_prop(name)
+ self._set_prop(name, new_value)
+ self._prop_stacks[name].append(old_value.strip())
+
+ def pop_prop(self, name):
+ '''Restore the value of an Android system property previously set by
+ push_prop.
+
+ Args:
+ name: Name of the property of interest [string].
+
+ Returns:
+ Current value of the property [string].
+ '''
+ old_value = self._prop_stacks[name].pop()
+ self._set_prop(name, old_value)
+
+ def reset_all_props(self):
+ '''Restore all the android properties to the state before the first push
+
+ This is equivalent to popping each property the number of times it has
+ been pushed.
+ '''
+ for name in self._prop_stacks:
+ if self._prop_stacks[name] != []:
+ self._set_prop(name, self._prop_stacks[name][0])
+ self._prop_stacks[name] = []
+
+ def make_device_writeable(self):
+ ''' Ensure the device is full writable, in particular the system folder.
+
+ This disables verity and remounts.
+ '''
+ output = self.adb('disable-verity')
+
+ # if the remote is an emulator do not even try to reboot
+ # otherwise check whether a reboot is advised
+ if (self._get_prop('ro.kernel.qemu') != '1' and output and
+ 'Now reboot your device for settings to take effect' in output):
+ self._reboot_device()
+
+ self._adb_remount()
+ self.wait_for_device()
+ self.adb_root()
+ self.wait_for_device()
+
+ @staticmethod
+ def _execute_command_local(command, async=False):
+ '''Execute the given shell command in the same process.
+
+ Args:
+ command: String, the command to execute
+ async: Boolean to specify whether adb should run the command
+ asynchronously.
+
+ Returns:
+ if async == False, it returns a tuple with the return code and
+ the output from the executed command. Otherwise the tuple
+ (None, None).
+ '''
+ proc = subprocess.Popen(command,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ shell=True)
+ if async:
+ return None, None
+
+ # read the whole output from the command
+ with proc.stdout as file_proc:
+ output = ''.join(line for line in file_proc)
+
+ # release the process state
+ proc.terminate()
+ return_code = proc.wait()
+
+ return return_code, output
+
+ @staticmethod
+ def _execute_command_remote(command, timeout):
+ '''Execute the given shell command remotely, in a separate process.
+
+ It spawns an ad hoc process to execute the given command. It waits up
+ to timeout for the command to complete, otherwise it aborts the
+ execution and returns None.
+
+ Args:
+ command: String, the command to execute.
+ timeout: the number of seconds to wait for the command to complete.
+
+ Returns:
+ a pair with the return code and the output from the command, if it
+ completed by the specified 'timeout' seconds. Otherwise the tuple
+ (None, None).
+ '''
+
+ channel = multiprocessing.Queue()
+ proc = multiprocessing.Process(
+ target=_handle_remote_request,
+ name="Executor of `{0}'".format(command),
+ args=(command, channel)
+ )
+
+ # execute the command
+ proc.start()
+ return_code = None
+ output = None
+
+ # wait for the result
+ try:
+ return_code, output = channel.get(True, timeout)
+ except Queue.Empty:
+ # timeout hit, the remote process has not fulfilled our request by
+ # the given time. We are going to return <None, None>, nothing to
+ # do here as it already holds return_code = output = None.
+ pass
+
+ # terminate the helper process
+ proc.terminate()
+
+ return return_code, output
+
+
+def _handle_remote_request(command, channel):
+ '''Entry point for the remote process.
+
+ It executes the given command and reports the result into the channel.
+ This function is supposed to be only called by
+ UtilAndroid._execute_command_remote to handle the inter-process
+ communication.
+
+ Args:
+ command: the command to execute.
+ channel: the channel to communicate with the caller process.
+ '''
+ channel.put(UtilAndroid._execute_command_local(command))
+
diff --git a/tests/lldb/tests/harness/util_bundle.py b/tests/lldb/tests/harness/util_bundle.py
new file mode 100644
index 0000000..ecd413a
--- /dev/null
+++ b/tests/lldb/tests/harness/util_bundle.py
@@ -0,0 +1,368 @@
+'''Module that contains the class UtilBundle, representing a collection of RS
+binaries.'''
+
+import os
+import time
+from . import util_constants
+from . import util_log
+from exception import TestSuiteException
+
+
+class UtilBundle(object):
+ '''Represents the collection of RS binaries that are debugged.'''
+
+ # Map of binary name to package name of all Java apps debugged
+ _tests_apk = {
+ 'JavaInfiniteLoop': 'com.android.rs.infiniteloop',
+ 'JavaDebugWaitAttach': 'com.android.rs.waitattachdebug',
+ 'JavaNoDebugWaitAttach': 'com.android.rs.waitattachnodebug',
+ 'BranchingFunCalls': 'com.android.rs.branchingfuncalls',
+ 'KernelVariables': 'com.android.rs.kernelvariables',
+ 'Allocations': 'com.android.rs.allocations',
+ 'MultipleRSFiles': 'com.android.rs.multiplersfiles'
+ }
+
+ _tests_jni = {
+ 'JNIInfiniteLoop': 'com.android.rs.jniinfiniteloop',
+ 'JNIDebugWaitAttach': 'com.android.rs.jnidebugwaitattach',
+ 'JNINoDebugWaitAttach': 'com.android.rs.jninodebugwaitattach',
+ 'JNIBranchingFunCalls': 'com.android.rs.jnibranchingfuncalls',
+ 'JNIKernelVariables': 'com.android.rs.jnikernelvariables',
+ 'JNIAllocations': 'com.android.rs.jniallocations',
+ 'JNIMultipleRSFiles': 'com.android.rs.jnimultiplersfiles'
+ }
+
+ _tests_ndk = {'CppInfiniteLoop', 'CppNoDebugWaitAttach',
+ 'CppDebugWaitAttach', 'CppBranchingFunCalls',
+ 'CppKernelVariables', 'CppAllocations', 'CppMultipleRSFiles'}
+
+ _missing_path_msg = (
+ 'No product path has been provided, if using the '
+ 'default environmental variable check it is set '
+ 'by running lunch. Alternatively hardcode '
+ 'your own path in the config file or set it via the '
+ 'command line.'
+ )
+
+ def __init__(self, android, aosp_product_path):
+ assert android
+ self._android = android # Link to the android module
+ self._aosp_product_path = aosp_product_path
+ self._log = util_log.get_logger()
+
+ def is_apk(self, name):
+ '''Checks if a binary of a given name is an apk.
+
+ Checks whether the name of the apk is in the dictionary of apks.
+
+ Args:
+ name: The string that is the name of the binary to check.
+
+ Returns:
+ True if the binary is an apk, False if it is not.
+
+ Raises:
+ TestSuiteException: The string does not match any item in the list
+ of APK or NDK binaries.
+ '''
+ if name in self._tests_apk:
+ return True
+ if name not in self._tests_ndk and name not in self._tests_jni:
+ raise TestSuiteException('test not apk or ndk')
+ return False
+
+ def uninstall_all(self):
+ '''Uninstall/Delete all the testsuite's apks and binaries on the device.
+
+ Raises:
+ TestSuiteException: One or more apks could not be uninstalled.
+ '''
+ self.uninstall_all_apk()
+ self._delete_all_ndk()
+ self._uninstall_all_jni()
+
+ def uninstall_all_apk(self):
+ '''Uninstall all apks used by the test suite from the device.
+
+ Raises:
+ TestSuiteException: An apk could not be uninstalled.
+ '''
+ max_num_attempts = 3
+ timeout = 180
+
+ for app, package in self._tests_apk.items():
+ self._log.info('Uninstalling the application: %s', app)
+ output = self._android.adb_retry('uninstall ' + package,
+ max_num_attempts, timeout)
+
+ if output is None:
+ raise TestSuiteException('Repeated timeouts when uninstalling '
+ 'the application: ' + app)
+ elif 'Success' not in output:
+ outmsg = '\n' + output.rstrip() if output else '<empty>'
+ self._log.error('Cannot match the string "Success" in the '
+ 'output: %s', outmsg)
+ raise TestSuiteException('Unable to uninstall app ' + app)
+ else:
+ self._log.debug('Application uninstalled: %r', app)
+
+ if 'Success' not in output:
+ self._log.warning('unable to uninstall app ' + app)
+
+ def _uninstall_all_jni(self):
+ '''Uninstall all apks used by the test suite from the device.
+
+ Raises:
+ TestSuiteException: An apk could not be uninstalled.
+ '''
+ for app, package in self._tests_jni.items():
+ output = self._android.adb('uninstall ' + package)
+
+ if 'Success' not in output:
+ raise TestSuiteException('unable to uninstall app ' + app)
+
+ output = self._android.shell('rm /system/lib/lib%s.so'
+ % app.lower())
+ if 'No such file or directory' in output:
+ self._log.warning(
+ 'unable to remove library file for app ' + app)
+
+ def _delete_all_ndk(self):
+ '''Delete all ndk binaries that were pushed to the device.
+
+ Raises:
+ TestSuiteException: A binary could not be deleted from the device.
+ '''
+ for app in self._tests_ndk:
+ output = self._android.shell('rm /data/' + app)
+ if 'No such file or directory' in output:
+ self._log.warning('unable to uninstall app ' + app)
+
+
+ def push_all(self):
+ '''Push all apk and ndk binaries required by the testsuite to the device
+
+ Raises:
+ TestSuiteException: One or more apks could not be installed or
+ previously running processes thereof could not
+ be killed.
+ '''
+ self._push_all_java()
+ self._push_all_ndk()
+ self._push_all_jni()
+
+ def _install_apk(self, app, package):
+ '''Push an apk files to the device.
+
+ This involves uninstalling any old installation and installing again.
+
+ Args:
+ app: A string that is the name of the apk.
+ package: A string that is the name of the package of the apk.
+
+ Raises:
+ TestSuiteException: The apk could not be installed.
+ '''
+ self._log.info('pushing {0}'.format(app))
+
+ self._android.stop_app(package)
+
+ self._android.adb('uninstall ' + package)
+ # Ignore the output of uninstall.
+ # The app may not have been installed in the first place. That's ok.
+
+ flags = ''
+
+ product_folder = self._aosp_product_path
+ if not product_folder:
+ raise TestSuiteException(self._missing_path_msg)
+
+ app_folder = os.path.join(product_folder, 'data/app')
+
+ cmd = 'install {0} {1}/{2}/{2}.apk'.format(flags, app_folder, app)
+ output = self._android.adb(cmd, False, True,
+ util_constants.PUSH_TIMEOUT)
+ if ('Success' not in output) or ("can't find" in output):
+ raise TestSuiteException('unable to install app ' + app)
+
+ def _push_all_java(self):
+ '''Push all apk files to the device.
+
+ This involves uninstalling any old installations and installing again.
+
+ Raises:
+ TestSuiteException: An apk could not be installed.
+ '''
+ for app, package in self._tests_apk.iteritems():
+ self._install_apk(app, package)
+
+ def _push_all_ndk(self):
+ '''Push all ndk binaries to the device.
+
+ Raises:
+ TestSuiteException: A binary could not be pushed to the device or
+ a previous process could not be killed.
+ '''
+ product_folder = self._aosp_product_path
+ if not product_folder:
+ raise TestSuiteException(self._missing_path_msg)
+
+ bin_folder = os.path.join(product_folder, 'system/bin')
+
+ for app in self._tests_ndk:
+ self._log.info('pushing {0}'.format(app))
+
+ self._android.kill_all_processes(app)
+
+ cmd = 'push %s/%s /data' % (bin_folder, app)
+ output = self._android.adb(cmd, False, True,
+ util_constants.PUSH_TIMEOUT)
+ if ('failed to copy' in output or
+ 'No such file or directory' in output):
+ raise TestSuiteException('unable to push binary ' + app)
+
+ # be sure to set the execute bit for NDK binaries
+ self._android.shell('chmod 777 /data/{0}'.format(app))
+
+ def _push_all_jni(self):
+ '''Push all JNI apk files to the device.
+
+ This involves uninstalling any old installations and installing again.
+
+ Raises:
+ TestSuiteException: An apk could not be installed.
+ '''
+ product_folder = self._aosp_product_path
+ if not product_folder:
+ raise TestSuiteException(self._missing_path_msg)
+
+ app_folder = os.path.join(product_folder, 'system/lib')
+
+ # Ensure the system/lib directory is writable
+ self._android.make_device_writeable()
+
+ for app, package in self._tests_jni.iteritems():
+ self._install_apk(app, package)
+ output = self._android.adb('push %s/lib%s.so /system/lib' %
+ (app_folder, app.lower()), False, True,
+ util_constants.PUSH_TIMEOUT)
+ if ("error" in output or
+ "failed to copy" in output):
+ raise TestSuiteException(
+ 'unable to copy %s/lib%s.so to /system/lib: %s'
+ % (app_folder, app.lower(), output))
+
+ def delete_ndk_cache(self):
+ '''Deletes NDK cached scripts from the device.
+
+ The NDK caches compiled scripts as shared libraries in
+ the folder specified when calling `rs->init()`.
+
+ For all out tests this is set to '/data/rscache'.
+ '''
+ self._android.shell('rm -r /data/rscache')
+
+ def get_package(self, app_name):
+ '''From a given apk name get the name of its package.
+
+ Args:
+ app_name: The string that is the name of the apk.
+
+ Returns:
+ A string representing the name of the package of the app.
+
+ Raises:
+ TestSuiteException: The app name is not in the list of apks.
+ '''
+ if app_name in self._tests_apk:
+ return self._tests_apk[app_name]
+ elif app_name in self._tests_jni:
+ return self._tests_jni[app_name]
+ else:
+ msg = ('unknown app %s. (Do you need to add an '
+ 'entry to bundle.py :: test_apps_?)' % app_name)
+ raise TestSuiteException(msg)
+ return self._tests_apk[app_name]
+
+ def launch(self, app_name):
+ '''Launch an apk/ndk app on a remote device.
+
+ Args:
+ app_name: The string that is the name of the APK or NDK executable.
+
+ Returns:
+ The Process ID of the launched executable, otherwise None
+
+ Raises:
+ TestSuiteException: Previous processes of this apk could not be
+ killed.
+ '''
+ process_name = ''
+ success = False
+ if app_name in self._tests_apk:
+ process_name = self._tests_apk[app_name]
+
+ self._android.kill_all_processes(process_name)
+
+ success = self._android.launch_app(process_name, 'MainActivity')
+ elif app_name in self._tests_ndk:
+ process_name = app_name
+ self._android.kill_all_processes(process_name)
+ success = self._android.launch_elf(process_name)
+ elif app_name in self._tests_jni:
+ package = self._tests_jni[app_name]
+
+ self._android.kill_process(package)
+
+ success = self._android.launch_app(package, 'MainActivity')
+ if not success:
+ self._log.log_and_print(app_name +
+ ' is not installed. Try removing the --no-install option?')
+ return None
+
+ # Give the app time to crash if it needs to
+ time.sleep(2)
+ return self._android.find_app_pid(package)
+ else:
+ self._log.error('Executable {0} neither Java nor NDK.'
+ .format(app_name))
+
+ self._log.fatal('Failed to launch test executable {0}'
+ .format(app_name))
+ return None
+
+ if not success:
+ self._log.log_and_print(app_name +
+ ' is not installed. Try removing the --no-install option?')
+ return None
+
+ # Give the app time to crash if it needs to
+ time.sleep(20)
+ return self._android.find_app_pid(process_name)
+
+ def check_apps_installed(self, java_only):
+ ''' Check whether all Java/JNI/NDK apps are installed on the device.
+
+ Args:
+ java_only: Boolean to specify whether only the Java apks should be
+ checked (in case of --wimpy mode for example).
+
+ Raises:
+ TestSuiteException: Not all apps are installed.
+ '''
+ java_and_jni_apks = self._tests_apk.copy()
+
+ if not java_only:
+ java_and_jni_apks.update(self._tests_jni)
+
+ installed = self._android.shell('pm list packages -f')
+
+ for app, package in java_and_jni_apks.iteritems():
+ if package not in installed:
+ raise TestSuiteException('apk %s is not installed.' % app)
+
+ if not java_only:
+ ls_data = self._android.shell('ls /data')
+ for app in self._tests_ndk:
+ if app not in ls_data:
+ raise TestSuiteException('app %s is not installed.' % app)
diff --git a/tests/lldb/tests/harness/util_constants.py b/tests/lldb/tests/harness/util_constants.py
new file mode 100644
index 0000000..c50793a
--- /dev/null
+++ b/tests/lldb/tests/harness/util_constants.py
@@ -0,0 +1,8 @@
+'''This file contains constants shared between the test suite runner and the
+individual test runner.'''
+
+RC_TEST_OK = 0
+RC_TEST_TIMEOUT = 64
+RC_TEST_ERROR = 65
+RC_TEST_FATAL = 66
+PUSH_TIMEOUT = 60*5
diff --git a/tests/lldb/tests/harness/util_functions.py b/tests/lldb/tests/harness/util_functions.py
new file mode 100644
index 0000000..10e461c
--- /dev/null
+++ b/tests/lldb/tests/harness/util_functions.py
@@ -0,0 +1,36 @@
+'''This file contains utility functions used by both the test suite and the
+single test executor.'''
+
+import os
+import importlib
+import sys
+
+
+def load_py_module(path):
+ '''Load a python file from disk.
+
+ Args:
+ path: String path to python file.
+
+ Returns:
+ python module if success, None otherwise.
+ '''
+ assert isinstance(path, str)
+ try:
+ if not os.path.exists(path):
+ print 'Path does not exist: ' + path
+ return None
+ path = os.path.abspath(path)
+ module_dir, module_file = os.path.split(path)
+ module_name, _ = os.path.splitext(module_file)
+ # adjust sys.path, runtime counterpart of PYTHONPATH, to temporarily
+ # include the folder containing the user configuration module
+ sys.path.append(module_dir)
+ module_obj = importlib.import_module(module_name)
+ sys.path.pop(0)
+ return module_obj
+ except ImportError as err:
+ print str(err)
+ print "Looking in directory "
+ print module_dir
+ return None
diff --git a/tests/lldb/tests/harness/util_lldb.py b/tests/lldb/tests/harness/util_lldb.py
new file mode 100644
index 0000000..3f6d4d5
--- /dev/null
+++ b/tests/lldb/tests/harness/util_lldb.py
@@ -0,0 +1,71 @@
+'''Module that contains the class UtilLLDB, which provides lldb utility
+methods.'''
+
+import util_constants
+
+try:
+ import lldb
+except ImportError:
+ print 'unable to import lldb'
+ print 'please run "lldb -P" and add to $PYTHONPATH'
+ quit(util_constants.RC_TEST_ERROR)
+
+
+class UtilLLDB(object):
+ '''Provides utility methods to interface with lldb's python bindings.'''
+
+ @staticmethod
+ def start():
+ '''Initialise the lldb debugger framework.'''
+ lldb.SBDebugger_Initialize()
+
+ @staticmethod
+ def stop():
+ '''Terminate the lldb debugger framework.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert lldb
+ lldb.SBDebugger_Terminate()
+
+ @staticmethod
+ def create_debugger():
+ '''Create an lldb debugger instance.
+
+ Returns:
+ The SBDebugger instance that was created.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert lldb
+ inst = lldb.SBDebugger_Create()
+ inst.SetAsync(False)
+ return inst
+
+ @staticmethod
+ def destroy_debugger(dbg):
+ '''Destroy the lldb debugger instance.
+
+ Args:
+ dbg: Instance of SBDebugger that is to be destroyed.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert lldb
+ lldb.SBDebugger_Destroy(dbg)
+
+ @staticmethod
+ def get_module():
+ '''Get the lldb module.
+
+ Returns:
+ The lldb module.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert lldb
+ return lldb
diff --git a/tests/lldb/tests/harness/util_log.py b/tests/lldb/tests/harness/util_log.py
new file mode 100644
index 0000000..fa1b70d
--- /dev/null
+++ b/tests/lldb/tests/harness/util_log.py
@@ -0,0 +1,125 @@
+'''Initialise the Python logging facility for the test suite.
+
+It provides the function to initialise the logging facility and retrieve an
+instance of the logger class. It also contains the definition of the internal
+logger class.
+'''
+from __future__ import print_function
+
+import io
+import sys
+import logging
+
+
+INITIALISED = False
+NAMESPACE = 'RS_LLDB_TESTSUITE'
+
+def initialise(identifier, level=logging.INFO, print_to_stdout=False,
+ file_path=None, file_mode='a'):
+ '''Initialise the logging facility for the test suite.
+
+ This function should be invoked only once, at the start of the program, and
+ before emitting any log.
+
+ Args:
+ identifier: String, a label that will be part of each record. It is
+ usually the test case name.
+ level: Integer, all messages above this log level will be discarded.
+ Valid values are those recognised by the python logging module:
+ https://docs.python.org/2/library/logging.html#levels .
+ print_to_stdout: Boolean, whether the logs should be redirected to
+ sys.stdout (true) or stored into a text file (false).
+ file_path: String, path to the text file in which to store the logs.
+ This option is only meaningful when print_to_stdout = False.
+ file_mode: String, the mode to open the text file. Valid modes are
+ those recognised by the standard Python `open' function.
+ This option is only meaningful when print_to_stdout = False.
+
+ Raises:
+ RuntimeError: If the logging has already been initialised
+ ValueError: If the argument "file_path" has not been provided when
+ print_to_stdout=False
+ '''
+ # pylint: disable=global-statement
+ global INITIALISED
+ if INITIALISED:
+ raise RuntimeError('Already initialised')
+
+ # set the logging class
+ old_logger_class = logging.getLoggerClass()
+ logging.setLoggerClass(RsLogger)
+
+ # initialise the Logger
+ log = logging.getLogger(NAMESPACE)
+ log.setLevel(level) # reject all logs below
+
+ # don't propagate the log records to the logging root
+ log.propagate = False
+
+ # restore the previous class
+ logging.setLoggerClass(old_logger_class)
+
+ # handler
+ if print_to_stdout:
+ handler_default = logging.StreamHandler(sys.stdout)
+ else:
+ if file_path is None:
+ raise ValueError('Missing mandatory argument "file_path"')
+
+ handler_default = logging.FileHandler(file_path, file_mode)
+
+ # Do not filter records in the handler because of the level
+ handler_default.setLevel(logging.NOTSET)
+
+ # format the message
+ handler_default.setFormatter(
+ logging.Formatter(
+ '%(asctime)s [{0}] [%(levelname)s] %(message)s'
+ .format(identifier)
+ ))
+
+ log.addHandler(handler_default)
+
+ INITIALISED = True
+
+
+class RsLogger(logging.getLoggerClass()):
+ '''Internal logging class.
+
+ This is an internal class to enhance the logging facility with the methods
+ "log_and_print" and "seek_to_end".
+ '''
+ # pylint: disable=too-many-public-methods
+
+ def log_and_print(self, msg, level=logging.INFO):
+ '''Print "msg" to stdout and emit a log record.
+
+ Args:
+ msg: The message to emit.
+ level: The level to use. By default it is logging.INFO.
+ '''
+ print(msg)
+ self.log(level, msg)
+
+ def seek_to_end(self):
+ '''Reset the cursor position to the end for all handlers that are
+ Text File managers.'''
+ for hndlr in self.handlers:
+ if isinstance(hndlr, logging.FileHandler):
+ hndlr.stream.seek(0, io.SEEK_END)
+
+
+def get_logger():
+ '''Retrieves the Logger instance related to the testsuite.
+
+ Throws:
+ RuntimeError: If the logging facility has not been initialised with
+ "initialise" beforehand.
+
+ Returns:
+ An instance of logging.Logger to write the logs.
+ '''
+ if not INITIALISED:
+ raise RuntimeError('Logging facility not initialised')
+
+ return logging.getLogger(NAMESPACE)
diff --git a/tests/lldb/tests/harness/util_timer.py b/tests/lldb/tests/harness/util_timer.py
new file mode 100644
index 0000000..a7b0a26
--- /dev/null
+++ b/tests/lldb/tests/harness/util_timer.py
@@ -0,0 +1,76 @@
+'''Timer utility'''
+
+import threading
+
+
+class Timer(object):
+ '''A Timer utility to execute a callback after a certain interval.'''
+
+ def __init__(self, interval, callback):
+ '''Initialise the Timer without starting it.
+
+ Args:
+ interval: int or float, interval in seconds to count, before
+ invoking the callback
+ callback: function, it handles the function to call once
+ the timeout expires.
+ '''
+
+ # validate input parameters
+ if not isinstance(interval, (int, float)):
+ raise TypeError('Argument "interval" is not a number: '
+ '{0}'.format(type(interval)))
+ if not callable(callback):
+ raise TypeError('Argument "callback" is not a function: '
+ '{0}'.format(type(callback)))
+
+ self._timer = None
+ self._callback = callback
+ self._interval = interval
+
+ def _is_running(self):
+ '''Checks whether the timer is executing.
+
+ Returns:
+ boolean, true if the timer is currently running, false otherwise
+ '''
+ return self._timer is not None
+
+ def start(self):
+ '''Starts the timer.
+
+ Returns:
+ self, the Timer instance
+
+ Throws:
+ RuntimeError: if the timer is already running
+ '''
+ if self._is_running():
+ raise RuntimeError('Timer already running')
+
+ self._timer = threading.Timer(self._interval, self._callback)
+ self._timer.start()
+ return self # so that we can perform Timer(...).start()
+
+ def stop(self):
+ '''Stops the timer if it's executing.
+
+ Returns:
+ self, the Timer instance
+ '''
+
+ if self._is_running():
+ self._timer.cancel()
+ self._timer = None
+ return self
+
+ def reset(self):
+ '''Restart the timer.
+
+ Returns:
+ self, the Timer instance
+ '''
+
+ self.stop()
+ self.start()
+ return self
diff --git a/tests/lldb/tests/harness/util_warnings.py b/tests/lldb/tests/harness/util_warnings.py
new file mode 100644
index 0000000..def8e24
--- /dev/null
+++ b/tests/lldb/tests/harness/util_warnings.py
@@ -0,0 +1,44 @@
+'''Redirect the Python warnings into the log.'''
+
+import warnings
+
+from . import util_log
+
+_OLD_WARNINGS_HANDLER = None
+
+
+def redirect_warnings():
+ '''Redirect all warnings issued by warnings::warn to the log.
+
+ By default all python warnings are printed into sys.stderr. This method
+ will force to redirect them into the test suite logger.
+ '''
+
+ # pylint: disable=global-statement
+ global _OLD_WARNINGS_HANDLER
+
+ # Already redirecting?
+ if _OLD_WARNINGS_HANDLER:
+ return None
+
+ _OLD_WARNINGS_HANDLER = warnings.showwarning
+
+ log = util_log.get_logger()
+
+ def _redirect_warnings_to_log(*args):
+ '''Redirect the warnings to the Logger.'''
+ log.warn(warnings.formatwarning(*args).rstrip())
+
+ warnings.showwarning = _redirect_warnings_to_log
+
+
+def restore_warnings():
+ '''Restore the reporting of warnings::warn as before.'''
+
+ # pylint: disable=global-statement
+ global _OLD_WARNINGS_HANDLER
+
+ if _OLD_WARNINGS_HANDLER:
+ warnings.showwarning = _OLD_WARNINGS_HANDLER
+ _OLD_WARNINGS_HANDLER = None
+
diff --git a/tests/lldb/tests/java/test_allocation_dump_1.py b/tests/lldb/tests/java/test_allocation_dump_1.py
new file mode 100644
index 0000000..e04a9de
--- /dev/null
+++ b/tests/lldb/tests/java/test_allocation_dump_1.py
@@ -0,0 +1,324 @@
+'''Module that contains the test TestAllocationDump1.'''
+
+from harness.test_base_remote import TestBaseRemote
+import os
+
+
+class TestAllocationDump1(TestBaseRemote):
+ '''Tests printing the contents of allocations.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test dumping large allocations to file
+ output_file_1 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file_1,
+ ["Results written to '%s'" % output_file_1])
+
+ # Check the file was created
+ self.test_assert(os.path.isfile(output_file_1))
+ os.remove(output_file_1)
+
+ if not wimpy:
+ output_file_2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation dump 2 -f ' +
+ output_file_2,
+ ["Results written to '%s'" % output_file_2])
+
+ self.test_assert(os.path.isfile(output_file_2))
+ os.remove(output_file_2)
+
+ # char
+ self.try_command('language renderscript allocation dump 3',
+ ['(0, 0, 0) = 0',
+ '(0, 1, 0) = 1',
+ '(0, 2, 0) = 2',
+ '(0, 0, 1) = 3',
+ '(0, 1, 1) = 4',
+ '(0, 2, 1) = 5',
+ '(0, 0, 2) = 6',
+ '(0, 1, 2) = 7',
+ '(0, 2, 2) = 8',
+ '(0, 0, 3) = 9',
+ '(0, 1, 3) = 10',
+ '(0, 2, 3) = 11',
+ '(0, 0, 4) = 12',
+ '(0, 1, 4) = 13',
+ '(0, 2, 4) = 14',
+ '(0, 0, 5) = 15',
+ '(0, 1, 5) = 16',
+ '(0, 2, 5) = 17',
+ '(0, 0, 6) = 18',
+ '(0, 1, 6) = 19',
+ '(0, 2, 6) = 20',
+ '(0, 0, 7) = 21',
+ '(0, 1, 7) = 22',
+ '(0, 2, 7) = 23'])
+
+ if not wimpy:
+ # char2
+ self.try_command('language renderscript allocation dump 4',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # char3
+ self.try_command('language renderscript allocation dump 5',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # char4
+ self.try_command('language renderscript allocation dump 6',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # short
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # short2
+ self.try_command('language renderscript allocation dump 8',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(0, 0, 1) = {12 13}',
+ '(1, 0, 1) = {14 15}',
+ '(2, 0, 1) = {16 17}',
+ '(3, 0, 1) = {18 19}',
+ '(4, 0, 1) = {20 21}',
+ '(5, 0, 1) = {22 23}'])
+
+ # short3
+ self.try_command('language renderscript allocation dump 9',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # short4
+ self.try_command('language renderscript allocation dump 10',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # int
+ self.try_command('language renderscript allocation dump 11',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # int2
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # int3
+ self.try_command('language renderscript allocation dump 13',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(0, 1, 0) = {12 13 14}',
+ '(1, 1, 0) = {16 17 18}',
+ '(2, 1, 0) = {20 21 22}'])
+ # int4
+ self.try_command('language renderscript allocation dump 14',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # long
+ self.try_command('language renderscript allocation dump 15',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # long2
+ self.try_command('language renderscript allocation dump 16',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # long3
+ self.try_command('language renderscript allocation dump 17',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # long4
+ self.try_command('language renderscript allocation dump 18',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(0, 1, 0) = {4 5 6 7}',
+ '(0, 2, 0) = {8 9 10 11}',
+ '(0, 3, 0) = {12 13 14 15}',
+ '(0, 4, 0) = {16 17 18 19}',
+ '(0, 5, 0) = {20 21 22 23}'])
+
+ # bool
+ self.try_command('language renderscript allocation dump 19',
+ ['(0, 0, 0) = false',
+ '(1, 0, 0) = true',
+ '(2, 0, 0) = false',
+ '(3, 0, 0) = true',
+ '(4, 0, 0) = false',
+ '(5, 0, 0) = true',
+ '(6, 0, 0) = false',
+ '(7, 0, 0) = true',
+ '(8, 0, 0) = false',
+ '(9, 0, 0) = true',
+ '(10, 0, 0) = false',
+ '(11, 0, 0) = true',
+ '(12, 0, 0) = false',
+ '(13, 0, 0) = true',
+ '(14, 0, 0) = false',
+ '(15, 0, 0) = true',
+ '(16, 0, 0) = false',
+ '(17, 0, 0) = true',
+ '(18, 0, 0) = false',
+ '(19, 0, 0) = true',
+ '(20, 0, 0) = false',
+ '(21, 0, 0) = true',
+ '(22, 0, 0) = false',
+ '(23, 0, 0) = true'])
diff --git a/tests/lldb/tests/java/test_allocation_dump_2.py b/tests/lldb/tests/java/test_allocation_dump_2.py
new file mode 100644
index 0000000..f747894
--- /dev/null
+++ b/tests/lldb/tests/java/test_allocation_dump_2.py
@@ -0,0 +1,589 @@
+'''Module that contains the test TestAllocationDump2'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationDump2(TestBaseRemote):
+ '''Tests printing the contents of allocations.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # uchar
+ self.try_command('language renderscript allocation dump 20',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ if not wimpy:
+ # uchar2
+ self.try_command('language renderscript allocation dump 21',
+ ['(0, 0, 0) = {0x00 0x01}',
+ '(1, 0, 0) = {0x02 0x03}',
+ '(0, 1, 0) = {0x04 0x05}',
+ '(1, 1, 0) = {0x06 0x07}',
+ '(0, 2, 0) = {0x08 0x09}',
+ '(1, 2, 0) = {0x0a 0x0b}',
+ '(0, 3, 0) = {0x0c 0x0d}',
+ '(1, 3, 0) = {0x0e 0x0f}',
+ '(0, 4, 0) = {0x10 0x11}',
+ '(1, 4, 0) = {0x12 0x13}',
+ '(0, 5, 0) = {0x14 0x15}',
+ '(1, 5, 0) = {0x16 0x17}'])
+
+ # uchar3
+ self.try_command('language renderscript allocation dump 22',
+ ['(0, 0, 0) = {0x00 0x01 0x02}',
+ '(1, 0, 0) = {0x04 0x05 0x06}',
+ '(2, 0, 0) = {0x08 0x09 0x0a}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e}',
+ '(4, 0, 0) = {0x10 0x11 0x12}',
+ '(5, 0, 0) = {0x14 0x15 0x16}'])
+
+ # uchar4
+ self.try_command('language renderscript allocation dump 23',
+ ['(0, 0, 0) = {0x00 0x01 0x02 0x03}',
+ '(1, 0, 0) = {0x04 0x05 0x06 0x07}',
+ '(2, 0, 0) = {0x08 0x09 0x0a 0x0b}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e 0x0f}',
+ '(4, 0, 0) = {0x10 0x11 0x12 0x13}',
+ '(5, 0, 0) = {0x14 0x15 0x16 0x17}'])
+
+ # ushort
+ self.try_command('language renderscript allocation dump 24',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # ushort2
+ self.try_command('language renderscript allocation dump 25',
+ ['(0, 0, 0) = {0x0000 0x0001}',
+ '(1, 0, 0) = {0x0002 0x0003}',
+ '(2, 0, 0) = {0x0004 0x0005}',
+ '(3, 0, 0) = {0x0006 0x0007}',
+ '(4, 0, 0) = {0x0008 0x0009}',
+ '(5, 0, 0) = {0x000a 0x000b}',
+ '(6, 0, 0) = {0x000c 0x000d}',
+ '(7, 0, 0) = {0x000e 0x000f}',
+ '(8, 0, 0) = {0x0010 0x0011}',
+ '(9, 0, 0) = {0x0012 0x0013}',
+ '(10, 0, 0) = {0x0014 0x0015}',
+ '(11, 0, 0) = {0x0016 0x0017}'])
+
+ # ushort3
+ self.try_command('language renderscript allocation dump 26',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002}',
+ '(0, 1, 0) = {0x0004 0x0005 0x0006}',
+ '(0, 2, 0) = {0x0008 0x0009 0x000a}',
+ '(0, 3, 0) = {0x000c 0x000d 0x000e}',
+ '(0, 4, 0) = {0x0010 0x0011 0x0012}',
+ '(0, 5, 0) = {0x0014 0x0015 0x0016}'])
+
+ # ushort4
+ self.try_command('language renderscript allocation dump 27',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002 0x0003}',
+ '(1, 0, 0) = {0x0004 0x0005 0x0006 0x0007}',
+ '(2, 0, 0) = {0x0008 0x0009 0x000a 0x000b}',
+ '(3, 0, 0) = {0x000c 0x000d 0x000e 0x000f}',
+ '(4, 0, 0) = {0x0010 0x0011 0x0012 0x0013}',
+ '(5, 0, 0) = {0x0014 0x0015 0x0016 0x0017}'])
+
+ # uint
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # uint2
+ self.try_command('language renderscript allocation dump 29',
+ ['(0, 0, 0) = {0x00000000 0x00000001}',
+ '(1, 0, 0) = {0x00000002 0x00000003}',
+ '(2, 0, 0) = {0x00000004 0x00000005}',
+ '(3, 0, 0) = {0x00000006 0x00000007}',
+ '(4, 0, 0) = {0x00000008 0x00000009}',
+ '(5, 0, 0) = {0x0000000a 0x0000000b}',
+ '(6, 0, 0) = {0x0000000c 0x0000000d}',
+ '(7, 0, 0) = {0x0000000e 0x0000000f}',
+ '(8, 0, 0) = {0x00000010 0x00000011}',
+ '(9, 0, 0) = {0x00000012 0x00000013}',
+ '(10, 0, 0) = {0x00000014 0x00000015}',
+ '(11, 0, 0) = {0x00000016 0x00000017}'])
+
+ # uint3
+ self.try_command('language renderscript allocation dump 30',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002}',
+ '(1, 0, 0) = {0x00000004 0x00000005 0x00000006}',
+ '(2, 0, 0) = {0x00000008 0x00000009 0x0000000a}',
+ '(3, 0, 0) = {0x0000000c 0x0000000d 0x0000000e}',
+ '(4, 0, 0) = {0x00000010 0x00000011 0x00000012}',
+ '(5, 0, 0) = {0x00000014 0x00000015 0x00000016}'])
+
+ # uint4
+ self.try_command('language renderscript allocation dump 31',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002 0x00000003}',
+ '(0, 0, 1) = {0x00000004 0x00000005 0x00000006 0x00000007}',
+ '(0, 0, 2) = {0x00000008 0x00000009 0x0000000a 0x0000000b}',
+ '(0, 0, 3) = {0x0000000c 0x0000000d 0x0000000e 0x0000000f}',
+ '(0, 0, 4) = {0x00000010 0x00000011 0x00000012 0x00000013}',
+ '(0, 0, 5) = {0x00000014 0x00000015 0x00000016 0x00000017}'])
+
+ # ulong
+ self.try_command('language renderscript allocation dump 32',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(0, 1, 0) = 4',
+ '(1, 1, 0) = 5',
+ '(2, 1, 0) = 6',
+ '(3, 1, 0) = 7',
+ '(0, 2, 0) = 8',
+ '(1, 2, 0) = 9',
+ '(2, 2, 0) = 10',
+ '(3, 2, 0) = 11',
+ '(0, 0, 1) = 12',
+ '(1, 0, 1) = 13',
+ '(2, 0, 1) = 14',
+ '(3, 0, 1) = 15',
+ '(0, 1, 1) = 16',
+ '(1, 1, 1) = 17',
+ '(2, 1, 1) = 18',
+ '(3, 1, 1) = 19',
+ '(0, 2, 1) = 20',
+ '(1, 2, 1) = 21',
+ '(2, 2, 1) = 22',
+ '(3, 2, 1) = 23'])
+
+ # ulong2
+ self.try_command('language renderscript allocation dump 33',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001}',
+ '(1, 0, 0) = {0x0000000000000002 0x0000000000000003}',
+ '(2, 0, 0) = {0x0000000000000004 0x0000000000000005}',
+ '(3, 0, 0) = {0x0000000000000006 0x0000000000000007}',
+ '(4, 0, 0) = {0x0000000000000008 0x0000000000000009}',
+ '(5, 0, 0) = {0x000000000000000a 0x000000000000000b}',
+ '(6, 0, 0) = {0x000000000000000c 0x000000000000000d}',
+ '(7, 0, 0) = {0x000000000000000e 0x000000000000000f}',
+ '(8, 0, 0) = {0x0000000000000010 0x0000000000000011}',
+ '(9, 0, 0) = {0x0000000000000012 0x0000000000000013}',
+ '(10, 0, 0) = {0x0000000000000014 0x0000000000000015}',
+ '(11, 0, 0) = {0x0000000000000016 0x0000000000000017}'])
+
+ # ulong3
+ self.try_command('language renderscript allocation dump 34',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 0x0000000000000002}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 0x0000000000000006}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 0x000000000000000a}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d 0x000000000000000e}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 0x0000000000000012}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 0x0000000000000016}'])
+
+ # ulong4
+ self.try_command('language renderscript allocation dump 35',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 '
+ '0x0000000000000002 0x0000000000000003}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 '
+ '0x0000000000000006 0x0000000000000007}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 '
+ '0x000000000000000a 0x000000000000000b}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d '
+ '0x000000000000000e 0x000000000000000f}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 '
+ '0x0000000000000012 0x0000000000000013}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 '
+ '0x0000000000000016 0x0000000000000017}'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ if not wimpy:
+ # half
+ self.try_command('language renderscript allocation dump 36',
+ ['(0, 0, 0) = 1',
+ '(1, 0, 0) = 1.00098',
+ '(2, 0, 0) = 1.00195',
+ '(3, 0, 0) = 1.00293',
+ '(4, 0, 0) = 1.00391',
+ '(5, 0, 0) = 1.00488',
+ '(6, 0, 0) = 1.00586',
+ '(7, 0, 0) = 1.00684',
+ '(8, 0, 0) = 1.00781',
+ '(9, 0, 0) = 1.00879',
+ '(10, 0, 0) = 1.00977',
+ '(11, 0, 0) = 1.01074',
+ '(12, 0, 0) = 1.01172',
+ '(13, 0, 0) = 1.0127',
+ '(14, 0, 0) = 1.01367',
+ '(15, 0, 0) = 1.01465',
+ '(16, 0, 0) = 1.0156',
+ '(17, 0, 0) = 1.0166',
+ '(18, 0, 0) = 1.01758',
+ '(19, 0, 0) = 1.01855',
+ '(20, 0, 0) = 1.01953',
+ '(21, 0, 0) = 1.02051',
+ '(22, 0, 0) = 1.02148',
+ '(23, 0, 0) = 1.02246'])
+
+ # half2
+ self.try_command('language renderscript allocation dump 37',
+ ['(0, 0, 0) = {1 1.00098}',
+ '(1, 0, 0) = {1.00195 1.00293}',
+ '(2, 0, 0) = {1.00391 1.00488}',
+ '(3, 0, 0) = {1.00586 1.00684}',
+ '(4, 0, 0) = {1.00781 1.00879}',
+ '(5, 0, 0) = {1.00977 1.01074}',
+ '(6, 0, 0) = {1.01172 1.0127}',
+ '(7, 0, 0) = {1.01367 1.01465}',
+ '(9, 0, 0) = {1.01758 1.01855}',
+ '(10, 0, 0) = {1.01953 1.02051}',
+ '(11, 0, 0) = {1.02148 1.02246}'],
+ [r'\(8, 0, 0\) = \{1\.0156[23] 1\.0166\}'])
+
+ # half3
+ self.try_command('language renderscript allocation dump 38',
+ ['(0, 0, 0) = {1 1.00098 1.00195}',
+ '(0, 1, 0) = {1.00391 1.00488 1.00586}',
+ '(0, 2, 0) = {1.00781 1.00879 1.00977}',
+ '(0, 3, 0) = {1.01172 1.0127 1.01367}',
+ '(0, 5, 0) = {1.01953 1.02051 1.02148}'],
+ [r'\(0, 4, 0\) = \{1\.0156[23] 1\.0166 1\.01758\}'])
+
+ # half4
+ self.try_command('language renderscript allocation dump 39',
+ ['(0, 0, 0) = {1 1.00098 1.00195 1.00293}',
+ '(1, 0, 0) = {1.00391 1.00488 1.00586 1.00684}',
+ '(2, 0, 0) = {1.00781 1.00879 1.00977 1.01074}',
+ '(3, 0, 0) = {1.01172 1.0127 1.01367 1.01465}',
+ '(5, 0, 0) = {1.01953 1.02051 1.02148 1.02246}'],
+ [r'\(4, 0, 0\) = \{1\.0156[23] 1\.0166 1\.01758 1\.01855\}'])
+
+ # float
+ self.try_command('language renderscript allocation dump 40',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166667',
+ '(7, 0, 0) = 0.142857',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909091',
+ '(12, 0, 0) = 0.0833333',
+ '(13, 0, 0) = 0.0769231',
+ '(14, 0, 0) = 0.0714286',
+ '(15, 0, 0) = 0.0666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235',
+ '(18, 0, 0) = 0.0555556',
+ '(19, 0, 0) = 0.0526316',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.047619',
+ '(22, 0, 0) = 0.0454545',
+ '(23, 0, 0) = 0.0434783'])
+
+ # float2
+ self.try_command('language renderscript allocation dump 41',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166667 0.142857}',
+ '(4, 0, 0) = {0.125 0.111111}',
+ '(5, 0, 0) = {0.1 0.0909091}',
+ '(6, 0, 0) = {0.0833333 0.0769231}',
+ '(7, 0, 0) = {0.0714286 0.0666667}',
+ '(8, 0, 0) = {0.0625 0.0588235}',
+ '(9, 0, 0) = {0.0555556 0.0526316}',
+ '(10, 0, 0) = {0.05 0.047619}',
+ '(11, 0, 0) = {0.0454545 0.0434783}'])
+
+ # float3
+ self.try_command('language renderscript allocation dump 42',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(1, 0, 0) = {0.25 0.2 0.166667}',
+ '(2, 0, 0) = {0.125 0.111111 0.1}',
+ '(3, 0, 0) = {0.0833333 0.0769231 0.0714286}',
+ '(4, 0, 0) = {0.0625 0.0588235 0.0555556}',
+ '(5, 0, 0) = {0.05 0.047619 0.0454545}'])
+
+ # float4
+ self.try_command('language renderscript allocation dump 43',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333}',
+ '(1, 0, 0) = {0.25 0.2 0.166667 0.142857}',
+ '(2, 0, 0) = {0.125 0.111111 0.1 0.0909091}',
+ '(0, 1, 0) = {0.0833333 0.0769231 0.0714286 0.0666667}',
+ '(1, 1, 0) = {0.0625 0.0588235 0.0555556 0.0526316}',
+ '(2, 1, 0) = {0.05 0.047619 0.0454545 0.0434783}'])
+
+ # double
+ self.try_command('language renderscript allocation dump 44',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333333333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166666666666667',
+ '(7, 0, 0) = 0.142857142857143',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111111111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909090909090909',
+ '(12, 0, 0) = 0.0833333333333333',
+ '(13, 0, 0) = 0.0769230769230769',
+ '(14, 0, 0) = 0.0714285714285714',
+ '(15, 0, 0) = 0.0666666666666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235294117647',
+ '(18, 0, 0) = 0.0555555555555556',
+ '(19, 0, 0) = 0.0526315789473684',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.0476190476190476',
+ '(22, 0, 0) = 0.0454545454545455',
+ '(23, 0, 0) = 0.0434782608695652'])
+
+ # double2
+ self.try_command('language renderscript allocation dump 45',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333333333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111}',
+ '(1, 0, 1) = {0.1 0.0909090909090909}',
+ '(2, 0, 1) = {0.0833333333333333 0.0769230769230769}',
+ '(3, 0, 1) = {0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647}',
+ '(1, 0, 2) = {0.0555555555555556 0.0526315789473684}',
+ '(2, 0, 2) = {0.05 0.0476190476190476}',
+ '(3, 0, 2) = {0.0454545454545455 0.0434782608695652}'])
+
+ # double3
+ self.try_command('language renderscript allocation dump 46',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 0.0555555555555556}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 0.0454545454545455}'])
+
+ # double4
+ self.try_command('language renderscript allocation dump 47',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333333333333}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1 0.0909090909090909}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 '
+ '0.0555555555555556 0.0526315789473684}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 '
+ '0.0454545454545455 0.0434782608695652}'])
+
+ # Delete kernel breakpoint on add_half_kernel
+ self.try_command('breakpoint del 3',
+ ['1 breakpoints deleted'])
+
+ # Hit struct_kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Double 3 has been modified by add_half_kernel
+ self.try_command('language renderscript allocation dump 46',
+ ['(0, 0, 0) = {inf 1.5 1}',
+ '(0, 1, 0) = {0.75 0.7 0.666666666666667}',
+ '(0, 0, 1) = {0.625 0.611111111111111 0.6}',
+ '(0, 1, 1) = {0.583333333333333 0.576923076923077 0.571428571428571}',
+ '(0, 0, 2) = {0.5625 0.558823529411765 0.555555555555556}',
+ '(0, 1, 2) = {0.55 0.547619047619048 0.545454545454545}'])
+
+ # Floating point allocation data should have been overwritten
+ self.try_command('language renderscript allocation dump 40',
+ ['(0, 0, 0) = -inf',
+ '(1, 0, 0) = -1',
+ '(2, 0, 0) = -0.5',
+ '(3, 0, 0) = -0.333333',
+ '(4, 0, 0) = -0.25',
+ '(5, 0, 0) = -0.2',
+ '(6, 0, 0) = -0.166667',
+ '(7, 0, 0) = -0.142857',
+ '(8, 0, 0) = -0.125',
+ '(9, 0, 0) = -0.111111',
+ '(10, 0, 0) = -0.1',
+ '(11, 0, 0) = -0.0909091',
+ '(12, 0, 0) = -0.0833333',
+ '(13, 0, 0) = -0.0769231',
+ '(14, 0, 0) = -0.0714286',
+ '(15, 0, 0) = -0.0666667',
+ '(16, 0, 0) = -0.0625',
+ '(17, 0, 0) = -0.0588235',
+ '(18, 0, 0) = -0.0555556',
+ '(19, 0, 0) = -0.0526316',
+ '(20, 0, 0) = -0.05',
+ '(21, 0, 0) = -0.047619',
+ '(22, 0, 0) = -0.0454545',
+ '(23, 0, 0) = -0.0434783'])
+
+ self.try_command('language renderscript allocation dump 41',
+ ['(0, 0, 0) = {-inf -1}',
+ '(1, 0, 0) = {-0.5 -0.333333}',
+ '(2, 0, 0) = {-0.25 -0.2}',
+ '(3, 0, 0) = {-0.166667 -0.142857}',
+ '(4, 0, 0) = {-0.125 -0.111111}',
+ '(5, 0, 0) = {-0.1 -0.0909091}',
+ '(6, 0, 0) = {-0.0833333 -0.0769231}',
+ '(7, 0, 0) = {-0.0714286 -0.0666667}',
+ '(8, 0, 0) = {-0.0625 -0.0588235}',
+ '(9, 0, 0) = {-0.0555556 -0.0526316}',
+ '(10, 0, 0) = {-0.05 -0.047619}',
+ '(11, 0, 0) = {-0.0454545 -0.0434783}'])
+
+ self.try_command('language renderscript allocation dump 42',
+ ['(0, 0, 0) = {-inf -1 -0.5}',
+ '(1, 0, 0) = {-0.25 -0.2 -0.166667}',
+ '(2, 0, 0) = {-0.125 -0.111111 -0.1}',
+ '(3, 0, 0) = {-0.0833333 -0.0769231 -0.0714286}',
+ '(4, 0, 0) = {-0.0625 -0.0588235 -0.0555556}',
+ '(5, 0, 0) = {-0.05 -0.047619 -0.0454545}'])
+
+ self.try_command('language renderscript allocation dump 43',
+ ['(0, 0, 0) = {-inf -1 -0.5 -0.333333}',
+ '(1, 0, 0) = {-0.25 -0.2 -0.166667 -0.142857}',
+ '(2, 0, 0) = {-0.125 -0.111111 -0.1 -0.0909091}',
+ '(0, 1, 0) = {-0.0833333 -0.0769231 -0.0714286 -0.0666667}',
+ '(1, 1, 0) = {-0.0625 -0.0588235 -0.0555556 -0.0526316}',
+ '(2, 1, 0) = {-0.05 -0.047619 -0.0454545 -0.0434783}'])
diff --git a/tests/lldb/tests/java/test_allocation_dump_struct.py b/tests/lldb/tests/java/test_allocation_dump_struct.py
new file mode 100644
index 0000000..ee6c2d0
--- /dev/null
+++ b/tests/lldb/tests/java/test_allocation_dump_struct.py
@@ -0,0 +1,160 @@
+'''Module that contains the test TestAllocationDumpStruct.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationDumpStruct(TestBaseRemote):
+ '''Tests printing the contents of a struct allocation.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # Hit struct_kernel on last coordinate, so almost all elements have been initalised
+ self.try_command('language renderscript kernel breakpoint set struct_kernel -c 23',
+ ['Conditional kernel breakpoint on coordinate 23, 0, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # complex_struct output allocation
+ self.try_command('language renderscript allocation dump 49',
+ ['(0, 0, 0) = (complexStruct) {\n'
+ ' (i = 0, j = 0)\n'
+ ' (0x00, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 0, [1] = 0.5)\n'
+ '}',
+ '(1, 0, 0) = (complexStruct) {\n'
+ ' (i = 1, j = 1)\n'
+ ' (0x01, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 1, [1] = 1.5)\n'
+ '}',
+ '(2, 0, 0) = (complexStruct) {\n'
+ ' (i = 2, j = 2)\n'
+ ' (0x02, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 2, [1] = 2.5)\n'
+ '}',
+ '(3, 0, 0) = (complexStruct) {\n'
+ ' (i = 3, j = 3)\n'
+ ' (0x03, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 3, [1] = 3.5)\n'
+ '}',
+ '(4, 0, 0) = (complexStruct) {\n'
+ ' (i = 4, j = 4)\n'
+ ' (0x04, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 4, [1] = 4.5)\n'
+ '}',
+ '(5, 0, 0) = (complexStruct) {\n'
+ ' (i = 5, j = 5)\n'
+ ' (0x05, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 5, [1] = 5.5)\n'
+ '}',
+ '(6, 0, 0) = (complexStruct) {\n'
+ ' (i = 6, j = 6)\n'
+ ' (0x06, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 6, [1] = 6.5)\n'
+ '}',
+ '(7, 0, 0) = (complexStruct) {\n'
+ ' (i = 7, j = 7)\n'
+ ' (0x07, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 7, [1] = 7.5)\n'
+ '}',
+ '(8, 0, 0) = (complexStruct) {\n'
+ ' (i = 8, j = 8)\n'
+ ' (0x08, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 8, [1] = 8.5)\n'
+ '}',
+ '(9, 0, 0) = (complexStruct) {\n'
+ ' (i = 9, j = 9)\n'
+ ' (0x09, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 9, [1] = 9.5)\n'
+ '}',
+ '(10, 0, 0) = (complexStruct) {\n'
+ ' (i = 10, j = 10)\n'
+ ' (0x0a, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 10, [1] = 10.5)\n'
+ '}',
+ '(11, 0, 0) = (complexStruct) {\n'
+ ' (i = 11, j = 11)\n'
+ ' (0x0b, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 11, [1] = 11.5)\n'
+ '}',
+ '(12, 0, 0) = (complexStruct) {\n'
+ ' (i = 12, j = 12)\n'
+ ' (0x0c, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 12, [1] = 12.5)\n'
+ '}',
+ '(13, 0, 0) = (complexStruct) {\n'
+ ' (i = 13, j = 13)\n'
+ ' (0x0d, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 13, [1] = 13.5)\n'
+ '}',
+ '(14, 0, 0) = (complexStruct) {\n'
+ ' (i = 14, j = 14)\n'
+ ' (0x0e, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 14, [1] = 14.5)\n'
+ '}',
+ '(15, 0, 0) = (complexStruct) {\n'
+ ' (i = 15, j = 15)\n'
+ ' (0x0f, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 15, [1] = 15.5)\n'
+ '}',
+ '(16, 0, 0) = (complexStruct) {\n'
+ ' (i = 16, j = 16)\n'
+ ' (0x10, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 16, [1] = 16.5)\n'
+ '}',
+ '(17, 0, 0) = (complexStruct) {\n'
+ ' (i = 17, j = 17)\n'
+ ' (0x11, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 17, [1] = 17.5)\n'
+ '}',
+ '(18, 0, 0) = (complexStruct) {\n'
+ ' (i = 18, j = 18)\n'
+ ' (0x12, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 18, [1] = 18.5)\n'
+ '}',
+ '(19, 0, 0) = (complexStruct) {\n'
+ ' (i = 19, j = 19)\n'
+ ' (0x13, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 19, [1] = 19.5)\n'
+ '}',
+ '(20, 0, 0) = (complexStruct) {\n'
+ ' (i = 20, j = 20)\n'
+ ' (0x14, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 20, [1] = 20.5)\n'
+ '}',
+ '(21, 0, 0) = (complexStruct) {\n'
+ ' (i = 21, j = 21)\n'
+ ' (0x15, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 21, [1] = 21.5)\n'
+ '}',
+ '(22, 0, 0) = (complexStruct) {\n'
+ ' (i = 22, j = 22)\n'
+ ' (0x16, 0x41, 0x42, 0x43)\n'
+ ' ([0] = 22, [1] = 22.5)\n'
+ '}'])
diff --git a/tests/lldb/tests/java/test_allocation_file.py b/tests/lldb/tests/java/test_allocation_file.py
new file mode 100644
index 0000000..84f8b27
--- /dev/null
+++ b/tests/lldb/tests/java/test_allocation_file.py
@@ -0,0 +1,189 @@
+'''Module that contains the test TestAllocationFile.'''
+
+from harness.test_base_remote import TestBaseRemote
+import os
+
+
+class TestAllocationFile(TestBaseRemote):
+ '''Tests saving the contents of allocations to disk and reloading them.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of int2 allocation
+ file_int2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 12 ' +
+ file_int2,
+ ["Allocation written to file '%s'" % file_int2])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_int2))
+
+ # Load the file we just created, to assert the allocation contents are
+ # the same
+ self.try_command('language renderscript allocation load 12 ' +
+ file_int2,
+ ["Contents of file '%s' read into allocation 12" %
+ file_int2])
+ os.remove(file_int2)
+
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of uint allocation
+ file_uint = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 28 ' +
+ file_uint,
+ ["Allocation written to file '%s'" % file_uint])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_uint))
+
+ # Test loading file into allocation with an incompatible type 'short'
+ self.try_command('language renderscript allocation load 7 ' + file_uint,
+ ["Contents of file '%s' read into allocation 7" %
+ file_uint,
+ "Warning: Mismatched Element sizes",
+ "Warning: Mismatched Types",
+ "Warning: Mismatched allocation sizes"])
+
+ # Check result of size inconsistency, mapping 4-byte unsigned to 2-byte
+ # int
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 0',
+ '(2, 0, 0) = 1',
+ '(3, 0, 0) = 0',
+ '(4, 0, 0) = 2',
+ '(5, 0, 0) = 0',
+ '(6, 0, 0) = 3',
+ '(7, 0, 0) = 0',
+ '(8, 0, 0) = 4',
+ '(9, 0, 0) = 0',
+ '(10, 0, 0) = 5',
+ '(11, 0, 0) = 0',
+ '(12, 0, 0) = 6',
+ '(13, 0, 0) = 0',
+ '(14, 0, 0) = 7',
+ '(15, 0, 0) = 0',
+ '(16, 0, 0) = 8',
+ '(17, 0, 0) = 0',
+ '(18, 0, 0) = 9',
+ '(19, 0, 0) = 0',
+ '(20, 0, 0) = 10',
+ '(21, 0, 0) = 0',
+ '(22, 0, 0) = 11',
+ '(23, 0, 0) = 0'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ # Load uint allocation from save before square_kernel had been run
+ self.try_command('language renderscript allocation load 28 ' +
+ file_uint,
+ ["Contents of file '%s' read into allocation 28" %
+ file_uint])
+ os.remove(file_uint)
+
+ # Check contents are back to original
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
diff --git a/tests/lldb/tests/java/test_allocation_list.py b/tests/lldb/tests/java/test_allocation_list.py
new file mode 100644
index 0000000..5641406
--- /dev/null
+++ b/tests/lldb/tests/java/test_allocation_list.py
@@ -0,0 +1,523 @@
+'''Module that contains the test TestAllocationList.'''
+
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationList(TestBaseRemote):
+ '''Tests printing the details of all allocations.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=anomalous-backslash-in-string
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test command line flag for single allocation
+ self.try_command('language renderscript allocation list -i 3',
+ [],
+ ['3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User'])
+
+ if not wimpy:
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User',
+ '4:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: char2\n'
+ ' Data Kind: User',
+ '5:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char3\n'
+ ' Data Kind: User',
+ '6:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char4\n'
+ ' Data Kind: User',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '8:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 1, 2\)\n'
+ ' Data Type: short2\n'
+ ' Data Kind: User',
+ '9:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short3\n'
+ ' Data Kind: User',
+ '10:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short4\n'
+ ' Data Kind: User',
+ '11:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: int\n'
+ ' Data Kind: User',
+ '12:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: int2\n'
+ ' Data Kind: User',
+ '13:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: int3\n'
+ ' Data Kind: User',
+ '14:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: int4\n'
+ ' Data Kind: User',
+ '15:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: long\n'
+ ' Data Kind: User',
+ '16:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: long2\n'
+ ' Data Kind: User',
+ '17:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: long3\n'
+ ' Data Kind: User',
+ '18:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: long4\n'
+ ' Data Kind: User',
+ '19:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: bool\n'
+ ' Data Kind: User'
+ ])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ if not wimpy:
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '20:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uchar\n'
+ ' Data Kind: User',
+ '21:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(2, 6, 0\)\n'
+ ' Data Type: uchar2\n'
+ ' Data Kind: User',
+ '22:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar3\n'
+ ' Data Kind: User',
+ '23:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: User',
+ '24:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: ushort\n'
+ ' Data Kind: User',
+ '25:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ushort2\n'
+ ' Data Kind: User',
+ '26:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: ushort3\n'
+ ' Data Kind: User',
+ '27:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ushort4\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '29:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: uint2\n'
+ ' Data Kind: User',
+ '30:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uint3\n'
+ ' Data Kind: User',
+ '31:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 1, 6\)\n'
+ ' Data Type: uint4\n'
+ ' Data Kind: User',
+ '32:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 3, 2\)\n'
+ ' Data Type: ulong\n'
+ ' Data Kind: User',
+ '33:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ulong2\n'
+ ' Data Kind: User',
+ '34:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong3\n'
+ ' Data Kind: User',
+ '35:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong4\n'
+ ' Data Kind: User'
+ ])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ if not wimpy:
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '36:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: half\n'
+ ' Data Kind: User',
+ '37:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: half2\n'
+ ' Data Kind: User',
+ '38:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: half3\n'
+ ' Data Kind: User',
+ '39:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: half4\n'
+ ' Data Kind: User',
+ '40:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: float\n'
+ ' Data Kind: User',
+ '41:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: float2\n'
+ ' Data Kind: User',
+ '42:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: float3\n'
+ ' Data Kind: User',
+ '43:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: float4\n'
+ ' Data Kind: User',
+ '44:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: double\n'
+ ' Data Kind: User',
+ '45:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 1, 3\)\n'
+ ' Data Type: double2\n'
+ ' Data Kind: User',
+ '46:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double3\n'
+ ' Data Kind: User',
+ '47:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double4\n'
+ ' Data Kind: User'])
+
+ self.try_command('breakpoint del 3',
+ ['1 breakpoints deleted'])
+
+ # Hit last kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '46:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double3\n'
+ ' Data Kind: User',
+ '48:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: complexStruct\n'
+ ' Data Kind: User',
+ '49:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: complexStruct\n'
+ ' Data Kind: User'])
diff --git a/tests/lldb/tests/java/test_backtrace.py b/tests/lldb/tests/java/test_backtrace.py
new file mode 100644
index 0000000..5c532c4
--- /dev/null
+++ b/tests/lldb/tests/java/test_backtrace.py
@@ -0,0 +1,72 @@
+'''Module that contains the test TestBacktrace.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBacktrace(TestBaseRemote):
+ '''Tests breaking on a kernel and a function, and viewing the call stack.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'BranchingFunCalls'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see three functions in bt:
+ # libRSCpuRef, kernel.expand and the kernel
+ 'frame #2:',
+ 'librs.scalars.so',
+ 'simple_kernel'],
+ [r'scalars\.rs:4[567]'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('b set_i',
+ ['Breakpoint 2',
+ 'set_i'],
+ [r'scalars\.rs:2[012]'])
+
+ self.try_command('breakpoint list',
+ ['set_i', 'resolved'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see five functions in bt:
+ # libRSCpuRef, kernel.expand, kernel and two functions
+ 'frame #4:',
+ 'librs.scalars.so',
+ 'modify_i',
+ 'set_i'],
+ [r'scalars\.rs:2[012]'])
diff --git a/tests/lldb/tests/java/test_breakpoint_coordinate.py b/tests/lldb/tests/java/test_breakpoint_coordinate.py
new file mode 100644
index 0000000..1709301
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_coordinate.py
@@ -0,0 +1,165 @@
+'''Module that contains the test TestBreakpointCoordinate.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointCoordinate(TestBaseRemote):
+ '''Tests breaking on a specific kernel invocation.
+
+ Uses the -c option to specify the coordinate.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'Allocations'
+
+ def test_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 test_shutdown(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')
+
+ def _check_coordinates(self, (x_coord, y_coord, z_coord), kernel):
+ '''Run lldb commands to check that coordinates match expected values.
+
+ Args:
+ (x_coord, y_coord, z_coord): The expected coordinates.
+ kernel: String that is the name of the kernel function.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.allocs.so`%s' % kernel])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (%d, %d, %d)'
+ % (x_coord, y_coord, z_coord)])
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ if not wimpy:
+ # Test conditional coordinate in a two dimensions
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 3,7',
+ ['Conditional kernel breakpoint on coordinate 3, 7, 0',
+ 'Breakpoint(s) created'])
+
+ # We will delete this breakpoint before we hit it.
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 199,199',
+ ['Conditional kernel breakpoint on coordinate 199, 199, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((3, 7, 0), 'swizzle_kernel')
+
+ # Check breakpoints that have been hit are disabled
+ self.try_command('breakpoint list',
+ ["1: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1 Options: disabled",
+ "2: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on 199,199,0
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ # Test conditional coordinate in a single dimension
+ self.try_command('language renderscript kernel breakpoint set square_kernel -c 8',
+ ['Conditional kernel breakpoint on coordinate 8, 0, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((8, 0, 0), 'square_kernel')
+
+ # Test conditional coordinate in three dimensions
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,0,1',
+ ['Conditional kernel breakpoint on coordinate 0, 0, 1',
+ 'Breakpoint(s) created'])
+
+ # Test we can set more than one conditional kernel breakpoint and both
+ # will be hit
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,1,2',
+ ['Conditional kernel breakpoint on coordinate 0, 1, 2',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 0, 1), 'add_half_kernel')
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'add_half_kernel')
+
+ # Check we can see the coordinate from a function invoked by the kernel
+ self.try_command('break set -n half_helper',
+ ['librs.allocs.so`half_helper'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'half_helper')
+
+ # Delete helper function breakpoint
+ if wimpy:
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+ else:
+ self.try_command('breakpoint delete 6',
+ ['1 breakpoints deleted'])
+
+ # Check our delete breakpoints have been removed
+ if wimpy:
+ self.try_command('breakpoint list',
+ ["1: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled",
+ "2: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled"])
+ else:
+ # Delete breakpoint which has already been disabled
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["3: RenderScript kernel breakpoint for 'square_kernel', locations = 1 Options: disabled",
+ "4: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled",
+ "5: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled"])
diff --git a/tests/lldb/tests/java/test_breakpoint_fileline.py b/tests/lldb/tests/java/test_breakpoint_fileline.py
new file mode 100644
index 0000000..175dc44
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_fileline.py
@@ -0,0 +1,54 @@
+'''Module that contains the test TestBreakpointFileLine.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointFileLine(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a specific line of a RS file.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('bt',
+ ['librs.simple.so',
+ 'simple_kernel',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ['simple.rs',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command(
+ 'language renderscript kernel breakpoint set simple_kernel',
+ ['where = librs.simple.so`simple_kernel',
+ 'Breakpoint(s) created'])
+
+ self.try_command('breakpoint list',
+ [])
diff --git a/tests/lldb/tests/java/test_breakpoint_fileline_multiple_rs_files.py b/tests/lldb/tests/java/test_breakpoint_fileline_multiple_rs_files.py
new file mode 100644
index 0000000..78993ae
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_fileline_multiple_rs_files.py
@@ -0,0 +1,63 @@
+'''Module that contains the test TestBreakpointFileLineMultipleRSFiles.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointFileLineMultipleRSFiles(TestBaseRemote):
+ '''Tests the setting of a breakpoint on one of multiple RS files.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'MultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ 'at first.rs:12',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('breakpoint set --file second.rs --line 7',
+ ['Breakpoint 2',
+ 'librs.second.so`second_kernel',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint list',
+ ['first.rs',
+ 'second.rs',
+ 'resolved = 1',
+ 'first.rs:12',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.second.so`second_kernel',
+ 'at second.rs:7',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 2'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/java/test_breakpoint_kernel_1.py b/tests/lldb/tests/java/test_breakpoint_kernel_1.py
new file mode 100644
index 0000000..d365759
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_kernel_1.py
@@ -0,0 +1,77 @@
+'''Module that contains the test TestBreakpointKernel1.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernel1(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ # Try set a breakpoint on a kernel which doesn't exist
+ self.try_command('language renderscript kernel breakpoint set imaginary_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 0 (pending)",
+ "'imaginary_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.simple.so',
+ 'simple_kernel'])
+
+ self.try_command('breakpoint list',
+ ["'imaginary_kernel', locations = 0 (pending)",
+ "'simple_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on kernel which doesn't exist
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
diff --git a/tests/lldb/tests/java/test_breakpoint_kernel_2.py b/tests/lldb/tests/java/test_breakpoint_kernel_2.py
new file mode 100644
index 0000000..bed4d8b
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_kernel_2.py
@@ -0,0 +1,48 @@
+'''Module that contains the test TestBreakpointKernel2.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernel2(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaInfiniteLoop'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.infiniteloop.so',
+ 'simple_kernel'],
+ [r'infiniteloop\.rs:2[78]'])
+
+ self.try_command('breakpoint list',
+ ['simple_kernel',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ '.so`simple_kernel',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/java/test_breakpoint_kernel_all.py b/tests/lldb/tests/java/test_breakpoint_kernel_all.py
new file mode 100644
index 0000000..4101bec
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_kernel_all.py
@@ -0,0 +1,75 @@
+'''Module that contains the test TestBreakpointKernelAll.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelAll(TestBaseRemote):
+ '''Tests setting breakpoints on every RS kernel.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/java/test_breakpoint_kernel_all_multiple_rs_files.py b/tests/lldb/tests/java/test_breakpoint_kernel_all_multiple_rs_files.py
new file mode 100644
index 0000000..cd7ebb6
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_kernel_all_multiple_rs_files.py
@@ -0,0 +1,75 @@
+'''Module that contains the test TestBreakpointKernelAllMultipleRSFiles.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelAllMultipleRSFiles(TestBaseRemote):
+ '''Tests setting breakpoints on every RS kernel in multiple kernel files.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'MultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/java/test_breakpoint_kernel_multiple_rs_files.py b/tests/lldb/tests/java/test_breakpoint_kernel_multiple_rs_files.py
new file mode 100644
index 0000000..d2e1c99
--- /dev/null
+++ b/tests/lldb/tests/java/test_breakpoint_kernel_multiple_rs_files.py
@@ -0,0 +1,70 @@
+'''Module that contains the test TestBreakpointKernelMultipleRSFiles.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestBreakpointKernelMultipleRSFiles(TestBaseRemote):
+ '''Tests the setting of a breakpoint on RS kernels in multiple files.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'MultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set first_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'],
+ [r'at first\.rs:1[012]'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('language renderscript kernel breakpoint set second_kernel',
+ ['Breakpoint(s) created',
+ 'Breakpoint 2',
+ 'Breakpoint(s) created'],
+ [r"librs\.second\.so`second_kernel at second\.rs:[56]",])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint',
+ "librs.second.so`second_kernel"],
+ [r'second\.rs:[56]'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
diff --git a/tests/lldb/tests/java/test_call_api_funs.py b/tests/lldb/tests/java/test_call_api_funs.py
new file mode 100644
index 0000000..4b505a5
--- /dev/null
+++ b/tests/lldb/tests/java/test_call_api_funs.py
@@ -0,0 +1,146 @@
+'''Module that contains the test TestCallApiFuns.'''
+
+from harness.test_base_remote import TestBaseRemote
+from harness import RS_funs
+
+
+class TestCallApiFuns(TestBaseRemote):
+ '''Tests calling of some RS API functions. This tests that JITing works.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test
+ can be run with.
+ '''
+ return "KernelVariables"
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test the atomics separately because we want to check the output
+ # AtomicAdd(1234, 2)
+ self.try_command('expr rsAtomicAdd(&int_global, 2)',
+ ['1234'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '1236'])
+
+ # AtomicAnd(2345, 333)
+ self.try_command('expr rsAtomicAnd(&uint_global, 333)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '265'])
+
+ # AtomicCas(1236, 1236, 2345)
+ self.try_command('expr rsAtomicCas(&int_global, 1236, 2345)',
+ ['1236'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2345'])
+
+ # AtomicDec(265)
+ self.try_command('expr rsAtomicDec(&uint_global)',
+ ['265'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '264'])
+
+ # AtomicInc(2345)
+ self.try_command('expr rsAtomicInc(&int_global)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2346'])
+
+ # AtomicMax(264, 3456)
+ self.try_command('expr rsAtomicMax(&uint_global, 3456)',
+ ['264'],
+ [r'\(uint(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3456'])
+
+ # AtomicMin(2346, 3)
+ self.try_command('expr rsAtomicMin(&int_global, 3)',
+ ['2346'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '3'])
+
+ # AtomicOr(3, 456)
+ self.try_command('expr rsAtomicOr(&int_global, 456)',
+ ['3'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '459'])
+
+ # AtomicSub(3456, 7)
+ self.try_command('expr rsAtomicSub(&uint_global, 7)',
+ ['3456'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3449'])
+
+ # AtomicXor(459, 89)
+ self.try_command('expr rsAtomicXor(&int_global, 89)',
+ ['459'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '402'])
+
+ count = 0
+ for line in RS_funs.FUNC_LIST:
+ count += 1
+ if wimpy and not count % 10 == 0:
+ continue
+
+ # build the expression
+ ret, expr = RS_funs.build_expr(line)
+ # query return type table
+ if ret in RS_funs.TYPE_MAP:
+ # evaluate the expression
+ self.try_command(expr, [], [RS_funs.TYPE_MAP[ret]])
+ else:
+ # evaluate the expression
+ self.try_command(expr, '('+ret+')')
diff --git a/tests/lldb/tests/java/test_coordinates.py b/tests/lldb/tests/java/test_coordinates.py
new file mode 100644
index 0000000..844e81f
--- /dev/null
+++ b/tests/lldb/tests/java/test_coordinates.py
@@ -0,0 +1,108 @@
+'''Module that contains the test TestCoordinates.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestCoordinates(TestBaseRemote):
+ '''Tests the inspection of coordinates.
+
+ Tests the inspection of the range and dimension of coordinates as well
+ as the current coordinates.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_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 test_shutdown(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')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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))
+
+ 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)])
diff --git a/tests/lldb/tests/java/test_dwarf_lang.py b/tests/lldb/tests/java/test_dwarf_lang.py
new file mode 100644
index 0000000..5aa4c40
--- /dev/null
+++ b/tests/lldb/tests/java/test_dwarf_lang.py
@@ -0,0 +1,29 @@
+'''Module that contains the test DWARF language attribute test.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestDWARFLang(TestBaseRemote):
+ '''Tests the DWARF language attribute is present in RenderScript kernels.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status', [])
+ self.try_command('b simple_kernel', [])
+ self.try_command('process continue', [])
+
+ self.assert_lang_renderscript()
diff --git a/tests/lldb/tests/java/test_invoke_fun.py b/tests/lldb/tests/java/test_invoke_fun.py
new file mode 100644
index 0000000..0e67823
--- /dev/null
+++ b/tests/lldb/tests/java/test_invoke_fun.py
@@ -0,0 +1,49 @@
+'''Module that contains the test TestInvokeFun.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestInvokeFun(TestBaseRemote):
+ '''Tests debugging a function executed from Java using invoke_*.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return "BranchingFunCalls"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --name addToGlobal',
+ ['Breakpoint 1', '(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint'],
+ [r'scalars\.rs:5[789]'])
+
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint 2', 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'simple_kernel'],
+ [r'scalars\.rs:4[567]'])
+
+ self.try_command('expr glob',
+ ['(int)',
+ '357'])
diff --git a/tests/lldb/tests/java/test_language.py b/tests/lldb/tests/java/test_language.py
new file mode 100644
index 0000000..aaba524
--- /dev/null
+++ b/tests/lldb/tests/java/test_language.py
@@ -0,0 +1,55 @@
+'''Module that contains the test TestLanguage.'''
+
+from harness.test_base import TestBase
+
+
+class TestLanguage(TestBase):
+ '''Tests the "language" command and "language renderscript" subcommand.
+
+ This doesn't require a binary to be running.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return None
+
+ def run(self, dbg, _, lldb, _unused):
+ '''Execute the test case.
+
+ Args:
+ dbg: The instance of the SBDebugger that is used to test commands.
+ lldb: A handle to the lldb module.
+
+ Returns:
+ True: test passed, False: test failed.
+ '''
+ assert dbg
+ assert lldb
+
+ self._lldb = lldb
+
+ try:
+ self._ci = dbg.GetCommandInterpreter()
+ assert self._ci
+
+ if (not self._ci.IsValid() or
+ not self._ci.HasCommands() or
+ not self._ci.CommandExists('language')):
+ return False
+
+ self.try_command('language', ['renderscript'])
+
+ self.try_command('language renderscript', ['kernel',
+ 'context',
+ 'module',
+ 'status'])
+
+ except self.TestFail:
+ return False
+
+ return True
diff --git a/tests/lldb/tests/java/test_language_subcmds.py b/tests/lldb/tests/java/test_language_subcmds.py
new file mode 100644
index 0000000..92e33a3
--- /dev/null
+++ b/tests/lldb/tests/java/test_language_subcmds.py
@@ -0,0 +1,132 @@
+'''Module that contains the test TestLanguageSubcmds.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestLanguageSubcmds(TestBaseRemote):
+ '''Tests the 'language renderscript' subcommands.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaDebugWaitAttach'
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ self.try_command('language',
+ [])
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked',
+ 'rsdAllocationInit',
+ 'rsdAllocationRead2D',
+ 'rsdScriptInit',
+ 'rsdScriptInvokeForEach',
+ 'rsdScriptInvokeForEachMulti',
+ 'rsdScriptSetGlobalVar'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel breakpoint',
+ ['all',
+ 'set'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (0, 0, 0)'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 3',
+ 'root',
+ 'simple_kernel',
+ 'other_kernel',
+ 'java_package_name: com.android.rs.waitattachdebug',
+ 'version:'])
diff --git a/tests/lldb/tests/java/test_language_subcmds_no_debug.py b/tests/lldb/tests/java/test_language_subcmds_no_debug.py
new file mode 100644
index 0000000..615a4a7
--- /dev/null
+++ b/tests/lldb/tests/java/test_language_subcmds_no_debug.py
@@ -0,0 +1,112 @@
+'''Module that contains the test TestLanguageSubcmdsNoDebug.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestLanguageSubcmdsNoDebug(TestBaseRemote):
+ '''Tests the 'language renderscript' subcommands without debug info.
+
+ In particular, module dump should report missing debug info.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JavaNoDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ # 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'
+ '',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info does not exist.',
+ 'Globals: 1',
+ 'gColor - variable identified, but not found in '
+ 'binary (symbol exists)',
+ 'Kernels: 2',
+ 'root',
+ 'simple_kernel',
+ 'java_package_name: com.android.rs.waitattachnodebug',
+ 'version'])
diff --git a/tests/lldb/tests/java/test_multiple_rs_files.py b/tests/lldb/tests/java/test_multiple_rs_files.py
new file mode 100644
index 0000000..a20e386
--- /dev/null
+++ b/tests/lldb/tests/java/test_multiple_rs_files.py
@@ -0,0 +1,59 @@
+'''Module that contains the test TestMultipleRSFiles.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestMultipleRSFiles(TestBaseRemote):
+ '''Tests some commands on an apk which has two rs files.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'MultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ 'at first.rs:12',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'first'",
+ "Resource 'second'",
+ 'root',
+ 'first_kernel',
+ 'second_kernel'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '2 script instances'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.first.so',
+ 'librs.second.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 2',
+ 'root',
+ 'first_kernel',
+ 'second_kernel',
+ 'java_package_name: com.android.rs.multiplersfiles',
+ 'version:'])
diff --git a/tests/lldb/tests/java/test_read_global.py b/tests/lldb/tests/java/test_read_global.py
new file mode 100644
index 0000000..5bd26af
--- /dev/null
+++ b/tests/lldb/tests/java/test_read_global.py
@@ -0,0 +1,315 @@
+'''Module that contains the test TestReadGlobal.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestReadGlobal(TestBaseRemote):
+ '''Tests inspecting global variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output,
+ expected_regex=None):
+ '''Inspect a global and check for the output.
+
+ Run the "expr" and "target variable" commands on a given global and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + global_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('target variable',
+ ['Global variables for',
+ 'librs.simple.so',
+ "(uchar) uchar_global = '\\xea'",
+ '(short) short_global = -321',
+ '(ushort) ushort_global = 432',
+ '(int) int_global = 1234',
+ '(uint) uint_global = 2345',
+ '(float) float_global = 4.5',
+ '(ulong) ulong_global = 8888',
+ '(double) double_global = -456.5',
+ '(char2) char2_global = (11, -22)',
+ '(uchar2) uchar2_global = (0x21, 0x2c)',
+ '(short2) short2_global = (-555, 666)',
+ '(ushort2) ushort2_global = (777, 888)',
+ '(int2) int2_global = (999, -1111)',
+ '(uint2) uint2_global = (2222, 3333)',
+ '(float2) float2_global = (4.5, -5)',
+ '(long2) long2_global = (-4444, 5555)',
+ '(ulong2) ulong2_global = (6666, 7777)',
+ '(double2) double2_global = (88.5, -99)',
+ '(char3) char3_global = (11, -22, -33,',
+ '(uchar3) uchar3_global = (0x21, 0x2c, 0x37,',
+ '(short3) short3_global = (-555, 666, 777,',
+ '(ushort3) ushort3_global = (777, 888, 999,',
+ '(int3) int3_global = (999, -1111, 2222,',
+ '(uint3) uint3_global = (2222, 3333, 4444,',
+ '(float3) float3_global = (4.5, -5, -6.5,',
+ '(long3) long3_global = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_global = (6666, 7777, 8888,',
+ '(double3) double3_global = (88.5, -99, 111.5,',
+ '(char4) char4_global = (55, 11, -22, -33)',
+ '(uchar4) uchar4_global = (0xde, 0x21, 0x2c, 0x37)',
+ '(short4) short4_global = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_global = (666, 777, 888, 999)',
+ '(int4) int4_global = (888, 999, -1111, 2222)',
+ '(uint4) uint4_global = (1111, 2222, 3333, 4444)',
+ '(float4) float4_global = (3, 4.5, -5, -6.5)',
+ '(long4) long4_global = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_global = (5555, 6666, 7777, 8888)',
+ '(double4) double4_global = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_global = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_global = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_global = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_global = (4.5, 5.5, 6, 3)'],
+ [r"\((signed )?char\) char_global = '\\f'",
+ r'\((long )?long\) long_global = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_global('char_global',
+ ["'\\f'"],
+ [r'\((signed )?char\)'])
+
+ if not wimpy:
+ self._try_inspecting_global('uchar_global',
+ ['(uchar)', "'\\xea'"])
+
+ self._try_inspecting_global('short_global',
+ ['(short)', '-321'])
+
+ self._try_inspecting_global('ushort_global',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_global('int_global',
+ ['(int)', '1234'])
+
+ self._try_inspecting_global('uint_global',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_global('float_global',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_global('long_global',
+ ['-77777'],
+ [r'\((long )?long\)'])
+
+ self._try_inspecting_global('ulong_global',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_global('double_global',
+ ['(double)', '-456.5'])
+
+ self._try_inspecting_global('char2_global',
+ ['(char2)', '(11, -22)'])
+
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ if not wimpy:
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ if not wimpy:
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ if not wimpy:
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
+
+ self._try_inspecting_global('matrix2x2_global',
+ ['(rs_matrix2x2)',
+ '= (m = (1, 2.5, 3, 4.5))'])
+
+ self._try_inspecting_global('matrix3x3_global',
+ ['(rs_matrix3x3)',
+ '= {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)'])
+
+ self._try_inspecting_global('matrix4x4_global',
+ ['(rs_matrix4x4)',
+ '= {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n'])
+
+ self._try_inspecting_global('quaternion_global',
+ ['(rs_quaternion)',
+ '(4.5, 5.5, 6, 3)'])
diff --git a/tests/lldb/tests/java/test_read_local.py b/tests/lldb/tests/java/test_read_local.py
new file mode 100644
index 0000000..17b1a79
--- /dev/null
+++ b/tests/lldb/tests/java/test_read_local.py
@@ -0,0 +1,312 @@
+'''Module that contains the test TestReadLocal.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestReadLocal(TestBaseRemote):
+ '''Tests inspecting local variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output,
+ expected_regex=None):
+ '''Inspect a local and check for the output.
+
+ Run the "expr" and "frame variable" commands on a given local and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ local_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + local_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('frame variable',
+ ["(uchar) uchar_local = 'b'",
+ '(short) short_local = -321',
+ '(ushort) ushort_local = 432',
+ '(int) int_local = 1234',
+ '(uint) uint_local = 2345',
+ '(float) float_local = 4.5',
+ '(ulong) ulong_local = 8888',
+ '(double) double_local = -456.5',
+ '(char2) char2_local = (-11, -22)',
+ '(uchar2) uchar2_local = (0x21, 0x2c)',
+ '(short2) short2_local = (-555, 666)',
+ '(ushort2) ushort2_local = (777, 888)',
+ '(int2) int2_local = (999, -1111)',
+ '(uint2) uint2_local = (2222, 3333)',
+ '(float2) float2_local = (4.5, -5)',
+ '(long2) long2_local = (-4444, 5555)',
+ '(ulong2) ulong2_local = (6666, 7777)',
+ '(double2) double2_local = (88.5, -99)',
+ '(char3) char3_local = (11, -22, -33,',
+ '(uchar3) uchar3_local = (0x21, 0x2c, 0x37,',
+ '(short3) short3_local = (-555, 666, 777,',
+ '(ushort3) ushort3_local = (777, 888, 999,',
+ '(int3) int3_local = (999, -1111, 2222,',
+ '(uint3) uint3_local = (2222, 3333, 4444,',
+ '(float3) float3_local = (4.5, -5, -6.5,',
+ '(long3) long3_local = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_local = (6666, 7777, 8888,',
+ '(double3) double3_local = (88.5, -99, 111.5,',
+ '(char4) char4_local = (55, 11, -22, -33)',
+ '(uchar4) uchar4_local = (0x16, 0x21, 0x2c, 0x37)',
+ '(short4) short4_local = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_local = (666, 777, 888, 999)',
+ '(int4) int4_local = (888, 999, -1111, 2222)',
+ '(uint4) uint4_local = (1111, 2222, 3333, 4444)',
+ '(float4) float4_local = (3, 4.5, -5, -6.5)',
+ '(long4) long4_local = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_local = (5555, 6666, 7777, 8888)',
+ '(double4) double4_local = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_local = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_local = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_local = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_local = (8, 9, 0.5, 7.5)'],
+ [r"\((signed )?char\) char_local = 'a'",
+ r'\((long )?long\) long_local = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_local('char_local',
+ ["'a'"],
+ [r'\((signed )?char\)'])
+
+ if not wimpy:
+ self._try_inspecting_local('uchar_local',
+ ['(uchar)', "'b'"])
+
+ self._try_inspecting_local('short_local',
+ ['(short)', '-321'])
+
+ self._try_inspecting_local('ushort_local',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_local('int_local',
+ ['(int)', '1234'])
+
+ self._try_inspecting_local('uint_local',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_local('float_local',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_local('long_local',
+ ['-77777'], [r'\((long )?long\)'])
+
+ self._try_inspecting_local('ulong_local',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_local('double_local',
+ ['(double)', '-456.5'])
+
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(-11, -22)'])
+
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ if not wimpy:
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ if not wimpy:
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ if not wimpy:
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
+
+ self._try_inspecting_local('matrix2x2_local',
+ ['(rs_matrix2x2)',
+ '= (m = (1, 2.5, 3, 4.5))'])
+
+ self._try_inspecting_local('matrix3x3_local',
+ ['(rs_matrix3x3)',
+ '= {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)'])
+
+ self._try_inspecting_local('matrix4x4_local',
+ ['(rs_matrix4x4)',
+ '= {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n'])
+
+ self._try_inspecting_local('quaternion_local',
+ ['(rs_quaternion)',
+ '(8, 9, 0.5, 7.5)'])
diff --git a/tests/lldb/tests/java/test_rs_consts.py b/tests/lldb/tests/java/test_rs_consts.py
new file mode 100644
index 0000000..319154d
--- /dev/null
+++ b/tests/lldb/tests/java/test_rs_consts.py
@@ -0,0 +1,76 @@
+'''Module that contains the test TestRSConsts.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestRSConsts(TestBaseRemote):
+ '''Tests examining the RenderScript constants.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('language renderscript kernel breakpoint set kernel',
+ [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Constants
+ self.try_command('expr M_1_PI',
+ ['0.318309'])
+
+ self.try_command('expr M_2_PI',
+ ['0.636619'])
+
+ self.try_command('expr M_2_SQRTPI',
+ ['1.128379'])
+
+ self.try_command('expr M_E',
+ ['2.718281'])
+
+ self.try_command('expr M_LN10',
+ ['2.302585'])
+
+ self.try_command('expr M_LN2',
+ ['0.693147'])
+
+ self.try_command('expr M_LOG10E',
+ ['0.434294'])
+
+ self.try_command('expr M_LOG2E',
+ ['1.442695'])
+
+ self.try_command('expr M_PI',
+ ['3.141592'])
+
+ self.try_command('expr M_PI_2',
+ ['1.570796'])
+
+ self.try_command('expr M_PI_4',
+ ['0.785398'])
+
+ self.try_command('expr M_SQRT1_2',
+ ['0.707106'])
+
+ self.try_command('expr M_SQRT2',
+ ['1.414213'])
diff --git a/tests/lldb/tests/java/test_source_step.py b/tests/lldb/tests/java/test_source_step.py
new file mode 100644
index 0000000..355eed3
--- /dev/null
+++ b/tests/lldb/tests/java/test_source_step.py
@@ -0,0 +1,83 @@
+'''Module that contains the test TestSourceStep.'''
+
+import os
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestSourceStep(TestBaseRemote):
+ '''Test stepping through the source using step-in, -over and -out.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "BranchingFunCalls"
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f scalars.rs -l 47',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'scalars.rs:47'])
+
+ # set the source mapping
+ file_dir = os.path.dirname(os.path.realpath(__file__))
+ new_dir = os.path.join(file_dir, '..', '..', 'java',
+ 'BranchingFunCalls', 'src', 'rs')
+ self.set_src_map('scalars.rs', new_dir)
+
+ self.try_command('process status',
+ ['-> 47',
+ 'int i = in;'])
+
+ #47 int i = in;
+ self.try_command('thread step-in',
+ ['-> 48'])
+ #48 float f = (float) i;
+ self.try_command('thread step-in',
+ ['-> 49'])
+ #49 modify_f(&f);
+ self.try_command('thread step-over',
+ ['-> 50'])
+ #50 modify_i(&i);
+ self.try_command('thread step-in',
+ ['-> 33'])
+ #33 int j = *i;
+ self.try_command('b -f scalars.rs -l 38',
+ ['librs.scalars.so`modify_i',
+ 'scalars.rs:38'])
+ self.try_command('c',
+ ['stop reason = breakpoint',
+ 'scalars.rs:38',
+ '-> 38'])
+ #38 set_i(i, 0);
+ # For the line number anything between #20 and #22 is fine
+ self.try_command('thread step-in',
+ [],
+ [r'-> 2[012]'])
+ #22 int tmp = b;
+ self.try_command('thread step-out',
+ ['-> 38'])
diff --git a/tests/lldb/tests/java/test_write_global.py b/tests/lldb/tests/java/test_write_global.py
new file mode 100644
index 0000000..4b4712b
--- /dev/null
+++ b/tests/lldb/tests/java/test_write_global.py
@@ -0,0 +1,210 @@
+'''Module that contains the test TestWriteGlobal.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteGlobal(TestBaseRemote):
+ '''Tests modifying global variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_modifying_global(self, global_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-arguments
+ self.try_command('expr %s = %s%s' %
+ (global_name, data_type_in, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char_global', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ if not wimpy:
+ self._try_modifying_global('uchar_global', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_global('short_global', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_global('ushort_global', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_global('int_global', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_global('uint_global', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_global('float_global', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_global('long_global', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_global('ulong_global', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_global('double_global', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+ self._try_modifying_global('char2_global', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_global('uchar2_global', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ if not wimpy:
+ self._try_modifying_global('short2_global', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_global('ushort2_global', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_global('int2_global', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_global('uint2_global', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_global('float2_global', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_global('long2_global', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_global('ulong2_global', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_global('double2_global', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_global('char3_global', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_global('uchar3_global', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_global('short3_global', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ if not wimpy:
+ self._try_modifying_global('ushort3_global', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_global('int3_global', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_global('uint3_global', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_global('float3_global', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_global('long3_global', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_global('ulong3_global', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_global('double3_global', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_global('char4_global', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_global('uchar4_global', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_global('short4_global', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_global('ushort4_global', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ if not wimpy:
+ self._try_modifying_global('int4_global', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_global('uint4_global', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_global('float4_global', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_global('long4_global', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_global('ulong4_global', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_global('double4_global', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
diff --git a/tests/lldb/tests/java/test_write_global_element.py b/tests/lldb/tests/java/test_write_global_element.py
new file mode 100644
index 0000000..9ed3d86
--- /dev/null
+++ b/tests/lldb/tests/java/test_write_global_element.py
@@ -0,0 +1,269 @@
+'''Module that contains the test TestWriteGlobalElement.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteGlobalElement(TestBaseRemote):
+ '''Tests modifying elements of global variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output):
+ '''Run the "expr" command on a given global and with a given output.
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + global_name, expected_output)
+
+ def _try_modifying_global(self, global_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (global_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-statements
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char2_global[0]', '2',
+ ['\'\\x02\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char2_global', ['(char2)', '(2, -22)'])
+
+ if not wimpy:
+ self._try_modifying_global('uchar2_global[1]', '3',
+ ['\'\\x03\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_global('short2_global[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_global('ushort2_global[1]', '55',
+ ['55'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_global('int2_global[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_global('uint2_global[1]', '777',
+ ['777'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_global('float2_global[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_global('long2_global[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_global('ulong2_global[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_global('double2_global[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -11)'])
+
+ self._try_modifying_global('char3_global[0]', '12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self._try_modifying_global('uchar3_global[1]', '\'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ if not wimpy:
+ self._try_modifying_global('short3_global[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_global('ushort3_global[0]', '1414',
+ ['1414'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_global('int3_global[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_global('uint3_global[1]', '161616',
+ ['161616'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_global('float3_global[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_global('long3_global[0]', '-181818181818',
+ ['-181818181818'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_global('ulong3_global[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_global('double3_global[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self._try_modifying_global('char4_global[0]', '-21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self._try_modifying_global('uchar4_global[1]', '22',
+ ['\'\\x16\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_global('short4_global[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ if not wimpy:
+ self._try_modifying_global('ushort4_global[3]', '24',
+ ['24'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_global('int4_global[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_global('uint4_global[1]', '26262',
+ ['26262'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_global('float4_global[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_global('long4_global[3]', '-28282828282',
+ ['-28282828282'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_global('ulong4_global[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_global('double4_global[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/java/test_write_local.py b/tests/lldb/tests/java/test_write_local.py
new file mode 100644
index 0000000..6e560b4
--- /dev/null
+++ b/tests/lldb/tests/java/test_write_local.py
@@ -0,0 +1,209 @@
+'''Module that contains the test TestWriteLocal.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestWriteLocal(TestBaseRemote):
+ '''Tests modifying local variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_modifying_local(self, local_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Try getting lldb to modify a local and check the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-arguments
+ self.try_command('expr %s = %s%s'
+ % (local_name, data_type_in, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char_local', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ if not wimpy:
+ self._try_modifying_local('uchar_local', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_local('short_local', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_local('ushort_local', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_local('int_local', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_local('uint_local', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_local('float_local', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_local('long_local', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_local('ulong_local', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_local('double_local', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+ self._try_modifying_local('char2_local', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_local('uchar2_local', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ if not wimpy:
+ self._try_modifying_local('short2_local', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_local('ushort2_local', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_local('int2_local', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_local('uint2_local', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_local('float2_local', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_local('long2_local', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_local('ulong2_local', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_local('double2_local', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_local('char3_local', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_local('uchar3_local', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_local('short3_local', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ if not wimpy:
+ self._try_modifying_local('ushort3_local', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_local('int3_local', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_local('uint3_local', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_local('float3_local', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_local('long3_local', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_local('ulong3_local', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_local('double3_local', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_local('char4_local', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_local('uchar4_local', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_local('short4_local', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_local('ushort4_local', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ if not wimpy:
+ self._try_modifying_local('int4_local', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_local('uint4_local', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_local('float4_local', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_local('long4_local', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_local('ulong4_local', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_local('double4_local', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
diff --git a/tests/lldb/tests/java/test_write_local_element.py b/tests/lldb/tests/java/test_write_local_element.py
new file mode 100644
index 0000000..5af7d5a
--- /dev/null
+++ b/tests/lldb/tests/java/test_write_local_element.py
@@ -0,0 +1,280 @@
+'''Module that contains the test TestWriteLocalElement.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestWriteLocalElement(TestBaseRemote):
+ '''Tests modifying elements of local variables of all types.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "KernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output):
+ '''Run the "expr" command on a given local and with a given output.
+
+ Args:
+ local_name: String which is the name of the local to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + local_name, expected_output)
+
+ def _try_modifying_local(self, local_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a local and check for the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (local_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, wimpy):
+ '''Run the lldb commands that are being tested.
+
+ Args:
+ wimpy: Boolean to specify whether only a subset of the commands in
+ this test should be executed.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=too-many-statements
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char2_local[0]', '2',
+ ['2'], [r'\((signed )?char\)'])
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(2, -22)'])
+
+ if not wimpy:
+ self._try_modifying_local('uchar2_local[1]', '3',
+ ['3'], [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_local('short2_local[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_local('ushort2_local[1]', '55',
+ ['55'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_local('int2_local[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_local('uint2_local[1]', '777',
+ ['777'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_local('float2_local[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_local('long2_local[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_local('ulong2_local[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_local('double2_local[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -11)'])
+
+ # For some reason the result of some char and uchar expr is in hex
+ # and that of frame variable in decimal, so calling
+ # try_modifying_local doesn't work, because it reuses the expected
+ # output for both commands.
+ self.try_command('expr char3_local[0] = 12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char3_local[0]',
+ ['12'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self.try_command('expr uchar3_local[1] = \'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar3_local[1]',
+ ['0x64'],
+ [r'\(u(nsigned )?char\)'])
+
+ if not wimpy:
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ self._try_modifying_local('short3_local[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_local('ushort3_local[0]', '1414',
+ ['1414'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_local('int3_local[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_local('uint3_local[1]', '161616',
+ ['161616'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_local('float3_local[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_local('long3_local[0]', '-181818181818',
+ ['-181818181818'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_local('ulong3_local[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_local('double3_local[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self.try_command('expr char4_local[0] = -21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char4_local[0]',
+ ['-21'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self.try_command('expr uchar4_local[1] = 22',
+ ['\'\\x16\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar4_local[1]',
+ ['0x16'],
+ [r'\(u(nsigned )?char\)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_local('short4_local[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ if not wimpy:
+ self._try_modifying_local('ushort4_local[3]', '24',
+ ['24'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_local('int4_local[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_local('uint4_local[1]', '26262',
+ ['26262'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_local('float4_local[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_local('long4_local[3]', '-28282828282',
+ ['-28282828282'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_local('ulong4_local[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_local('double4_local[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/jni/test_allocation_dump_1_jni.py b/tests/lldb/tests/jni/test_allocation_dump_1_jni.py
new file mode 100644
index 0000000..136c261
--- /dev/null
+++ b/tests/lldb/tests/jni/test_allocation_dump_1_jni.py
@@ -0,0 +1,316 @@
+'''Module that contains the test TestAllocationDump1JNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+import os
+
+
+class TestAllocationDump1(TestBaseRemote):
+ '''Tests printing the contents of allocations.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return 'JNIAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test dumping large allocations to file
+ output_file_1 = self.get_tmp_file_path()
+ output_file_2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file_1,
+ ["Results written to '%s'" % output_file_1])
+
+ self.try_command('language renderscript allocation dump 2 -f '
+ + output_file_2,
+ ["Results written to '%s'" % output_file_2])
+
+ # Check files were created
+ self.test_assert(os.path.isfile(output_file_1))
+ self.test_assert(os.path.isfile(output_file_2))
+ os.remove(output_file_1)
+ os.remove(output_file_2)
+
+ # char
+ self.try_command('language renderscript allocation dump 3',
+ ['(0, 0, 0) = 0',
+ '(0, 1, 0) = 1',
+ '(0, 2, 0) = 2',
+ '(0, 0, 1) = 3',
+ '(0, 1, 1) = 4',
+ '(0, 2, 1) = 5',
+ '(0, 0, 2) = 6',
+ '(0, 1, 2) = 7',
+ '(0, 2, 2) = 8',
+ '(0, 0, 3) = 9',
+ '(0, 1, 3) = 10',
+ '(0, 2, 3) = 11',
+ '(0, 0, 4) = 12',
+ '(0, 1, 4) = 13',
+ '(0, 2, 4) = 14',
+ '(0, 0, 5) = 15',
+ '(0, 1, 5) = 16',
+ '(0, 2, 5) = 17',
+ '(0, 0, 6) = 18',
+ '(0, 1, 6) = 19',
+ '(0, 2, 6) = 20',
+ '(0, 0, 7) = 21',
+ '(0, 1, 7) = 22',
+ '(0, 2, 7) = 23'])
+
+ # char2
+ self.try_command('language renderscript allocation dump 4',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # char3
+ self.try_command('language renderscript allocation dump 5',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # char4
+ self.try_command('language renderscript allocation dump 6',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # short
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # short2
+ self.try_command('language renderscript allocation dump 8',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(0, 0, 1) = {12 13}',
+ '(1, 0, 1) = {14 15}',
+ '(2, 0, 1) = {16 17}',
+ '(3, 0, 1) = {18 19}',
+ '(4, 0, 1) = {20 21}',
+ '(5, 0, 1) = {22 23}'])
+
+ # short3
+ self.try_command('language renderscript allocation dump 9',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # short4
+ self.try_command('language renderscript allocation dump 10',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # int
+ self.try_command('language renderscript allocation dump 11',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # int2
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # int3
+ self.try_command('language renderscript allocation dump 13',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(0, 1, 0) = {12 13 14}',
+ '(1, 1, 0) = {16 17 18}',
+ '(2, 1, 0) = {20 21 22}'])
+ # int4
+ self.try_command('language renderscript allocation dump 14',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(1, 0, 0) = {4 5 6 7}',
+ '(2, 0, 0) = {8 9 10 11}',
+ '(3, 0, 0) = {12 13 14 15}',
+ '(4, 0, 0) = {16 17 18 19}',
+ '(5, 0, 0) = {20 21 22 23}'])
+
+ # long
+ self.try_command('language renderscript allocation dump 15',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # long2
+ self.try_command('language renderscript allocation dump 16',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ # long3
+ self.try_command('language renderscript allocation dump 17',
+ ['(0, 0, 0) = {0 1 2}',
+ '(1, 0, 0) = {4 5 6}',
+ '(2, 0, 0) = {8 9 10}',
+ '(3, 0, 0) = {12 13 14}',
+ '(4, 0, 0) = {16 17 18}',
+ '(5, 0, 0) = {20 21 22}'])
+
+ # long4
+ self.try_command('language renderscript allocation dump 18',
+ ['(0, 0, 0) = {0 1 2 3}',
+ '(0, 1, 0) = {4 5 6 7}',
+ '(0, 2, 0) = {8 9 10 11}',
+ '(0, 3, 0) = {12 13 14 15}',
+ '(0, 4, 0) = {16 17 18 19}',
+ '(0, 5, 0) = {20 21 22 23}'])
+
+ # bool
+ self.try_command('language renderscript allocation dump 19',
+ ['(0, 0, 0) = false',
+ '(1, 0, 0) = true',
+ '(2, 0, 0) = false',
+ '(3, 0, 0) = true',
+ '(4, 0, 0) = false',
+ '(5, 0, 0) = true',
+ '(6, 0, 0) = false',
+ '(7, 0, 0) = true',
+ '(8, 0, 0) = false',
+ '(9, 0, 0) = true',
+ '(10, 0, 0) = false',
+ '(11, 0, 0) = true',
+ '(12, 0, 0) = false',
+ '(13, 0, 0) = true',
+ '(14, 0, 0) = false',
+ '(15, 0, 0) = true',
+ '(16, 0, 0) = false',
+ '(17, 0, 0) = true',
+ '(18, 0, 0) = false',
+ '(19, 0, 0) = true',
+ '(20, 0, 0) = false',
+ '(21, 0, 0) = true',
+ '(22, 0, 0) = false',
+ '(23, 0, 0) = true'])
diff --git a/tests/lldb/tests/jni/test_allocation_dump_2_jni.py b/tests/lldb/tests/jni/test_allocation_dump_2_jni.py
new file mode 100644
index 0000000..4f4bfe7
--- /dev/null
+++ b/tests/lldb/tests/jni/test_allocation_dump_2_jni.py
@@ -0,0 +1,507 @@
+'''Module that contains the test TestAllocationDump2JNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestAllocationDump2JNI(TestBaseRemote):
+ '''Tests printing the contents of allocations of a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # uchar
+ self.try_command('language renderscript allocation dump 20',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # uchar2
+ self.try_command('language renderscript allocation dump 21',
+ ['(0, 0, 0) = {0x00 0x01}',
+ '(1, 0, 0) = {0x02 0x03}',
+ '(0, 1, 0) = {0x04 0x05}',
+ '(1, 1, 0) = {0x06 0x07}',
+ '(0, 2, 0) = {0x08 0x09}',
+ '(1, 2, 0) = {0x0a 0x0b}',
+ '(0, 3, 0) = {0x0c 0x0d}',
+ '(1, 3, 0) = {0x0e 0x0f}',
+ '(0, 4, 0) = {0x10 0x11}',
+ '(1, 4, 0) = {0x12 0x13}',
+ '(0, 5, 0) = {0x14 0x15}',
+ '(1, 5, 0) = {0x16 0x17}'])
+
+ # uchar3
+ self.try_command('language renderscript allocation dump 22',
+ ['(0, 0, 0) = {0x00 0x01 0x02}',
+ '(1, 0, 0) = {0x04 0x05 0x06}',
+ '(2, 0, 0) = {0x08 0x09 0x0a}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e}',
+ '(4, 0, 0) = {0x10 0x11 0x12}',
+ '(5, 0, 0) = {0x14 0x15 0x16}'])
+
+ # uchar4
+ self.try_command('language renderscript allocation dump 23',
+ ['(0, 0, 0) = {0x00 0x01 0x02 0x03}',
+ '(1, 0, 0) = {0x04 0x05 0x06 0x07}',
+ '(2, 0, 0) = {0x08 0x09 0x0a 0x0b}',
+ '(3, 0, 0) = {0x0c 0x0d 0x0e 0x0f}',
+ '(4, 0, 0) = {0x10 0x11 0x12 0x13}',
+ '(5, 0, 0) = {0x14 0x15 0x16 0x17}'])
+
+ # ushort
+ self.try_command('language renderscript allocation dump 24',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # ushort2
+ self.try_command('language renderscript allocation dump 25',
+ ['(0, 0, 0) = {0x0000 0x0001}',
+ '(1, 0, 0) = {0x0002 0x0003}',
+ '(2, 0, 0) = {0x0004 0x0005}',
+ '(3, 0, 0) = {0x0006 0x0007}',
+ '(4, 0, 0) = {0x0008 0x0009}',
+ '(5, 0, 0) = {0x000a 0x000b}',
+ '(6, 0, 0) = {0x000c 0x000d}',
+ '(7, 0, 0) = {0x000e 0x000f}',
+ '(8, 0, 0) = {0x0010 0x0011}',
+ '(9, 0, 0) = {0x0012 0x0013}',
+ '(10, 0, 0) = {0x0014 0x0015}',
+ '(11, 0, 0) = {0x0016 0x0017}'])
+
+ # ushort3
+ self.try_command('language renderscript allocation dump 26',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002}',
+ '(0, 1, 0) = {0x0004 0x0005 0x0006}',
+ '(0, 2, 0) = {0x0008 0x0009 0x000a}',
+ '(0, 3, 0) = {0x000c 0x000d 0x000e}',
+ '(0, 4, 0) = {0x0010 0x0011 0x0012}',
+ '(0, 5, 0) = {0x0014 0x0015 0x0016}'])
+
+ # ushort4
+ self.try_command('language renderscript allocation dump 27',
+ ['(0, 0, 0) = {0x0000 0x0001 0x0002 0x0003}',
+ '(1, 0, 0) = {0x0004 0x0005 0x0006 0x0007}',
+ '(2, 0, 0) = {0x0008 0x0009 0x000a 0x000b}',
+ '(3, 0, 0) = {0x000c 0x000d 0x000e 0x000f}',
+ '(4, 0, 0) = {0x0010 0x0011 0x0012 0x0013}',
+ '(5, 0, 0) = {0x0014 0x0015 0x0016 0x0017}'])
+
+ # uint
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
+
+ # uint2
+ self.try_command('language renderscript allocation dump 29',
+ ['(0, 0, 0) = {0x00000000 0x00000001}',
+ '(1, 0, 0) = {0x00000002 0x00000003}',
+ '(2, 0, 0) = {0x00000004 0x00000005}',
+ '(3, 0, 0) = {0x00000006 0x00000007}',
+ '(4, 0, 0) = {0x00000008 0x00000009}',
+ '(5, 0, 0) = {0x0000000a 0x0000000b}',
+ '(6, 0, 0) = {0x0000000c 0x0000000d}',
+ '(7, 0, 0) = {0x0000000e 0x0000000f}',
+ '(8, 0, 0) = {0x00000010 0x00000011}',
+ '(9, 0, 0) = {0x00000012 0x00000013}',
+ '(10, 0, 0) = {0x00000014 0x00000015}',
+ '(11, 0, 0) = {0x00000016 0x00000017}'])
+
+ # uint3
+ self.try_command('language renderscript allocation dump 30',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002}',
+ '(1, 0, 0) = {0x00000004 0x00000005 0x00000006}',
+ '(2, 0, 0) = {0x00000008 0x00000009 0x0000000a}',
+ '(3, 0, 0) = {0x0000000c 0x0000000d 0x0000000e}',
+ '(4, 0, 0) = {0x00000010 0x00000011 0x00000012}',
+ '(5, 0, 0) = {0x00000014 0x00000015 0x00000016}'])
+
+ # uint4
+ self.try_command('language renderscript allocation dump 31',
+ ['(0, 0, 0) = {0x00000000 0x00000001 0x00000002 0x00000003}',
+ '(0, 0, 1) = {0x00000004 0x00000005 0x00000006 0x00000007}',
+ '(0, 0, 2) = {0x00000008 0x00000009 0x0000000a 0x0000000b}',
+ '(0, 0, 3) = {0x0000000c 0x0000000d 0x0000000e 0x0000000f}',
+ '(0, 0, 4) = {0x00000010 0x00000011 0x00000012 0x00000013}',
+ '(0, 0, 5) = {0x00000014 0x00000015 0x00000016 0x00000017}'])
+
+ # ulong
+ self.try_command('language renderscript allocation dump 32',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(0, 1, 0) = 4',
+ '(1, 1, 0) = 5',
+ '(2, 1, 0) = 6',
+ '(3, 1, 0) = 7',
+ '(0, 2, 0) = 8',
+ '(1, 2, 0) = 9',
+ '(2, 2, 0) = 10',
+ '(3, 2, 0) = 11',
+ '(0, 0, 1) = 12',
+ '(1, 0, 1) = 13',
+ '(2, 0, 1) = 14',
+ '(3, 0, 1) = 15',
+ '(0, 1, 1) = 16',
+ '(1, 1, 1) = 17',
+ '(2, 1, 1) = 18',
+ '(3, 1, 1) = 19',
+ '(0, 2, 1) = 20',
+ '(1, 2, 1) = 21',
+ '(2, 2, 1) = 22',
+ '(3, 2, 1) = 23'])
+
+ # ulong2
+ self.try_command('language renderscript allocation dump 33',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001}',
+ '(1, 0, 0) = {0x0000000000000002 0x0000000000000003}',
+ '(2, 0, 0) = {0x0000000000000004 0x0000000000000005}',
+ '(3, 0, 0) = {0x0000000000000006 0x0000000000000007}',
+ '(4, 0, 0) = {0x0000000000000008 0x0000000000000009}',
+ '(5, 0, 0) = {0x000000000000000a 0x000000000000000b}',
+ '(6, 0, 0) = {0x000000000000000c 0x000000000000000d}',
+ '(7, 0, 0) = {0x000000000000000e 0x000000000000000f}',
+ '(8, 0, 0) = {0x0000000000000010 0x0000000000000011}',
+ '(9, 0, 0) = {0x0000000000000012 0x0000000000000013}',
+ '(10, 0, 0) = {0x0000000000000014 0x0000000000000015}',
+ '(11, 0, 0) = {0x0000000000000016 0x0000000000000017}'])
+
+ # ulong3
+ self.try_command('language renderscript allocation dump 34',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 0x0000000000000002}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 0x0000000000000006}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 0x000000000000000a}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d 0x000000000000000e}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 0x0000000000000012}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 0x0000000000000016}'])
+
+ # ulong4
+ self.try_command('language renderscript allocation dump 35',
+ ['(0, 0, 0) = {0x0000000000000000 0x0000000000000001 '
+ '0x0000000000000002 0x0000000000000003}',
+ '(1, 0, 0) = {0x0000000000000004 0x0000000000000005 '
+ '0x0000000000000006 0x0000000000000007}',
+ '(2, 0, 0) = {0x0000000000000008 0x0000000000000009 '
+ '0x000000000000000a 0x000000000000000b}',
+ '(3, 0, 0) = {0x000000000000000c 0x000000000000000d '
+ '0x000000000000000e 0x000000000000000f}',
+ '(4, 0, 0) = {0x0000000000000010 0x0000000000000011 '
+ '0x0000000000000012 0x0000000000000013}',
+ '(5, 0, 0) = {0x0000000000000014 0x0000000000000015 '
+ '0x0000000000000016 0x0000000000000017}'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ # half
+ self.try_command('language renderscript allocation dump 36',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333252',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.199951',
+ '(6, 0, 0) = 0.166626',
+ '(7, 0, 0) = 0.142822',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111084',
+ '(10, 0, 0) = 0.0999756',
+ '(11, 0, 0) = 0.0908813',
+ '(12, 0, 0) = 0.083313',
+ '(13, 0, 0) = 0.0769043',
+ '(14, 0, 0) = 0.0714111',
+ '(15, 0, 0) = 0.0666504',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588379',
+ '(18, 0, 0) = 0.055542',
+ '(19, 0, 0) = 0.0526428',
+ '(20, 0, 0) = 0.0499878',
+ '(21, 0, 0) = 0.0476074',
+ '(22, 0, 0) = 0.0454407',
+ '(23, 0, 0) = 0.0434875'])
+
+ # half2
+ self.try_command('language renderscript allocation dump 37',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333252}',
+ '(2, 0, 0) = {0.25 0.199951}',
+ '(3, 0, 0) = {0.166626 0.142822}',
+ '(4, 0, 0) = {0.125 0.111084}',
+ '(5, 0, 0) = {0.0999756 0.0908813}',
+ '(6, 0, 0) = {0.083313 0.0769043}',
+ '(7, 0, 0) = {0.0714111 0.0666504}',
+ '(8, 0, 0) = {0.0625 0.0588379}',
+ '(9, 0, 0) = {0.055542 0.0526428}',
+ '(10, 0, 0) = {0.0499878 0.0476074}',
+ '(11, 0, 0) = {0.0454407 0.0434875}'])
+
+ # half3
+ self.try_command('language renderscript allocation dump 38',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(0, 1, 0) = {0.25 0.199951 0.166626}',
+ '(0, 2, 0) = {0.125 0.111084 0.0999756}',
+ '(0, 3, 0) = {0.083313 0.0769043 0.0714111}',
+ '(0, 4, 0) = {0.0625 0.0588379 0.055542}',
+ '(0, 5, 0) = {0.0499878 0.0476074 0.0454407}'])
+
+ # half4
+ self.try_command('language renderscript allocation dump 39',
+ ['(0, 0, 0) = {inf 1 0.5 0.333252}',
+ '(1, 0, 0) = {0.25 0.199951 0.166626 0.142822}',
+ '(2, 0, 0) = {0.125 0.111084 0.0999756 0.0908813}',
+ '(3, 0, 0) = {0.083313 0.0769043 0.0714111 0.0666504}',
+ '(4, 0, 0) = {0.0625 0.0588379 0.055542 0.0526428}',
+ '(5, 0, 0) = {0.0499878 0.0476074 0.0454407 0.0434875}'])
+
+ # float
+ self.try_command('language renderscript allocation dump 40',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166667',
+ '(7, 0, 0) = 0.142857',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909091',
+ '(12, 0, 0) = 0.0833333',
+ '(13, 0, 0) = 0.0769231',
+ '(14, 0, 0) = 0.0714286',
+ '(15, 0, 0) = 0.0666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235',
+ '(18, 0, 0) = 0.0555556',
+ '(19, 0, 0) = 0.0526316',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.047619',
+ '(22, 0, 0) = 0.0454545',
+ '(23, 0, 0) = 0.0434783'])
+
+ # float2
+ self.try_command('language renderscript allocation dump 41',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166667 0.142857}',
+ '(4, 0, 0) = {0.125 0.111111}',
+ '(5, 0, 0) = {0.1 0.0909091}',
+ '(6, 0, 0) = {0.0833333 0.0769231}',
+ '(7, 0, 0) = {0.0714286 0.0666667}',
+ '(8, 0, 0) = {0.0625 0.0588235}',
+ '(9, 0, 0) = {0.0555556 0.0526316}',
+ '(10, 0, 0) = {0.05 0.047619}',
+ '(11, 0, 0) = {0.0454545 0.0434783}'])
+
+ # float3
+ self.try_command('language renderscript allocation dump 42',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(1, 0, 0) = {0.25 0.2 0.166667}',
+ '(2, 0, 0) = {0.125 0.111111 0.1}',
+ '(3, 0, 0) = {0.0833333 0.0769231 0.0714286}',
+ '(4, 0, 0) = {0.0625 0.0588235 0.0555556}',
+ '(5, 0, 0) = {0.05 0.047619 0.0454545}'])
+
+ # float4
+ self.try_command('language renderscript allocation dump 43',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333}',
+ '(1, 0, 0) = {0.25 0.2 0.166667 0.142857}',
+ '(2, 0, 0) = {0.125 0.111111 0.1 0.0909091}',
+ '(0, 1, 0) = {0.0833333 0.0769231 0.0714286 0.0666667}',
+ '(1, 1, 0) = {0.0625 0.0588235 0.0555556 0.0526316}',
+ '(2, 1, 0) = {0.05 0.047619 0.0454545 0.0434783}'])
+
+ # double
+ self.try_command('language renderscript allocation dump 44',
+ ['(0, 0, 0) = inf',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 0.5',
+ '(3, 0, 0) = 0.333333333333333',
+ '(4, 0, 0) = 0.25',
+ '(5, 0, 0) = 0.2',
+ '(6, 0, 0) = 0.166666666666667',
+ '(7, 0, 0) = 0.142857142857143',
+ '(8, 0, 0) = 0.125',
+ '(9, 0, 0) = 0.111111111111111',
+ '(10, 0, 0) = 0.1',
+ '(11, 0, 0) = 0.0909090909090909',
+ '(12, 0, 0) = 0.0833333333333333',
+ '(13, 0, 0) = 0.0769230769230769',
+ '(14, 0, 0) = 0.0714285714285714',
+ '(15, 0, 0) = 0.0666666666666667',
+ '(16, 0, 0) = 0.0625',
+ '(17, 0, 0) = 0.0588235294117647',
+ '(18, 0, 0) = 0.0555555555555556',
+ '(19, 0, 0) = 0.0526315789473684',
+ '(20, 0, 0) = 0.05',
+ '(21, 0, 0) = 0.0476190476190476',
+ '(22, 0, 0) = 0.0454545454545455',
+ '(23, 0, 0) = 0.0434782608695652'])
+
+ # double2
+ self.try_command('language renderscript allocation dump 45',
+ ['(0, 0, 0) = {inf 1}',
+ '(1, 0, 0) = {0.5 0.333333333333333}',
+ '(2, 0, 0) = {0.25 0.2}',
+ '(3, 0, 0) = {0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111}',
+ '(1, 0, 1) = {0.1 0.0909090909090909}',
+ '(2, 0, 1) = {0.0833333333333333 0.0769230769230769}',
+ '(3, 0, 1) = {0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647}',
+ '(1, 0, 2) = {0.0555555555555556 0.0526315789473684}',
+ '(2, 0, 2) = {0.05 0.0476190476190476}',
+ '(3, 0, 2) = {0.0454545454545455 0.0434782608695652}'])
+
+ # double3
+ self.try_command('language renderscript allocation dump 46',
+ ['(0, 0, 0) = {inf 1 0.5}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 0.0555555555555556}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 0.0454545454545455}'])
+
+ # double4
+ self.try_command('language renderscript allocation dump 47',
+ ['(0, 0, 0) = {inf 1 0.5 0.333333333333333}',
+ '(0, 1, 0) = {0.25 0.2 0.166666666666667 0.142857142857143}',
+ '(0, 0, 1) = {0.125 0.111111111111111 0.1 0.0909090909090909}',
+ '(0, 1, 1) = {0.0833333333333333 0.0769230769230769 '
+ '0.0714285714285714 0.0666666666666667}',
+ '(0, 0, 2) = {0.0625 0.0588235294117647 '
+ '0.0555555555555556 0.0526315789473684}',
+ '(0, 1, 2) = {0.05 0.0476190476190476 '
+ '0.0454545454545455 0.0434782608695652}'])
diff --git a/tests/lldb/tests/jni/test_allocation_file_jni.py b/tests/lldb/tests/jni/test_allocation_file_jni.py
new file mode 100644
index 0000000..afec575
--- /dev/null
+++ b/tests/lldb/tests/jni/test_allocation_file_jni.py
@@ -0,0 +1,188 @@
+'''Module that contains the test TestAllocationFileJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+import os
+
+class TestAllocationFileJNI(TestBaseRemote):
+ '''Tests saving an allocation of a JNI apk to disk and reloading it.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of int2 allocation
+ file_int2 = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 12 ' +
+ file_int2,
+ ["Allocation written to file '%s'" % file_int2])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_int2))
+
+ # Load the file we just created, to assert the allocation contents are
+ # the same
+ self.try_command('language renderscript allocation load 12 ' +
+ file_int2,
+ ["Contents of file '%s' read into allocation 12" %
+ file_int2])
+ os.remove(file_int2)
+
+ self.try_command('language renderscript allocation dump 12',
+ ['(0, 0, 0) = {0 1}',
+ '(1, 0, 0) = {2 3}',
+ '(2, 0, 0) = {4 5}',
+ '(3, 0, 0) = {6 7}',
+ '(4, 0, 0) = {8 9}',
+ '(5, 0, 0) = {10 11}',
+ '(6, 0, 0) = {12 13}',
+ '(7, 0, 0) = {14 15}',
+ '(8, 0, 0) = {16 17}',
+ '(9, 0, 0) = {18 19}',
+ '(10, 0, 0) = {20 21}',
+ '(11, 0, 0) = {22 23}'])
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Binary file of uint allocation
+ file_uint = self.get_tmp_file_path()
+
+ self.try_command('language renderscript allocation save 28 ' +
+ file_uint,
+ ["Allocation written to file '%s'" % file_uint])
+
+ # Check file was created
+ self.test_assert(os.path.isfile(file_uint))
+
+ # Test loading file into allocation with an incompatible type 'short'
+ self.try_command('language renderscript allocation load 7 ' + file_uint,
+ ["Contents of file '%s' read into allocation 7" %
+ file_uint,
+ "Warning: Mismatched Element sizes",
+ "Warning: Mismatched Types",
+ "Warning: Mismatched allocation sizes"])
+
+ # Check result of size inconsistency, mapping 4-byte unsigned to 2-byte
+ # int
+ self.try_command('language renderscript allocation dump 7',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 0',
+ '(2, 0, 0) = 1',
+ '(3, 0, 0) = 0',
+ '(4, 0, 0) = 2',
+ '(5, 0, 0) = 0',
+ '(6, 0, 0) = 3',
+ '(7, 0, 0) = 0',
+ '(8, 0, 0) = 4',
+ '(9, 0, 0) = 0',
+ '(10, 0, 0) = 5',
+ '(11, 0, 0) = 0',
+ '(12, 0, 0) = 6',
+ '(13, 0, 0) = 0',
+ '(14, 0, 0) = 7',
+ '(15, 0, 0) = 0',
+ '(16, 0, 0) = 8',
+ '(17, 0, 0) = 0',
+ '(18, 0, 0) = 9',
+ '(19, 0, 0) = 0',
+ '(20, 0, 0) = 10',
+ '(21, 0, 0) = 0',
+ '(22, 0, 0) = 11',
+ '(23, 0, 0) = 0'])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test that uint allocation has been squared by square_kernel
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 4',
+ '(3, 0, 0) = 9',
+ '(4, 0, 0) = 16',
+ '(5, 0, 0) = 25',
+ '(6, 0, 0) = 36',
+ '(7, 0, 0) = 49',
+ '(8, 0, 0) = 64',
+ '(9, 0, 0) = 81',
+ '(10, 0, 0) = 100',
+ '(11, 0, 0) = 121',
+ '(12, 0, 0) = 144',
+ '(13, 0, 0) = 169',
+ '(14, 0, 0) = 196',
+ '(15, 0, 0) = 225',
+ '(16, 0, 0) = 256',
+ '(17, 0, 0) = 289',
+ '(18, 0, 0) = 324',
+ '(19, 0, 0) = 361',
+ '(20, 0, 0) = 400',
+ '(21, 0, 0) = 441',
+ '(22, 0, 0) = 484',
+ '(23, 0, 0) = 529'])
+
+ # Load uint allocation from save before square_kernel had been run
+ self.try_command('language renderscript allocation load 28 ' +
+ file_uint,
+ ["Contents of file '%s' read into allocation 28" %
+ file_uint])
+ os.remove(file_uint)
+
+ # Check contents are back to original
+ self.try_command('language renderscript allocation dump 28',
+ ['(0, 0, 0) = 0',
+ '(1, 0, 0) = 1',
+ '(2, 0, 0) = 2',
+ '(3, 0, 0) = 3',
+ '(4, 0, 0) = 4',
+ '(5, 0, 0) = 5',
+ '(6, 0, 0) = 6',
+ '(7, 0, 0) = 7',
+ '(8, 0, 0) = 8',
+ '(9, 0, 0) = 9',
+ '(10, 0, 0) = 10',
+ '(11, 0, 0) = 11',
+ '(12, 0, 0) = 12',
+ '(13, 0, 0) = 13',
+ '(14, 0, 0) = 14',
+ '(15, 0, 0) = 15',
+ '(16, 0, 0) = 16',
+ '(17, 0, 0) = 17',
+ '(18, 0, 0) = 18',
+ '(19, 0, 0) = 19',
+ '(20, 0, 0) = 20',
+ '(21, 0, 0) = 21',
+ '(22, 0, 0) = 22',
+ '(23, 0, 0) = 23'])
diff --git a/tests/lldb/tests/jni/test_allocation_list_jni.py b/tests/lldb/tests/jni/test_allocation_list_jni.py
new file mode 100644
index 0000000..a454194
--- /dev/null
+++ b/tests/lldb/tests/jni/test_allocation_list_jni.py
@@ -0,0 +1,439 @@
+'''Module that contains the test TestAllocationListJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+#
+class TestAllocationListJNI(TestBaseRemote):
+ '''Tests printing the details of all allocations of a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIAllocations'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=anomalous-backslash-in-string
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test command line flag for single allocation
+ self.try_command('language renderscript allocation list -i 3',
+ [],
+ ['3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['1:\n'
+ # Regex for non zero hex number
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '3:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 3, 8\)\n'
+ ' Data Type: char\n'
+ ' Data Kind: User',
+ '4:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: char2\n'
+ ' Data Kind: User',
+ '5:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char3\n'
+ ' Data Kind: User',
+ '6:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: char4\n'
+ ' Data Kind: User',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '8:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 1, 2\)\n'
+ ' Data Type: short2\n'
+ ' Data Kind: User',
+ '9:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short3\n'
+ ' Data Kind: User',
+ '10:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: short4\n'
+ ' Data Kind: User',
+ '11:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: int\n'
+ ' Data Kind: User',
+ '12:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: int2\n'
+ ' Data Kind: User',
+ '13:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: int3\n'
+ ' Data Kind: User',
+ '14:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: int4\n'
+ ' Data Kind: User',
+ '15:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: long\n'
+ ' Data Kind: User',
+ '16:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: long2\n'
+ ' Data Kind: User',
+ '17:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: long3\n'
+ ' Data Kind: User',
+ '18:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: long4\n'
+ ' Data Kind: User',
+ '19:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: bool\n'
+ ' Data Kind: User'
+ ])
+
+
+ self.try_command('breakpoint del 1',
+ ['1 breakpoints deleted'])
+
+ # Hit second kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '20:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uchar\n'
+ ' Data Kind: User',
+ '21:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(2, 6, 0\)\n'
+ ' Data Type: uchar2\n'
+ ' Data Kind: User',
+ '22:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar3\n'
+ ' Data Kind: User',
+ '23:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: User',
+ '24:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: ushort\n'
+ ' Data Kind: User',
+ '25:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ushort2\n'
+ ' Data Kind: User',
+ '26:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: ushort3\n'
+ ' Data Kind: User',
+ '27:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ushort4\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '29:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: uint2\n'
+ ' Data Kind: User',
+ '30:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: uint3\n'
+ ' Data Kind: User',
+ '31:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 1, 6\)\n'
+ ' Data Type: uint4\n'
+ ' Data Kind: User',
+ '32:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 3, 2\)\n'
+ ' Data Type: ulong\n'
+ ' Data Kind: User',
+ '33:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: ulong2\n'
+ ' Data Kind: User',
+ '34:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong3\n'
+ ' Data Kind: User',
+ '35:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: ulong4\n'
+ ' Data Kind: User'
+ ])
+
+ self.try_command('breakpoint del 2',
+ ['1 breakpoints deleted'])
+
+ # Hit third kernel
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('language renderscript allocation list',
+ [],
+ ['2:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(64, 64, 0\)\n'
+ ' Data Type: uchar4\n'
+ ' Data Kind: RGBA Pixel',
+ '7:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: short\n'
+ ' Data Kind: User',
+ '28:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: uint\n'
+ ' Data Kind: User',
+ '36:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: half\n'
+ ' Data Kind: User',
+ '37:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: half2\n'
+ ' Data Kind: User',
+ '38:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 6, 0\)\n'
+ ' Data Type: half3\n'
+ ' Data Kind: User',
+ '39:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: half4\n'
+ ' Data Kind: User',
+ '40:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: float\n'
+ ' Data Kind: User',
+ '41:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(12, 0, 0\)\n'
+ ' Data Type: float2\n'
+ ' Data Kind: User',
+ '42:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(6, 0, 0\)\n'
+ ' Data Type: float3\n'
+ ' Data Kind: User',
+ '43:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(3, 2, 0\)\n'
+ ' Data Type: float4\n'
+ ' Data Kind: User',
+ '44:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(24, 0, 0\)\n'
+ ' Data Type: double\n'
+ ' Data Kind: User',
+ '45:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(4, 1, 3\)\n'
+ ' Data Type: double2\n'
+ ' Data Kind: User',
+ '46:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double3\n'
+ ' Data Kind: User',
+ '47:\n'
+ ' Context: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Address: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Data pointer: 0x0*[1-9a-fA-F][0-9a-fA-F]*\n'
+ ' Dimensions: \(1, 2, 3\)\n'
+ ' Data Type: double4\n'
+ ' Data Kind: User'
+ ])
diff --git a/tests/lldb/tests/jni/test_backtrace_jni.py b/tests/lldb/tests/jni/test_backtrace_jni.py
new file mode 100644
index 0000000..0bd8280
--- /dev/null
+++ b/tests/lldb/tests/jni/test_backtrace_jni.py
@@ -0,0 +1,71 @@
+'''Module that contains the test TestBacktraceJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBacktraceJNI(TestBaseRemote):
+ '''Tests viewing the call stack of a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIBranchingFunCalls'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see three functions in bt:
+ # libRSCpuRef, kernel.expand and the kernel
+ 'frame #2:',
+ 'librs.simple.so',
+ 'simple_kernel'],
+ [r'simple\.rs:4[567]'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('b set_i',
+ ['Breakpoint 2',
+ 'set_i'],
+ [r'simple.rs:2[012]'])
+
+ self.try_command('breakpoint list',
+ ['set_i', 'resolved'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ # We should be able to see five functions in bt:
+ # libRSCpuRef, kernel.expand, kernel and two functions
+ 'frame #4:',
+ 'librs.simple.so',
+ 'modify_i',
+ 'set_i'],
+ [r'simple\.rs:2[012]'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_coordinate_jni.py b/tests/lldb/tests/jni/test_breakpoint_coordinate_jni.py
new file mode 100644
index 0000000..ec2ecc4
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_coordinate_jni.py
@@ -0,0 +1,149 @@
+'''Module that contains the test TestBreakpointCoordinateJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointCoordinateJNI(TestBaseRemote):
+ '''Tests breaking on a specific kernel invocation in a JNI apk.
+
+ Uses the -c option to specify the coordinate.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIAllocations'
+
+ def test_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 test_shutdown(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')
+
+ def _check_coordinates(self, (x_coord, y_coord, z_coord), kernel):
+ '''Run lldb commands to check that coordinates match expected values.
+
+ Args:
+ (x_coord, y_coord, z_coord): The expected coordinates.
+ kernel: String that is the name of the kernel function.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.allocs.so`%s' % kernel])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (%d, %d, %d)' %
+ (x_coord, y_coord, z_coord)])
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # Test conditional coordinate in a two dimensions
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 3,7',
+ ['Conditional kernel breakpoint on coordinate 3, 7, 0',
+ 'Breakpoint(s) created'])
+
+ # We will delete this breakpoint before we hit it.
+ self.try_command('language renderscript kernel breakpoint set swizzle_kernel -c 199,199',
+ ['Conditional kernel breakpoint on coordinate 199, 199, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((3, 7, 0), 'swizzle_kernel')
+
+ # Check breakpoints that have been hit are disabled
+ self.try_command('breakpoint list',
+ ["1: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1 Options: disabled",
+ "2: RenderScript kernel breakpoint for 'swizzle_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on 199,199,0
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ # Test conditional coordinate in a single dimension
+ self.try_command('language renderscript kernel breakpoint set square_kernel -c 8',
+ ['Conditional kernel breakpoint on coordinate 8, 0, 0',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((8, 0, 0), 'square_kernel')
+
+ # Test conditional coordinate in three dimensions
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,0,1',
+ ['Conditional kernel breakpoint on coordinate 0, 0, 1',
+ 'Breakpoint(s) created'])
+
+ # Test we can set more than one conditional kernel breakpoint and both
+ # will be hit
+ self.try_command('language renderscript kernel breakpoint set add_half_kernel -c 0,1,2',
+ ['Conditional kernel breakpoint on coordinate 0, 1, 2',
+ 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 0, 1), 'add_half_kernel')
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'add_half_kernel')
+
+ # Check we can see the coordinate from a function invoked by the kernel
+ self.try_command('break set -n half_helper',
+ ['librs.allocs.so`half_helper'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._check_coordinates((0, 1, 2), 'half_helper')
+
+ # Delete helper function breakpoint
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Delete breakpoint which has already been disabled
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ # Check our delete breakpoints have been removed
+ self.try_command('breakpoint list',
+ ["4: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled",
+ "5: RenderScript kernel breakpoint for 'add_half_kernel', locations = 1 Options: disabled"])
diff --git a/tests/lldb/tests/jni/test_breakpoint_fileline_jni.py b/tests/lldb/tests/jni/test_breakpoint_fileline_jni.py
new file mode 100644
index 0000000..98882f2
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_fileline_jni.py
@@ -0,0 +1,48 @@
+'''Module that contains the test TestBreakpointFileLineJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointFileLineJNI(TestBaseRemote):
+ '''Tests setting a bp on a specific line of a RS file in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('bt',
+ ['librs.simple.so',
+ 'simple_kernel',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ['simple.rs',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_fileline_multiple_rs_files_jni.py b/tests/lldb/tests/jni/test_breakpoint_fileline_multiple_rs_files_jni.py
new file mode 100644
index 0000000..6362802
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_fileline_multiple_rs_files_jni.py
@@ -0,0 +1,62 @@
+'''Module that contains the test TestBreakpointFileLineMultipleRSFilesJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointFileLineMultipleRSFilesJNI(TestBaseRemote):
+ '''Tests setting a breakpoint on one of multiple RS files in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ 'at first.rs:12',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('breakpoint set --file second.rs --line 7',
+ ['Breakpoint 2',
+ 'librs.second.so`second_kernel',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint list',
+ ['first.rs',
+ 'second.rs',
+ 'resolved = 1',
+ 'first.rs:12',
+ 'second.rs:7'])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.second.so`second_kernel',
+ 'at second.rs:7',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 2'])
+
+ self.try_command('process status',
+ ['stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_kernel_1_jni.py b/tests/lldb/tests/jni/test_breakpoint_kernel_1_jni.py
new file mode 100644
index 0000000..9657c7d
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_kernel_1_jni.py
@@ -0,0 +1,76 @@
+'''Module that contains the test TestBreakpointKernel1JNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointKernel1JNI(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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)'])
+
+ # Try set a breakpoint on a kernel which doesn't exist
+ self.try_command('language renderscript kernel breakpoint set imaginary_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 0 (pending)",
+ "'imaginary_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.simple.so',
+ 'simple_kernel'])
+
+ self.try_command('breakpoint list',
+ ["'imaginary_kernel', locations = 0 (pending)",
+ "'simple_kernel', locations = 1, resolved = 1"])
+
+ # Delete breakpoint on kernel which doesn't exist
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_kernel_2_jni.py b/tests/lldb/tests/jni/test_breakpoint_kernel_2_jni.py
new file mode 100644
index 0000000..1d99f62
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_kernel_2_jni.py
@@ -0,0 +1,47 @@
+'''Module that contains the test TestBreakpointKernel2JNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointKernel2JNI(TestBaseRemote):
+ '''Tests the setting of a breakpoint on a RS kernel in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIInfiniteLoop'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('bt',
+ ['stop reason = breakpoint',
+ 'frame #0:',
+ 'librs.infiniteLoop.so',
+ 'simple_kernel'],
+ [r'infiniteLoop\.rs:2[78]'])
+
+ self.try_command('breakpoint list',
+ ['simple_kernel',
+ 'resolved = 1'])
+
+ self.try_command('process status',
+ ['stopped',
+ '.so`simple_kernel',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_kernel_all_jni.py b/tests/lldb/tests/jni/test_breakpoint_kernel_all_jni.py
new file mode 100644
index 0000000..e620342
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_kernel_all_jni.py
@@ -0,0 +1,74 @@
+'''Module that contains the test TestBreakpointKernelAllJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointKernelAllJNI(TestBaseRemote):
+ '''Tests setting breakpoints on every RS kernel on a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'simple_kernel', locations = 1, resolved = 1",
+ "'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'other_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_kernel_all_multiple_rs_files_jni.py b/tests/lldb/tests/jni/test_breakpoint_kernel_all_multiple_rs_files_jni.py
new file mode 100644
index 0000000..7f65514
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_kernel_all_multiple_rs_files_jni.py
@@ -0,0 +1,74 @@
+'''Module that contains the test TestBreakpointKernelAllMultipleRSFilesJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointKernelAllMultipleRSFilesJNI(TestBaseRemote):
+ '''Tests setting bp on every RS kernel in many kernel files in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # Test command works with no kernels currently loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ # Check disable doesn't delete breakpoints
+ self.try_command('language renderscript kernel breakpoint all disable',
+ ['Breakpoints will not be set on any new kernels'])
+
+ # Delete all breakpoints manually
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["No breakpoints currently set"])
+
+ # Test command works when kernels are loaded
+ self.try_command('language renderscript kernel breakpoint all enable',
+ ['Breakpoints will be set on all kernels'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('breakpoint delete 3',
+ ['1 breakpoints deleted'])
+
+ # Check other_kernel breakpoint gets hit
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
diff --git a/tests/lldb/tests/jni/test_breakpoint_kernel_multiple_rs_files_jni.py b/tests/lldb/tests/jni/test_breakpoint_kernel_multiple_rs_files_jni.py
new file mode 100644
index 0000000..49459b2
--- /dev/null
+++ b/tests/lldb/tests/jni/test_breakpoint_kernel_multiple_rs_files_jni.py
@@ -0,0 +1,69 @@
+'''Module that contains the test TestBreakpointKernelMultipleRSFilesJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestBreakpointKernelMultipleRSFilesJNI(TestBaseRemote):
+ '''Tests setting a breakpoint on RS kernels in many files in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript kernel breakpoint set first_kernel',
+ ['Breakpoint(s) created',
+ '(pending)'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 0 (pending)"])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'],
+ [r'at first\.rs:1[012]'])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('language renderscript kernel breakpoint set second_kernel',
+ ['Breakpoint(s) created',
+ 'Breakpoint 2',
+ 'Breakpoint(s) created'],
+ [r"librs\.second\.so`second_kernel at second\.rs:[56]",])
+
+ self.try_command('breakpoint list',
+ ["'first_kernel', locations = 1, resolved = 1",
+ "'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('breakpoint delete 1',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ["'second_kernel', locations = 1, resolved = 1"])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint',
+ "librs.second.so`second_kernel"],
+ [r'second\.rs:[56]'])
+
+ self.try_command('breakpoint delete 2',
+ ['1 breakpoints deleted'])
+
+ self.try_command('breakpoint list',
+ ['No breakpoints currently set'])
diff --git a/tests/lldb/tests/jni/test_call_api_funs_jni.py b/tests/lldb/tests/jni/test_call_api_funs_jni.py
new file mode 100644
index 0000000..af454e2
--- /dev/null
+++ b/tests/lldb/tests/jni/test_call_api_funs_jni.py
@@ -0,0 +1,139 @@
+'''Module that contains the test TestCallApiFunsJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+from harness import RS_funs
+
+
+class TestCallApiFunsJNI(TestBaseRemote):
+ '''Tests calling of some RS API functions on a JNI apk.
+
+ This tests that JITing works.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test
+ can be run with.
+ '''
+ return "JNIKernelVariables"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Test the atomics separately because we want to check the output
+ # AtomicAdd(1234, 2)
+ self.try_command('expr rsAtomicAdd(&int_global, 2)',
+ ['1234'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '1236'])
+
+ # AtomicAnd(2345, 333)
+ self.try_command('expr rsAtomicAnd(&uint_global, 333)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '265'])
+
+ # AtomicCas(1236, 1236, 2345)
+ self.try_command('expr rsAtomicCas(&int_global, 1236, 2345)',
+ ['1236'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2345'])
+
+ # AtomicDec(265)
+ self.try_command('expr rsAtomicDec(&uint_global)',
+ ['265'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '264'])
+
+ # AtomicInc(2345)
+ self.try_command('expr rsAtomicInc(&int_global)',
+ ['2345'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '2346'])
+
+ # AtomicMax(264, 3456)
+ self.try_command('expr rsAtomicMax(&uint_global, 3456)',
+ ['264'],
+ [r'\(uint(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3456'])
+
+ # AtomicMin(2346, 3)
+ self.try_command('expr rsAtomicMin(&int_global, 3)',
+ ['2346'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '3'])
+
+ # AtomicOr(3, 456)
+ self.try_command('expr rsAtomicOr(&int_global, 456)',
+ ['3'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '459'])
+
+ # AtomicSub(3456, 7)
+ self.try_command('expr rsAtomicSub(&uint_global, 7)',
+ ['3456'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr uint_global',
+ ['(uint)',
+ '3449'])
+
+ # AtomicXor(459, 89)
+ self.try_command('expr rsAtomicXor(&int_global, 89)',
+ ['459'],
+ [r'\(int(32_t)?\)'])
+
+ self.try_command('expr int_global',
+ ['(int)',
+ '402'])
+
+ for line in RS_funs.FUNC_LIST:
+ # build the expression
+ ret, expr = RS_funs.build_expr(line)
+ # query return type table
+ if ret in RS_funs.TYPE_MAP:
+ # evaluate the expression
+ self.try_command(expr, [], [RS_funs.TYPE_MAP[ret]])
+ else:
+ # evaluate the expression
+ self.try_command(expr, '('+ret+')')
diff --git a/tests/lldb/tests/jni/test_coordinates_jni.py b/tests/lldb/tests/jni/test_coordinates_jni.py
new file mode 100644
index 0000000..84d23d0
--- /dev/null
+++ b/tests/lldb/tests/jni/test_coordinates_jni.py
@@ -0,0 +1,107 @@
+'''Module that contains the test TestCoordinatesJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestCoordinatesJNI(TestBaseRemote):
+ '''Tests the inspection of coordinates in a JNI apk.
+
+ Tests the inspection of the range and dimension of coordinates as well
+ as the current coordinates.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_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 test_shutdown(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')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # 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))
+
+ 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)])
diff --git a/tests/lldb/tests/jni/test_dwarf_lang_jni.py b/tests/lldb/tests/jni/test_dwarf_lang_jni.py
new file mode 100644
index 0000000..a4de77d
--- /dev/null
+++ b/tests/lldb/tests/jni/test_dwarf_lang_jni.py
@@ -0,0 +1,29 @@
+'''Module that contains the test DWARF language attribute test for JNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestDWARFLangJNI(TestBaseRemote):
+ '''Tests the DWARF language attribute is present in RS kernels in a JNI.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status', [])
+ self.try_command('b simple_kernel', [])
+ self.try_command('process continue', [])
+
+ self.assert_lang_renderscript()
diff --git a/tests/lldb/tests/jni/test_invoke_fun_jni.py b/tests/lldb/tests/jni/test_invoke_fun_jni.py
new file mode 100644
index 0000000..c0511a1
--- /dev/null
+++ b/tests/lldb/tests/jni/test_invoke_fun_jni.py
@@ -0,0 +1,49 @@
+'''Module that contains the test TestInvokeFunJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+
+class TestInvokeFunJNI(TestBaseRemote):
+ '''Tests debugging a function executed from JNI using invoke_*.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ String that is the name of the binary that this test should be run
+ with.
+ '''
+ return "JNIBranchingFunCalls"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --name addToGlobal',
+ ['Breakpoint 1', '(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint'],
+ [r'simple\.rs:5[789]'])
+
+ self.try_command('language renderscript kernel breakpoint set simple_kernel',
+ ['Breakpoint 2', 'Breakpoint(s) created'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'simple_kernel'],
+ [r'simple\.rs:4[567]'])
+
+ self.try_command('expr glob',
+ ['(int)',
+ '357'])
diff --git a/tests/lldb/tests/jni/test_language_subcmds_jni.py b/tests/lldb/tests/jni/test_language_subcmds_jni.py
new file mode 100644
index 0000000..5970515
--- /dev/null
+++ b/tests/lldb/tests/jni/test_language_subcmds_jni.py
@@ -0,0 +1,132 @@
+'''Module that contains the test TestLanguageSubcmdsJNI.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestLanguageSubcmdsJNI(TestBaseRemote):
+ '''Tests the 'language renderscript' subcommands on a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIDebugWaitAttach'
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ # pylint: disable=line-too-long
+ self.try_command('language',
+ [])
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked',
+ 'rsdAllocationInit',
+ 'rsdAllocationRead2D',
+ 'rsdScriptInit',
+ 'rsdScriptInvokeForEach',
+ 'rsdScriptInvokeForEachMulti',
+ 'rsdScriptSetGlobalVar'])
+
+ self.try_command('breakpoint set --file simple.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel breakpoint',
+ ['all',
+ 'set'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('language renderscript kernel coordinate',
+ ['Coordinate: (0, 0, 0)'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 3',
+ 'root',
+ 'simple_kernel',
+ 'other_kernel',
+ 'java_package_name: com.android.rs.jnidebugwaitattach',
+ 'version:'])
diff --git a/tests/lldb/tests/jni/test_language_subcmds_no_debug_jni.py b/tests/lldb/tests/jni/test_language_subcmds_no_debug_jni.py
new file mode 100644
index 0000000..97cfa0d
--- /dev/null
+++ b/tests/lldb/tests/jni/test_language_subcmds_no_debug_jni.py
@@ -0,0 +1,111 @@
+'''Module that contains the test TestLanguageSubcmdsNoDebugJNI.'''
+
+import os
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestLanguageSubcmdsNoDebugJNI(TestBaseRemote):
+ '''Tests the 'language renderscript' command on a JNI apk without debug info
+
+ In particular, module dump should report missing debug info.
+ '''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNINoDebugWaitAttach'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+ # 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'
+ '',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ [])
+
+ self.try_command('language renderscript kernel',
+ ['breakpoint',
+ 'coordinate',
+ 'list'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'simple'",
+ 'root',
+ 'simple_kernel'])
+
+ self.try_command('language renderscript context',
+ ['dump'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '1 script instances'])
+
+ self.try_command('language renderscript allocation',
+ ['list',
+ 'load',
+ 'save',
+ 'dump',
+ 'refresh'])
+
+ self.try_command('language renderscript allocation list',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list -i 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation list --id 0',
+ ['RenderScript Allocations:'])
+
+ self.try_command('language renderscript allocation dump 1',
+ ['Data (X, Y, Z):'])
+
+ output_file = self.get_tmp_file_path()
+ self.try_command('language renderscript allocation dump 1 -f ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ if os.path.isfile(output_file):
+ os.remove(output_file)
+
+ self.try_command('language renderscript allocation dump 1 --file ' +
+ output_file,
+ ["Results written to '%s'" % output_file])
+
+ self.try_command('language renderscript allocation save 1 ' +
+ output_file,
+ ["Allocation written to file '%s'" % output_file])
+
+ self.try_command('language renderscript allocation load 1 ' +
+ output_file,
+ ["Contents of file '%s' read into allocation 1" %
+ output_file])
+
+ self.try_command('language renderscript allocation refresh',
+ ['All allocations successfully recomputed'])
+
+ self.try_command('language renderscript module',
+ ['dump'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.simple.so',
+ 'Debug info does not exist.',
+ 'Globals: 1',
+ 'gColor - variable identified, but not found in '
+ 'binary (symbol exists)',
+ 'Kernels: 2',
+ 'root',
+ 'simple_kernel',
+ 'java_package_name: com.android.rs.jninodebugwaitattach',
+ 'version'])
diff --git a/tests/lldb/tests/jni/test_multiple_rs_files_jni.py b/tests/lldb/tests/jni/test_multiple_rs_files_jni.py
new file mode 100644
index 0000000..a58a26a
--- /dev/null
+++ b/tests/lldb/tests/jni/test_multiple_rs_files_jni.py
@@ -0,0 +1,61 @@
+'''Module that contains the test TestMultipleRSFilesJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestMultipleRSFilesJNI(TestBaseRemote):
+ '''Tests some commands on a JNI apk which has two rs files.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return 'JNIMultipleRSFiles'
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.'''
+
+ # pylint: disable=line-too-long
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered',
+ 'Runtime functions hooked'])
+
+ self.try_command('breakpoint set --file first.rs --line 12',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'librs.first.so`first_kernel',
+ 'at first.rs:12',
+ "name = 'multiplersfiles'",
+ 'stop reason = breakpoint 1'])
+
+ self.try_command('language renderscript kernel list',
+ ['RenderScript Kernels',
+ "Resource 'first'",
+ "Resource 'second'",
+ 'root',
+ 'first_kernel',
+ 'second_kernel'])
+
+ self.try_command('language renderscript context dump',
+ ['Inferred RenderScript Contexts',
+ '2 script instances'])
+
+ self.try_command('language renderscript module dump',
+ ['RenderScript Modules:',
+ 'librs.first.so',
+ 'librs.second.so',
+ 'Debug info loaded',
+ 'Globals: 1',
+ 'gColor - float4',
+ 'Kernels: 2',
+ 'root',
+ 'first_kernel',
+ 'second_kernel',
+ 'java_package_name: com.android.rs.jnimultiplersfiles',
+ 'version:'])
diff --git a/tests/lldb/tests/jni/test_read_global_jni.py b/tests/lldb/tests/jni/test_read_global_jni.py
new file mode 100644
index 0000000..5fffac2
--- /dev/null
+++ b/tests/lldb/tests/jni/test_read_global_jni.py
@@ -0,0 +1,272 @@
+'''Module that contains the test TestReadGlobalJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestReadGlobalJNI(TestBaseRemote):
+ '''Tests inspecting global variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output,
+ expected_regex=None):
+ '''Inspect a global and check for the output.
+
+ Run the "expr" and "target variable" commands on a given global and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + global_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('target variable',
+ ['Global variables for',
+ 'librs.simple.so',
+ "(uchar) uchar_global = '\\xea'",
+ '(short) short_global = -321',
+ '(ushort) ushort_global = 432',
+ '(int) int_global = 1234',
+ '(uint) uint_global = 2345',
+ '(float) float_global = 4.5',
+ '(ulong) ulong_global = 8888',
+ '(double) double_global = -456.5',
+ '(char2) char2_global = (11, -22)',
+ '(uchar2) uchar2_global = (0x21, 0x2c)',
+ '(short2) short2_global = (-555, 666)',
+ '(ushort2) ushort2_global = (777, 888)',
+ '(int2) int2_global = (999, -1111)',
+ '(uint2) uint2_global = (2222, 3333)',
+ '(float2) float2_global = (4.5, -5)',
+ '(long2) long2_global = (-4444, 5555)',
+ '(ulong2) ulong2_global = (6666, 7777)',
+ '(double2) double2_global = (88.5, -99)',
+ '(char3) char3_global = (11, -22, -33,',
+ '(uchar3) uchar3_global = (0x21, 0x2c, 0x37,',
+ '(short3) short3_global = (-555, 666, 777,',
+ '(ushort3) ushort3_global = (777, 888, 999,',
+ '(int3) int3_global = (999, -1111, 2222,',
+ '(uint3) uint3_global = (2222, 3333, 4444,',
+ '(float3) float3_global = (4.5, -5, -6.5,',
+ '(long3) long3_global = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_global = (6666, 7777, 8888,',
+ '(double3) double3_global = (88.5, -99, 111.5,',
+ '(char4) char4_global = (55, 11, -22, -33)',
+ '(uchar4) uchar4_global = (0xde, 0x21, 0x2c, 0x37)',
+ '(short4) short4_global = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_global = (666, 777, 888, 999)',
+ '(int4) int4_global = (888, 999, -1111, 2222)',
+ '(uint4) uint4_global = (1111, 2222, 3333, 4444)',
+ '(float4) float4_global = (3, 4.5, -5, -6.5)',
+ '(long4) long4_global = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_global = (5555, 6666, 7777, 8888)',
+ '(double4) double4_global = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_global = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_global = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_global = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_global = (4.5, 5.5, 6, 3)'],
+ [r"\((signed )?char\) char_global = '\\f'",
+ r'\((long )?long\) long_global = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_global('char_global',
+ ["'\\f'"],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_global('uchar_global',
+ ['(uchar)', "'\\xea'"])
+
+ self._try_inspecting_global('short_global',
+ ['(short)', '-321'])
+
+ self._try_inspecting_global('ushort_global',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_global('int_global',
+ ['(int)', '1234'])
+
+ self._try_inspecting_global('uint_global',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_global('float_global',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_global('long_global',
+ ['-77777'],
+ [r'\((long )?long\)'])
+
+ self._try_inspecting_global('ulong_global',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_global('double_global',
+ ['(double)', '-456.5'])
+
+
+ self._try_inspecting_global('char2_global',
+ ['(char2)', '(11, -22)'])
+
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/jni/test_read_local_jni.py b/tests/lldb/tests/jni/test_read_local_jni.py
new file mode 100644
index 0000000..5c67559
--- /dev/null
+++ b/tests/lldb/tests/jni/test_read_local_jni.py
@@ -0,0 +1,268 @@
+'''Module that contains the test TestReadLocalJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestReadLocalJNI(TestBaseRemote):
+ '''Tests inspecting local variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output,
+ expected_regex=None):
+ '''Inspect a local and check for the output.
+
+ Run the "expr" and "frame variable" commands on a given local and
+ with a given output. (The commands should be equivalent.)
+
+ Args:
+ local_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+ expected_regex: List of regular expressions that should match lldb's
+ output.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr ' + local_name,
+ expected_output,
+ expected_regex)
+
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ # pylint: disable=line-too-long
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('breakpoint set --file simple.rs --line 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self.try_command('frame variable',
+ ["(uchar) uchar_local = 'b'",
+ '(short) short_local = -321',
+ '(ushort) ushort_local = 432',
+ '(int) int_local = 1234',
+ '(uint) uint_local = 2345',
+ '(float) float_local = 4.5',
+ '(ulong) ulong_local = 8888',
+ '(double) double_local = -456.5',
+ '(char2) char2_local = (-11, -22)',
+ '(uchar2) uchar2_local = (0x21, 0x2c)',
+ '(short2) short2_local = (-555, 666)',
+ '(ushort2) ushort2_local = (777, 888)',
+ '(int2) int2_local = (999, -1111)',
+ '(uint2) uint2_local = (2222, 3333)',
+ '(float2) float2_local = (4.5, -5)',
+ '(long2) long2_local = (-4444, 5555)',
+ '(ulong2) ulong2_local = (6666, 7777)',
+ '(double2) double2_local = (88.5, -99)',
+ '(char3) char3_local = (11, -22, -33,',
+ '(uchar3) uchar3_local = (0x21, 0x2c, 0x37,',
+ '(short3) short3_local = (-555, 666, 777,',
+ '(ushort3) ushort3_local = (777, 888, 999,',
+ '(int3) int3_local = (999, -1111, 2222,',
+ '(uint3) uint3_local = (2222, 3333, 4444,',
+ '(float3) float3_local = (4.5, -5, -6.5,',
+ '(long3) long3_local = (-4444, 5555, 6666,',
+ '(ulong3) ulong3_local = (6666, 7777, 8888,',
+ '(double3) double3_local = (88.5, -99, 111.5,',
+ '(char4) char4_local = (55, 11, -22, -33)',
+ '(uchar4) uchar4_local = (0x16, 0x21, 0x2c, 0x37)',
+ '(short4) short4_local = (-444, -555, 666, 777)',
+ '(ushort4) ushort4_local = (666, 777, 888, 999)',
+ '(int4) int4_local = (888, 999, -1111, 2222)',
+ '(uint4) uint4_local = (1111, 2222, 3333, 4444)',
+ '(float4) float4_local = (3, 4.5, -5, -6.5)',
+ '(long4) long4_local = (-3333, -4444, 5555, 6666)',
+ '(ulong4) ulong4_local = (5555, 6666, 7777, 8888)',
+ '(double4) double4_local = (-77, 88.5, -99, 111.5)',
+ '(rs_matrix2x2) matrix2x2_local = (m = (1, 2.5, 3, 4.5))',
+ '(rs_matrix3x3) matrix3x3_local = {\n'
+ ' m = ([0] = 5, [1] = 6.5, [2] = 7, [3] = 8.5, [4] = 9, [5] = 1.5, [6] = 2, [7] = 3.5, [8] = 4)',
+ '(rs_matrix4x4) matrix4x4_local = {\n'
+ ' m = {\n'
+ ' [0] = 5.5\n'
+ ' [1] = 6\n'
+ ' [2] = 7.5\n'
+ ' [3] = 8\n'
+ ' [4] = 9\n'
+ ' [5] = 1.5\n'
+ ' [6] = 2\n'
+ ' [7] = 3.5\n'
+ ' [8] = 4.5\n'
+ ' [9] = 5.5\n'
+ ' [10] = 6.5\n'
+ ' [11] = 7\n'
+ ' [12] = 8\n'
+ ' [13] = 9.5\n'
+ ' [14] = 1.5\n'
+ ' [15] = 2.5\n'
+ ' }\n',
+ '(rs_quaternion) quaternion_local = (8, 9, 0.5, 7.5)'],
+ [r"\((signed )?char\) char_local = 'a'",
+ r'\((long )?long\) long_local = -77777'])
+
+ # Use expr to inspect locals
+ self._try_inspecting_local('char_local',
+ ["'a'"],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('uchar_local',
+ ['(uchar)', "'b'"])
+
+ self._try_inspecting_local('short_local',
+ ['(short)', '-321'])
+
+ self._try_inspecting_local('ushort_local',
+ ['(ushort)', '432'])
+
+ self._try_inspecting_local('int_local',
+ ['(int)', '1234'])
+
+ self._try_inspecting_local('uint_local',
+ ['(uint)', '2345'])
+
+ self._try_inspecting_local('float_local',
+ ['(float)', '4.5'])
+
+ self._try_inspecting_local('long_local',
+ ['-77777'], [r'\((long )?long\)'])
+
+ self._try_inspecting_local('ulong_local',
+ ['(ulong)', '8888'])
+
+ self._try_inspecting_local('double_local',
+ ['(double)', '-456.5'])
+
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(-11, -22)'])
+
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x2c)'])
+
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-555, 666)'])
+
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 888)'])
+
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(999, -1111)'])
+
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 3333)'])
+
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(4.5, -5)'])
+
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 5555)'])
+
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(6666, 7777)'])
+
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -99)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(11, -22, -33,'])
+
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x2c, 0x37,'])
+
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, 777,'])
+
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(777, 888, 999,'])
+
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(999, -1111, 2222,'])
+
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 3333, 4444,'])
+
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, -6.5,'])
+
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-4444, 5555, 6666,'])
+
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 7777, 8888,'])
+
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 111.5,'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(55, 11, -22, -33)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x21, 0x2c, 0x37)'])
+
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 666, 777)'])
+
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 999)'])
+
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(888, 999, -1111, 2222)'])
+
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 2222, 3333, 4444)'])
+
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, -5, -6.5)'])
+
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, 6666)'])
+
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(5555, 6666, 7777, 8888)'])
+
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 88.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/jni/test_rs_consts_jni.py b/tests/lldb/tests/jni/test_rs_consts_jni.py
new file mode 100644
index 0000000..d4a063a
--- /dev/null
+++ b/tests/lldb/tests/jni/test_rs_consts_jni.py
@@ -0,0 +1,75 @@
+'''Module that contains the test TestRSConstsJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestRSConstsJNI(TestBaseRemote):
+ '''Tests examining the RenderScript constants in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('language renderscript kernel breakpoint set kernel',
+ [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ # Constants
+ self.try_command('expr M_1_PI',
+ ['0.318309'])
+
+ self.try_command('expr M_2_PI',
+ ['0.636619'])
+
+ self.try_command('expr M_2_SQRTPI',
+ ['1.128379'])
+
+ self.try_command('expr M_E',
+ ['2.718281'])
+
+ self.try_command('expr M_LN10',
+ ['2.302585'])
+
+ self.try_command('expr M_LN2',
+ ['0.693147'])
+
+ self.try_command('expr M_LOG10E',
+ ['0.434294'])
+
+ self.try_command('expr M_LOG2E',
+ ['1.442695'])
+
+ self.try_command('expr M_PI',
+ ['3.141592'])
+
+ self.try_command('expr M_PI_2',
+ ['1.570796'])
+
+ self.try_command('expr M_PI_4',
+ ['0.785398'])
+
+ self.try_command('expr M_SQRT1_2',
+ ['0.707106'])
+
+ self.try_command('expr M_SQRT2',
+ ['1.414213'])
diff --git a/tests/lldb/tests/jni/test_source_step_jni.py b/tests/lldb/tests/jni/test_source_step_jni.py
new file mode 100644
index 0000000..908ae79
--- /dev/null
+++ b/tests/lldb/tests/jni/test_source_step_jni.py
@@ -0,0 +1,82 @@
+'''Module that contains the test TestSourceStepJNI.'''
+
+import os
+from harness.test_base_remote import TestBaseRemote
+
+class TestSourceStepJNI(TestBaseRemote):
+ '''Test stepping through the source in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIBranchingFunCalls"
+
+ def test_setup(self, android):
+ '''This test requires to be run on one thread.'''
+ android.push_prop('debug.rs.max-threads', 1)
+
+ def test_shutdown(self, android):
+ '''Reset the number of RS threads to the previous value.'''
+ android.pop_prop('debug.rs.max-threads')
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 47',
+ ['(pending)'])
+
+ self.try_command('process continue',
+ ['stopped',
+ 'stop reason = breakpoint',
+ 'simple.rs:47'])
+
+ # set the source mapping
+ file_dir = os.path.dirname(os.path.realpath(__file__))
+ new_dir = os.path.join(file_dir, '..', '..', 'jni', 'BranchingFunCalls',
+ 'jnibranchingfuncalls')
+ self.set_src_map('simple.rs', new_dir)
+
+ self.try_command('process status',
+ ['-> 47',
+ 'int i = in;'])
+
+ #47 int i = in;
+ self.try_command('thread step-in',
+ ['-> 48'])
+ #48 float f = (float) i;
+ self.try_command('thread step-in',
+ ['-> 49'])
+ #49 modify_f(&f);
+ self.try_command('thread step-over',
+ ['-> 50'])
+ #50 modify_i(&i);
+ self.try_command('thread step-in',
+ ['-> 33'])
+ #33 int j = *i;
+ self.try_command('b -f simple.rs -l 38',
+ ['librs.simple.so`modify_i',
+ 'simple.rs:38'])
+ self.try_command('c',
+ ['stop reason = breakpoint',
+ 'simple.rs:38',
+ '-> 38'])
+ #38 set_i(i, 0);
+ # For the line number anything between #20 and #22 is fine
+ self.try_command('thread step-in',
+ [],
+ [r'-> 2[012]'])
+ #22 int tmp = b;
+ self.try_command('thread step-out',
+ ['-> 38'])
diff --git a/tests/lldb/tests/jni/test_write_global_element_jni.py b/tests/lldb/tests/jni/test_write_global_element_jni.py
new file mode 100644
index 0000000..c7ed21b
--- /dev/null
+++ b/tests/lldb/tests/jni/test_write_global_element_jni.py
@@ -0,0 +1,263 @@
+'''Module that contains the test TestWriteGlobalElementJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestWriteGlobalElementJNI(TestBaseRemote):
+ '''Tests modifying global variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_inspecting_global(self, global_name, expected_output):
+ '''Run the "expr" command on a given global and with a given output.
+
+ Args:
+ global_name: String which is the name of the global to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + global_name, expected_output)
+
+ def _try_modifying_global(self, global_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (global_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char2_global[0]', '2',
+ ['\'\\x02\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char2_global', ['(char2)', '(2, -22)'])
+
+ self._try_modifying_global('uchar2_global[1]', '3',
+ ['\'\\x03\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar2_global',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_global('short2_global[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_global('short2_global',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_global('ushort2_global[1]', '55',
+ ['55'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort2_global',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_global('int2_global[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_global('int2_global',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_global('uint2_global[1]', '777',
+ ['777'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint2_global',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_global('float2_global[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_global('float2_global',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_global('long2_global[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long2_global',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_global('ulong2_global[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong2_global',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_global('double2_global[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_global('double2_global',
+ ['(double2)', '(88.5, -11)'])
+
+
+ self._try_modifying_global('char3_global[0]', '12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char3_global',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self._try_modifying_global('uchar3_global[1]', '\'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar3_global',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ self._try_modifying_global('short3_global[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_global('short3_global',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_global('ushort3_global[0]', '1414',
+ ['1414'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort3_global',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_global('int3_global[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_global('int3_global',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_global('uint3_global[1]', '161616',
+ ['161616'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint3_global',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_global('float3_global[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_global('float3_global',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_global('long3_global[0]', '-181818181818',
+ ['-181818181818'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long3_global',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_global('ulong3_global[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong3_global',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_global('double3_global[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_global('double3_global',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self._try_modifying_global('char4_global[0]', '-21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self._try_inspecting_global('char4_global',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self._try_modifying_global('uchar4_global[1]', '22',
+ ['\'\\x16\''], [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_global('uchar4_global',
+ ['(uchar4)',
+ '(0xde, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_global('short4_global[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_global('short4_global',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ self._try_modifying_global('ushort4_global[3]', '24',
+ ['24'],
+ [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_global('ushort4_global',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_global('int4_global[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_global('int4_global',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_global('uint4_global[1]', '26262',
+ ['26262'],
+ [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_global('uint4_global',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_global('float4_global[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_global('float4_global',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_global('long4_global[3]', '-28282828282',
+ ['-28282828282'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_global('long4_global',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_global('ulong4_global[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_global('ulong4_global',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_global('double4_global[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_global('double4_global',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/jni/test_write_global_jni.py b/tests/lldb/tests/jni/test_write_global_jni.py
new file mode 100644
index 0000000..2d77da0
--- /dev/null
+++ b/tests/lldb/tests/jni/test_write_global_jni.py
@@ -0,0 +1,204 @@
+'''Module that contains the test TestWriteGlobalJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestWriteGlobalJNI(TestBaseRemote):
+ '''Tests modifying global variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_modifying_global(self, global_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Modify and then inspect a global and check for the output.
+
+ Run the "expr" command to set a given global to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ global_name: String which is the name of the global to modify.
+ new_value: A string that is the new value of the global.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the global.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=too-many-arguments
+
+ self.try_command('expr %s = %s%s' %
+ (global_name, data_type_in, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('target variable ' + global_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_global('char_global', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ self._try_modifying_global('uchar_global', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_global('short_global', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_global('ushort_global', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_global('int_global', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_global('uint_global', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_global('float_global', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_global('long_global', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_global('ulong_global', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_global('double_global', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+
+ self._try_modifying_global('char2_global', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_global('uchar2_global', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ self._try_modifying_global('short2_global', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_global('ushort2_global', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_global('int2_global', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_global('uint2_global', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_global('float2_global', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_global('long2_global', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_global('ulong2_global', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_global('double2_global', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_global('char3_global', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_global('uchar3_global', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_global('short3_global', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ self._try_modifying_global('ushort3_global', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_global('int3_global', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_global('uint3_global', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_global('float3_global', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_global('long3_global', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_global('ulong3_global', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_global('double3_global', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_global('char4_global', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_global('uchar4_global', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_global('short4_global', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_global('ushort4_global', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ self._try_modifying_global('int4_global', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_global('uint4_global', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_global('float4_global', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_global('long4_global', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_global('ulong4_global', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_global('double4_global', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
diff --git a/tests/lldb/tests/jni/test_write_local_element_jni.py b/tests/lldb/tests/jni/test_write_local_element_jni.py
new file mode 100644
index 0000000..84c660d
--- /dev/null
+++ b/tests/lldb/tests/jni/test_write_local_element_jni.py
@@ -0,0 +1,273 @@
+'''Module that contains the test TestWriteLocalElementJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestWriteLocalElementJNI(TestBaseRemote):
+ '''Tests modifying elements of local variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_inspecting_local(self, local_name, expected_output):
+ '''Run the "expr" command on a given local and with a given output.
+
+ Args:
+ local_name: String which is the name of the local to inspect.
+ expected_output: List of strings that should be found in the output.
+
+ Raises:
+ TestFail: The lldb command did not provide the expected output.
+ '''
+ self.try_command('expr ' + local_name, expected_output)
+
+ def _try_modifying_local(self, local_name, new_value, expected_output,
+ expected_output_regex=None):
+ '''Modify and then inspect a local and check for the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+ self.try_command('expr %s = %s' % (local_name, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=too-many-statements
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char2_local[0]', '2',
+ ['2'], [r'\((signed )?char\)'])
+ self._try_inspecting_local('char2_local',
+ ['(char2)', '(2, -22)'])
+
+ self._try_modifying_local('uchar2_local[1]', '3',
+ ['3'], [r'\(u(nsigned )?char\)'])
+ self._try_inspecting_local('uchar2_local',
+ ['(uchar2)', '(0x21, 0x03)'])
+
+ self._try_modifying_local('short2_local[0]', '-44',
+ ['(short)', '-44'])
+ self._try_inspecting_local('short2_local',
+ ['(short2)', '(-44, 666)'])
+
+ self._try_modifying_local('ushort2_local[1]', '55',
+ ['55'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort2_local',
+ ['(ushort2)', '(777, 55)'])
+
+ self._try_modifying_local('int2_local[0]', '666',
+ ['(int)', '666'])
+ self._try_inspecting_local('int2_local',
+ ['(int2)', '(666, -1111)'])
+
+ self._try_modifying_local('uint2_local[1]', '777',
+ ['777'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint2_local',
+ ['(uint2)', '(2222, 777)'])
+
+ self._try_modifying_local('float2_local[0]', '-8.5',
+ ['(float)', '-8.5'])
+ self._try_inspecting_local('float2_local',
+ ['(float2)', '(-8.5, -5)'])
+
+ self._try_modifying_local('long2_local[1]', '999999',
+ ['999999'],
+ [r'\((long )?long\)'])
+ self._try_inspecting_local('long2_local',
+ ['(long2)', '(-4444, 999999)'])
+
+ self._try_modifying_local('ulong2_local[0]', '10101010101',
+ ['10101010101'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong2_local',
+ ['(ulong2)', '(10101010101, 7777)'])
+
+ self._try_modifying_local('double2_local[1]', '-11.000',
+ ['(double)', '-11'])
+ self._try_inspecting_local('double2_local',
+ ['(double2)', '(88.5, -11)'])
+
+ # For some reason the result of some char and uchar expr is in hex and
+ # that of frame variable in decimal, so calling try_modifying_local
+ # doesn't work, because it reuses the expected output for both commands.
+ self.try_command('expr char3_local[0] = 12',
+ ['\'\\f\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char3_local[0]',
+ ['12'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char3_local',
+ ['(char3)',
+ '(12, -22, -33,'])
+
+ self.try_command('expr uchar3_local[1] = \'d\'',
+ ['\'d\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar3_local[1]',
+ ['0x64'],
+ [r'\(u(nsigned )?char\)'])
+
+ self._try_inspecting_local('uchar3_local',
+ ['(uchar3)',
+ '(0x21, 0x64, 0x37,'])
+
+ self._try_modifying_local('short3_local[2]', '-131',
+ ['(short)', '-131'])
+ self._try_inspecting_local('short3_local',
+ ['(short3)',
+ '(-555, 666, -131,'])
+
+ self._try_modifying_local('ushort3_local[0]', '1414',
+ ['1414'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort3_local',
+ ['(ushort3)',
+ '(1414, 888, 999,'])
+
+ self._try_modifying_local('int3_local[0]', '151515',
+ ['(int)', '151515'])
+ self._try_inspecting_local('int3_local',
+ ['(int3)',
+ '(151515, -1111, 2222,'])
+
+ self._try_modifying_local('uint3_local[1]', '161616',
+ ['161616'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint3_local',
+ ['(uint3)',
+ '(2222, 161616, 4444,'])
+
+ self._try_modifying_local('float3_local[2]', '17.5',
+ ['(float)', '17.5'])
+ self._try_inspecting_local('float3_local',
+ ['(float3)',
+ '(4.5, -5, 17.5,'])
+
+ self._try_modifying_local('long3_local[0]', '-181818181818',
+ ['-181818181818'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long3_local',
+ ['(long3)',
+ '(-181818181818, 5555, 6666,'])
+
+ self._try_modifying_local('ulong3_local[1]', '191919191919',
+ ['191919191919'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong3_local',
+ ['(ulong3)',
+ '(6666, 191919191919, 8888,'])
+
+ self._try_modifying_local('double3_local[2]', '20.5',
+ ['(double)', '20.5'])
+ self._try_inspecting_local('double3_local',
+ ['(double3)',
+ '(88.5, -99, 20.5,'])
+
+ self.try_command('expr char4_local[0] = -21',
+ ['\'\\xeb\''],
+ [r'\((signed )?char\)'])
+ self.try_command('frame variable char4_local[0]',
+ ['-21'],
+ [r'\((signed )?char\)'])
+
+ self._try_inspecting_local('char4_local',
+ ['(char4)',
+ '(-21, 11, -22, -33)'])
+
+ self.try_command('expr uchar4_local[1] = 22',
+ ['\'\\x16\''],
+ [r'\(u(nsigned )?char\)'])
+ self.try_command('frame variable uchar4_local[1]',
+ ['0x16'],
+ [r'\(u(nsigned )?char\)'])
+
+ self._try_inspecting_local('uchar4_local',
+ ['(uchar4)',
+ '(0x16, 0x16, 0x2c, 0x37)'])
+
+ self._try_modifying_local('short4_local[2]', '23',
+ ['(short)', '23'])
+ self._try_inspecting_local('short4_local',
+ ['(short4)',
+ '(-444, -555, 23, 777)'])
+
+ self._try_modifying_local('ushort4_local[3]', '24',
+ ['24'], [r'\(u(nsigned )?short\)'])
+ self._try_inspecting_local('ushort4_local',
+ ['(ushort4)',
+ '(666, 777, 888, 24)'])
+
+ self._try_modifying_local('int4_local[0]', '-2525',
+ ['(int)', '-2525'])
+ self._try_inspecting_local('int4_local',
+ ['(int4)',
+ '(-2525, 999, -1111, 2222)'])
+
+ self._try_modifying_local('uint4_local[1]', '26262',
+ ['26262'], [r'\(u(nsigned )?int\)'])
+ self._try_inspecting_local('uint4_local',
+ ['(uint4)',
+ '(1111, 26262, 3333, 4444)'])
+
+ self._try_modifying_local('float4_local[2]', '27.0f',
+ ['(float)', '27'])
+ self._try_inspecting_local('float4_local',
+ ['(float4)',
+ '(3, 4.5, 27, -6.5)'])
+
+ self._try_modifying_local('long4_local[3]', '-28282828282',
+ ['-28282828282'], [r'\((long )?long\)'])
+ self._try_inspecting_local('long4_local',
+ ['(long4)',
+ '(-3333, -4444, 5555, -28282828282)'])
+
+ self._try_modifying_local('ulong4_local[0]', '2929292929',
+ ['2929292929'],
+ [r'\(u(nsigned )?(long )?long\)'])
+ self._try_inspecting_local('ulong4_local',
+ ['(ulong4)',
+ '(2929292929, 6666, 7777, 8888)'])
+
+ self._try_modifying_local('double4_local[1]', '30.5',
+ ['(double)', '30.5'])
+ self._try_inspecting_local('double4_local',
+ ['(double4)',
+ '(-77, 30.5, -99, 111.5)'])
diff --git a/tests/lldb/tests/jni/test_write_local_jni.py b/tests/lldb/tests/jni/test_write_local_jni.py
new file mode 100644
index 0000000..c9dada3
--- /dev/null
+++ b/tests/lldb/tests/jni/test_write_local_jni.py
@@ -0,0 +1,203 @@
+'''Module that contains the test TestWriteLocalJNI.'''
+
+from harness.test_base_remote import TestBaseRemote
+
+class TestWriteLocalJNI(TestBaseRemote):
+ '''Tests modifying local variables of all types in a JNI apk.'''
+
+ def get_bundle_target(self):
+ '''Return string with name of bundle executable to run.
+
+ Returns:
+ A string containing the name of the binary that this test can be run
+ with.
+ '''
+ return "JNIKernelVariables"
+
+ def _try_modifying_local(self, local_name, new_value, data_type_in,
+ expected_output, expected_output_regex=None):
+ '''Try getting lldb to modify a local and check the output.
+
+ Run the "expr" command to set a given local to a new value and
+ check that it is set afterwards by running the "target variable"
+ command.
+
+ Args:
+ local_name: String which is the name of the local to modify.
+ new_value: A string that is the new value of the local.
+ data_type_in: A string containing a c-style parenthesised data type
+ representing the type of the local.
+ expected_output: List of strings that should be found in the output
+ of both commands.
+ expected_output_regex: List of regular expressions that should be
+ found in the output of the target variable
+ command.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=too-many-arguments
+
+ self.try_command('expr %s = %s%s' %
+ (local_name, data_type_in, new_value),
+ expected_output,
+ expected_output_regex)
+ self.try_command('frame variable ' + local_name,
+ expected_output,
+ expected_output_regex)
+
+ def test_case(self, _):
+ '''Run the lldb commands that are being tested.
+
+ Raises:
+ TestFail: One of the lldb commands did not provide the expected
+ output.
+ '''
+
+ # pylint: disable=line-too-long
+ # There is no way we can make this look nice
+
+ self.try_command('language renderscript status',
+ ['Runtime Library discovered',
+ 'Runtime Driver discovered'])
+
+ self.try_command('b -f simple.rs -l 129', [])
+
+ self.try_command('process continue',
+ ['resuming',
+ 'stopped',
+ 'stop reason = breakpoint'])
+
+ self._try_modifying_local('char_local', '-2',
+ '(signed char)', ['\'\\xfe\''],
+ [r'\((signed )?char\)'])
+
+ self._try_modifying_local('uchar_local', '22',
+ '(uchar)', ['(uchar)', '\'\\x16\''])
+
+ self._try_modifying_local('short_local', '-33',
+ '(short)', ['(short)', '-33'])
+
+ self._try_modifying_local('ushort_local', '44',
+ '(ushort)', ['(ushort)', '44'])
+
+ self._try_modifying_local('int_local', '-55',
+ '(int)', ['(int)', '-55'])
+
+ self._try_modifying_local('uint_local', '66',
+ '(uint)', ['(uint)', '66'])
+
+ self._try_modifying_local('float_local', '-7.5',
+ '(float)', ['(float)', '-7.5'])
+
+ self._try_modifying_local('long_local', '-888888',
+ '(long long)', ['-888888'],
+ [r'\((long )?long\)'])
+
+ self._try_modifying_local('ulong_local', '99999999',
+ '(ulong)', ['(ulong)', '99999999'])
+
+ self._try_modifying_local('double_local', '-10101.5',
+ '(double)', ['(double)', '-10101.5'])
+
+ self._try_modifying_local('char2_local', '{22, 4}',
+ '(char2)', ['(char2)', '(22, 4)'])
+
+ self._try_modifying_local('uchar2_local', '{44, 55}',
+ '(uchar2)', ['(uchar2)', '(0x2c, 0x37)'])
+
+ self._try_modifying_local('short2_local', '{-66, 77}',
+ '(short2)', ['(short2)', '(-66, 77)'])
+
+ self._try_modifying_local('ushort2_local', '{88, 99}',
+ '(ushort2)', ['(ushort2)', '(88, 99)'])
+
+ self._try_modifying_local('int2_local', '{111, -222}',
+ '(int2)', ['(int2)', '(111, -222)'])
+
+ self._try_modifying_local('uint2_local', '{333, 444}',
+ '(uint2)', ['(uint2)', '(333, 444)'])
+
+ self._try_modifying_local('float2_local', '{-55.5f, 6.0}',
+ '(float2)', ['(float2)', '(-55.5, 6)'])
+
+ self._try_modifying_local('long2_local', '{666666, -777777}',
+ '(long2)', ['(long2)', '(666666, -777777)'])
+
+ self._try_modifying_local('ulong2_local', '{888888, 999999}',
+ '(ulong2)', ['(ulong2)', '(888888, 999999)'])
+
+ self._try_modifying_local('double2_local', '{11.0000000, -0.0l}',
+ '(double2)', ['(double2)', '(11, -0)'])
+
+ self._try_modifying_local('char3_local', '{2, -3, 4}',
+ '(char3)', ['(char3)', '(2, -3, 4,'])
+
+ self._try_modifying_local('uchar3_local', '{\'a\', \'b\', \'c\'}',
+ '(uchar3)', ['(uchar3)', '(0x61, 0x62, 0x63,'])
+
+ self._try_modifying_local('short3_local', '{44, -55, 66}',
+ '(short3)', ['(short3)', '(44, -55, 66,'])
+
+ self._try_modifying_local('ushort3_local', '{88, 99, 111}',
+ '(ushort3)', ['(ushort3)', '(88, 99, 111,'])
+
+ self._try_modifying_local('int3_local', '{-111, 222, -333}',
+ '(int3)', ['(int3)', '(-111, 222, -333,'])
+
+ self._try_modifying_local('uint3_local', '{444, 555, 666}',
+ '(uint3)', ['(uint3)', '(444, 555, 666,'])
+
+ self._try_modifying_local('float3_local', '{7.5F, 0008.000, 9}',
+ '(float3)', ['(float3)', '(7.5, 8, 9,'])
+
+ self._try_modifying_local('long3_local', '{111111, -22222222, 3333333}',
+ '(long3)', ['(long3)', '(111111, -22222222, 3333333,'])
+
+ self._try_modifying_local('ulong3_local', '{4444444, 5555555, 66666666}',
+ '(ulong3)', ['(ulong3)', '(4444444, 5555555, 66666666,'])
+
+ self._try_modifying_local('double3_local', '{7.5L, -0, 8.9e1}',
+ '(double3)', ['(double3)', '(7.5, 0, 89,'])
+
+ self._try_modifying_local('char4_local', '{0x1, 0x2, 0x3, 0x4}',
+ '(char4)',
+ ['(char4)', '(1, 2, 3, 4)'])
+
+ self._try_modifying_local('uchar4_local', '{0x5, 0x6, 0x7, 0x8}',
+ '(uchar4)',
+ ['(uchar4)', '(0x05, 0x06, 0x07, 0x08)'])
+
+ self._try_modifying_local('short4_local', '{0x9, 0xa, 0xb, 0xc}',
+ '(short4)',
+ ['(short4)', '(9, 10, 11, 12)'])
+
+ self._try_modifying_local('ushort4_local', '{0xd, 0xe, 0xf, 0x10}',
+ '(ushort4)',
+ ['(ushort4)', '(13, 14, 15, 16)'])
+
+ self._try_modifying_local('int4_local', '{0x11, 0x12, 0x13, 0x14}',
+ '(int4)',
+ ['(int4)', '(17, 18, 19, 20)'])
+
+ self._try_modifying_local('uint4_local', '{0x15, 0x16, 0x17, 0x18}',
+ '(uint4)',
+ ['(uint4)', '(21, 22, 23, 24)'])
+
+ self._try_modifying_local('float4_local', '{19.0, 20.5, -21, -22.5}',
+ '(float4)',
+ ['(float4)', '(19, 20.5, -21, -22.5)'])
+
+ self._try_modifying_local('long4_local', '{0x1d, 0x1e, 0x1f, 0x20}',
+ '(long4)',
+ ['(long4)', '(29, 30, 31, 32)'])
+
+ self._try_modifying_local('ulong4_local', '{0x21, 0x22, 0x23, 0x24}',
+ '(ulong4)',
+ ['(ulong4)', '(33, 34, 35, 36)'])
+
+ self._try_modifying_local('double4_local', '{25.000, -26, -27.5, 28.0}',
+ '(double4)',
+ ['(double4)', '(25, -26, -27.5, 28)'])
diff --git a/tests/lldb/tests/run_test.py b/tests/lldb/tests/run_test.py
new file mode 100644
index 0000000..b9e2145
--- /dev/null
+++ b/tests/lldb/tests/run_test.py
@@ -0,0 +1,363 @@
+#!/usr/bin/env python2.7
+'''This script will run one specific test.'''
+from __future__ import print_function
+
+import sys
+import atexit
+import inspect
+import logging
+import os
+
+import harness
+from harness import util_constants
+from harness import util_log
+from harness import util_warnings
+from harness.util_functions import load_py_module
+from harness.util_lldb import UtilLLDB
+from harness.exception import DisconnectedException
+from harness.exception import TestSuiteException
+from harness.util_timer import Timer
+
+
+def _test_pre_run(state):
+ '''This function is called before a test is executed (setup).
+
+ Args:
+ state: Test suite state collection, instance of State.
+
+ Returns:
+ True if the pre_run step completed without error. Currently the pre-run
+ will launch the target test binary on the device and attach an
+ lldb-server to it in platform mode.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ TestSuiteException: Previous processes of this apk required for this
+ test could not be killed.
+ '''
+ assert state.test
+ assert state.bundle
+
+ log = util_log.get_logger()
+ log.info('running: {0}'.format(state.name))
+
+ # Remove any cached NDK scripts between tests
+ state.bundle.delete_ndk_cache()
+
+ # query our test case for the remote target app it needs
+ target_name = state.test.get_bundle_target()
+ if not target_name:
+ # test case doesn't require a remote process to debug
+ return True
+ else:
+ # find the pid of our remote test process
+ state.pid = state.bundle.launch(target_name)
+ if not state.pid:
+ log.error('unable to get pid of target')
+ return False
+ state.android.kill_servers()
+ # spawn lldb platform on the target device
+ state.android.launch_lldb_platform(state.device_port)
+ return True
+
+
+def _test_post_run(state):
+ '''This function is called after a test is executed (cleanup).
+
+ Args:
+ state: Test suite state collection, instance of State.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert state.test
+ assert state.bundle
+
+ target_name = state.test.get_bundle_target()
+ if target_name:
+ if state.bundle.is_apk(target_name):
+ state.android.stop_app(state.bundle.get_package(target_name))
+ else:
+ state.android.kill_process(target_name)
+
+
+def _test_run(state):
+ '''Execute a single test case.
+
+ Args:
+ state: test suite state collection, instance of State.
+
+ Returns:
+ True: if the test case ran successfully and passed.
+ False: if the test case failed or suffered an error.
+
+ Raises:
+ AssertionError: If an assertion fails.
+ '''
+ assert state.lldb
+ assert state.lldb_module
+ assert state.test
+
+ if not state.test.run(state.lldb, state.pid, state.lldb_module,
+ state.wimpy):
+ util_log.get_logger().error('test {0} failed'.format(state.name))
+ return False
+
+ return True
+
+
+def _initialise_timer(android, interval):
+ '''Start a 'timeout' timer, to catch stalled execution.
+
+ This function will start a timer that will act as a timeout killing this
+ test session if a test becomes un-responsive.
+
+ Args:
+ android: current instance of harness.UtilAndroid
+ interval: the interval for the timeout, in seconds
+
+ Returns:
+ The instance of the Timer class that was created.
+ '''
+
+ def on_timeout():
+ '''This is a callback function that will fire if a test takes longer
+ then a threshold time to complete.'''
+ # Clean up the android properties
+ android.reset_all_props()
+ # pylint: disable=protected-access
+ sys.stdout.flush()
+ # hard exit to force kill all threads that may block our exit
+ os._exit(util_constants.RC_TEST_TIMEOUT)
+
+ timer = Timer(interval, on_timeout)
+ timer.start()
+ atexit.register(Timer.stop, timer)
+ return timer
+
+
+def _quit_test(num, timer):
+ '''This function will exit making sure the timeout thread is killed.
+
+ Args:
+ num: An integer specifying the exit status, 0 meaning "successful
+ termination".
+ timer: The current Timer instance.
+ '''
+ if timer:
+ timer.stop()
+ sys.stdout.flush()
+ sys.exit(num)
+
+
+def _execute_test(state):
+ '''Execute a test case.
+
+ Args:
+ state: The current State object.
+ log: The current Log object.
+ '''
+ log = util_log.get_logger()
+
+ state.test.test_setup(state.android)
+ try:
+ if not _test_pre_run(state):
+ raise TestSuiteException('test_pre_run() failed')
+ if not _test_run(state):
+ raise TestSuiteException('test_run() failed')
+ _test_post_run(state)
+ log.info('Test passed')
+
+ finally:
+ state.test.post_run()
+ state.test.test_shutdown(state.android)
+
+
+def _get_test_case_class(module):
+ '''Inspect a test case module and return the test case class.
+
+ Args:
+ module: A loaded test case module.
+ '''
+ for _, obj in inspect.getmembers(module):
+ if inspect.isclass(obj):
+ if (hasattr(module, "TestBase") and
+ issubclass(obj, module.TestBase) and
+ obj is not module.TestBase):
+ return obj
+ if (hasattr(module, "TestBaseRemote") and
+ issubclass(obj, module.TestBaseRemote) and
+ obj is not module.TestBaseRemote):
+ return obj
+ return None
+
+
+def get_test_dir(test_name):
+ ''' Get the directory that contains a test with a given name.
+
+ Returns:
+ A string that is the directory containing the test.
+
+ Raises:
+ TestSuiteException: If a test with this name does not exist.
+ '''
+ tests_dir = os.path.dirname(os.path.realpath(__file__))
+ for sub_dir in os.listdir(tests_dir):
+ current_test_dir = os.path.join(tests_dir, sub_dir)
+ if (os.path.isdir(current_test_dir) and
+ test_name in os.listdir(current_test_dir)):
+ return current_test_dir
+
+ raise TestSuiteException(
+ 'unable to find test: {0}'.format(test_name))
+
+
+def main():
+ '''Test runner entry point.'''
+
+ # re-open stdout with no buffering
+ sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+
+ android = None
+ timer = None
+ log = None
+
+ try:
+ # parse the command line
+ if len(sys.argv) < 12:
+ raise TestSuiteException('Invalid number of arguments')
+
+ assert sys.argv[8] in ('True', 'False')
+ args = dict(test_name=sys.argv[1],
+ log_file_path=sys.argv[2],
+ adb_path=sys.argv[3],
+ lldb_server_path_device=sys.argv[4],
+ aosp_product_path=sys.argv[5],
+ device_port=int(sys.argv[6]),
+ device=sys.argv[7],
+ print_to_stdout=sys.argv[8] == 'True',
+ verbose=sys.argv[9] == 'True',
+ wimpy=sys.argv[10] == 'True',
+ timeout=int(sys.argv[11]))
+
+ # create utility classes
+ harness.util_log.initialise(args['test_name'],
+ print_to_stdout=args['print_to_stdout'],
+ level=logging.INFO if not args['verbose'] else logging.DEBUG,
+ file_path=args['log_file_path'],
+ file_mode='a'
+ )
+ log = util_log.get_logger()
+ log.debug('Logger initialised')
+
+ android = harness.UtilAndroid(args['adb_path'],
+ args['lldb_server_path_device'],
+ args['device'])
+
+ # start the timeout counter
+ timer = _initialise_timer(android, args['timeout'])
+
+ # startup lldb and register teardown handler
+ atexit.register(UtilLLDB.stop)
+ UtilLLDB.start()
+
+ current_test_dir = get_test_dir(args['test_name'])
+
+ # load a test case module
+ test_module = load_py_module(os.path.join(current_test_dir,
+ args['test_name']))
+ assert test_module
+ assert (hasattr(test_module, "TestBase") or
+ hasattr(test_module, "TestBaseRemote"))
+
+ # inspect the test module and locate our test case class
+ test_class = _get_test_case_class(test_module)
+ assert test_class
+
+ # if our test inherits from TestBaseRemote, check we have a valid device
+ if (hasattr(test_module, "TestBaseRemote") and
+ issubclass(test_class, test_module.TestBaseRemote)):
+ android.validate_device()
+
+ # create an instance of our test case
+ test_inst = test_class(args['device_port'], args['device'], timer)
+ assert test_inst
+
+ # instantiate a test target bundle
+ bundle = harness.UtilBundle(android, args['aosp_product_path'])
+
+ # execute the test case
+ try:
+ for _ in range(2):
+ try:
+ # create an lldb instance
+ lldb = UtilLLDB.create_debugger()
+
+ # create state object to encapsulate instances
+ state = type('State',
+ (object,),
+ dict(
+ android=android,
+ bundle=bundle,
+ lldb=lldb,
+ lldb_module=UtilLLDB.get_module(),
+ test=test_inst,
+ pid=None,
+ name=args['test_name'],
+ device_port=args['device_port'],
+ wimpy=args['wimpy'])
+ )
+
+ util_warnings.redirect_warnings()
+
+ _execute_test(state)
+
+ # tear down the lldb instance
+ UtilLLDB.destroy_debugger(lldb)
+ break
+ except DisconnectedException as error:
+ log.warning(error)
+ log.warning('Trying again.')
+ else:
+ log.fatal('Not trying again, maximum retries exceeded.')
+ raise TestSuiteException('Lost connection to lldb-server')
+
+ finally:
+ util_warnings.restore_warnings()
+
+ _quit_test(util_constants.RC_TEST_OK, timer)
+
+ except AssertionError:
+ if log:
+ log.critical('Internal test suite error', exc_info=1)
+ print('Internal test suite error', file=sys.stderr)
+ _quit_test(util_constants.RC_TEST_FATAL, timer)
+
+ except TestSuiteException as error:
+ if log:
+ log.exception(str(error))
+ else:
+ print(str(error), file=sys.stderr)
+ _quit_test(util_constants.RC_TEST_ERROR, timer)
+
+ # use a global exception handler to be sure that we will
+ # exit safely and correctly
+ except Exception:
+ if log:
+ log.exception('INTERNAL ERROR')
+ else:
+ import traceback
+ print('Exception {0}'.format(traceback.format_exc()),
+ file=sys.stderr)
+ _quit_test(util_constants.RC_TEST_FATAL, timer)
+
+ finally:
+ if android:
+ android.reset_all_props()
+ if timer:
+ timer.stop()
+
+
+# execution trampoline
+if __name__ == '__main__':
+ main()