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]

[PATCH] add testcases for variables scope


	* 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")
+}
-- 
1.8.3.1


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