Java Concolic Unit Testing Engine

Related tags

JSON jcute
Overview

jCUTE

The Java Concolic Unit Testing Engine (jCUTE) automatically generates unit tests for Java programs. Concolic execution combines randomized concrete execution with symbolic execution and automatic constraint solving. Symbolic execution allows jCUTE to discern inputs that lead down different execution paths; randomized concrete execution helps it overcome limitations of the constraint solver, like the inability to analyze system calls or solve general systems of non-linear integer equations. Through this combination, jCUTE is able to generate test cases that execute many different execution paths in real Java programs.

jCUTE supports multi-threaded programs. It can discover race conditions and deadlocks through systematic schedule exploration.

Running

jCUTE requires an installed and working Java Development Kit (JDK) version 1.4 or later. It expects both java and javac to be in the PATH. To run jCUTE on a 32-bit system, simply download and unzip the binary distribution from the jCUTE homepage. To run jCUTE on a 64-bit system, you will have to build the distribution archive from the sources in this repository; see the instructions below.

  • On Linux, run the setup script. Then execute the jcutegui script.
  • On Windows, run the jcutegui.bat batch file.

The src/ directory contains a number of examples. See the script runtests to know how to run these examples.

Usage

  • jcutec is the instrumentor plus compiler script for distributed Java programs under test.
  • jcute is the script to concolically test the executable of the instrumented program under test.

Instrumentation

Command line: ./jcutec SOURCE_DIRECTORY MAIN_JAVA_FILE MAIN_JAVA_CLASS -sequential

  • SOURCE_DIRECTORY is the directory containing the sources of the Java program to be tested
  • MAIN_JAVA_FILE is the name of the Java source file containing the main function
  • MAIN_JAVA_CLASS is the name of the class of the Java source file containing the main function

For example, to compile and instrument the Demo example in the directory src/tests in the package tests, execute

./jcutec src/ src/dtests/DExample1.java dtests.DExample1 -sequential

Concolic Execution

Command line: ./jcute class -i iterations [-?] [-help] [-d DEPTH=0] [-s SEED] [-t DEBUG_LEVEL=0] [-m PATH_MODE=0] [-r] [-q] [-p] [-v] [-a] [-n ARGUMENT=0]

Options include:

  • -help, -?: Displays help information
  • -d <decimal integer>: Depth of search. Default is 0, which implies infinite depth
  • -s <decimal integer>: Seed for random number generator in case -r option is given. Default is current system time.
  • -t <decimal integer>: Various debug information and statistics. Default is 0 (no debug information printed).
    • 1: Print trace of instrumentation function call's entry and exit.
    • 2: Print info about instrumented function call inserted for concurrency.
    • 4: Print input map after reading from disk.
    • 8: Print history at every history change.
    • 16: Print symbolic state at every state change.
    • 32: Print path constraint whenever path constraint is updated.
    • 64: Print old and new history at the end of execution.
    • 128: Print old and new input map at the end of the execution.
    • 256: Print path constraint at the end of the execution.
    • 512: Print line number executed.
  • -m <decimal integer {0,1,2}>: Path selection. Default is 0.
    • 0: Next path (depends on history),
    • 1: Replay last execution,
    • 2: Start fresh execution without looking at any history.
  • -r: If specified, inputs are randomly initialized; else, inputs are set to 0. Objects are initialized to null in either cases.
  • -p: Random search strategy is invoked
  • -q: Record branch coverage information
  • -a: Turn off Optimal Distributed Search
  • -v: Verbose: logs inputs and trace of execution
  • -n <decimal integer>: Pass a single integer argument

For example, to test the Demo example run

./jcute dtests.DExample1 -i 100 -q

To see the statistics about branch coverage and runtime execute

java -classpath jcute.jar cute.concolic.BranchCoverage

Graphical User Interface

In the Graphical user Interface, try selecting the directory src/ and the Java program dtests/DExample1.java. Then "Compile" and "(Re)start" for testing. Click on a Run # to get the Input and Trace log.

Building

Instead of downloading the binary distribution archive, the archive can also be built from the sources in this repository.

Compiling the Constraint Solving Library on Linux

jCUTE uses the lp_solve linear programming library for constraint solving. It comes with pre-compiled 32-bit versions of this C library, which it accesses via the Java Native Interface (JNI). However, the library and the wrapper were compiled against old standard libraries (libstdc++5.so) that are no longer available on modern Linux systems. A potential solution for this is to install an old 32-bit Linux image into a virtual machine for running jCUTE in it. Another solution is to compile the libraries on one's system.

64-bit Systems

The lp_solve library compiles and appears to work fine on 64-bit systems.

Compiling lp_solve

Compiling the lp_solve Java Wrapper

  • Download the Java wrapper source code archive lp_solve_5.1_java.zip from http://optimum2.mii.lt/lp2jdk/
  • Unzip the archive into a temporary directory.
  • Change to the lib/linux/ directory and edit the file build:
    • Set the LPSOLVE_DIR variable to the path that contains lp_lib.h; this should be the lp_solve_5.1/ directory from above.
    • Tell the linker where to find liblpsolve51.so by adding the command line option -L/path/to/containing/dir/ to the second g++ invocation in the build file. Replace /path/to/containing/dir with the path containing liblpsolve51.so.
    • Set the JDK_DIR variable to your JDK root directory, for example /opt/java6/ on Arch Linux.
  • Run sh build to build liblpsolve51j.so.
  • Copy liblpsolve51j.so into the jCUTE root directory.

Compiling and Packaging jCUTE

Execute the package shell script in the project's root directory to build the jCUTE JAR file and the distribution archive: sh package.

License

The jCUTE software is NOT in the public domain. However, it is freely available without fee for education, research, and non-profit purposes as described in the complete jCUTE license. The third-party libraries used by jCUTE are licensed as described in their license files.

History

jCUTE was designed and implemented by Koushik Sen around 2006.

You might also like...

Set of support modules for Java 8 datatypes (Optionals, date/time) and features (parameter names)

Overview This is a multi-module umbrella project for Jackson modules needed to support Java 8 features, especially with Jackson 2.x that only requires

Dec 23, 2022

A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Dec 31, 2022

A fast JSON parser/generator for Java.

A fast JSON parser/generator for Java.

fastjson Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON str

Dec 31, 2022

JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Dec 30, 2022

Java JsonPath implementation

Jayway JsonPath A Java DSL for reading JSON documents. Jayway JsonPath is a Java port of Stefan Goessner JsonPath implementation. News 10 Dec 2020 - R

Jan 4, 2023

A streaming JsonPath processor in Java

JsonSurfer - Let's surf on Json! Why JsonSurfer Streaming No need to deserialize entire json into memory. JsonPath Selectively extract json data by th

Dec 12, 2022

Sawmill is a JSON transformation Java library

Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Jan 1, 2023

Genson a fast & modular Java Json library

Genson Genson is a complete json - java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

Jan 3, 2023

A reference implementation of a JSON package in Java.

JSON in Java [package org.json] Click here if you just want the latest release jar file. Overview JSON is a light-weight language-independent data int

Jan 6, 2023
Comments
  • Unable to generate tests with jcutegui

    Unable to generate tests with jcutegui

    Every time I'm trying to generate tests with the binary distribution from their website (on Windows) I get the following error:

    Exception in thread "main" java.lang.RuntimeException: couldn't find class: java.lang.Object (is your soot-class-path set properly?)
    	at soot.SootResolver.bringToHierarchy(SootResolver.java:139)
    	at soot.SootResolver.bringToSignatures(SootResolver.java:172)
    	at soot.SootResolver.processResolveWorklist(SootResolver.java:104)
    	at soot.SootResolver.resolveClass(SootResolver.java:89)
    	at soot.Scene.loadClass(Scene.java:329)
    	at soot.Scene.loadClassAndSupport(Scene.java:314)
    	at cute.instrument.CuteInstrumenter.main(CuteInstrumenter.java:179)
    

    I tried to solve it in many ways, but nothing seems to work...

    opened by lucaparimbelli 1
  • Unable to run jcutegui.bat file

    Unable to run jcutegui.bat file

    im having trouble to run jcutegui.bat file since a couple of days, i tried to run it in other systems as well to confirm if my system is having some problem, but each time i try to run the file i get the same error saying "could not find or load main class cute.Cute"

    Please help me out

    opened by sunilmethuku 4
Owner
Open Systems Laboratory
Open Systems Laboratory
Compare JSON in your Unit Tests

JsonUnit JsonUnit is a library that simplifies JSON comparison in tests. APIs AssertJ integration Hamcrest matchers Spring MVC assertions Spring WebTe

Lukáš Křečan 719 Dec 29, 2022
Benchmark testing number reading/writing in Java.

double-reader-writer Benchmark testing number reading/writing in Java. Relates to FasterXML/jackson-core#577 So far, FastDoubleParser looks useful if

PJ Fanning 2 Apr 12, 2022
100% Java, Lambda Enabled, Lightweight Rules Engine with a Simple and Intuitive DSL

RuleBook » A Simple & Intuitive Rules Abstraction for Java 100% Java · Lambda Enabled · Simple, Intuitive DSL · Lightweight Why RuleBook? RuleBook rul

Delivered Technologies Labs 666 Dec 21, 2022
An Engine to run batch request with JSON based REST APIs

JsonBatch An Engine to run batch request with JSON based REST APIs Some usecase for this library: Provide a batch API to your REST API set. Quickly ro

Rey Pham 11 Jan 3, 2022
A query language for JSON and a template engine to generate text output.

Josson & Jossons Josson is a query language for JSON. Jossons is a template engine to generate text output. Features and Capabilities of Josson Query

Octomix Software 16 Dec 14, 2022
Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer.

json-io Perfect Java serialization to and from JSON format (available on Maven Central). To include in your project: <dependency> <groupId>com.cedar

John DeRegnaucourt 303 Dec 30, 2022
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back, with a transparent support of any kind of self-references and with a full Java 9 compatibility.

Andrey Mogilev 9 Dec 30, 2021
A simple java JSON deserializer that can convert a JSON into a java object in an easy way

JSavON A simple java JSON deserializer that can convert a JSON into a java object in an easy way. This library also provide a strong object convertion

null 0 Mar 18, 2022
Java with functions is a small java tools and utils library.

Java with functions is a small java tools and utils library.

null 4 Oct 14, 2022