From: Jonathan Lebon Date: Fri, 2 May 2014 14:19:06 +0000 (-0400) Subject: PR16894: new wordexp.exp to check -c COMMAND handling X-Git-Tag: release-2.6~125^2~2 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=1922e1acf2c08afa8afd0f43c025fd880cbe66fd;p=systemtap.git PR16894: new wordexp.exp to check -c COMMAND handling This simple testcase checks that invalid -c COMMANDs for unspecified process probes are properly handled (e.g. prior to commit eb94071, we segfaulted). --- diff --git a/testsuite/systemtap.base/wordexp.exp b/testsuite/systemtap.base/wordexp.exp new file mode 100644 index 000000000..0fcb22f2f --- /dev/null +++ b/testsuite/systemtap.base/wordexp.exp @@ -0,0 +1,45 @@ +set test "wordexp" + +# Makes sure SystemTap gracefully handles various -c failures. + +proc expect_semerror { command experror } { + global test + set subtest "$test -c \"$command\"" + + set script "probe process.function(\"foo\") { next }" + if {[string length $command]} { + eval spawn stap -e {$script} -c {$command} + } else { + eval spawn stap -e {$script} + } + + set failed 1 + expect { + -timeout 20 + -re "$experror" { + set failed 0 + } + eof { + fail "$subtest (eof)" + } + timeout { + kill -INT -[exp_pid] 2 + fail "$subtest (timeout)" + } + } + catch {close}; catch {wait} + if {!$failed} { + pass "$subtest" + } +} + +expect_semerror "" \ + "semantic error: unspecified process probe is invalid without a -c COMMAND" +expect_semerror "ls || true" \ + "semantic error: invalid -c command .* illegal characters" +expect_semerror "ls \$HOPEFULLYTHISISNTACTUALLYDEFINED" \ + "semantic error: invalid -c command .* undefined shell variables" +expect_semerror "ls `out`" \ + "semantic error: invalid -c command .* contains command substitutions" +expect_semerror "ls \"string" \ + "semantic error: invalid -c command .* contains shell syntax errors"