]> sourceware.org Git - systemtap.git/commitdiff
PR16894: new wordexp.exp to check -c COMMAND handling
authorJonathan Lebon <jlebon@redhat.com>
Fri, 2 May 2014 14:19:06 +0000 (10:19 -0400)
committerJonathan Lebon <jlebon@redhat.com>
Fri, 2 May 2014 14:22:17 +0000 (10:22 -0400)
This simple testcase checks that invalid -c COMMANDs for unspecified
process probes are properly handled (e.g. prior to commit eb94071, we
segfaulted).

testsuite/systemtap.base/wordexp.exp [new file with mode: 0644]

diff --git a/testsuite/systemtap.base/wordexp.exp b/testsuite/systemtap.base/wordexp.exp
new file mode 100644 (file)
index 0000000..0fcb22f
--- /dev/null
@@ -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"
This page took 0.030235 seconds and 5 git commands to generate.