* [PATCH 2/2] [TAKE 3] Testcase For str_replace()
@ 2009-06-18 10:00 Varun Chandramohan
2009-06-18 15:04 ` Frank Ch. Eigler
0 siblings, 1 reply; 3+ messages in thread
From: Varun Chandramohan @ 2009-06-18 10:00 UTC (permalink / raw)
To: systemtap; +Cc: 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.
Signed-off-by: Varun Chandramohan <varunc@linux.vnet.ibm.com>
---
testsuite/systemtap.string/str_replace.exp | 27 ++++++++++++++++++++++
testsuite/systemtap.string/str_replace.stp | 34 ++++++++++++++++++++++++++++
2 files changed, 61 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..3376f88
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.exp
@@ -0,0 +1,27 @@
+set test "str_replace"
+
+set ok 0
+set ko 0
+
+spawn stap -DMAXERRORS=2 $srcdir/$subdir/$test.stp
+expect {
+ -timeout 15
+ -re {ERROR: Invalid Search String} { incr ko; exp_continue }
+ -re {WARNING: Number of errors} { incr ko ; exp_continue }
+ -re {Result = hello pointer tap} { incr ok ; exp_continue }
+ -re {Result = pointer system tap} { incr ok ; exp_continue }
+ -re {Result = hello system pointer} { incr ok ; exp_continue }
+ -re {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} { incr ok ; exp_continue }
+ -re {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} { incr ok ; exp_continue }
+ -re {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} { incr ok ; exp_continue }
+ -re {Result = hello tap} { incr ok ; exp_continue }
+ eof { }
+}
+catch { close }
+wait
+
+if {$ok == 7 && $ko == 4} {
+ pass $test
+} else {
+ fail "$test ($ok $ko)"
+}
diff --git a/testsuite/systemtap.string/str_replace.stp b/testsuite/systemtap.string/str_replace.stp
new file mode 100644
index 0000000..f8509db
--- /dev/null
+++ b/testsuite/systemtap.string/str_replace.stp
@@ -0,0 +1,34 @@
+# 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"))
+}
+probe begin {
+ printf("Result = %s\n",str_replace(long_str1, "\0", long_rlpc_str))
+}
+probe begin {
+ printf("Result = %s\n",str_replace("\0", "\0", long_rlpc_str))
+}
+probe begin {
+ printf("Result = %s\n",str_replace("\0", "\0", "\0"))
+}
+probe begin {
+ exit()
+}
+
--
1.6.0.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] [TAKE 3] Testcase For str_replace()
2009-06-18 10:00 [PATCH 2/2] [TAKE 3] Testcase For str_replace() Varun Chandramohan
@ 2009-06-18 15:04 ` Frank Ch. Eigler
2009-06-19 4:33 ` Varun Chandramohan
0 siblings, 1 reply; 3+ messages in thread
From: Frank Ch. Eigler @ 2009-06-18 15:04 UTC (permalink / raw)
To: Varun Chandramohan; +Cc: systemtap, Josh Stone
Varun Chandramohan <varunc@linux.vnet.ibm.com> writes:
> This patch adds the test case needed for this function. [...]
> +spawn stap -DMAXERRORS=2 $srcdir/$subdir/$test.stp
> +expect {
> + -timeout 15
> + -re {ERROR: Invalid Search String} { incr ko; exp_continue }
> + -re {WARNING: Number of errors} { incr ko ; exp_continue }
> + -re {Result = hello pointer tap} { incr ok ; exp_continue }
> + -re {Result = pointer system tap} { incr ok ; exp_continue }
> + -re {Result = hello system pointer} { incr ok ; exp_continue }
> [...]
One nit: your search strings are not regular expressions, so you
wouldn't normally use "-re" there.
However, I've had cases where I had to use -re anyway, forcing precise
line-begin/end matches, so that multiple output lines in expect's
input buffer aren't matched (=> consumed) by just a single regexp
line. This is what all those wacky regexps are for. Maybe you need
these too.
e.g., systemtap.base/skipped.exp:
-re {^WARNING: Number of errors: 0, skipped probes: [0-9]+\r\n} { incr ok; exp_continue }
- FChE
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] [TAKE 3] Testcase For str_replace()
2009-06-18 15:04 ` Frank Ch. Eigler
@ 2009-06-19 4:33 ` Varun Chandramohan
0 siblings, 0 replies; 3+ messages in thread
From: Varun Chandramohan @ 2009-06-19 4:33 UTC (permalink / raw)
To: Frank Ch. Eigler; +Cc: systemtap, Josh Stone
On Thursday 18 Jun 2009 8:34:20 pm Frank Ch. Eigler wrote:
> Varun Chandramohan <varunc@linux.vnet.ibm.com> writes:
> > This patch adds the test case needed for this function. [...]
> > +spawn stap -DMAXERRORS=2 $srcdir/$subdir/$test.stp
> > +expect {
> > + -timeout 15
> > + -re {ERROR: Invalid Search String} { incr ko; exp_continue }
> > + -re {WARNING: Number of errors} { incr ko ; exp_continue }
> > + -re {Result = hello pointer tap} { incr ok ; exp_continue }
> > + -re {Result = pointer system tap} { incr ok ; exp_continue }
> > + -re {Result = hello system pointer} { incr ok ; exp_continue }
> > [...]
>
> One nit: your search strings are not regular expressions, so you
> wouldn't normally use "-re" there.
>
> However, I've had cases where I had to use -re anyway, forcing precise
> line-begin/end matches, so that multiple output lines in expect's
> input buffer aren't matched (=> consumed) by just a single regexp
> line. This is what all those wacky regexps are for. Maybe you need
> these too.
>
> e.g., systemtap.base/skipped.exp:
>
> -re {^WARNING: Number of errors: 0, skipped probes: [0-9]+\r\n} { incr
> ok; exp_continue }
>
>
> - FChE
With the function now not returning errors, we dont this right? I can probably
use the test case i have sent with TAKE 2?
--
Regards,
Varun Chandramohan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-19 4:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-18 10:00 [PATCH 2/2] [TAKE 3] Testcase For str_replace() Varun Chandramohan
2009-06-18 15:04 ` Frank Ch. Eigler
2009-06-19 4:33 ` 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).