SymbolicPathFinder / jpf-symbc

Symbolic PathFinder
https://github.com/SymbolicPathFinder/jpf-symbc
124 stars 89 forks source link

Bash script to setup JPF and SPF in unix-based systems #61

Open y553546436 opened 3 years ago

y553546436 commented 3 years ago

Thanks to Yannic's guidance (in google group discussion), I successfully installed and run the SPF from the command line. I wrote a bash script for unix-based system users. I hope this script can help you get started faster.

# Prerequisites: git,ant,java
dir=$(pwd)

# set up JPF
git clone https://github.com/javapathfinder/jpf-core
cd jpf-core
jpf_dir=$(pwd)
git checkout java-8
# remove deprecated import
sed -i.back '/import com.sun.org.apache.bcel.internal.generic.InstructionConstants;/d' src/main/gov/nasa/jpf/vm/MJIEnv.java
ant build

# set up SPF
cd ${dir}
git clone https://github.com/SymbolicPathFinder/jpf-symbc
cd jpf-symbc
spf_dir=$(pwd)

# set up site.properties
mkdir -p ~/.jpf
echo "jpf-core=${jpf_dir}" >> ~/.jpf/site.properties
echo "jpf-symbc=${spf_dir}" >> ~/.jpf/site.properties
echo "extensions=\${jpf-core},\${jpf-symbc}" >> ~/.jpf/site.properties

# build SPF
ant build

# set the Java library path to include SPF's lib folder
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
    # for linux; better append this line to ~/.bash_profile
    export LD_LIBRARY_PATH=${spf_dir}/lib
elif [[ "$OSTYPE" == "darwin"* ]]; then
    # for Mac OSX; better append this line to ~/.bash_profile
    export DYLD_LIBRARY_PATH=${spf_dir}/lib
    # DYLD_LIBRARY_PATH works only after disabling the SIP
    # see https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection
fi

# run a simple example
java -Xmx1024m -ea -cp "${jpf_dir}/build/*:${spf_dir}/build/*" gov.nasa.jpf.tool.RunJPF ${spf_dir}/src/examples/ByteTest.jpf
# include also ${spf_dir}/lib/com.microsoft.z3.jar in the java classpath if you see such error: "java.lang.NoClassDefFoundError: com/microsoft/z3/Expr"