Defects4cpp User Guide

Displaying a List of Defects

To view a list of defects, execute the following command:

python bugscpp/bugscpp.py show

Project Checkout

Before using the other commands, you need to checkout one of the projects from the displayed list. The available projects are: To checkout a project, use the following command:

python bugscpp/bugscpp.py checkout <PROJECT> <INDEX> [-b|--buggy] [-t|--target <WORKSPACE>]

Replace <PROJECT> with the name of the project you want to checkout, and <INDEX> with the index of the defect. The project will be stored in either ./<WORKSPACE>/fixed-<INDEX> or ./<PROJECT>/buggy-<INDEX> (if the option``-b`` is provided). If -t is not given, <WORKSPACE> is automatically set to ./<PROJECT>.

For example, to checkout the first buggy version of the cpp_peglib project, use the following command:

python bugscpp/bugscpp.py checkout cpp_peglib 1 --buggy

By default, the project will be stored in ./cpp_peglib/buggy-1.

Building and Testing a Project

To build and test a project, use the following commands:

python bugscpp/bugscpp.py build <PATH>
python bugscpp/bugscpp.py test <PATH>

Replace <PATH> with the path to the checkout directory of the project. For example, to build and test the buggy version of cpp_peglib-1, you can use the following commands:

python bugscpp/bugscpp.py build ./cpp_peglib/buggy-1
python bugscpp/bugscpp.py test ./cpp_peglib/buggy-1

Running Specific Test Cases

You can run specific test cases separately using the following command:

python bugscpp/bugscpp.py test <PATH> --case <EXPR>

Replace <PATH> with the path to the checkout directory of the project, and <EXPR> with the test case IDs. For example, to run test cases 1 to 4 and 7 of the cpp_peglib project, use the following command:

python bugscpp/bugscpp.py test ./cpp_peglib/buggy-1 --case 1-4,7

Generating Code Coverage Data

To generate code coverage data, add the --coverage flag to the build and test commands:

python bugscpp/bugscpp.py build <PATH> --coverage
python bugscpp/bugscpp.py test <PATH> --coverage

For example, to generate code coverage data for the cpp_peglib project, you can use the following commands:

python bugscpp/bugscpp.py build ./cpp_peglib/buggy-1 --coverage
python bugscpp/bugscpp.py test ./cpp_peglib/buggy-1 --coverage

Searching Defects by Tags

To search for defects using specific tags, use the following command:

python bugscpp/bugscpp.py search <TAG1> <TAG2> ...

Replace <TAG1>, <TAG2>, and so on, with the specific tags you want to search for.

For example, to search for defects related to “cve”, “single-line”, and “memory-error”, use the following command:

python bugscpp/bugscpp.py search cve single-line memory-error

The command will display the projects that match the specified tags.

bugscpp checkout

Checkout defect taxonomy.

usage: bugcpp.py checkout PROJECT INDEX [-b|--buggy] [-t|--target WORKSPACE] [-s|--source-only] [-v|--verbose]
project

name of defect taxonomy.

index

index of defects.

-h, --help

show this help message and exit

--compilation_db_tool

command to capture build. (default: bear)

-b, --buggy

checkout a buggy commit.

-t, --target

checkout to the specified directory instead of the current directory.

-s, --source-only

checkout source code only.

-v, --verbose

verbose mode

bugscpp build

Build project inside docker.

usage: bugcpp.py build PATH [-j|--jobs=JOBS] [--coverage] [-v|--verbose] [-u|--uid=UID_DPP_DOCKER_USER] [-e|--export[=EXPORT_PATH]]
path

path to checkout directory.

-h, --help

show this help message and exit

--compilation_db_tool

command to capture build. (default: bear)

-v, --verbose

redirect output to stdout.

--coverage

set coverage flags.

--rebuild-image

rebuild docker image.

--env

set ‘key=value’ environment variables within container. (can be used multiple times)

-j <jobs>, --jobs <jobs>

number of jobs to run in parallel.

-e, --export

export build commands.

-u <uid>, --uid <uid>

set uid of user defects4cpp

bugscpp test

Run testsuite inside docker. The project must have been built previously.

usage: bugcpp.py test PATH [-j|--jobs=JOBS] [--coverage [--additional-gcov-options=ADDITIONAL_GCOV_OPTIONS]] [-v|--verbose] [-c|--case=expr] [--output-dir=directory]
path

path to checkout directory.

-h, --help

show this help message and exit

--compilation_db_tool

command to capture build. (default: bear)

-v, --verbose

redirect output to stdout.

--coverage

set coverage flags.

--rebuild-image

rebuild docker image.

--env

set ‘key=value’ environment variables within container. (can be used multiple times)

-j <jobs>, --jobs <jobs>

number of jobs to run in parallel.

-c, --case

expression to filter cases (see example)

--output-dir

output directory to generate coverage data instead of the current directory.

--additional-gcov-options

set additional options to gcov command

Case Expression:

,
select distinctive cases
–case=1,2,3 will run 1, 2 and 3.
-
select a range of cases
–case=1-3 will run from 1 to 3.
:
expression after colon will be used to exclude cases
–case=1-5:1 will run from 1 to 5 except 1.
–case=1-5:1,2 will run from 1 to 5 except 1 and 2.
–case=1-5:3-5 will run from 1 to 5 except from 3 to 5.