This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] add testcases for variables scope


Hello David,

During this work, I found some logic in the testsuite is not so correct.
For example, in the testcase of "if":
probe end
{
        println("systemtap ending probe")
        if (1) {
                println("systemtap test success");
        } else {
                println("systemtap test failure");
        }
        if (0) {
                println("systemtap test failure");
        } else {
                println("systemtap test success");
        }
}
The output is:
systemtap ending probe
systemtap test success
systemtap test success


The testsuite only focus on the first message after "systemtap ending probe".
If the message is "systemtap test success", then pass the case.
It don't care whether the following message is success or fail.
It leads to the result that even if the output message is the following,
there also won't be any error message in the result.

systemtap ending probe
systemtap test success
systemtap test failure


I think there are two ways to fix it, if it needs to be fixed.
1,
adjust the function stap_run

2,
change the way of printing "systemtap test success" (likes the implementation in this patch)

I prefer the second, for it won't introduce some other errors.

--
Thanks
Zhou

On 11/05/2015 04:27 PM, Zhou Wenjian wrote:
	* testsuite/systemtap.base/var_scope.exp: New test case.
	* testsuite/systemtap.base/var_scope.stp: New test file.
---
  testsuite/systemtap.base/var_scope.exp | 14 ++++++++++++
  testsuite/systemtap.base/var_scope.stp | 41 ++++++++++++++++++++++++++++++++++
  2 files changed, 55 insertions(+)
  create mode 100755 testsuite/systemtap.base/var_scope.exp
  create mode 100755 testsuite/systemtap.base/var_scope.stp

diff --git a/testsuite/systemtap.base/var_scope.exp b/testsuite/systemtap.base/var_scope.exp
new file mode 100755
index 0000000..70a25a9
--- /dev/null
+++ b/testsuite/systemtap.base/var_scope.exp
@@ -0,0 +1,14 @@
+# Check variables scope
+
+set test "var_scope"
+if {![installtest_p]} { untested "$test"; return }
+
+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/var_scope.stp b/testsuite/systemtap.base/var_scope.stp
new file mode 100755
index 0000000..78b6f46
--- /dev/null
+++ b/testsuite/systemtap.base/var_scope.stp
@@ -0,0 +1,41 @@
+/*
+ * var_scope.stp
+ *
+ * Check variables scope
+ */
+global var_global=2015;
+
+probe begin {
+    println("systemtap starting probe")
+    var_probe=2015
+}
+probe end   {  println("systemtap ending probe")    }
+
+
+function changevar()
+{
+    var_local=2014
+}
+
+probe end {
+    ret=0
+    if (var_global != 2015) {
+        ret=1
+        printf("systemtap test failure - var_global:%d != 2015\n", var_global)
+    }
+
+    var_local=2015
+    changevar()
+    if (var_local != 2015) {
+        ret=1
+        printf("systemtap test failure - var_local:%d != 2015\n", var_local)
+    }
+
+    if (var_probe == 2015) {
+        ret=1
+        printf("systemtap test failure - var_probe:%d == 2015\n", var_probe)
+    }
+
+    if (ret == 0)
+        println("systemtap test success")
+}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]