Work alone on this assignment.
This homework has two parts. First, you will use the Grobo test coverage tool to assess the coverage of a test suite, then enhance the test suite to improve the statement and branch coverage. In the second part, you will use ESC/Java2 to automatically analyze a program for faults.
Be on the lookout for bugs in the code. There are several. As you find each bug, jot down what the bug is, what the fix is, and how you found it (ESC/Java2, test coverage, inspection, etc.) You will turn this report in later.
By the way, you are not allowed to just look up the right implementation of Quicksort to finish this assignment.
Here is information on getting the files and building the project. You can either work in Eclipse, or just use your favorite text editor. Download and unzip the files for this assignment, which are located here.
ESC/Java2 is a program verifier that attempts to find common run-time errors in Java programs by static analysis of the program text. Users can control the amount and kinds of checking that ESC/Java2 performs by annotating their program with specially formatted comments called pragmas. The goal of ESC/Java2 is not to provide formally rigorous program verification. Rather, it is to help programmers find some kinds of errors more quickly than they might be found by other methods, such as testing or code reviews. Like testing, it is neither sound nor complete, but it is easier to do.
ESC/Java2 pragmas must occur within pragma-containing comments. Pragma comments look like
//@ <PRAGMA_NAME> expressionor
/*@ <PRAGMA_NAME expression */
More information can be found in this summary. The user's manual is here. (You should read Chapter 0.) There are also more resources on the class homepage. Below are some example pragmas.
An assert pragma is a statement pragma. The pragma causes ESC/Java2 to issue a warning if it cannot establish that the expression is true whenever control reaches the pragma.
/*@ assert x < 10 && y < 10 */ int a[10] a[x][y] = 0
A requires pragma is a routine modifier pragma. The pragma makes the expression a precondition of the routine the pragma modifies. When checking the body of the routine, ESC/Java2 assumes that that precondition holds initially. When checking a call to the routine, ESC/Java2 issues a warning if it cannot establish that the expression holds at the call site.
/*@ requires v!= null */
public void doSomething(Vector v) {
...
}
A non_null pragma is a modifier pragma. It may modify the declaration of a variable of a reference type. The variable may be a static field, instance variable, local variable, or parameter. The pragma causes ESC/Java2 to check, at each assignment to the variable, that the value assigned is not null, and to assume at each use (except in one case, described below) that the value is not null. When a formal parameter declaration is annotated with a non_null pragma, ESC/Java2 checks at each call site that the corresponding actual is not null.
/*@ non_null */ char[] c;
public void doSomething(/*@ non_null */ Vector v) {
...
}
An invariant pragma is a declaration pragma. The pragma declares the expression to be an object invariant of the class within whose declaration the pragma occurs.
int len; //@ invariant 0 <= len && len <= a.length;
Test coverage is a proxy measurement for test quality. (It is assumed that high coverage corresponds to good quality, but this is not always the case, nor is it sufficient.) The code we provide has a small number of JUnit test cases that do not give complete code coverage. You will need to augment the test cases to give as much coverage as possible. The code contains an Ant build file that will run Grobo for you.
Email three files, the updated Quicksort.java and QuicksortTest.java, and the bug log, to csci435@coppit.org.
150 points total
If you have any questions, feel free to ask them in the discussion forum.
Back to CSci 435/535 Homepage.
Last changed February 03 2006 10:00:49.
David Coppit,
coppit@cs.wm.edu
There have been 1221275 hits since Thu Jun 9 14:49:55 2005