summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrolley <brolley>2008-03-10 18:45:34 +0000
committerbrolley <brolley>2008-03-10 18:45:34 +0000
commit8512b2a199b5059cc95844f4c022351fc1edaafa (patch)
tree4f47b50f1d53c4a17f2e0016b754b752167bdb28
parent1775b972583588e562c1e6f614da60806c720168 (diff)
downloadsystemtap-steved-8512b2a199b5059cc95844f4c022351fc1edaafa.tar.gz
systemtap-steved-8512b2a199b5059cc95844f4c022351fc1edaafa.tar.xz
systemtap-steved-8512b2a199b5059cc95844f4c022351fc1edaafa.zip
2008-03-10 Dave Brolley <brolley@redhat.com>
PR5189 * systemtap.printf/memory1.{stp,exp}: Rewrite to reflect new %m safety checks. * systemtap.stress/conversions.exp: Add a test for invalid argument to %m.
-rw-r--r--testsuite/ChangeLog8
-rw-r--r--testsuite/systemtap.printf/memory1.exp16
-rw-r--r--testsuite/systemtap.printf/memory1.stp146
-rw-r--r--testsuite/systemtap.stress/conversions.exp2
-rw-r--r--testsuite/systemtap.stress/conversions.stp1
5 files changed, 130 insertions, 43 deletions
diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog
index 1596711d..2d43ba3c 100644
--- a/testsuite/ChangeLog
+++ b/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-10 Dave Brolley <brolley@redhat.com>
+
+ PR5189
+ * systemtap.printf/memory1.{stp,exp}: Rewrite to reflect new %m safety checks.
+ * systemtap.stress/conversions.exp: Add a test for invalid argument to %m.
+
2008-03-05 David Smith <dsmith@redhat.com>
PR5422
@@ -30,7 +36,7 @@
2008-02-23 Frank Ch. Eigler <fche@elastic.org>
* systemtap.samples/args.exp: Remove installation-specific paths from
- pass/fail judgements.
+ pass/fail judgements.<
2008-02-23 Frank Ch. Eigler <fche@elastic.org>
diff --git a/testsuite/systemtap.printf/memory1.exp b/testsuite/systemtap.printf/memory1.exp
index 2389cdc5..7b55a3d7 100644
--- a/testsuite/systemtap.printf/memory1.exp
+++ b/testsuite/systemtap.printf/memory1.exp
@@ -1,18 +1,4 @@
set test "memory1"
-set ::result_string {Memory default width and precision :m:
-Memory static precision smaller than input :my st:
-Memory dynamic precision smaller than input :my st:
-Memory static precision equal to input :my string:
-Memory dynamic precision equal to input :my string:
-Memory static width default precision : m:
-Memory dynamic width default precision : m:
-Memory static width smaller than static precision :my string:
-Memory static width larger than static precision : my string:
-Memory dynamic width smaller than static precision :my string:
-Memory dynamic width larger than static precision : my string:
-Memory static width smaller than dynamic precision :my string:
-Memory static width larger than dynamic precision : my string:
-Memory dynamic width smaller than dynamic precision :my string:
-Memory dynamic width larger than dynamic precision : my string:
+set ::result_string {Test passed
}
stap_run2 $srcdir/$subdir/$test.stp
diff --git a/testsuite/systemtap.printf/memory1.stp b/testsuite/systemtap.printf/memory1.stp
index 3b4d6d5e..f9cbf60b 100644
--- a/testsuite/systemtap.printf/memory1.stp
+++ b/testsuite/systemtap.printf/memory1.stp
@@ -1,27 +1,121 @@
-probe begin {
- five = 5;
- nine = 9;
- fifteen = 15;
- s = "my string";
-
- printf ("Memory default width and precision\t:%m:\n", s);
-
- printf ("Memory static precision smaller than input\t:%.5m:\n", s);
- printf ("Memory dynamic precision smaller than input\t:%.*m:\n", five, s);
- printf ("Memory static precision equal to input\t:%.9m:\n", s);
- printf ("Memory dynamic precision equal to input\t:%.*m:\n", nine, s);
-
- printf ("Memory static width default precision\t:%5m:\n", s);
- printf ("Memory dynamic width default precision\t:%*m:\n", five, s);
-
- printf ("Memory static width smaller than static precision\t:%5.9m:\n", s);
- printf ("Memory static width larger than static precision\t:%15.9m:\n", s);
- printf ("Memory dynamic width smaller than static precision\t:%*.9m:\n", five, s);
- printf ("Memory dynamic width larger than static precision\t:%*.9m:\n", fifteen, s);
- printf ("Memory static width smaller than dynamic precision\t:%5.*m:\n", nine, s);
- printf ("Memory static width larger than dynamic precision\t:%15.*m:\n", nine, s);
- printf ("Memory dynamic width smaller than dynamic precision\t:%*.*m:\n", five, nine, s);
- printf ("Memory dynamic width larger than dynamic precision\t:%*.*m:\n", fifteen, nine, s);
-
- exit()
+probe syscall.open {
+ actualLength = strlen (filename);
+
+ if (actualLength > 5 && actualLength < 15 && filename != "<unknown>") {
+ four = 4;
+ five = 5;
+ fifteen = 15;
+ success = 1;
+
+ expected_1_1 = sprintf ("%.1s", filename);
+ testName = "%m default width and precision";
+ result = sprintf ("%m", $filename);
+ if (result != expected_1_1) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_5_5 = sprintf ("%.5s", filename);
+ testName = "%m static precision smaller than input";
+ result = sprintf ("%.5m", $filename);
+ if (result != expected_5_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic precision smaller than input";
+ result = sprintf ("%.*m", five, $filename);
+ if (result != expected_5_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic precision equal to input";
+ expected_actual_actual = filename;
+ result = sprintf ("%.*m", actualLength, $filename);
+ if (result != expected_actual_actual) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_5_1 = sprintf (" %.1s", filename);
+ testName = "%m static width default precision";
+ result = sprintf ("%5m", $filename);
+ if (result != expected_5_1) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic width default precision";
+ result = sprintf ("%*m", five, $filename);
+ if (result != expected_5_1) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_4_5 = expected_5_5;
+ testName = "%m static width smaller than static precision";
+ result = sprintf ("%4.5m", $filename);
+ if (result != expected_4_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_15_5 = sprintf (" %.5s", filename);
+ testName = "%m static width larger than static precision";
+ result = sprintf ("%15.5m", $filename);
+ if (result != expected_15_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic width smaller than static precision";
+ result = sprintf ("%*.5m", four, $filename);
+ if (result != expected_4_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic width larger than static precision";
+ result = sprintf ("%*.5m", fifteen, $filename);
+ if (result != expected_15_5) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_4_actual = expected_actual_actual;
+ testName = "%m static width smaller than dynamic precision";
+ result = sprintf ("%4.*m", actualLength, $filename);
+ if (result != expected_4_actual) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ expected_15_actual = sprintf ("%15s", filename);
+ testName = "%m static width larger than dynamic precision";
+ result = sprintf ("%15.*m", actualLength, $filename);
+ if (result != expected_15_actual) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic width smaller than dynamic precision";
+ result = sprintf ("%*.*m", four, actualLength, $filename);
+ if (result != expected_4_actual) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ testName = "%m dynamic width larger than dynamic precision";
+ result = sprintf ("%*.*m", fifteen, actualLength, $filename);
+ if (result != expected_15_actual) {
+ printf ("Test %s failed\n", testName);
+ success = 0;
+ }
+
+ if (success)
+ print ("Test passed\n");
+
+ exit();
+ }
}
diff --git a/testsuite/systemtap.stress/conversions.exp b/testsuite/systemtap.stress/conversions.exp
index 230904ee..34cd3889 100644
--- a/testsuite/systemtap.stress/conversions.exp
+++ b/testsuite/systemtap.stress/conversions.exp
@@ -19,6 +19,6 @@ foreach value {0 0xffffffff 0xffffffffffffffff} {
}
verbose -log "done exp $test $errs"
wait
- if {$errs == 8} { pass $test } else { fail "$test ($errs)" }
+ if {$errs == 9} { pass $test } else { fail "$test ($errs)" }
verbose -log "done $test $errs"
}
diff --git a/testsuite/systemtap.stress/conversions.stp b/testsuite/systemtap.stress/conversions.stp
index 797626ab..07795a6d 100644
--- a/testsuite/systemtap.stress/conversions.stp
+++ b/testsuite/systemtap.stress/conversions.stp
@@ -8,6 +8,7 @@ probe begin { print (kernel_int ($1)) }
probe begin { print (kernel_short ($1)) }
probe begin { print (kernel_char ($1)) }
probe begin { print (kernel_int ($1)) }
+probe begin { printf ("%m", $1) }
probe begin { print (user_string ($1)) }
probe begin { print (user_string2 ($1,"<only suspected, not known>")) }
probe begin { print (user_string_warn ($1)) }