summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.string
diff options
context:
space:
mode:
authorhunt <hunt>2006-08-21 16:39:35 +0000
committerhunt <hunt>2006-08-21 16:39:35 +0000
commitfc98aa95b304065ebbf8beb77699d7b686591259 (patch)
tree6de0c75a45af70b7d3ceba77ef62c2dfaa0b756f /testsuite/systemtap.string
parent8267555c5fefa23a30988e3327c4aaeeed662c54 (diff)
downloadsystemtap-steved-fc98aa95b304065ebbf8beb77699d7b686591259.tar.gz
systemtap-steved-fc98aa95b304065ebbf8beb77699d7b686591259.tar.xz
systemtap-steved-fc98aa95b304065ebbf8beb77699d7b686591259.zip
New tests for string functions.
Diffstat (limited to 'testsuite/systemtap.string')
-rw-r--r--testsuite/systemtap.string/isinstr.exp7
-rw-r--r--testsuite/systemtap.string/isinstr.stp25
-rw-r--r--testsuite/systemtap.string/strlen.exp8
-rw-r--r--testsuite/systemtap.string/strlen.stp15
-rw-r--r--testsuite/systemtap.string/substr.exp19
-rw-r--r--testsuite/systemtap.string/substr.stp49
-rw-r--r--testsuite/systemtap.string/text_str.exp58
-rw-r--r--testsuite/systemtap.string/text_str.stp79
8 files changed, 260 insertions, 0 deletions
diff --git a/testsuite/systemtap.string/isinstr.exp b/testsuite/systemtap.string/isinstr.exp
new file mode 100644
index 00000000..746e6c74
--- /dev/null
+++ b/testsuite/systemtap.string/isinstr.exp
@@ -0,0 +1,7 @@
+load_lib "stap_run2.exp"
+set test "isinstr"
+set ::result_string {"foo" is in "abcfoobad"
+"foo" is NOT in "abcdefg"
+"" is in ""
+}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.string/isinstr.stp b/testsuite/systemtap.string/isinstr.stp
new file mode 100644
index 00000000..4688fe18
--- /dev/null
+++ b/testsuite/systemtap.string/isinstr.stp
@@ -0,0 +1,25 @@
+probe begin
+{
+ a = "foo"
+ str = "abcfoobad"
+
+ if (isinstr(str,a))
+ printf("\"%s\" is in \"%s\"\n", a, str)
+ else
+ printf("\"%s\" is NOT in \"%s\"\n", a, str)
+
+ str = "abcdefg"
+ if (isinstr(str,a))
+ printf("\"%s\" is in \"%s\"\n", a, str)
+ else
+ printf("\"%s\" is NOT in \"%s\"\n", a, str)
+
+ a = ""
+ str = ""
+ if (isinstr(str,a))
+ printf("\"%s\" is in \"%s\"\n", a, str)
+ else
+ printf("\"%s\" is NOT in \"%s\"\n", a, str)
+
+ exit()
+}
diff --git a/testsuite/systemtap.string/strlen.exp b/testsuite/systemtap.string/strlen.exp
new file mode 100644
index 00000000..7fe84ad7
--- /dev/null
+++ b/testsuite/systemtap.string/strlen.exp
@@ -0,0 +1,8 @@
+load_lib "stap_run2.exp"
+set test "strlen"
+set ::result_string {strlen("") = 0
+strlen("1") = 1
+strlen("0123456789") = 10
+strlen("012345678901234567890123456789012345678901234567890123456789012") = 63
+}
+stap_run2 $srcdir/$subdir/$test.stp -DMAXSTRINGLEN=64
diff --git a/testsuite/systemtap.string/strlen.stp b/testsuite/systemtap.string/strlen.stp
new file mode 100644
index 00000000..028cf004
--- /dev/null
+++ b/testsuite/systemtap.string/strlen.stp
@@ -0,0 +1,15 @@
+probe begin
+{
+ printf("strlen(\"%s\") = %d\n", a, strlen(a))
+
+ a = "1"
+ printf("strlen(\"%s\") = %d\n", a, strlen(a))
+
+ a = "0123456789"
+ printf("strlen(\"%s\") = %d\n", a, strlen(a))
+
+ a = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ printf("strlen(\"%s\") = %d\n", a, strlen(a))
+
+ exit()
+}
diff --git a/testsuite/systemtap.string/substr.exp b/testsuite/systemtap.string/substr.exp
new file mode 100644
index 00000000..ee906e5e
--- /dev/null
+++ b/testsuite/systemtap.string/substr.exp
@@ -0,0 +1,19 @@
+load_lib "stap_run2.exp"
+set test "substr"
+set ::result_string {Hello World!
+0,0:
+-1,10:
+10,0:
+0,1: H
+1,1: e
+2,1: l
+2,5: llo W
+6,1: W
+11,1: !
+11,100: !
+12,1:
+0,10: Hello Worl
+0,100: Hello World!
+0,100000: Hello World!
+}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.string/substr.stp b/testsuite/systemtap.string/substr.stp
new file mode 100644
index 00000000..52046e2b
--- /dev/null
+++ b/testsuite/systemtap.string/substr.stp
@@ -0,0 +1,49 @@
+probe begin
+{
+ s = "Hello World!"
+ printf("%s\n", s)
+
+ x = substr(s,0,0)
+ printf("0,0: %s\n", x)
+
+ x = substr(s,-1,10)
+ printf("-1,10: %s\n", x)
+
+ x = substr(s,10,0)
+ printf("10,0: %s\n", x)
+
+ x = substr(s,0,1)
+ printf("0,1: %s\n", x)
+
+ x = substr(s,1,1)
+ printf("1,1: %s\n", x)
+
+ x = substr(s,2,1)
+ printf("2,1: %s\n", x)
+
+ x = substr(s,2,5)
+ printf("2,5: %s\n", x)
+
+ x = substr(s,6,1)
+ printf("6,1: %s\n", x)
+
+ x = substr(s,11,1)
+ printf("11,1: %s\n", x)
+
+ x = substr(s,11,100)
+ printf("11,100: %s\n", x)
+
+ x = substr(s,12,1)
+ printf("12,1: %s\n", x)
+
+ x = substr(s,0,10)
+ printf("0,10: %s\n", x)
+
+ x = substr(s,0,100)
+ printf("0,100: %s\n", x)
+
+ x = substr(s,0,100000)
+ printf("0,100000: %s\n", x)
+
+ exit()
+}
diff --git a/testsuite/systemtap.string/text_str.exp b/testsuite/systemtap.string/text_str.exp
new file mode 100644
index 00000000..2871b2ea
--- /dev/null
+++ b/testsuite/systemtap.string/text_str.exp
@@ -0,0 +1,58 @@
+load_lib "stap_run2.exp"
+set test "text_str"
+set ::result_string {a=1234567890
+b=12345678901234567890
+c=123456789012345678901234567890
+----- Using text_str -----
+a=1234567890
+b=12345678901234567890
+c=123456789012345678901234567890
+----- Using text_strn -----
+a=1234567890
+b=12345678901234567890
+c=123456789012345678901234567890
+----- Using text_strn len = 10 -----
+a=1234567890
+b=1234567890
+c=1234567890
+----- Using text_strn quoted -----
+a="1234567890"
+b="12345678901234567890"
+c="123456789012345678901234567890"
+----- Using text_strn len=10, quoted -----
+a="12345"...
+b="12345"...
+c="12345"...
+----- Using text_strn len=12, quoted -----
+a="1234567890"
+b="1234567"...
+c="1234567"...
+----- Using text_str -----
+a=\n\nXYZZY\31
+b=?\31\a\n\n\r\n
+c=\n\nXYZZY\31?\31\a\n\n\r\n
+----- Using text_strn -----
+a=\n\nXYZZY\31
+b=?\31\a\n\n\r\n
+c=\n\nXYZZY\31?\31\a\n\n\r\n
+----- Using text_strn len = 10 -----
+a=\n\nXYZZY
+b=?\31\a\n\n
+c=\n\nXYZZY
+----- Using text_strn len = 12 -----
+a=\n\nXYZZY\31
+b=?\31\a\n\n\r
+c=\n\nXYZZY\31
+----- Using text_strn quoted -----
+a="\n\nXYZZY\31"
+b="?\31\a\n\n\r\n"
+c="\n\nXYZZY\31?\31\a\n\n\r\n"
+----- Using text_strn len=10, quoted -----
+a="\n\nX"...
+b="?\31\"...
+c="\n\nX"...
+----- Using text_strn len=14, quoted -----
+a="\n\nXYZZY\31"
+b="?\31\a\n\"...
+c="\n\nXYZZY"...}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.string/text_str.stp b/testsuite/systemtap.string/text_str.stp
new file mode 100644
index 00000000..05acc431
--- /dev/null
+++ b/testsuite/systemtap.string/text_str.stp
@@ -0,0 +1,79 @@
+probe begin {
+ a = "1234567890"
+ b = a.a
+ c = a.b
+ printf("a=%s\n", a)
+ printf("b=%s\n", b)
+ printf("c=%s\n", c)
+
+ printf("----- Using text_str -----\n");
+ printf("a=%s\n", text_str(a))
+ printf("b=%s\n", text_str(b))
+ printf("c=%s\n", text_str(c))
+
+ printf("----- Using text_strn -----\n");
+ printf("a=%s\n", text_strn(a,0,0))
+ printf("b=%s\n", text_strn(b,0,0))
+ printf("c=%s\n", text_strn(c,0,0))
+
+ printf("----- Using text_strn len = 10 -----\n");
+ printf("a=%s\n", text_strn(a,10,0))
+ printf("b=%s\n", text_strn(b,10,0))
+ printf("c=%s\n", text_strn(c,10,0))
+
+ printf("----- Using text_strn quoted -----\n");
+ printf("a=%s\n", text_strn(a,0,1))
+ printf("b=%s\n", text_strn(b,0,1))
+ printf("c=%s\n", text_strn(c,0,1))
+
+ printf("----- Using text_strn len=10, quoted -----\n");
+ printf("a=%s\n", text_strn(a,10,1))
+ printf("b=%s\n", text_strn(b,10,1))
+ printf("c=%s\n", text_strn(c,10,1))
+
+ printf("----- Using text_strn len=12, quoted -----\n");
+ printf("a=%s\n", text_strn(a,12,1))
+ printf("b=%s\n", text_strn(b,12,1))
+ printf("c=%s\n", text_strn(c,12,1))
+
+ a = "\n\nXYZZY\031"
+ b = "\077\031\a\n\n\r\n"
+ c = a.b
+
+ printf("----- Using text_str -----\n");
+ printf("a=%s\n", text_str(a))
+ printf("b=%s\n", text_str(b))
+ printf("c=%s\n", text_str(c))
+
+ printf("----- Using text_strn -----\n");
+ printf("a=%s\n", text_strn(a,0,0))
+ printf("b=%s\n", text_strn(b,0,0))
+ printf("c=%s\n", text_strn(c,0,0))
+
+ printf("----- Using text_strn len = 10 -----\n");
+ printf("a=%s\n", text_strn(a,10,0))
+ printf("b=%s\n", text_strn(b,10,0))
+ printf("c=%s\n", text_strn(c,10,0))
+
+ printf("----- Using text_strn len = 12 -----\n");
+ printf("a=%s\n", text_strn(a,12,0))
+ printf("b=%s\n", text_strn(b,12,0))
+ printf("c=%s\n", text_strn(c,12 ,0))
+
+ printf("----- Using text_strn quoted -----\n");
+ printf("a=%s\n", text_strn(a,0,1))
+ printf("b=%s\n", text_strn(b,0,1))
+ printf("c=%s\n", text_strn(c,0,1))
+
+ printf("----- Using text_strn len=10, quoted -----\n");
+ printf("a=%s\n", text_strn(a,10,1))
+ printf("b=%s\n", text_strn(b,10,1))
+ printf("c=%s\n", text_strn(c,10,1))
+
+ printf("----- Using text_strn len=14, quoted -----\n");
+ printf("a=%s\n", text_strn(a,14,1))
+ printf("b=%s\n", text_strn(b,14,1))
+ printf("c=%s\n", text_strn(c,14,1))
+
+ exit()
+}