public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Testcase For str_replace()
@ 2009-06-20  4:10 Varun Chandramohan
  0 siblings, 0 replies; only message in thread
From: Varun Chandramohan @ 2009-06-20  4:10 UTC (permalink / raw)
  To: systemtap; +Cc: Frank Ch. Eigler, Josh Stone

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>
---
 testsuite/systemtap.string/str_replace.exp |   14 ++++++++++++++
 testsuite/systemtap.string/str_replace.stp |   25 +++++++++++++++++++++++++
 2 files changed, 39 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..4eedf1c
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.exp
@@ -0,0 +1,14 @@
+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 bored again. there I am, up on the stage, Here I go, playing star again. There I go, turn the page.- Bob Sege
+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 = hello  tap
+Result = hello system tap
+Result = 
+Result = }
+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..87e0935
--- /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()
+}
-- 
1.6.0.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-20  4:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-20  4:10 [PATCH 2/2] Testcase For str_replace() Varun Chandramohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).