anadroid.instrument package

Submodules

anadroid.instrument.AbstractInstrumenter module

class anadroid.instrument.AbstractInstrumenter.AbstractInstrumenter(profiler, mirror_dirname='_TRANSFORMED_')[source]

Bases: ABC

Provides basic interface to perform instrumentation of project sources of Android projects. .. attribute:: profiler

targeted profiler.

type:

Profiler

mirror_dirname

name of the directory where the changes will be performed.

Type:

str

abstract get_build_classpaths()[source]

retrieves the needed gradle dependencies for the performed instrumentation.

abstract get_build_dependencies()[source]

retrieves the needed build dependencies for the performed instrumentation.

abstract get_build_plugins()[source]

retrieves the needed build plugins for the performed instrumentation.

get_instrumentation_log(proj)[source]

loads information from the file containing the specs of the last instrumentation performed. :param proj: project. :type proj: AndroidProject

Returns:

last instrumentation specs.

Return type:

dict

abstract get_log_filename()[source]

returns the name of the log file where the instrumentation output will be written. :returns: name of the file. :rtype: str

abstract init()[source]

inits class.

abstract instrument(android_project, mirror_dirname='_TRANSFORMED_', test_approach=TESTING_APPROACH.WHITEBOX, test_frame=TESTING_FRAMEWORK.MONKEY, instr_strategy=INSTRUMENTATION_STRATEGY.METHOD_CALL, instr_type=INSTRUMENTATION_TYPE.TEST, **kwargs)[source]

Method responsible for instrument project sources. :param android_project: the project to instrument. :type android_project: AndroidProject :param mirror_dirname: name of the directory where the changes will be performed. :type mirror_dirname: str :param test_approach: testing approach. :type test_approach: TESTING_APPROACH :param test_frame: the testing framework to be used. :type test_frame: TESTING_FRAMEWORK :param instr_strategy: instrumentation strategy to perform. :type instr_strategy: INSTRUMENTATION_STRATEGY :param instr_type: type of instrumentation. :type instr_type: INSTRUMENTATION_TYPE :param **kwargs:

abstract needs_build_classpaths()[source]

checks if additional gradle dependencies are needed for the performed instrumentation.

abstract needs_build_dependency()[source]

checks if additional build dependencies are needed.

abstract needs_build_plugin()[source]

checks if a build plugin is needed.

needs_reinstrumentation(proj, test_approach, instr_type, instr_strategy)[source]

checks if the project needs to be instrumented again (i.e. if the last instrumentation performed is == to the instrumentation to be performed). :param proj: project. :type proj: AndroidProject :param test_approach: testing approach. :type test_approach: TESTING_APPROACH :param instr_strategy: instrumentation strategy to perform. :type instr_strategy: INSTRUMENTATION_STRATEGY :param instr_type: type of instrumentation. :type instr_type: INSTRUMENTATION_TYPE

Returns:

True if needs to be instrumented again, False otherwise.

Return type:

bool

write_instrumentation_log_file(proj, test_approach, instr_type, instr_strategy)[source]

write instrumentation attributes to a file. This file is inspected when there is need to evaluate if there is need to instrument again. :param proj: :param test_approach: :param instr_type: :param instr_strategy:

anadroid.instrument.JInstInstrumenter module

class anadroid.instrument.JInstInstrumenter.JInstInstrumenter(profiler, mirror_dirname='_TRANSFORMED_', build_system=BUILD_SYSTEM.GRADLE)[source]

Bases: AbstractInstrumenter

Implements defined interface of AbstractInstrumenter to perform source code instrumentation with JInst. .. attribute:: build_system

build system to be used.

type:

BUILD_SYSTEM

build_dependencies

list of build dependencies to insert in project’ build files.

Type:

list

classpath_dependencies

set of classpath dependencies to insert in project’ build files.

Type:

dict

build_plugins

set of build plugins to insert in project’ build files

Type:

dict

get_build_classpaths()[source]

retrieves the needed gradle dependencies for the performed instrumentation.

get_build_dependencies()[source]

retrieves the needed build dependencies for the performed instrumentation.

get_build_plugins()[source]

retrieves the needed build plugins for the performed instrumentation.

get_log_filename()[source]

returns the name of the log file where the instrumentation output will be written. :returns: name of the file. :rtype: str

init()[source]

inits class.

instrument(android_project, mirror_dirname='_TRANSFORMED_', test_approach=TESTING_APPROACH.WHITEBOX, test_frame=TESTING_FRAMEWORK.MONKEY, instr_strategy=INSTRUMENTATION_STRATEGY.METHOD_CALL, instr_type=INSTRUMENTATION_TYPE.TEST, **kwargs)[source]

Method responsible for instrument project sources. :param android_project: the project to instrument. :type android_project: AndroidProject :param mirror_dirname: name of the directory where the changes will be performed. :type mirror_dirname: str :param test_approach: testing approach. :type test_approach: TESTING_APPROACH :param test_frame: the testing framework to be used. :type test_frame: TESTING_FRAMEWORK :param instr_strategy: instrumentation strategy to perform. :type instr_strategy: INSTRUMENTATION_STRATEGY :param instr_type: type of instrumentation. :type instr_type: INSTRUMENTATION_TYPE :param **kwargs:

needs_build_classpaths()[source]

checks if additional gradle dependencies are needed for the performed instrumentation.

needs_build_dependency()[source]

checks if additional build dependencies are needed.

needs_build_plugin()[source]

checks if a build plugin is needed.

anadroid.instrument.NoneInstrumenter module

class anadroid.instrument.NoneInstrumenter.NoneInstrumenter(profiler, mirror_dirname='_TRANSFORMED_')[source]

Bases: AbstractInstrumenter

Implements defined interface of AbstractInstrumenter to simulate instrumentation while not performing any project sources’ changes.

get_build_classpaths()[source]

retrieves the needed gradle dependencies for the performed instrumentation.

get_build_dependencies()[source]

retrieves the needed build dependencies for the performed instrumentation.

get_build_plugins()[source]

retrieves the needed build plugins for the performed instrumentation.

get_dirname(mirror_dirname='_TRANSFORMED_')[source]
get_log_filename()[source]

returns the name of the log file where the instrumentation output will be written. :returns: name of the file. :rtype: str

init()[source]

inits class.

instrument(android_project, mirror_dirname='_TRANSFORMED_', test_approach=TESTING_APPROACH.WHITEBOX, test_frame=TESTING_FRAMEWORK.MONKEY, instr_strategy=INSTRUMENTATION_STRATEGY.METHOD_CALL, instr_type=INSTRUMENTATION_TYPE.TEST, **kwargs)[source]

just clone the project files to a new directory.

needs_build_classpaths()[source]

checks if additional gradle dependencies are needed for the performed instrumentation.

needs_build_dependency()[source]

checks if additional build dependencies are needed.

needs_build_plugin()[source]

checks if a build plugin is needed.

needs_reinstrumentation(proj, test_approach, instr_type, instr_strategy)[source]

checks if the project needs to be instrumented again (i.e. if the last instrumentation performed is == to the instrumentation to be performed). :param proj: project. :type proj: AndroidProject :param test_approach: testing approach. :type test_approach: TESTING_APPROACH :param instr_strategy: instrumentation strategy to perform. :type instr_strategy: INSTRUMENTATION_STRATEGY :param instr_type: type of instrumentation. :type instr_type: INSTRUMENTATION_TYPE

Returns:

True if needs to be instrumented again, False otherwise.

Return type:

bool

anadroid.instrument.Types module

class anadroid.instrument.Types.INSTRUMENTATION_STRATEGY(value)[source]

Bases: Enum

Enumerate the instrumentation strategies that can be applied

ANNOTATION = 'Annotation'
BLOCK = 'Block'
METHOD_CALL = 'Method Call'
class anadroid.instrument.Types.INSTRUMENTATION_TYPE(value)[source]

Bases: Enum

Enumerate the type of instrumentation that can be performed

ACTIVITY = ('ActivityOriented',)
ANNOTATION = 'AnnotationOriented'
METHOD = 'MethodOriented'
NONE = 'None'
TEST = 'TestOriented'

Module contents