From dfd8bb34d4d06033c5062ef19f2e5a2f77d5f6c9 Mon Sep 17 00:00:00 2001 From: mmason Date: Tue, 23 Jan 2007 18:03:50 +0000 Subject: Added new string functions tokenize() and strtol(). --- testsuite/ChangeLog | 6 +++++ testsuite/systemtap.string/strtol.exp | 15 +++++++++++ testsuite/systemtap.string/strtol.stp | 29 +++++++++++++++++++++ testsuite/systemtap.string/tokenize.exp | 26 +++++++++++++++++++ testsuite/systemtap.string/tokenize.stp | 46 +++++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 testsuite/systemtap.string/strtol.exp create mode 100644 testsuite/systemtap.string/strtol.stp create mode 100644 testsuite/systemtap.string/tokenize.exp create mode 100644 testsuite/systemtap.string/tokenize.stp (limited to 'testsuite') diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index e34d66f2..82749ee7 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-01-23 Mike Mason + + * systemtap.string/tokenize.exp, systemtap.string/tokenize.stp, + systemtap.string/strtol.exp, systemtap.string/strtol.stp: + Tests for new tokenize and strtol functions. + 2007-01-22 Josh Stone * systemtap.base/deref.stp: Rewrite test, and now also check the ability diff --git a/testsuite/systemtap.string/strtol.exp b/testsuite/systemtap.string/strtol.exp new file mode 100644 index 00000000..12d63f0d --- /dev/null +++ b/testsuite/systemtap.string/strtol.exp @@ -0,0 +1,15 @@ +set test "strtol" +set ::result_string {1 +-1 +123456789 +-123456789 +0 +1 +0 +0 +1000 +4096 +512 +8 +0} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.string/strtol.stp b/testsuite/systemtap.string/strtol.stp new file mode 100644 index 00000000..dcd1fe71 --- /dev/null +++ b/testsuite/systemtap.string/strtol.stp @@ -0,0 +1,29 @@ +probe begin +{ + teststr1 = "1" + teststr2 = "-1" + teststr3 = "123456789" + teststr4 = "-123456789" + teststr5 = "abcdef" + teststr6 = "123456789abcdef" + teststr7 = " 1 2 3 4" + teststr8 = "" + teststr9 = "1000" + teststr6 = "1a2b3c4d5e6f7g8h9" + + printf("%d\n", strtol(teststr1, 10)) + printf("%d\n", strtol(teststr2, 10)) + printf("%d\n", strtol(teststr3, 10)) + printf("%d\n", strtol(teststr4, 10)) + printf("%d\n", strtol(teststr5, 10)) + printf("%d\n", strtol(teststr6, 10)) + printf("%d\n", strtol(teststr7, 10)) + printf("%d\n", strtol(teststr8, 10)) + printf("%d\n", strtol(teststr9, 10)) + printf("%d\n", strtol(teststr9, 16)) + printf("%d\n", strtol(teststr9, 8)) + printf("%d\n", strtol(teststr9, 2)) + printf("%d\n", strtol(teststr10, 2)) + + exit() +} diff --git a/testsuite/systemtap.string/tokenize.exp b/testsuite/systemtap.string/tokenize.exp new file mode 100644 index 00000000..697b7c7e --- /dev/null +++ b/testsuite/systemtap.string/tokenize.exp @@ -0,0 +1,26 @@ +set test "tokenize" +set ::result_string {one +two +three +four +five +six +seven +eight +nine +ten +one|two|three|four|five|six|seven|eight|nine|ten +a +b +c +d +e +f +g +1 +2 +3 + +4 +this is a string with no delimiters} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.string/tokenize.stp b/testsuite/systemtap.string/tokenize.stp new file mode 100644 index 00000000..10703d90 --- /dev/null +++ b/testsuite/systemtap.string/tokenize.stp @@ -0,0 +1,46 @@ +probe begin +{ + teststr1 = "one|two|three|four|five|six|seven|eight|nine|ten" + teststr2 = "a,b,c,d,e,f,g" + teststr3 = "1,,2,3, ,4" + teststr4 = "" + teststr5 = "this is a string with no delimiters" + + tok = tokenize(teststr1, "|") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", "|") + } + + tok = tokenize(teststr1, ",") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", "|") + } + + tok = tokenize(teststr2, ",") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", ",") + } + + tok = tokenize(teststr3, ",") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", ",") + } + + tok = tokenize(teststr4, ",") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", ",") + } + + tok = tokenize(teststr5, ",") + while (tok != "") { + printf("%s\n", tok) + tok = tokenize("", ",") + } + + exit() +} -- cgit