This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 2/2] [TAKE 2] 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.

Signed-off-by: Varun Chandramohan <varunc@linux.vnet.ibm.com>
---
 testsuite/systemtap.string/str_replace.exp |   12 ++++++++++++
 testsuite/systemtap.string/str_replace.stp |   26 ++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 testsuite/systemtap.string/str_replace.exp
 create mode 100644 testsuite/systemtap.string/str_replace.stp

diff --git a/testsuite/systemtap.string/str_replace.exp b/testsuite/systemtap.string/str_replace.exp
new file mode 100644
index 0000000..622bd6e
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.exp
@@ -0,0 +1,12 @@
+set test "str_replace"
+set ::result_string {Result = hello pointer tap
+Result = pointer system tap
+Result = hello system pointer
+Result = 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
+Result = 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
+Result = 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.- Metallica
+Result = 
+Result = 
+Result = 
+Result = hello  tap}
+stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.string/str_replace.stp b/testsuite/systemtap.string/str_replace.stp
new file mode 100644
index 0000000..d4b80a7
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.stp
@@ -0,0 +1,26 @@
+# Test of str_replace() 
+
+probe begin {
+	long_str1 = "hello system tap"
+	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"
+	long_src_str1 = "system"
+	long_src_str2 = "hello"
+	long_src_str3 = "tap"
+	long_rlpc_str = "pointer"
+	
+	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, "\0", long_rlpc_str))
+	printf("Result = %s\n",str_replace("\0", "\0", long_rlpc_str))
+	printf("Result = %s\n",str_replace("\0", "\0", "\0"))
+	printf("Result = %s\n",str_replace(long_str1, long_src_str1, "\0"))
+
+	exit()
+}
+
-- 
1.6.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]