This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[PATCH] add testcases for variables scope
- From: Zhou Wenjian <zhouwj-fnst at cn dot fujitsu dot com>
- To: <systemtap at sourceware dot org>
- Date: Thu, 5 Nov 2015 16:27:47 +0800
- Subject: [PATCH] add testcases for variables scope
- Authentication-results: sourceware.org; auth=none
* 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