]> sourceware.org Git - systemtap.git/commitdiff
PR17749: add subtest to global_end.exp
authorJonathan Lebon <jlebon@redhat.com>
Mon, 26 Jan 2015 19:19:59 +0000 (14:19 -0500)
committerJonathan Lebon <jlebon@redhat.com>
Fri, 30 Jan 2015 16:34:21 +0000 (11:34 -0500)
Make a new test script checking all the ways in which a variable should
be marked as used.

Note that there are other places in which a var should be marked used
(e.g. stat_op), but they would need to be nested within a context which
already marks nested symbols as used (e.g. in an if() condition). Unless
it's placed on a line by itself, in which case it doesn't matter because
it would get elided as a side-effect-free expr.

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

index 67f5772653662488f1590d19c0219ecc54fbffaa..d38c131bfaabe5f4ec76b654223ae7ea71f4c715 100644 (file)
@@ -74,4 +74,24 @@ foreach runtime [get_runtime_list] {
     catch {close}; catch {wait}
     
     if {$ok == 6} { pass "$test ($ok)" } { fail "$test ($ok)" }
+
+    # test PR17749
+    set test "global_end_var_used"
+    if {$runtime != ""} {
+       set test "${test}_${runtime}"
+       spawn stap $srcdir/$subdir/global_end_var_used.stp --runtime=$runtime
+    } else {
+       spawn stap $srcdir/$subdir/global_end_var_used.stp
+    }
+    set ok 0
+    # strictly look for "hello". if anything else is printed it's a fail.
+    expect {
+       -timeout 180
+        -re {^hello!$} { incr ok; exp_continue }
+       timeout { fail "$test (timeout)" }
+       eof { }
+    }
+    catch {close}; catch {wait}
+
+    if {$ok == 1} { pass "$test ($ok)" } { fail "$test ($ok)" }
 }
diff --git a/testsuite/systemtap.base/global_end_var_used.stp b/testsuite/systemtap.base/global_end_var_used.stp
new file mode 100644 (file)
index 0000000..0581f11
--- /dev/null
@@ -0,0 +1,47 @@
+// None of these global vars should be
+// autoprinted because they are all used
+
+global a // if condition
+global b // function arg
+
+global arr // used in foreach
+global c // foreach array slice
+global d // foreach limit
+
+global e // return value
+global f // ternary cond
+global g // while condition
+global h // arrayindex index
+
+function foo(b) {
+   if (b)
+      printf("e")
+}
+
+function bar() {
+   return ++e;
+}
+
+probe oneshot {
+
+   if (++a)
+      printf("h")
+
+   foo(++b)
+
+   arr[1,1] = 1
+   foreach ([i,j] in arr[*,++c] limit ++d) {
+      printf("l")
+   }
+
+   if (bar()) {
+      printf("l")
+   }
+
+   ++f ? printf("o") : printf("");
+
+   while (!g++)
+      printf("!")
+
+   arr[++h, 1]++
+}
This page took 0.027641 seconds and 5 git commands to generate.