Skip to content

Commit b628450

Browse files
committed
add script to execute our examples.
1 parent ae34371 commit b628450

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

runExamples.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/bash
2+
3+
#------------------------------------------------------------------------------
4+
# check Java version
5+
#------------------------------------------------------------------------------
6+
7+
[ -z "$JAVA" ] && JAVA=java
8+
java_version="`$JAVA -XX:-UsePerfData -Xmx5m -version 2>&1`"
9+
result=$?
10+
if [ $result -eq 127 ]; then
11+
echo "Java not found, please install Java 1.8 or newer." 1>&2
12+
echo "For Ubuntu: sudo apt-get install openjdk-8-jre" 1>&2
13+
echo "If you have installed Java 8, but it is not in your PATH," 1>&2
14+
echo "let the environment variable JAVA point to the \"java\" binary." 1>&2
15+
exit 1
16+
fi
17+
if [ $result -ne 0 ]; then
18+
echo "Failed to execute Java VM, return code was $result and output was"
19+
echo "$java_version"
20+
echo "Please make sure you are able to execute Java processes by running \"$JAVA\"."
21+
exit 1
22+
fi
23+
java_version="`echo "$java_version" | grep -e "^\(java\|openjdk\) version" | cut -f2 -d\\\" | sed 's/\.//g' | cut -b1-2`"
24+
if [ -z "$java_version" ] || [ "$java_version" -lt 18 -a "$java_version" -gt 13 ] ; then
25+
echo "Your Java version is too old, please install Java 1.8 or newer." 1>&2
26+
echo "For Ubuntu: sudo apt-get install openjdk-8-jre" 1>&2
27+
echo "If you have installed Java 8, but it is not in your PATH," 1>&2
28+
echo "let the environment variable JAVA point to the \"java\" binary." 1>&2
29+
exit 1
30+
fi
31+
32+
33+
#------------------------------------------------------------------------------
34+
# build classpath for JavaSMT
35+
#------------------------------------------------------------------------------
36+
37+
platform="`uname -s`"
38+
39+
# where the project directory is, relative to the location of this script
40+
case "$platform" in
41+
Linux|CYGWIN*)
42+
SCRIPT="$(readlink -f "$0")"
43+
[ -n "$PATH_TO_JAVASMT" ] || PATH_TO_JAVASMT="$(readlink -f "$(dirname "$SCRIPT")")"
44+
;;
45+
# other platforms like Mac don't support readlink -f
46+
*)
47+
[ -n "$PATH_TO_JAVASMT" ] || PATH_TO_JAVASMT="$(dirname "$0")"
48+
;;
49+
esac
50+
51+
if [ ! -e "$PATH_TO_JAVASMT/bin/org/sosy_lab/java_smt/example/AllSatExample.class" ] ; then
52+
if [ ! -e "$PATH_TO_JAVASMT/javasmt.jar" ] ; then
53+
echo "Could not find JAVASMT binary, please check path to project directory" 1>&2
54+
exit 1
55+
fi
56+
fi
57+
58+
case "$platform" in
59+
CYGWIN*)
60+
JAVA_VM_ARGUMENTS="$JAVA_VM_ARGUMENTS -classpath `cygpath -wp $CLASSPATH`"
61+
;;
62+
esac
63+
64+
export CLASSPATH="$CLASSPATH:$PATH_TO_JAVASMT/bin:$PATH_TO_JAVASMT/JAVASMT.jar:$PATH_TO_JAVASMT/lib/*:$PATH_TO_JAVASMT/lib/java/runtime/*"
65+
66+
# Run Examples for Java-SMT.
67+
# PerfDisableSharedMem avoids hsperfdata in /tmp (disable it to connect easily with VisualConsole and Co.).
68+
69+
for EXAMPLE in AllSatExample HoudiniApp Interpolation OptimizationFormulaWeights OptimizationIntReal; do
70+
echo "####################################################"
71+
echo "# executing example $EXAMPLE"
72+
echo "####################################################"
73+
"$JAVA" \
74+
-XX:+PerfDisableSharedMem \
75+
-Djava.awt.headless=true \
76+
-ea \
77+
$JAVA_VM_ARGUMENTS \
78+
org.sosy_lab.java_smt.example.$EXAMPLE
79+
done

0 commit comments

Comments
 (0)