summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.base/bitfield.stp
diff options
context:
space:
mode:
authorDave Brolley <brolley@redhat.com>2009-04-14 12:34:11 -0400
committerDave Brolley <brolley@redhat.com>2009-04-14 12:34:11 -0400
commit6c39ba6093aa0b3b86aa7e6f17a23ef322bd67cd (patch)
tree7491c5c2357768fafe21752c3a16436f23c51f70 /testsuite/systemtap.base/bitfield.stp
parenta2422e707214a425e4e10ac5b7c39fc5ae4dea56 (diff)
parentb9c2e81cc7a62336ec1daf374cb3411add772ab4 (diff)
downloadsystemtap-steved-6c39ba6093aa0b3b86aa7e6f17a23ef322bd67cd.tar.gz
systemtap-steved-6c39ba6093aa0b3b86aa7e6f17a23ef322bd67cd.tar.xz
systemtap-steved-6c39ba6093aa0b3b86aa7e6f17a23ef322bd67cd.zip
Merge branch 'master' of git://sources.redhat.com/git/systemtap
Diffstat (limited to 'testsuite/systemtap.base/bitfield.stp')
-rw-r--r--testsuite/systemtap.base/bitfield.stp46
1 files changed, 46 insertions, 0 deletions
diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp
new file mode 100644
index 00000000..c2ff4929
--- /dev/null
+++ b/testsuite/systemtap.base/bitfield.stp
@@ -0,0 +1,46 @@
+%{
+#include <linux/tcp.h>
+static struct tcphdr foo = {0};
+%}
+
+function get_ptr:long() %{ THIS->__retvalue = (long)&foo; /* pure */ %}
+function get_ack:long() %{ THIS->__retvalue = foo.ack; /* pure */ %}
+function get_urg:long() %{ THIS->__retvalue = foo.urg; /* pure */ %}
+
+function check:long(ack:long, urg:long) {
+ ptr = get_ptr()
+
+ /* set the bits with cast */
+ @cast(ptr, "tcphdr")->ack = ack
+ @cast(ptr, "tcphdr")->urg = urg
+
+ /* check that reading with embedded-C is ok */
+ real_ack = get_ack()
+ real_urg = get_urg()
+ errors = (ack != real_ack) + (urg != real_urg)
+
+ /* check that reading with a cast is ok */
+ cast_ack = @cast(ptr, "tcphdr")->ack
+ cast_urg = @cast(ptr, "tcphdr")->urg
+ errors += (ack != cast_ack) + (urg != cast_urg)
+
+ if (errors)
+ printf("bitfield had %d errors; expect(%d%d), real(%d%d), cast(%d%d)\n",
+ errors, ack, urg, real_ack, real_urg, cast_ack, cast_urg)
+
+ return errors
+}
+
+probe begin {
+ println("systemtap starting probe")
+
+ errors = check(0, 0)
+ errors += check(0, 1)
+ errors += check(1, 0)
+ errors += check(1, 1)
+
+ println("systemtap ending probe")
+ if (errors == 0)
+ println("systemtap test success")
+ exit()
+}