From 7077306dff6768aedea63c736d85b8af7a180848 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 26 Jan 2015 14:19:59 -0500 Subject: [PATCH] PR17749: add subtest to global_end.exp 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 | 20 ++++++++ .../systemtap.base/global_end_var_used.stp | 47 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 testsuite/systemtap.base/global_end_var_used.stp diff --git a/testsuite/systemtap.base/global_end.exp b/testsuite/systemtap.base/global_end.exp index 67f577265..d38c131bf 100644 --- a/testsuite/systemtap.base/global_end.exp +++ b/testsuite/systemtap.base/global_end.exp @@ -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 index 000000000..0581f1156 --- /dev/null +++ b/testsuite/systemtap.base/global_end_var_used.stp @@ -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]++ +} -- 2.43.5