Skip to content

Commit 87e762b

Browse files
Wontae ChoiWontae Choi
Wontae Choi
authored and
Wontae Choi
committed
improved error message
1 parent 72b0f0a commit 87e762b

File tree

3 files changed

+78
-24
lines changed

3 files changed

+78
-24
lines changed

USAGE

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
USAGE
2+
------
3+
export ADK_ROOT=<ADK_ROOT>
4+
./test.sh <target apk> <mode> <timeout(s)> <random seed> <output dir> [optinos]
5+
6+
mode: interactive, learningAU (= swift), learningNU, learningA, learningN, learningWithScout, lstar, random
7+
options:
8+
-n<prefix> : Test name. This will become the prefix of output files. (default = <target apk file name>)
9+
-c<cycle> : Test progress logging cycle. (deafult = 1)
10+
-i<cycle> : Test guide algorithm logging cycle. (default = 1)
11+
-v : Verbosely print information to the screen (default = false)
12+
-x<filename> : A file containing the list of packages to exclude from coverage measurement (default = null)
13+
-d<deviceID> : The device ID of machine running the target application (default = a random available device)
14+
-p<port> : Port to use to communicate with an Android device. (default = 13337)
15+
-s<msec> : Necessary stable interval. (default = 1080ms)
16+
-t<msec> : Transition timeout (default = 30000msec)

build.sh

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
3+
# WARNING: Please assign proper contents and uncomment following four export statements.
4+
export ADK_ROOT="/Users/wtchoi/Library/Android/sdk"
5+
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home"
6+
export GUAVA_VERSION="17.0"
7+
export DX_VERSION="21.1.2"
8+
9+
10+
11+
DOLLAR="\$"
12+
declare -a arr=("ADK_ROOT" "JAVA_HOME" "GUAVA_VERSION" "DX_VERSION")
13+
for varname in "${arr[@]}"
14+
do
15+
eval VAR="$DOLLAR$varname"
16+
if [[ -z "$VAR" ]]; then
17+
echo "[build.sh] ERROR: \$$varname unset!"
18+
exit 1;
19+
fi
20+
done
21+
22+
IS="inst.sh"
23+
TS="test.sh"
24+
25+
cd src
26+
mvn package
27+
if (($? > 0)); then
28+
print "[build.sh] Maven build script failed"
29+
exit 2;
30+
fi
31+
cd ..
32+
33+
SWIFT_ROOT=$PWD
34+
35+
#create execution script
36+
FRONT_END_PATH="src/front-end/target/front-end-0.1-jar-with-dependencies.jar"
37+
KEY_PATH="src/front-end/resource/swifthand.keystore"
38+
SHARED_PATH="src/shared/target/shared-0.1.jar"
39+
40+
BACK_END_PATH="src/back-end/target/back-end-0.1-jar-with-dependencies.jar"
41+
42+
echo "[build.sh] Generating inst.sh instrumentation script"
43+
44+
echo "#!/bin/sh" > $IS
45+
echo "set -x" >> $IS
46+
echo "export ADK_ROOT=$ADK_ROOT" >> $IS
47+
echo "export JAVA_HOME=$JAVA_HOME" >> $IS
48+
echo "java -jar $SWIFT_ROOT/$FRONT_END_PATH \$1 $SWIFT_ROOT/$KEY_PATH $SWIFT_ROOT/$SHARED_PATH" >> $IS
49+
chmod 700 $IS
50+
51+
echo "[build.sh] Generating test.sh GUI testing script"
52+
53+
echo "#!/bin/sh" > $TS
54+
echo "set -x" >> $TS
55+
echo "export ADK_ROOT=$ADK_ROOT" >> $TS
56+
echo "export JAVA_HOME=$JAVA_HOME" >> $TS
57+
echo "java -jar $SWIFT_ROOT/$BACK_END_PATH \${*:1}" >> $TS
58+
echo "if ((\$? > 0));then" >>$TS
59+
echo " cat USAGE" >> $TS
60+
echo "fi" >> $TS
61+
chmod 700 $TS

src/back-end/src/main/java/edu/berkeley/wtchoi/swift/CommandLine.java

+1-24
Original file line numberDiff line numberDiff line change
@@ -106,30 +106,7 @@ public static void main(String args[]){
106106
}
107107
catch(Exception e){
108108
e.printStackTrace();
109-
110-
String instruction =
111-
"USAGE\n"+
112-
"------\n" +
113-
"export ADK_ROOT=<ADK_ROOT>\n"
114-
+ "export CLASSPATH=<ADK_ROOT>/ddms.jar:<ADK_ROOT>/ddmlib.jar:<ADK_ROOT>/guava-13.0.1.jar:<ADK_ROOT>/chimpchat.jar:./ChimpChat.jar\n"
115-
+ "java ed.berkeley.wtchoi.swift.CommandLine <target apk> <mode> <timeout(s)> <random seed> <output dir> [optinos]\n"
116-
+ "\n"
117-
+ "mode: interactive, learningAU, learningNU, learningA, learningN, learningWithScout, lstar\n"
118-
+ "options:\n"
119-
+ " -n<prefix> : test name. This will become the prefix of output files. (default = <target apk file name>)\n"
120-
+ " -c<cycle> : test summary dump frequency. (deafult = 1)\n"
121-
+ " -i<cycle> : test guide internal dump frequency. (default = 1)\n"
122-
+ " -v : verbosely print screen information and it's analysis result (default = false)\n"
123-
+ " -x<filename> : list of packages to exclude from coverage measurement (default = null)\n"
124-
+ " -d<deviceID> : device running target application (default = random available device)\n"
125-
+ " -p<port> : port to use to communicate with phone. (default = 13337)\n"
126-
+ " -s<msec> : necessary stable interval. (default = 1080ms)\n"
127-
+ " -t<msec> : transition timeout (default = 30000msec)\n";
128-
129-
130-
131-
System.out.println("Cannot handle parameters\n" + instruction);
132-
Runtime.getRuntime().halt(0);
109+
Runtime.getRuntime().halt(1);
133110
}
134111

135112

0 commit comments

Comments
 (0)