Skip to content

Getting Statement Coverage

nataniel.borges edited this page Aug 3, 2018 · 1 revision

Statement coverage

In order to monitor the reached statements, Droidmate must first instrument the application. The instrumentation adds a log statement after each Jimple statement. During exploration, Droidmate monitors the log for these statements and uses them measure statement coverage.

Each time Droidmate instruments an apk it generated unique values for each statement, ensuring that different instructions will not be mapped to the same statement, thus, each instrumented apk and json file are unique and a Json file works for a single instrumented apk.

Bellow are the necessary steps for instrumenting and app and obtaining statement coverage.

Intrumentation

To instrument and app execute Droidmate with the following arguments:

--Exploration-apksDir=apks --ExecutionMode-explore=false --ExecutionMode-coverage=true

If you imported Droidmate in your project, the same can be achieved by when using the method instrument of the ExplotationAPI class.

Once the instrumentation executes, the original apk will be moved to a newly-created originals directory and the instrumented apk will be placed in the input folder. Additionally, Droidmate will write a file with the signature .json in its output directory. This file contains all instrumented statements in the app, and can be used as a ground truth for evaluation.

Obtaining the raw coverage data

When the apk is intrumented, Droidmate will automatically monitor the reached statements and write them on multiple files in a coverage directory, within its output directory.

These raw files contain each reached statement (Jimple statement + unique id) and time it was reached.

Obtaining a processed report

To obtain the coverage report in the end of an exploration it is necessary to supply Droidmate with the Json file generated during instrumentation.

By default it is simply necessary to place the instrumentation file in an instrumentation-logs directory and Droidmate will output the processed report in the model/<apk>/coverage.txt file on its output directory.