de.uds.cs.st.dd.core
Class InputDeltaDebugger

java.lang.Object
  |
  +--de.uds.cs.st.dd.core.InputDeltaDebugger

public class InputDeltaDebugger
extends Object

Delta Debugging algorithm for files. This class provides functionality to automatically simplify a failing test case. All it needs to perform the minimization or isolation algorithm is a JUnit-test, and a filename.

Author:
Philipp Bouillon

Field Summary
private  TConfiguration config
          Stores the initial set of deltas (chunks of the input file).
private  int deltaDebuggingMode
          Stores the current mode of the Delta Debugging algorithm: MINIMIZATION * or ISOLATION.
private  String fileName
          Filename of the input file.
static int ISOLATION
          Isolation algorithm.
static int MINIMIZATION
          Minimization algorithm.
private  String originalFileName
          Stores the name of the original file.
private  int precision
          Precision of the test outcomes.
private  TConfiguration result
          Stores the result of the minimization.
private  junit.framework.Test testObject
          The JUnit-test.
private  Throwable throwable
          Original exception trace of the failing test.
private  Vector viewers
          Registered viewers.
 
Constructor Summary
InputDeltaDebugger(String fileName)
          Constructs an InputDeltaDebugger.
InputDeltaDebugger(String fileName, ISimpleViewer viewer)
          Constructs an InputDeltaDebugger.
 
Method Summary
 void addViewer(ISimpleViewer viewer)
          Adds a viewer to the registered viewers of this class.
private  void createDDReport(PrintWriter writer, String status, TConfiguration result)
          Sends a message to remotely connected processes by writing contents into * the writer object.
private  void createEnhancedDDReport(PrintWriter writer, String status, TConfiguration result, TConfiguration pass, TConfiguration fail)
          Sends a message to remotely connected processes by writing contents into * the writer object.
 void deltaDebug(PrintWriter writer)
          Performs Delta Debugging on the input of the JUnit-test.
private  void deltaDebugFile(DD dd, PrintWriter writer)
          Performs Delta Debugging on the file that has been stored in this object.
 ISimpleViewer[] getAttachedViewers()
          Returns all currently attached viewers as an array or null if no viewers * are attached.
 TConfiguration getResult()
          Returns the result of this Delta Debugging run.
private  void initialize()
          Initializes the fields of this object with default values.
private  DD initializeDeltaDebugging()
          Initializes the Delta Debugging algorithm and sets some values of the * DD class.
private  void isolateConfig(TConfiguration c, DD dd, PrintWriter writer)
          Isolates a given configuration.
private  void minimizeConfig(TConfiguration c, DD dd, PrintWriter writer)
          Minimizes a given configuration.
private  void postTextMessage(String message)
          Convenience method to send the specified message to all attached viewers.
 void sendMessage(PrintWriter writer, String msg)
          Sends any message to all connected processes by writing the text to * the specified writer object.
 void setDeltaDebuggingMode(int mode)
          Sets the mode of the Delta Debugging algorithm: Either MINIMIZATION or * ISOLATION.
 void setOriginalFileName(String originalFileName)
          Stores the name of the original file that is analyzed.
 void setPrecision(int precision)
          Sets the test outcome precision.
 void setTest(junit.framework.Test testObject)
          Assigns the specified JUnit-test object to the test of this class.
 void setThrowable(Throwable throwable)
          Sets the original failing exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMIZATION

public static final int MINIMIZATION
Minimization algorithm.

See Also:
Constant Field Values

ISOLATION

public static final int ISOLATION
Isolation algorithm.

See Also:
Constant Field Values

testObject

private junit.framework.Test testObject
The JUnit-test.


fileName

private String fileName
Filename of the input file.


config

private TConfiguration config
Stores the initial set of deltas (chunks of the input file).


viewers

private Vector viewers
Registered viewers. All output is delegated through the attached viewers.


precision

private int precision
Precision of the test outcomes.


result

private TConfiguration result
Stores the result of the minimization.


throwable

private Throwable throwable
Original exception trace of the failing test.


originalFileName

private String originalFileName
Stores the name of the original file.


deltaDebuggingMode

private int deltaDebuggingMode
Stores the current mode of the Delta Debugging algorithm: MINIMIZATION * or ISOLATION.

Constructor Detail

InputDeltaDebugger

public InputDeltaDebugger(String fileName)
Constructs an InputDeltaDebugger. No viewer will be attached. The file will be read line by line (or chunk by chunk) and each line is * stored in a TConfiguration object.

Parameters:
fileName - name of the input file to be analyzed.

InputDeltaDebugger

public InputDeltaDebugger(String fileName,
                          ISimpleViewer viewer)
Constructs an InputDeltaDebugger. The specified ISimpleViewer will be registered with this object. The file will be read line by line (or * chunk by chunk) and each line is stored in a TConfiguration object. *

Parameters:
fileName - name of the input file to be minimized.
Method Detail

initialize

private void initialize()
Initializes the fields of this object with default values. The TConfiguration is constructed: each delta represents a chunk of the input file. Initially, the file is divided into 50 * (or less) chunks.


setTest

public void setTest(junit.framework.Test testObject)
Assigns the specified JUnit-test object to the test of this class.

Parameters:
testObject - JUnit-test object

setDeltaDebuggingMode

public void setDeltaDebuggingMode(int mode)
Sets the mode of the Delta Debugging algorithm: Either MINIMIZATION or * ISOLATION. * * @param mode the mode to set.


initializeDeltaDebugging

private DD initializeDeltaDebugging()
Initializes the Delta Debugging algorithm and sets some values of the * DD class. * * @return DD object to perform the algorithm.


postTextMessage

private void postTextMessage(String message)
Convenience method to send the specified message to all attached viewers. * The message is sent to all viewers by calling their sendTextMessage * method. * * @param message the message to send.


minimizeConfig

private void minimizeConfig(TConfiguration c,
                            DD dd,
                            PrintWriter writer)
Minimizes a given configuration. * * @param c TConfiguration to minimize. * @param dd the DeltaDebugging object that is used to minimize. * @param writer PrintWriter to send messages to remotely connected * processes.


isolateConfig

private void isolateConfig(TConfiguration c,
                           DD dd,
                           PrintWriter writer)
Isolates a given configuration. * * @param c TConfiguration to isolate. * @param dd the DeltaDebugging object that is used to minimize. * @param writer PrintWriter to send messages to remotely connected * processes.


deltaDebugFile

private void deltaDebugFile(DD dd,
                            PrintWriter writer)
Performs Delta Debugging on the file that has been stored in this object. * * @param dd the Delta Debugging object to use. * @param writer PrintWriter to send messages to remotely connected * processes.


createDDReport

private void createDDReport(PrintWriter writer,
                            String status,
                            TConfiguration result)
Sends a message to remotely connected processes by writing contents into * the writer object. The message indicates the progress of the * Delta Debugging algorithm. * * @param writer PrintWriter to use. * @param status String to identify the status of the algorithm. Can be any * String (but not null). * @param result TConfiguration that contains the result of the Delta * Debugging progress.


createEnhancedDDReport

private void createEnhancedDDReport(PrintWriter writer,
                                    String status,
                                    TConfiguration result,
                                    TConfiguration pass,
                                    TConfiguration fail)
Sends a message to remotely connected processes by writing contents into * the writer object. The message indicates the progress of the * Delta Debugging algorithm. In addition to the result of the minimization * or isolation, it also sends the passing and failing subsets, if * applicable. * * @param writer PrintWriter to use. * @param status String to identify the status of the algorithm. Can be any * String (but not null). * @param result TConfiguration that contains the result of the Delta * Debugging progress. * @param pass TConfiguration that contains the passing subset of the * run or null. * @param fail TConfiguration that contains the failing subset of the * run or null.


sendMessage

public void sendMessage(PrintWriter writer,
                        String msg)
Sends any message to all connected processes by writing the text to * the specified writer object. * * @param writer PrinWriter to use. * @param msg the message to send.


setOriginalFileName

public void setOriginalFileName(String originalFileName)
Stores the name of the original file that is analyzed. Note that the * original file will not be modified. Instead, the algorithm operates on * a copy of this file. * * @param originalFileName name of the original file that (probably) caused * the JUnit test to fail.


deltaDebug

public void deltaDebug(PrintWriter writer)
Performs Delta Debugging on the input of the JUnit-test. * First, the file is copied into a temporary file. This file is then * divided into chunks which are minimized or isolated step by step. In the * end, the 1-minimal failure inducing input is returned. * * @param writer PrintWriter to use.


getResult

public TConfiguration getResult()
Returns the result of this Delta Debugging run. * * @return TConfiguration the 1-minimal configuration of this test.


setThrowable

public void setThrowable(Throwable throwable)
Sets the original failing exception. * * @param throwable failing exception.


setPrecision

public void setPrecision(int precision)
Sets the test outcome precision. * * @param precision new precision.


addViewer

public void addViewer(ISimpleViewer viewer)
Adds a viewer to the registered viewers of this class. * * @param viewer the viewer to add.


getAttachedViewers

public ISimpleViewer[] getAttachedViewers()
Returns all currently attached viewers as an array or null if no viewers * are attached. * * @return ISimpleViewer [] all currently attached viewers.