summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.printf
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 /testsuite/systemtap.printf
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.
Diffstat (limited to 'testsuite/systemtap.printf')
-rw-r--r--testsuite/systemtap.printf/memory1.exp16
-rw-r--r--testsuite/systemtap.printf/memory1.stp146
2 files changed, 121 insertions, 41 deletions
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();
+ }
}