]> sourceware.org Git - systemtap.git/commitdiff
Add multiple new testcases
authorLukas Berk <lberk@redhat.com>
Tue, 30 Apr 2013 21:44:40 +0000 (17:44 -0400)
committerLukas Berk <lberk@redhat.com>
Wed, 1 May 2013 15:13:38 +0000 (11:13 -0400)
*java.exp: add new testcases, fix existing
*java.stp: add error,end probe
*multiparams.java: multiparameter java program
*multiparams.stp: multiparameter stap script
*returnstatement.java: return testcase
*returnstatement.stp: return stap sript
*singleparam.java: adjust single parameter java program

testsuite/systemtap.apps/java.exp
testsuite/systemtap.apps/java.stp
testsuite/systemtap.apps/multiparams.java [new file with mode: 0644]
testsuite/systemtap.apps/multiparams.stp [new file with mode: 0644]
testsuite/systemtap.apps/returnstatement.java [new file with mode: 0644]
testsuite/systemtap.apps/returnstatement.stp [new file with mode: 0644]
testsuite/systemtap.apps/singleparam.java

index 666b0db88df0ec725cf7e0e2bc5c8edb98f77415..66587c1249651f493e05f323d4f1d2293559c10a 100644 (file)
@@ -1,24 +1,89 @@
-set test "java"
+set test "singleparam"
 
 # Test per method probing
 
 catch { exec javac -d ./ $srcdir/$subdir/singleparam.java } err
 if {$err == "" && [file exists ./singleparam.class]} then { pass "$test compile" } else { fail "$test compile $err" }
 
-catch { exec java singleparam }
-spawn stap $srcdir/$subdir/java.stp
+spawn stap $srcdir/$subdir/java.stp -c "java singleparam"
+set ok 0
 expect {
-"^printMessage(int) 42\n"
-"^printMessage(long) 254775806\n"
-"^printMessage(double) 3\n"
-"^printMessage(float) 2345987\n"
-"^printMessage(byte) 10\n"
-"^printMessage(boolean) 1\n"
-"^printMessage(char) 97\n"
-"^printMessage(short) 14\n"
+    -timeout 40
+    -re {^printMessage\(int\)\ 42\r\n} { incr ok; exp_continue}
+    -re {^printMessage\(long\)\ 254775806\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(double\)\ 3\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(float\)\ 2345987\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(byte\)\ 10\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(boolean\)\ 1\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(char\)\ 97\r\n} { incr ok; exp_continue }
+    -re {^printMessage\(short\)\ 14\r\n} { incr ok; exp_continue }
+    timeout { fail "$test (timeout)" }
 }
 
+    if {$ok == 8} then {
+       pass "$test ($ok)"
+    } else {
+       fail "$test ($ok)"
+    }
 catch {close}; catch {wait}
 catch {exec rm ./singleparam.class}
 
-pass $test
+set test "return"
+
+catch { exec javac -d ./ $srcdir/$subdir/returnstatement.java } err1
+if {$err1 == "" && [file exists ./returnstatement.class]} then { pass "$test compile" } else { fail "$test compile $err1" }
+
+spawn stap $srcdir/$subdir/returnstatement.stp -c "java returnstatement"
+set oka 0
+expect {
+    -timeout 40
+    -re {^printMessage\(int\)\ 42\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(long\)\ 254775806\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(double\)\ 3\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(float\)\ 2345987\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(byte\)\ 10\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(boolean\)\ 1\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(char\)\ 97\ ret\r\n} { incr oka; exp_continue }
+    -re {^printMessage\(short\)\ 14\ ret\r\n} { incr oka; exp_continue }
+    timeout { fail "$test unexpected timeout" }
+}
+
+    if {$oka == 8} then {
+       pass "$test ($oka)"
+    } else {
+       fail "$test ($oka)"
+    }
+
+catch {close}; catch {wait}
+catch {exec rm ./returnstatement.class}
+
+set test "multiparams"
+
+catch { exec javac -d ./ $srcdir/$subdir/multiparams.java } err2
+if {$err2 == "" && [file exists ./multiparams.class]} then { pass "$test compile" } else { fail "$test compile $err2" }
+
+spawn stap $srcdir/$subdir/multiparams.stp -c "java multiparams"
+set okb 0
+expect {
+    -timeout 40
+    -re {^printMessage1\(int\)\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage2\(long\,\ int\)\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage3\(double,\ long,\ int\)\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage4\(float,\ double,\ long,\ int\)\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage5\(byte,\ float,\ double,\ long,\ int\)\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage6\(boolean,\ byte,\ float,\ double,\ long,\ int\)\ 1\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage7\(char,\ boolean,\ byte,\ float,\ double,\ long,\ int\)\ 97\ 1\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage8\(short,\ char,\ boolean,\ byte,\ float,\ double,\ long,\ int\)\ 14\ 97\ 1\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage9\(short,\ short,\ char,\ boolean,\ byte,\ float,\ double,\ long,\ int\)\ 14\ 14\ 97\ 1\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    -re {^printMessage10\(short,\ short,\ short,\ char,\ boolean,\ byte,\ float,\ double,\ long,\ int\)\ 14\ 14\ 14\ 97\ 1\ 10\ 2345987\ 3\ 254775806\ 42\r\n} { incr okb; exp_continue }
+    timeout { fail "$test unexpected timeout" }
+}
+    if {$okb == 10} then {
+       pass "$test ($okb)"
+    } else {
+       fail "$test ($okb)"
+    }
+
+catch {close}; catch {wait}
+catch {exec rm ./multiparams.class}
+
index 0c8ca9a99f81b59c63e98e7c21e294d75ae71031..7cc785906d41bf9f5af84b6c7267bde8c714a461 100644 (file)
@@ -39,4 +39,4 @@ probe java("singleparam").class("singleparam").method("printMessage(short)")
 {
   printf("%s %d\n", user_string($name), $arg1)
 }
-
+probe end,error {exit()}
\ No newline at end of file
diff --git a/testsuite/systemtap.apps/multiparams.java b/testsuite/systemtap.apps/multiparams.java
new file mode 100644 (file)
index 0000000..3255d15
--- /dev/null
@@ -0,0 +1,39 @@
+class multiparams
+{
+    public static void printMessage1(int a){}
+    public static void printMessage2(long a, int b){}
+    public static void printMessage3(double a, long b, int c){}
+    public static void printMessage4(float a, double b, long c, int d){}
+    public static void printMessage5(byte a, float b, double c, long d, int e){}
+    public static void printMessage6(boolean a, byte b, float c, double d, long e, int f){}
+    public static void printMessage7(char a, boolean b, byte c, float d, double e, long f, int g){}
+    public static void printMessage8(short a, char b, boolean c, byte d, float e, double f, long g, int h){}
+    public static void printMessage9(short a, short b, char c, boolean d, byte e, float f, double g, long h, int i){}
+    public static void printMessage10(short a, short b, short c, char d, boolean e, byte f, float g, double h, long i, int j){}
+
+    public static void main(String[] args) throws InterruptedException
+    {
+       
+       Thread.sleep(20000);
+       final int i = 42;
+       final long j = 254775806;
+       final double k = 3.14;
+       final float l = 2345987;
+       final byte n = 10;
+       final boolean o = true;
+       final char p = 'a';
+       final short q = 14;
+
+       printMessage1(i);
+       printMessage2(j, i);
+       printMessage3(k, j, i);
+       printMessage4(l, k, j, i);
+       printMessage5(n, l, k, j, i);
+       printMessage6(o, n, l, k, j, i);
+       printMessage7(p, o, n, l, k, j, i);
+       printMessage8(q, p, o, n, l, k, j, i);
+       printMessage9(q, q, p, o, n, l, k, j, i);
+       printMessage10(q, q, q, p, o, n, l, k, j, i);
+
+    }
+}
diff --git a/testsuite/systemtap.apps/multiparams.stp b/testsuite/systemtap.apps/multiparams.stp
new file mode 100644 (file)
index 0000000..1e916e5
--- /dev/null
@@ -0,0 +1,50 @@
+probe java("multiparams").class("multiparams").method("printMessage1(int)")
+{
+  printf("%s %d\n", user_string($name), $arg1)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage2(long, int)")
+{
+  printf("%s %d %d\n", user_string($name), $arg1, $arg2)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage3(double, long, int)")
+{
+  printf("%s %d %d %d\n", user_string($name), $arg1, $arg2, $arg3)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage4(float, double, long, int)")
+{
+  printf("%s %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage5(byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage6(boolean, byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage7(char, boolean, byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage8(short, char, boolean, byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage9(short, short, char, boolean, byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9)
+}
+
+probe java("multiparams").class("multiparams").method("printMessage10(short, short, short, char, boolean, byte, float, double, long, int)")
+{
+  printf("%s %d %d %d %d %d %d %d %d %d %d\n", user_string($name), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9, $arg10)
+}
+probe end,error {exit()}
\ No newline at end of file
diff --git a/testsuite/systemtap.apps/returnstatement.java b/testsuite/systemtap.apps/returnstatement.java
new file mode 100644 (file)
index 0000000..90333fd
--- /dev/null
@@ -0,0 +1,42 @@
+class returnstatement
+{
+    public static void printMessage(int message){}
+
+    public static void printMessage(long message){}
+
+    public static void printMessage(double message){}
+
+    public static void printMessage(float message){}
+
+    public static void printMessage(byte message){}
+
+    public static void printMessage(boolean message){}
+
+    public static void printMessage(char message){}
+
+    public static void printMessage(short message){}
+
+    public static void main(String[] args) throws InterruptedException
+    {
+       
+       Thread.sleep(20000);
+       final int i = 42;
+       final long j = 254775806;
+       final double k = 3.14;
+       final float l = 2345987;
+       final byte n = 10;
+       final boolean o = true;
+       final char p = 'a';
+       final short q = 14;
+
+       printMessage(i);
+       printMessage(j);
+       printMessage(k);
+       printMessage(l);
+       printMessage(n);
+       printMessage(o);
+       printMessage(p);
+       printMessage(q);
+
+    }
+}
diff --git a/testsuite/systemtap.apps/returnstatement.stp b/testsuite/systemtap.apps/returnstatement.stp
new file mode 100644 (file)
index 0000000..a2e0e2d
--- /dev/null
@@ -0,0 +1,41 @@
+
+probe java("returnstatement").class("returnstatement").method("printMessage(int)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(long)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(double)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(float)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(byte)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(boolean)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(char)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+
+probe java("returnstatement").class("returnstatement").method("printMessage(short)").return
+{
+  printf("%s %d ret\n", user_string($name), $arg1)
+}
+probe end,error{exit()}
index 2ff5e9812c284f55b35685b3e4d4a4cc66978afc..eac87042ca7834290dbbbcd9b9f6dc5eff4f834d 100644 (file)
@@ -37,7 +37,7 @@ class singleparam
     public static void main(String[] args) throws InterruptedException
     {
        
-       Thread.sleep(20000);
+       Thread.sleep(30000);
        final int i = 42;
        final long j = 254775806;
        final double k = 3.14;
This page took 0.034741 seconds and 5 git commands to generate.