Skip to content

How to run SimpleExample

Claire Le Goues edited this page Jun 4, 2018 · 1 revision

SimpleExample is a 20-line simple program that is created with the purpose of demonstrating and sanity-checking GenProg4Java. This document describes how to run GenProg4Java on SimpleExample.

Step 1: Run the prepareSimpleExample.sh bash script, located in /path/to/genprog4java/tests//SimpleExample/prepareSimpleExample.sh. It takes one argument, which is the full path to GenProg4Java. For example:

sh prepareSimpleExample.sh /home/gp4j/genprog4java/

This step will compile the SimpleExample's code and tests, and creates a configuration file simpleExample.config for running GenProg4Java on SimpleExample.

Note that this config file assumes many defaults; if you want to verify that GenProg4Java will actually fix SimpleExample in minimal steps, see below.

Step 2: To run GenProg4Java on SimpleExample, open the GenProg4Java project in Eclipse. Create a run configuration if necessary; GenProg4Java's main class is located at: /home/gp4j/genprog4java/src/clegoues/genprog4java/main/Main.java.

Step 3: In Run Configuration, go to the Arguments tab and make sure these values are entered:

  • Program arguments: /home/gp4j/genprog4java/tests/SimpleExample/simpleExample.config

  • VM arguments: (copy and paste this text on the "VM arguments" entry) -ea -Dlog4j.configuration=file:${workspace_loc:GenProg4Java}/src/log4j.properties

  • Working directory: (Select "Other" and browse the path to /home/gp4j/genprog4java/tests/SimpleExample/)

Step 5: Push the button Run in the lower right corner of the Run Configuration.

Note 1: If you want to change the source code of the SimpleExample, you must erase everything in the /home/gp4j/genprog4java/tests/SimpleExample/tmp/ folder. If you don't erase everything in the tmp folder, your changes in the SimpleExample.java will be overwritten by the previous version of the file.

Note 2: You can specify which mutation operator templates GenProg4Java uses (e.g., NullCheck, Replacement) by setting these flags in the configuration file:

  • edits = semicolon separated list of edits you'd like to include

  • editsWithWeights = semicolon separated lists of edit, weight pairs. The pairs are separated by commas.

For example, if you wanted to do just a null check, you'd do edits=nullcheck and if you wanted null check and delete with equal weight, you could do: editsWithWeights = nullcheck,1.0;delete,1.0

A full list of edit names is available in the configure method near the top of Search.java.

The default option includes append, delete, and replace, with equal weighting. This is what happens if you don't specify either edits nor editsWithWeights in your configuration file.

If you want to check that GenProg4Java is able to find a repair, try adding the following to the end of your config:

edits=replace

negativePathWeight=10.0

positivePathWeight=0.001

(one option per line; that is, insert newlines between them, no matter what the wiki formatting is doing to this page.)

On Claire's machine and with seed=0, this finds a repair within the first 5 variants.

Clone this wiki locally