summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/ChangeLog5
-rwxr-xr-xtestsuite/systemtap.maps/exists.exp19
-rw-r--r--testsuite/systemtap.maps/exists.stp46
3 files changed, 70 insertions, 0 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index ad054909..6dd96c1f 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-22 Martin Hunt <hunt@redhat.com>
+
+ * systemtap.maps/exists.stp: New test to see if
+ array elements exist using the "in" keyword.
+
2007-01-20 Mike Mason <mmlnx@us.ibm.com>
PR 3899
diff --git a/testsuite/systemtap.maps/exists.exp b/testsuite/systemtap.maps/exists.exp
new file mode 100755
index 00000000..a223c9ce
--- /dev/null
+++ b/testsuite/systemtap.maps/exists.exp
@@ -0,0 +1,19 @@
+# test the "in" keyword with maps
+
+load_lib "stap_run2.exp"
+
+set test "exists"
+set ::result_string {0 is there
+1 is there
+comlete list for a: 0 1 2 3 4 5 6 7 8 9 10
+0 is still there
+comlete list for b: [0,0] [1,10] [2,20] [3,30] [4,40] [5,50] [6,60] [7,70] [8,80] [9,90] [10,100]
+[0,0] is still there
+emtpy string there
+hello there
+emtpy string still there
+}
+
+stap_run2 $srcdir/$subdir/$test.stp
+
+
diff --git a/testsuite/systemtap.maps/exists.stp b/testsuite/systemtap.maps/exists.stp
new file mode 100644
index 00000000..745990f7
--- /dev/null
+++ b/testsuite/systemtap.maps/exists.stp
@@ -0,0 +1,46 @@
+# test the "in" keyword with maps
+
+global a, b, c
+
+probe begin {
+ for (i=0;i<11;i++)
+ a[i] = i*i
+
+ if (0 in a) printf("0 is there\n")
+ if (1 in a) printf("1 is there\n")
+ if (50 in a) printf("ERROR: 50 is there\n")
+
+ printf("comlete list for a: ")
+ for (i=0;i<11;i++)
+ if (i in a) printf("%d ", i)
+ printf("\n")
+
+ a[0] = 0
+ if (0 in a) printf("0 is still there\n")
+
+ delete a[0]
+ if (0 in a) printf("ERROR: 0 is there after delete\n")
+
+ for (i=0;i<11;i++)
+ b[i, 10*i] = i*i
+ printf("comlete list for b: ")
+ for (i=0;i<11;i++)
+ if ([i,10*i] in b) printf("[%d,%d] ", i, 10*i)
+ printf("\n")
+ b[0,0] = 0
+ if ([0,0] in b) printf("[0,0] is still there\n")
+
+ delete b[0,0]
+ if ([0,0] in b) printf("ERROR: [0,0] is there after delete\n")
+
+ c[""] = "empty string"
+ c["hello"] = "HELLO"
+ if ([""] in c) printf ("emtpy string there\n")
+ if (["hello"] in c) printf ("hello there\n")
+ c[""] = ""
+ if ([""] in c) printf ("emtpy string still there\n")
+ delete c[""]
+ if ([""] in c) printf ("ERROR: emtpy string still there after delete\n")
+ exit()
+}
+