summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorfche <fche>2005-06-02 19:43:55 +0000
committerfche <fche>2005-06-02 19:43:55 +0000
commit69c68955b910a9f284fa25b9ebb30eff5c040e0b (patch)
tree3fa502458891d0b54150d678368f7a2dee18fa0f /testsuite
parentf37b5c92191dd81aad57ade2899a4999099a3e35 (diff)
downloadsystemtap-steved-69c68955b910a9f284fa25b9ebb30eff5c040e0b.tar.gz
systemtap-steved-69c68955b910a9f284fa25b9ebb30eff5c040e0b.tar.xz
systemtap-steved-69c68955b910a9f284fa25b9ebb30eff5c040e0b.zip
2005-06-02 Frank Ch. Eigler <fche@redhat.com>
Parse foreach construct. Added fuller copyright notices throughout. * staptree.h (foreach_loop): New tree node type. * staptree.cxx: Print it, visit it, love it, leave it. * parse.cxx: Parse it. (parse_stmt_block): Don't require ";" separators between statements. (parse_array_in): Use [] as index group operator instead of (). * elaborate.cxx (visit_foreach_loop): New code. * translate.cxx: Slightly tighten errorcount/actioncount handling. * main.cxx: Accept "-" as script file name standing for stdin. (visit_arrayindex): Switch to simpler set_arity call. * configure.ac: Generate DATE macro. * Makefile.in, configure, config.in: Regenerated. * testsuite/*: New/updated tests for syntax changes, foreach ().
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/parseko/eight.stp4
-rwxr-xr-xtestsuite/parseko/seven.stp6
-rwxr-xr-xtestsuite/parseko/three.stp5
-rwxr-xr-xtestsuite/parseok/eight.stp4
-rwxr-xr-xtestsuite/parseok/nine.stp15
-rwxr-xr-xtestsuite/semko/eleven.stp15
-rwxr-xr-xtestsuite/semok/eleven.stp38
-rwxr-xr-xtestsuite/semok/ten.stp19
8 files changed, 91 insertions, 15 deletions
diff --git a/testsuite/parseko/eight.stp b/testsuite/parseko/eight.stp
new file mode 100755
index 00000000..4d343159
--- /dev/null
+++ b/testsuite/parseko/eight.stp
@@ -0,0 +1,4 @@
+#! stap -p1
+probe foo {
+ foreach ([a, b, c] in) ;
+}
diff --git a/testsuite/parseko/seven.stp b/testsuite/parseko/seven.stp
index 06f8a3ba..0b72f9f8 100755
--- a/testsuite/parseko/seven.stp
+++ b/testsuite/parseko/seven.stp
@@ -1,8 +1,8 @@
#! stap -p1
probe foo {
- (a,) in b;
- (,c) in d;
- () in e;
+ [a,] in b;
+ [,c] in d;
+ [] in e;
a in e[2];
}
diff --git a/testsuite/parseko/three.stp b/testsuite/parseko/three.stp
index be810e9d..b40c7708 100755
--- a/testsuite/parseko/three.stp
+++ b/testsuite/parseko/three.stp
@@ -1,7 +1,4 @@
#! stap -p1
-
probe foo {
- a(1)
-# need ;
- b(2)
+ foreach (a) ;
}
diff --git a/testsuite/parseok/eight.stp b/testsuite/parseok/eight.stp
index 0da5c8d2..29602775 100755
--- a/testsuite/parseok/eight.stp
+++ b/testsuite/parseok/eight.stp
@@ -2,5 +2,7 @@
probe all
{
- "1" in a1; ("1", 2) in a2; (a) in a3;
+ "1" in a1; ["1", 2] in a2; [a] in a3; [("1").("2"), "1"."2"] in a4;
+ a = [akbar(("foo").("bar"))] in it_s_a_trap
+ foreach ([a, b] in a4) { foreach ([c, d] in a2) ; }
}
diff --git a/testsuite/parseok/nine.stp b/testsuite/parseok/nine.stp
new file mode 100755
index 00000000..13e40cbf
--- /dev/null
+++ b/testsuite/parseok/nine.stp
@@ -0,0 +1,15 @@
+#! stap -p1
+
+probe one
+{
+ if (a) if (b) d else e
+}
+
+probe two
+{
+ a = b
+ c = d
+ e = f();
+ g = h;
+ ;
+}
diff --git a/testsuite/semko/eleven.stp b/testsuite/semko/eleven.stp
new file mode 100755
index 00000000..34dfa225
--- /dev/null
+++ b/testsuite/semko/eleven.stp
@@ -0,0 +1,15 @@
+#! stap -p2
+
+global arr,rra
+
+probe begin {
+ arr[0]="value"
+ rra["key"]=0
+}
+probe end {
+ # confirm that typechecking works the same way for all array indexing
+ if (k in arr) { k.""; arr[k]+0 }
+ foreach (l in arr) { l.""; arr[l]+0 }
+ if (m in rra) { m+1; rra[m]."" }
+ foreach (n in rra) { n+0; rra[n]."" }
+}
diff --git a/testsuite/semok/eleven.stp b/testsuite/semok/eleven.stp
new file mode 100755
index 00000000..bcfa4222
--- /dev/null
+++ b/testsuite/semok/eleven.stp
@@ -0,0 +1,38 @@
+#! stap -p2
+
+global entry_time, my_count, my_fd, read_times
+
+# future built-ins
+function string (v) { return "" }
+function hexstring (v) { return "" }
+function trace (s) { return 0 }
+
+probe kernel.syscall("read") {
+ $count=0 $timestamp=0 $fd=0
+
+ thread->entry_time = $timestamp # "macro" variable
+ thread->my_count = $count # function argument
+ thread->my_fd = $fd # function argument
+ trace ("my_count = " . string(thread->my_count) .
+ "my_fd = " . string(thread->my_fd))
+}
+
+probe kernel.syscall("read").return {
+ $syscall_name="" $retvalue=0
+
+ if (thread->entry_time) {
+ read_times[$syscall_name] # variable from provider alias
+ += $timestamp - thread->entry_time
+ }
+ trace ("syscall " . $syscall_name .
+ " return value = " .
+ hexstring ($retvalue)) # function pseudo-argument
+}
+
+probe end {
+ foreach (syscall in read_times) {
+ trace ("syscall " . syscall .
+ " total-time=" . string (read_times[syscall]))
+ }
+}
+
diff --git a/testsuite/semok/ten.stp b/testsuite/semok/ten.stp
index d56c2a4a..bb353a9f 100755
--- a/testsuite/semok/ten.stp
+++ b/testsuite/semok/ten.stp
@@ -1,10 +1,15 @@
-#! stap -p1
+#! stap -p2
-global a1, a2, a3
+global arr,rra
-probe all
-{
- a = "1" in a1;
- a = ("1", a) in a2;
- a = (a, a+a, a1[a], a2[0+a]) in a3;
+probe begin {
+ arr["key"]=0
+ rra[0]="value"
+}
+probe end {
+ # confirm that typechecking works the same way for all array indexing
+ if (k in arr) { k.""; arr[k]+0 }
+ foreach (l in arr) { l.""; arr[l]+0 }
+ if (m in rra) { m+0; rra[m]."" }
+ foreach (n in rra) { n+0; rra[n]."" }
}