summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.string/str_replace.stp
diff options
context:
space:
mode:
authorVarun Chandramohan <varunc@linux.vnet.ibm.com>2009-06-20 09:40:36 +0530
committerJosh Stone <jistone@redhat.com>2009-06-22 14:10:00 -0700
commit6eec708abee9188d74602f2602925edd2daa6342 (patch)
tree47f6567ccf8c4c19a7ca765e86787316d5f5258f /testsuite/systemtap.string/str_replace.stp
parent7e788c262ae119a9e1b378605ce649cf1ae3f6cb (diff)
downloadsystemtap-steved-6eec708abee9188d74602f2602925edd2daa6342.tar.gz
systemtap-steved-6eec708abee9188d74602f2602925edd2daa6342.tar.xz
systemtap-steved-6eec708abee9188d74602f2602925edd2daa6342.zip
Testcase For str_replace()
This patch adds the test case needed for this function. I have added few tests. If required more can be added in future. As discussed in previous version, the testcase patch has been reverted to the original as the str_replace() functionality has changed wrt to error handle. Signed-off-by: Varun Chandramohan <varunc@linux.vnet.ibm.com> Signed-off-by: Josh Stone <jistone@redhat.com>
Diffstat (limited to 'testsuite/systemtap.string/str_replace.stp')
-rw-r--r--testsuite/systemtap.string/str_replace.stp25
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/systemtap.string/str_replace.stp b/testsuite/systemtap.string/str_replace.stp
new file mode 100644
index 00000000..87e09353
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.stp
@@ -0,0 +1,25 @@
+# Test of str_replace()
+
+global long_str1 = "hello system tap"
+global long_str2 = "Here I am, on the road again. there I am, up on the stage, Here I go, playing star again. There I go, turn the page.- Bob Seger"
+global long_src_str1 = "system"
+global long_src_str2 = "hello"
+global long_src_str3 = "tap"
+global long_rlpc_str = "pointer"
+
+probe begin {
+ printf("Result = %s\n",str_replace(long_str1, long_src_str1, long_rlpc_str))
+ printf("Result = %s\n",str_replace(long_str1, long_src_str2, long_rlpc_str))
+ printf("Result = %s\n",str_replace(long_str1, long_src_str3, long_rlpc_str))
+
+ printf("Result = %s\n",str_replace(long_str2, "road", "bored"))
+ printf("Result = %s\n",str_replace(long_str2, "Here", "here"))
+ printf("Result = %s\n",str_replace(long_str2, "Bob Seger", "Metallica"))
+ printf("Result = %s\n",str_replace(long_str1, long_src_str1, "\0"))
+ printf("Result = %s\n",str_replace(long_str1, "\0", long_rlpc_str))
+ printf("Result = %s\n",str_replace("\0", "\0", long_rlpc_str))
+ printf("Result = %s\n",str_replace("\0", "\0", "\0"))
+}
+probe begin {
+ exit()
+}