summaryrefslogtreecommitdiffstats
path: root/testsuite
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
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')
-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.exp (renamed from testsuite/systemtap.printf/text_str.exp)0
-rw-r--r--testsuite/systemtap.string/text_str.stp (renamed from testsuite/systemtap.printf/text_str.stp)0
8 files changed, 123 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.printf/text_str.exp b/testsuite/systemtap.string/text_str.exp
index 2871b2ea..2871b2ea 100644
--- a/testsuite/systemtap.printf/text_str.exp
+++ b/testsuite/systemtap.string/text_str.exp
diff --git a/testsuite/systemtap.printf/text_str.stp b/testsuite/systemtap.string/text_str.stp
index 05acc431..05acc431 100644
--- a/testsuite/systemtap.printf/text_str.stp
+++ b/testsuite/systemtap.string/text_str.stp