]> sourceware.org Git - systemtap.git/commitdiff
Add simple testcases for @cast
authorJosh Stone <jistone@redhat.com>
Thu, 12 Mar 2009 03:07:07 +0000 (20:07 -0700)
committerJosh Stone <jistone@redhat.com>
Thu, 12 Mar 2009 03:11:11 +0000 (20:11 -0700)
testsuite/semok/cast.stp [new file with mode: 0755]
testsuite/systemtap.base/cast.exp [new file with mode: 0644]
testsuite/systemtap.base/cast.stp [new file with mode: 0644]

diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp
new file mode 100755 (executable)
index 0000000..93da18e
--- /dev/null
@@ -0,0 +1,13 @@
+#! stap -p2
+
+probe begin {
+    // basic @cast test, with and without specifying kernel
+    println(@cast(0, "task_struct")->tgid)
+    println(@cast(0, "task_struct", "kernel")->tgid)
+
+    // check module-search paths
+    println(@cast(0, "task_struct", "foo:kernel:bar")->tgid)
+
+    // would be nice to test usermode @cast too,
+    // but who knows what debuginfo is installed...
+}
diff --git a/testsuite/systemtap.base/cast.exp b/testsuite/systemtap.base/cast.exp
new file mode 100644 (file)
index 0000000..df3246e
--- /dev/null
@@ -0,0 +1,4 @@
+set test "cast"
+set ::result_string {PID OK
+execname OK}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp
new file mode 100644 (file)
index 0000000..bec0cc9
--- /dev/null
@@ -0,0 +1,22 @@
+probe begin
+{
+    curr = task_current()
+
+    // Compare PIDs
+    pid = pid()
+    cast_pid = @cast(curr, "task_struct")->tgid
+    if (pid == cast_pid)
+        println("PID OK")
+    else
+        printf("PID %d != %d\n", pid, cast_pid)
+
+    // Compare execnames
+    name = execname()
+    cast_name = kernel_string(@cast(curr, "task_struct")->comm)
+    if (name == cast_name)
+        println("execname OK")
+    else
+        printf("execname \"%s\" != \"%s\"\n", name, cast_name)
+
+    exit()
+}
This page took 0.031959 seconds and 5 git commands to generate.