Commit 3d8621b2 authored by František Haas's avatar František Haas

added test script

parent b258b79e
...@@ -41,29 +41,27 @@ header files for your platform. On many systems, the JAVA_HOME environment ...@@ -41,29 +41,27 @@ header files for your platform. On many systems, the JAVA_HOME environment
variable points to the root of the JDK installation and you should be fine. variable points to the root of the JDK installation and you should be fine.
If this is not the case, please enter the src-agent-c directory, copy the If this is not the case, please enter the src-agent-c directory, copy the
Makefile.local.tmpl file to Makefile.local and modify it to set the JAVA_HOME javahome/var.local.tmp file to javahome/var.local and modify it to set the
variable to point to the root of the JDK installation you want to use. JAVA_HOME variable to point to the root of the JDK installation you want to
use.
Finally, to compile DiSL, run the "ant" command in the root directory. Finally, to compile DiSL, run the "ant" command in the root directory.
You can create javadoc documentation by running "ant javadoc". You can create javadoc documentation by running "ant javadoc".
EXAMPLES EXAMPLES ========
========
For the basic instrumentation example, please look in the example directory. For the basic instrumentation example, please look in the example directory.
Also the src-test directory contains simple examples of DiSL features. Also the src-test directory contains simple examples of DiSL features.
DOCUMENTATION DOCUMENTATION =============
=============
Please look at http://disl.projects.ow2.org/xwiki/bin/view/Main/Doc. Please look at http://disl.projects.ow2.org/xwiki/bin/view/Main/Doc.
USER ERRORS USER ERRORS ===========
===========
If you get a Java error during instrumentation or running your application, If you get a Java error during instrumentation or running your application,
please look at USERERRORS document describing most common problems. please look at USERERRORS document describing most common problems.
...@@ -16,6 +16,7 @@ build=build ...@@ -16,6 +16,7 @@ build=build
build.thread=build-thread build.thread=build-thread
build.afterbootstrap=build-abs build.afterbootstrap=build-abs
dist=dist dist=dist
test=test
extendedthread.path=${build}/extendedthread.jar extendedthread.path=${build}/extendedthread.jar
......
...@@ -169,6 +169,7 @@ ...@@ -169,6 +169,7 @@
<delete dir="${build.thread}" /> <delete dir="${build.thread}" />
<delete dir="${build.afterbootstrap}" /> <delete dir="${build.afterbootstrap}" />
<delete dir="${dist}" /> <delete dir="${dist}" />
<delete dir="${test}" />
<exec executable="make" dir="${src.agent.c}/javahome"> <exec executable="make" dir="${src.agent.c}/javahome">
<arg value="clean" /> <arg value="clean" />
</exec> </exec>
...@@ -230,7 +231,18 @@ ...@@ -230,7 +231,18 @@
<target name="package-test" depends="report-missing-property,prepare-all" description="create instrumentation package for specified test"> <target name="package-test" depends="report-missing-property,prepare-all" description="create instrumentation package for specified test">
<mkdir dir="${build}"/> <mkdir dir="${build}"/>
<jar jarfile="${build}/${instr.jar.name}" <jar jarfile="${build}/${instr.jar.name}.jar"
basedir="${bin}"
includes="${test.path}/**"
excludes="${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF"
manifest="${src.test}/${test.path}/MANIFEST.MF">
</jar>
</target>
<!-- unsafe for missing dependencies -->
<target name="unsafe-package-test" description="create instrumentation package for specified test">
<mkdir dir="${build}"/>
<jar jarfile="${build}/disl-instr-${test.name}.jar"
basedir="${bin}" basedir="${bin}"
includes="${test.path}/**" includes="${test.path}/**"
excludes="${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF" excludes="${test.path}/TargetClass*.class ${test.path}/MANIFEST.MF"
......
This diff is collapsed.
...@@ -49,6 +49,12 @@ def general_parser(parser): ...@@ -49,6 +49,12 @@ def general_parser(parser):
metavar="PATH", metavar="PATH",
help="path to jar containing disl instrumentation code, same as 'instr'") help="path to jar containing disl instrumentation code, same as 'instr'")
group.add_argument("-t",
dest="test_dir",
default=None,
metavar="PATH",
help="directory to run in, default=current")
return return
...@@ -101,6 +107,16 @@ def client_parser(parser): ...@@ -101,6 +107,16 @@ def client_parser(parser):
metavar="PATH", metavar="PATH",
help="path to java-agent library") help="path to java-agent library")
group.add_argument("-c_out",
default=None,
metavar="PATH",
help="file to save client stdout to")
group.add_argument("-c_err",
default=None,
metavar="PATH",
help="file to save client stderr to")
group.add_argument("-c_noexcepthandler", group.add_argument("-c_noexcepthandler",
action="store_true", action="store_true",
default=False, default=False,
...@@ -354,7 +370,7 @@ def run_server(args, parser): ...@@ -354,7 +370,7 @@ def run_server(args, parser):
s_cmd+= args.s_args s_cmd+= args.s_args
#print s_cmd #print s_cmd
server = Popen(s_cmd, shell=False) server = Popen(s_cmd, shell=False)
with open(".server.pid", "w") as pid_file: with open(".server.pid", "w") as pid_file:
...@@ -383,8 +399,16 @@ def run_client(args, parser): ...@@ -383,8 +399,16 @@ def run_client(args, parser):
c_cmd+= args.c_app c_cmd+= args.c_app
#print c_cmd #print c_cmd
c_out_f = None
c_err_f = None
if args.c_out is not None:
c_out_f = open(args.c_out, "w")
if args.c_err is not None:
c_err_f = open(args.c_err, "w")
client = Popen(c_cmd, stdout=c_out_f, stderr=c_err_f, shell=False)
client = Popen(c_cmd, shell=False)
client.wait() client.wait()
return return
...@@ -397,6 +421,9 @@ def main(): ...@@ -397,6 +421,9 @@ def main():
parser = make_parser() parser = make_parser()
args = parse_arguments(parser) args = parse_arguments(parser)
if args.test_dir is not None:
os.chdir(args.test_dir)
if args.server == True: if args.server == True:
run_server(args, parser) run_server(args, parser)
......
...@@ -8,11 +8,11 @@ public class DiSLClass { ...@@ -8,11 +8,11 @@ public class DiSLClass {
@After(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 0) @After(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 0)
public static void after() { public static void after() {
System.out.println("after"); System.out.println("disl: after");
} }
@AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 1) @AfterThrowing(marker = BodyMarker.class, scope = "TargetClass.print(boolean)", order = 1)
public static void afterThrowning() { public static void afterThrowning() {
System.out.println("afterThrowning"); System.out.println("disl: afterThrowning");
} }
} }
...@@ -4,26 +4,25 @@ public class TargetClass { ...@@ -4,26 +4,25 @@ public class TargetClass {
public void print(boolean flag) { public void print(boolean flag) {
try { try {
System.out.println("try-clause"); System.out.println("app: try-clause");
if (flag) { if (flag) {
String float_one = "1.0"; String float_one = "1.0";
int int_one = Integer.valueOf(float_one); int int_one = Integer.valueOf(float_one);
System.out.println(int_one + "This should not be printed!"); System.out.println("app: " + int_one + "This should not be printed!");
} }
System.out.println("normal return"); System.out.println("app: normal return");
} finally { } finally {
System.out.println("finally-clause"); System.out.println("app: finally-clause");
} }
} }
public static void main(String[] args) { public static void main(String[] args) {
TargetClass t = new TargetClass(); TargetClass t = new TargetClass();
System.out.println("=========call print(false)========="); System.out.println("app: call print(false)");
t.print(false); t.print(false);
System.out.println("=========call print(true) ========="); System.out.println("app: call print(true)");
t.print(true); t.print(true);
} }
} }
app: call print(false)
app: try-clause
app: normal return
app: finally-clause
disl: after
app: call print(true)
app: try-clause
app: finally-clause
disl: after
disl: afterThrowning
Throwing! for ethrowing1
Returning! for ereturning1
Throwing! for ethrowing2
Returning! for ereturning2
=========call print(false)=========
try-clause
normal return
finally-clause
after null
=========call print(true) =========
try-clause
finally-clause
after java.lang.NumberFormatException: For input string: "1.0"
afterThrowning java.lang.NumberFormatException: For input string: "1.0"
Constructing TargetClass
Before
Constructing TargetClass2
Construction end
After
=========call print(false)=========
Enter basic block 1! index: 0 size: 2
Enter basic block!
Exit basic block!
Exit basic block 1!
Enter basic block 1! index: 2 size: 3
Enter basic block!
Exit basic block!
Enter basic block!
false
Exit basic block!
Exit basic block 1!
Enter basic block 1! index: 3 size: 1
Enter basic block!
Exit basic block!
Exit basic block 1!
=========call print(true) =========
Enter basic block 1! index: 0 size: 2
Enter basic block!
Exit basic block!
Exit basic block 1!
Enter basic block 1! index: 1 size: 4
Enter basic block!
Exit basic block!
Enter basic block!
true
Exit basic block!
Enter basic block!
Exit basic block!
Exit basic block 1!
Enter basic block 1! index: 3 size: 1
Enter basic block!
Exit basic block!
Exit basic block 1!
Precondition2!
Precondition!
Precondition: This should be printed
This is the body of TargetClass.print
not branched
Postcondition!
Postcondition2!
Precondition2!
Precondition!
Precondition: This should be printed
This is the body of TargetClass.print
branched
Postcondition!
Postcondition2!
foo() called. will call goo()
goo called
hoo should not be in cflow of foo()
now calling goo, should not be in cflow neither
goo called
class ch.usi.dag.disl.test.classinfo.TargetClass
This is the body of TargetClass.print
not branched
class ch.usi.dag.disl.test.classinfo.TargetClass
This is the body of TargetClass.print
branched
exception body from snippet
exception handler from snippet
+++call print(false)+++
@Before
NumberFormatException handler
@AfterReturning
+++call print(true)+++
@Before
Exception handler
@AfterReturning
Enter basic block ! index: 0 loopstart? false
Enter basic block ! index: 1 loopstart? true
Enter basic block ! index: 2 loopstart? false
0
Enter basic block ! index: 1 loopstart? true
Enter basic block ! index: 2 loopstart? false
1
Enter basic block ! index: 1 loopstart? true
Enter basic block ! index: 2 loopstart? false
2
Enter basic block ! index: 1 loopstart? true
Enter basic block ! index: 2 loopstart? false
3
Enter basic block ! index: 1 loopstart? true
Enter basic block ! index: 3 loopstart? false
this is a public method.
this is a public method.
this is a private method.
Inside TargetClass.private_method.
this is a public method.
Inside TargetClass.public_method.
Go ahead
this shold be printed
Go ahead
init or clniit
this shold be printed
Go ahead
this shold be printed
Inside TargetClass.private_method.
Go ahead
this shold be printed
Inside TargetClass.public_method.
Inside TargetClass.private_method.
write:ch/usi/dag/disl/test/pe3/TargetClass:public_method:()V
read:ch/usi/dag/disl/test/pe3/TargetClass:public_method:()V
1
this_is_a_method_name
this_is_a_method_name
this_is_a_method_name
This is the body of TargetClass.this_is_a_method_name
Precondition!
Precondition: This should be printed
This is the body of TargetClass.print
not branched
Postcondition!
Postcondition: This should be printed
Precondition!
Precondition: This should be printed
This is the body of TargetClass.print
branched
Postcondition!
Postcondition: This should be printed
pre Thread[main,5,main] tlv ahoj
post Thread[main,5,main] tlv hello
pre Thread[Thread-0,5,main] tlv ahoj
post Thread[Thread-0,5,main] tlv hello
+++call print(false)+++
@Before
Without exception
@AfterReturning
+++call print(true)+++
@Before
@AfterThrowing
Exception handler
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment