]> sourceware.org Git - systemtap.git/commitdiff
Add testcase for "break" and "continue".
authorZhou Wenjian <zhouwj-fnst@cn.fujitsu.com>
Mon, 30 Nov 2015 22:27:41 +0000 (16:27 -0600)
committerDavid Smith <dsmith@redhat.com>
Mon, 30 Nov 2015 22:27:41 +0000 (16:27 -0600)
* testsuite/systemtap.base/break_and_continue.exp: New test case
* testsuite/systemtap.base/break_and_continue.stp: New test file

testsuite/systemtap.base/break_and_continue.exp [new file with mode: 0644]
testsuite/systemtap.base/break_and_continue.stp [new file with mode: 0644]

diff --git a/testsuite/systemtap.base/break_and_continue.exp b/testsuite/systemtap.base/break_and_continue.exp
new file mode 100644 (file)
index 0000000..0ddfdb9
--- /dev/null
@@ -0,0 +1,13 @@
+# Check break and continue in for, foreach and while work correctly
+
+set test "break_and_continue"
+
+foreach runtime [get_runtime_list] {
+    if {$runtime != ""} {
+       stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string \
+           --runtime=$runtime -w
+    } else {
+       stap_run $srcdir/$subdir/$test.stp no_load $all_pass_string \
+           -w
+    }
+}
diff --git a/testsuite/systemtap.base/break_and_continue.stp b/testsuite/systemtap.base/break_and_continue.stp
new file mode 100644 (file)
index 0000000..5f0afb4
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * break_and_continue.stp
+ *
+ * Check break and continue in for, foreach and while work correctly
+ */
+
+global a
+
+probe begin
+{
+       println("systemtap starting probe")
+       exit()
+}
+
+probe end
+{
+       a[1]=1
+       a[2]=2
+       a[3]=3
+       i=1
+       ret=0
+       println("systemtap ending probe")
+       for(i=1;i<3;i++)
+       {
+               break;
+               ret=1
+       }
+       if (i!=1)
+               ret=1
+
+       foreach(i in a)
+       {
+               break;
+               ret=1
+       }
+       if (i!=1)
+               ret=1
+
+       i=0
+       while(i<3)
+       {
+               i++
+               break;
+               ret=1
+       }
+       if (i!=1)
+               ret=1
+
+       for(i=1;i<3;i++)
+       {
+               continue;
+               ret=1
+       }
+       if (i!=3)
+               ret=1
+
+       foreach(i in a)
+       {
+               continue;
+               ret=1
+       }
+       if (i!=3)
+               ret=1
+
+       i=0
+       while(i<3)
+       {
+               i++
+               continue;
+               ret=1
+       }
+       if (i!=3)
+               ret=1
+
+
+       if (ret == 0)
+               println("systemtap test success")
+}
This page took 0.028321 seconds and 5 git commands to generate.